• 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

5.66
/core/src/main/java/com/aspectran/core/component/bean/proxy/AbstractBeanProxy.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.aspect.AdviceConstraintViolationException;
20
import com.aspectran.core.activity.aspect.AspectAdviceException;
21
import com.aspectran.core.activity.process.action.ActionExecutionException;
22
import com.aspectran.core.component.aspect.AspectAdviceRuleRegistry;
23
import com.aspectran.core.component.aspect.AspectRuleRegistry;
24
import com.aspectran.core.component.aspect.RelevantAspectRuleHolder;
25
import com.aspectran.core.component.aspect.pointcut.PointcutPattern;
26
import com.aspectran.core.component.bean.annotation.AvoidAdvice;
27
import com.aspectran.core.context.rule.AspectAdviceRule;
28
import com.aspectran.core.context.rule.AspectRule;
29
import com.aspectran.core.context.rule.BeanRule;
30
import com.aspectran.core.context.rule.ExceptionRule;
31
import com.aspectran.core.context.rule.SettingsAdviceRule;
32
import com.aspectran.utils.annotation.jsr305.NonNull;
33

34
import java.lang.reflect.Method;
35
import java.util.List;
36

37
/**
38
 * The Class AbstractDynamicBeanProxy.
39
 */
40
public abstract class AbstractBeanProxy {
41

42
    private final AspectRuleRegistry aspectRuleRegistry;
43

44
    public AbstractBeanProxy(AspectRuleRegistry aspectRuleRegistry) {
1✔
45
        this.aspectRuleRegistry = aspectRuleRegistry;
1✔
46
    }
1✔
47

48
    protected boolean isAvoidAdvice(@NonNull Method method) {
49
        return (Object.class == method.getDeclaringClass() ||
×
50
                method.getDeclaringClass().isAnnotationPresent(AvoidAdvice.class) ||
×
51
                method.isAnnotationPresent(AvoidAdvice.class));
×
52
    }
53

54
    protected AspectAdviceRuleRegistry getAspectAdviceRuleRegistry(@NonNull Activity activity,
55
            String beanId, String className, String methodName)
56
            throws AdviceConstraintViolationException, AspectAdviceException {
57
        String requestName;
58
        boolean literalPattern;
59
        if (activity.getTranslet() != null) {
×
60
            requestName = activity.getTranslet().getRequestName();
×
61
            literalPattern = !activity.getTranslet().hasPathVariables();
×
62
        } else {
63
            requestName = null;
×
64
            literalPattern = true;
×
65
        }
66

67
        PointcutPattern pointcutPattern = new PointcutPattern(requestName, beanId, className, methodName);
×
68
        RelevantAspectRuleHolder holder;
69
        if (literalPattern) {
×
70
            holder = aspectRuleRegistry.getRelevantAspectRuleHolderFromSoftCache(pointcutPattern);
×
71
        } else {
72
            holder = aspectRuleRegistry.getRelevantAspectRuleHolderFromWeakCache(pointcutPattern);
×
73
        }
74

75
        AspectAdviceRuleRegistry aarr = holder.getAspectAdviceRuleRegistry();
×
76
        if (aarr != null && aarr.getSettingsAdviceRuleList() != null) {
×
77
            for (SettingsAdviceRule sar : aarr.getSettingsAdviceRuleList()) {
×
78
                activity.registerSettingsAdviceRule(sar);
×
79
            }
×
80
        }
81
        if (holder.getDynamicAspectRuleList() != null) {
×
82
            for (AspectRule aspectRule : holder.getDynamicAspectRuleList()) {
×
83
                // register dynamically
84
                activity.registerAspectAdviceRule(aspectRule);
×
85
            }
×
86
        }
87
        return aarr;
×
88
    }
89

90
    protected void beforeAdvice(List<AspectAdviceRule> beforeAdviceRuleList, BeanRule beanRule, Activity activity)
91
            throws AspectAdviceException {
92
        if (beforeAdviceRuleList != null) {
×
93
            for (AspectAdviceRule aspectAdviceRule : beforeAdviceRuleList) {
×
94
                if (!isSameBean(beanRule, aspectAdviceRule)) {
×
95
                    activity.executeAdvice(aspectAdviceRule, true);
×
96
                }
97
            }
×
98
        }
99
    }
×
100

101
    protected void afterAdvice(List<AspectAdviceRule> afterAdviceRuleList, BeanRule beanRule, Activity activity)
102
            throws AspectAdviceException {
103
        if (afterAdviceRuleList != null) {
×
104
            for (AspectAdviceRule aspectAdviceRule : afterAdviceRuleList) {
×
105
                if (!isSameBean(beanRule, aspectAdviceRule)) {
×
106
                    activity.executeAdvice(aspectAdviceRule, true);
×
107
                }
108
            }
×
109
        }
110
    }
×
111

112
    protected void finallyAdvice(List<AspectAdviceRule> finallyAdviceRuleList, BeanRule beanRule, Activity activity)
113
            throws AspectAdviceException {
114
        if (finallyAdviceRuleList != null) {
×
115
            for (AspectAdviceRule aspectAdviceRule : finallyAdviceRuleList) {
×
116
                if (!isSameBean(beanRule, aspectAdviceRule)) {
×
117
                    activity.executeAdvice(aspectAdviceRule, false);
×
118
                }
119
            }
×
120
        }
121
    }
×
122

123
    protected boolean exceptionally(List<ExceptionRule> exceptionRuleList, Exception exception, @NonNull Activity activity)
124
            throws ActionExecutionException {
125
        activity.setRaisedException(exception);
×
126
        if (exceptionRuleList != null) {
×
127
            activity.handleException(exceptionRuleList);
×
128
            return activity.isResponseReserved();
×
129
        }
130
        return false;
×
131
    }
132

133
    private boolean isSameBean(@NonNull BeanRule beanRule, AspectAdviceRule aspectAdviceRule) {
134
        if (beanRule.getId() != null && beanRule.getId().equals(aspectAdviceRule.getAdviceBeanId())) {
×
135
            return true;
×
136
        }
137
        if (beanRule.getBeanClass() != null && aspectAdviceRule.getAdviceBeanClass() != null) {
×
138
            return (beanRule.getBeanClass() == aspectAdviceRule.getAdviceBeanClass());
×
139
        }
140
        return false;
×
141
    }
142

143
}
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