• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aspectran / aspectran / #3614

10 Jul 2024 08:30PM CUT coverage: 34.06% (-0.01%) from 34.07%
#3614

Pull #677

github

web-flow
Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.3.1

Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.3.0...surefire-3.3.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #677: Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.3.1

13340 of 39166 relevant lines covered (34.06%)

0.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.62
/core/src/main/java/com/aspectran/core/component/bean/proxy/JavassistBeanProxy.java
1
/*
2
 * Copyright (c) 2008-2024 The Aspectran Project
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.aspectran.core.component.bean.proxy;
17

18
import com.aspectran.core.activity.Activity;
19
import com.aspectran.core.activity.InstantActivity;
20
import com.aspectran.core.activity.InstantActivityException;
21
import com.aspectran.core.component.aspect.AspectAdviceRuleRegistry;
22
import com.aspectran.core.context.ActivityContext;
23
import com.aspectran.core.context.rule.BeanRule;
24
import com.aspectran.utils.annotation.jsr305.NonNull;
25
import com.aspectran.utils.annotation.jsr305.Nullable;
26
import javassist.util.proxy.MethodHandler;
27
import javassist.util.proxy.ProxyFactory;
28

29
import java.lang.reflect.InvocationTargetException;
30
import java.lang.reflect.Method;
31

32
/**
33
 * The Class JavassistDynamicBeanProxy.
34
 *
35
 * @since 1.1.0
36
 */
37
public class JavassistBeanProxy extends AbstractBeanProxy implements MethodHandler {
38

39
    private final ActivityContext context;
40

41
    private final BeanRule beanRule;
42

43
    private JavassistBeanProxy(@NonNull ActivityContext context, @NonNull BeanRule beanRule) {
44
        super(context.getAspectRuleRegistry());
1✔
45
        this.context = context;
1✔
46
        this.beanRule = beanRule;
1✔
47
    }
1✔
48

49
    @Override
50
    public Object invoke(Object self, Method overridden, Method proceed, Object[] args) throws Throwable {
51
        if (isAvoidAdvice(overridden)) {
×
52
            return proceed.invoke(self, args);
×
53
        }
54
        if (context.hasCurrentActivity()) {
×
55
            Activity activity = context.getCurrentActivity();
×
56
            return invoke(self, overridden, proceed, args, activity);
×
57
        } else {
58
            try {
59
                Activity activity = new InstantActivity(context);
×
60
                return activity.perform(() -> invoke(self, overridden, proceed, args, activity));
×
61
            } catch (Exception e) {
×
62
                throw new InstantActivityException(e);
×
63
            }
64
        }
65
    }
66

67
    @Nullable
68
    private Object invoke(Object self, @NonNull Method overridden, Method proceed, Object[] args,
69
                          Activity activity) throws Throwable {
70
        String beanId = beanRule.getId();
×
71
        String className = beanRule.getClassName();
×
72
        String methodName = overridden.getName();
×
73
        AspectAdviceRuleRegistry aarr = getAspectAdviceRuleRegistry(activity, beanId, className, methodName);
×
74
        if (aarr == null) {
×
75
            return invokeSuper(self, proceed, args);
×
76
        }
77
        try {
78
            try {
79
                beforeAdvice(aarr.getBeforeAdviceRuleList(), beanRule, activity);
×
80
                Object result = invokeSuper(self, proceed, args);
×
81
                afterAdvice(aarr.getAfterAdviceRuleList(), beanRule, activity);
×
82
                return result;
×
83
            } finally {
84
                finallyAdvice(aarr.getFinallyAdviceRuleList(), beanRule, activity);
×
85
            }
86
        } catch (Exception e) {
×
87
            if (exceptionally(aarr.getExceptionRuleList(), e, activity)) {
×
88
                return null;
×
89
            }
90
            throw e;
×
91
        }
92
    }
93

94
    private Object invokeSuper(Object self, @NonNull Method proceed, Object[] args) throws Throwable {
95
        try {
96
            return proceed.invoke(self, args);
×
97
        } catch (InvocationTargetException e) {
×
98
            throw e.getTargetException();
×
99
        }
100
    }
101

102
    /**
103
     * Creates a proxy class of bean and returns an instance of that class.
104
     * @param context the activity context
105
     * @param beanRule the bean rule
106
     * @param args the arguments passed to a constructor
107
     * @param argTypes the parameter types for a constructor
108
     * @return a new proxy bean object
109
     */
110
    public static Object create(ActivityContext context, BeanRule beanRule, Object[] args, Class<?>[] argTypes) {
111
        try {
112
            ProxyFactory proxyFactory = new ProxyFactory();
1✔
113
            proxyFactory.setSuperclass(beanRule.getBeanClass());
1✔
114
            MethodHandler methodHandler = new JavassistBeanProxy(context, beanRule);
1✔
115
            return proxyFactory.create(argTypes, args, methodHandler);
1✔
116
        } catch (Exception e) {
×
117
            throw new BeanProxyException(beanRule, e);
×
118
        }
119
    }
120

121
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc