Add @Override annotations to main sources
Issue: SPR-10130
This commit is contained in:
parent
9c2046c3ee
commit
3b40ce76bf
|
@ -39,6 +39,7 @@ public interface TargetSource extends TargetClassAware {
|
||||||
* target class.
|
* target class.
|
||||||
* @return the type of targets returned by this {@link TargetSource}
|
* @return the type of targets returned by this {@link TargetSource}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
Class<?> getTargetClass();
|
Class<?> getTargetClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,6 +34,7 @@ class TrueClassFilter implements ClassFilter, Serializable {
|
||||||
private TrueClassFilter() {
|
private TrueClassFilter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,17 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
|
||||||
private TrueMethodMatcher() {
|
private TrueMethodMatcher() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
// Should never be invoked as isRuntime returns false.
|
// Should never be invoked as isRuntime returns false.
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -34,10 +34,12 @@ class TruePointcut implements Pointcut, Serializable {
|
||||||
private TruePointcut() {
|
private TruePointcut() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return ClassFilter.TRUE;
|
return ClassFilter.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
return MethodMatcher.TRUE;
|
return MethodMatcher.TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,6 +203,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
return this.aspectInstanceFactory.getAspectClassLoader();
|
return this.aspectInstanceFactory.getAspectClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.aspectInstanceFactory.getOrder();
|
return this.aspectInstanceFactory.getOrder();
|
||||||
}
|
}
|
||||||
|
@ -212,6 +213,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
this.aspectName = name;
|
this.aspectName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getAspectName() {
|
public String getAspectName() {
|
||||||
return this.aspectName;
|
return this.aspectName;
|
||||||
}
|
}
|
||||||
|
@ -223,6 +225,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
this.declarationOrder = order;
|
this.declarationOrder = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDeclarationOrder() {
|
public int getDeclarationOrder() {
|
||||||
return this.declarationOrder;
|
return this.declarationOrder;
|
||||||
}
|
}
|
||||||
|
@ -678,6 +681,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
this.adviceMethod = adviceMethod;
|
this.adviceMethod = adviceMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return !this.adviceMethod.equals(method);
|
return !this.adviceMethod.equals(method);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* @param method the target {@link Method}
|
* @param method the target {@link Method}
|
||||||
* @return the parameter names
|
* @return the parameter names
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String[] getParameterNames(Method method) {
|
public String[] getParameterNames(Method method) {
|
||||||
this.argumentTypes = method.getParameterTypes();
|
this.argumentTypes = method.getParameterTypes();
|
||||||
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
|
this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
|
||||||
|
@ -309,6 +310,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* @throws UnsupportedOperationException if
|
* @throws UnsupportedOperationException if
|
||||||
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String[] getParameterNames(Constructor ctor) {
|
public String[] getParameterNames(Constructor ctor) {
|
||||||
if (this.raiseExceptions) {
|
if (this.raiseExceptions) {
|
||||||
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
|
||||||
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
|
@ -46,10 +47,12 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,12 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
|
||||||
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
|
||||||
setReturningNameNoCheck(name);
|
setReturningNameNoCheck(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
|
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
|
||||||
if (shouldInvokeOnReturnValueOf(method, returnValue)) {
|
if (shouldInvokeOnReturnValueOf(method, returnValue)) {
|
||||||
invokeAdviceMethod(getJoinPointMatch(), returnValue, null);
|
invokeAdviceMethod(getJoinPointMatch(), returnValue, null);
|
||||||
|
|
|
@ -37,10 +37,12 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
|
||||||
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +52,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
|
||||||
setThrowingNameNoCheck(name);
|
setThrowingNameNoCheck(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
|
|
|
@ -41,10 +41,12 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
|
||||||
super(aspectJAroundAdviceMethod, pointcut, aif);
|
super(aspectJAroundAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +57,7 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
if (!(mi instanceof ProxyMethodInvocation)) {
|
if (!(mi instanceof ProxyMethodInvocation)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
|
|
|
@ -155,16 +155,19 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
this.pointcutParameterTypes = types;
|
this.pointcutParameterTypes = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
return this;
|
return this;
|
||||||
|
@ -244,6 +247,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
return this.pointcutExpression;
|
return this.pointcutExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class targetClass) {
|
public boolean matches(Class targetClass) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
try {
|
try {
|
||||||
|
@ -267,6 +271,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) {
|
public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
||||||
|
@ -287,15 +292,18 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return matches(method, targetClass, false);
|
return matches(method, targetClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
return this.pointcutExpression.mayNeedDynamicTest();
|
return this.pointcutExpression.mayNeedDynamicTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
|
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
|
||||||
|
@ -506,10 +514,12 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
|
|
||||||
private static final String BEAN_DESIGNATOR_NAME = "bean";
|
private static final String BEAN_DESIGNATOR_NAME = "bean";
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDesignatorName() {
|
public String getDesignatorName() {
|
||||||
return BEAN_DESIGNATOR_NAME;
|
return BEAN_DESIGNATOR_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ContextBasedMatcher parse(String expression) {
|
public ContextBasedMatcher parse(String expression) {
|
||||||
return new BeanNameContextMatcher(expression);
|
return new BeanNameContextMatcher(expression);
|
||||||
}
|
}
|
||||||
|
@ -531,22 +541,27 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
this.expressionPattern = new NamePattern(expression);
|
this.expressionPattern = new NamePattern(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean couldMatchJoinPointsInType(Class someClass) {
|
public boolean couldMatchJoinPointsInType(Class someClass) {
|
||||||
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) {
|
public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) {
|
||||||
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matchesDynamically(MatchingContext context) {
|
public boolean matchesDynamically(MatchingContext context) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FuzzyBoolean matchesStatically(MatchingContext context) {
|
public FuzzyBoolean matchesStatically(MatchingContext context) {
|
||||||
return contextMatch(null);
|
return contextMatch(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean mayNeedDynamicTest() {
|
public boolean mayNeedDynamicTest() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -611,18 +626,22 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
this.other = other;
|
this.other = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean alwaysMatches() {
|
public boolean alwaysMatches() {
|
||||||
return primary.alwaysMatches();
|
return primary.alwaysMatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean maybeMatches() {
|
public boolean maybeMatches() {
|
||||||
return primary.maybeMatches();
|
return primary.maybeMatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean neverMatches() {
|
public boolean neverMatches() {
|
||||||
return primary.neverMatches();
|
return primary.neverMatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public JoinPointMatch matchesJoinPoint(Object thisObject,
|
public JoinPointMatch matchesJoinPoint(Object thisObject,
|
||||||
Object targetObject, Object[] args) {
|
Object targetObject, Object[] args) {
|
||||||
try {
|
try {
|
||||||
|
@ -632,6 +651,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMatchingContext(MatchingContext aMatchContext) {
|
public void setMatchingContext(MatchingContext aMatchContext) {
|
||||||
primary.setMatchingContext(aMatchContext);
|
primary.setMatchingContext(aMatchContext);
|
||||||
other.setMatchingContext(aMatchContext);
|
other.setMatchingContext(aMatchContext);
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
|
||||||
private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,17 @@ public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements
|
||||||
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void before(Method method, Object[] args, Object target) throws Throwable {
|
public void before(Method method, Object[] args, Object target) throws Throwable {
|
||||||
invokeAdviceMethod(getJoinPointMatch(), null, null);
|
invokeAdviceMethod(getJoinPointMatch(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,18 +56,22 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
if (this.order != null) {
|
if (this.order != null) {
|
||||||
return this.order;
|
return this.order;
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class AspectJWeaverMessageHandler implements IMessageHandler {
|
||||||
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
|
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean handleMessage(IMessage message) throws AbortException {
|
public boolean handleMessage(IMessage message) throws AbortException {
|
||||||
Kind messageKind = message.getKind();
|
Kind messageKind = message.getKind();
|
||||||
|
|
||||||
|
@ -93,15 +94,18 @@ public class AspectJWeaverMessageHandler implements IMessageHandler {
|
||||||
return AJ_ID + aMessage.getMessage();
|
return AJ_ID + aMessage.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isIgnoring(Kind messageKind) {
|
public boolean isIgnoring(Kind messageKind) {
|
||||||
// We want to see everything, and allow configuration of log levels dynamically.
|
// We want to see everything, and allow configuration of log levels dynamically.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dontIgnore(Kind messageKind) {
|
public void dontIgnore(Kind messageKind) {
|
||||||
// We weren't ignoring anything anyway...
|
// We weren't ignoring anything anyway...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void ignore(Kind kind) {
|
public void ignore(Kind kind) {
|
||||||
// We weren't ignoring anything anyway...
|
// We weren't ignoring anything anyway...
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
|
|
||||||
// Excludes methods implemented.
|
// Excludes methods implemented.
|
||||||
ClassFilter exclusion = new ClassFilter() {
|
ClassFilter exclusion = new ClassFilter() {
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return !(introducedInterface.isAssignableFrom(clazz));
|
return !(introducedInterface.isAssignableFrom(clazz));
|
||||||
}
|
}
|
||||||
|
@ -87,22 +88,27 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this.typePatternClassFilter;
|
return this.typePatternClassFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validateInterfaces() throws IllegalArgumentException {
|
public void validateInterfaces() throws IllegalArgumentException {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class[] getInterfaces() {
|
||||||
return new Class[] {this.introducedInterface};
|
return new Class[] {this.introducedInterface};
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
this.methodInvocation = methodInvocation;
|
this.methodInvocation = methodInvocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void set$AroundClosure(AroundClosure aroundClosure) {
|
public void set$AroundClosure(AroundClosure aroundClosure) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object proceed() throws Throwable {
|
public Object proceed() throws Throwable {
|
||||||
return this.methodInvocation.invocableClone().proceed();
|
return this.methodInvocation.invocableClone().proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object proceed(Object[] arguments) throws Throwable {
|
public Object proceed(Object[] arguments) throws Throwable {
|
||||||
Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
|
Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
|
||||||
if (arguments.length != this.methodInvocation.getArguments().length) {
|
if (arguments.length != this.methodInvocation.getArguments().length) {
|
||||||
|
@ -94,6 +97,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
/**
|
/**
|
||||||
* Returns the Spring AOP proxy. Cannot be {@code null}.
|
* Returns the Spring AOP proxy. Cannot be {@code null}.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getThis() {
|
public Object getThis() {
|
||||||
return this.methodInvocation.getProxy();
|
return this.methodInvocation.getProxy();
|
||||||
}
|
}
|
||||||
|
@ -101,10 +105,12 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
/**
|
/**
|
||||||
* Returns the Spring AOP target. May be {@code null} if there is no target.
|
* Returns the Spring AOP target. May be {@code null} if there is no target.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getTarget() {
|
public Object getTarget() {
|
||||||
return this.methodInvocation.getThis();
|
return this.methodInvocation.getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object[] getArgs() {
|
public Object[] getArgs() {
|
||||||
if (this.defensiveCopyOfArgs == null) {
|
if (this.defensiveCopyOfArgs == null) {
|
||||||
Object[] argsSource = this.methodInvocation.getArguments();
|
Object[] argsSource = this.methodInvocation.getArguments();
|
||||||
|
@ -114,6 +120,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
return this.defensiveCopyOfArgs;
|
return this.defensiveCopyOfArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Signature getSignature() {
|
public Signature getSignature() {
|
||||||
if (this.signature == null) {
|
if (this.signature == null) {
|
||||||
this.signature = new MethodSignatureImpl();
|
this.signature = new MethodSignatureImpl();
|
||||||
|
@ -121,6 +128,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SourceLocation getSourceLocation() {
|
public SourceLocation getSourceLocation() {
|
||||||
if (this.sourceLocation == null) {
|
if (this.sourceLocation == null) {
|
||||||
this.sourceLocation = new SourceLocationImpl();
|
this.sourceLocation = new SourceLocationImpl();
|
||||||
|
@ -128,23 +136,28 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
return this.sourceLocation;
|
return this.sourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getKind() {
|
public String getKind() {
|
||||||
return ProceedingJoinPoint.METHOD_EXECUTION;
|
return ProceedingJoinPoint.METHOD_EXECUTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
// TODO: It's just an adapter but returning 0 might still have side effects...
|
// TODO: It's just an adapter but returning 0 might still have side effects...
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public JoinPoint.StaticPart getStaticPart() {
|
public JoinPoint.StaticPart getStaticPart() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toShortString() {
|
public String toShortString() {
|
||||||
return "execution(" + getSignature().toShortString() + ")";
|
return "execution(" + getSignature().toShortString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toLongString() {
|
public String toLongString() {
|
||||||
return "execution(" + getSignature().toLongString() + ")";
|
return "execution(" + getSignature().toLongString() + ")";
|
||||||
}
|
}
|
||||||
|
@ -161,34 +174,42 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
|
|
||||||
private volatile String[] parameterNames;
|
private volatile String[] parameterNames;
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return methodInvocation.getMethod().getName();
|
return methodInvocation.getMethod().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getModifiers() {
|
public int getModifiers() {
|
||||||
return methodInvocation.getMethod().getModifiers();
|
return methodInvocation.getMethod().getModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class getDeclaringType() {
|
public Class getDeclaringType() {
|
||||||
return methodInvocation.getMethod().getDeclaringClass();
|
return methodInvocation.getMethod().getDeclaringClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDeclaringTypeName() {
|
public String getDeclaringTypeName() {
|
||||||
return methodInvocation.getMethod().getDeclaringClass().getName();
|
return methodInvocation.getMethod().getDeclaringClass().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class getReturnType() {
|
public Class getReturnType() {
|
||||||
return methodInvocation.getMethod().getReturnType();
|
return methodInvocation.getMethod().getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Method getMethod() {
|
public Method getMethod() {
|
||||||
return methodInvocation.getMethod();
|
return methodInvocation.getMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getParameterTypes() {
|
public Class[] getParameterTypes() {
|
||||||
return methodInvocation.getMethod().getParameterTypes();
|
return methodInvocation.getMethod().getParameterTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameterNames() {
|
public String[] getParameterNames() {
|
||||||
if (this.parameterNames == null) {
|
if (this.parameterNames == null) {
|
||||||
this.parameterNames = (new LocalVariableTableParameterNameDiscoverer()).getParameterNames(getMethod());
|
this.parameterNames = (new LocalVariableTableParameterNameDiscoverer()).getParameterNames(getMethod());
|
||||||
|
@ -196,14 +217,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
return this.parameterNames;
|
return this.parameterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getExceptionTypes() {
|
public Class[] getExceptionTypes() {
|
||||||
return methodInvocation.getMethod().getExceptionTypes();
|
return methodInvocation.getMethod().getExceptionTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toShortString() {
|
public String toShortString() {
|
||||||
return toString(false, false, false, false);
|
return toString(false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toLongString() {
|
public String toLongString() {
|
||||||
return toString(true, true, true, true);
|
return toString(true, true, true, true);
|
||||||
}
|
}
|
||||||
|
@ -267,6 +291,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
*/
|
*/
|
||||||
private class SourceLocationImpl implements SourceLocation {
|
private class SourceLocationImpl implements SourceLocation {
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class getWithinType() {
|
public Class getWithinType() {
|
||||||
if (methodInvocation.getThis() == null) {
|
if (methodInvocation.getThis() == null) {
|
||||||
throw new UnsupportedOperationException("No source location joinpoint available: target is null");
|
throw new UnsupportedOperationException("No source location joinpoint available: target is null");
|
||||||
|
@ -274,14 +299,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
return methodInvocation.getThis().getClass();
|
return methodInvocation.getThis().getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getLine() {
|
public int getLine() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumn() {
|
public int getColumn() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,35 +106,44 @@ class RuntimeTestWalker {
|
||||||
protected static final int AT_TARGET_VAR = 4;
|
protected static final int AT_TARGET_VAR = 4;
|
||||||
protected static final int AT_ANNOTATION_VAR = 8;
|
protected static final int AT_ANNOTATION_VAR = 8;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(And e) {
|
public void visit(And e) {
|
||||||
e.getLeft().accept(this);
|
e.getLeft().accept(this);
|
||||||
e.getRight().accept(this);
|
e.getRight().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Or e) {
|
public void visit(Or e) {
|
||||||
e.getLeft().accept(this);
|
e.getLeft().accept(this);
|
||||||
e.getRight().accept(this);
|
e.getRight().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Not e) {
|
public void visit(Not e) {
|
||||||
e.getBody().accept(this);
|
e.getBody().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Instanceof i) {
|
public void visit(Instanceof i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Literal literal) {
|
public void visit(Literal literal) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(Call call) {
|
public void visit(Call call) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(FieldGetCall fieldGetCall) {
|
public void visit(FieldGetCall fieldGetCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(HasAnnotation hasAnnotation) {
|
public void visit(HasAnnotation hasAnnotation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visit(MatchingContextBasedTest matchingContextTest) {
|
public void visit(MatchingContextBasedTest matchingContextTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Object getAspectInstance() {
|
public final Object getAspectInstance() {
|
||||||
try {
|
try {
|
||||||
return this.aspectClass.newInstance();
|
return this.aspectClass.newInstance();
|
||||||
|
@ -61,6 +62,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassLoader getAspectClassLoader() {
|
public ClassLoader getAspectClassLoader() {
|
||||||
return this.aspectClass.getClassLoader();
|
return this.aspectClass.getClassLoader();
|
||||||
}
|
}
|
||||||
|
@ -73,6 +75,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
* @see org.springframework.core.Ordered
|
* @see org.springframework.core.Ordered
|
||||||
* @see #getOrderForAspectClass
|
* @see #getOrderForAspectClass
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return getOrderForAspectClass(this.aspectClass);
|
return getOrderForAspectClass(this.aspectClass);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,12 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Object getAspectInstance() {
|
public final Object getAspectInstance() {
|
||||||
return this.aspectInstance;
|
return this.aspectInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassLoader getAspectClassLoader() {
|
public ClassLoader getAspectClassLoader() {
|
||||||
return this.aspectInstance.getClass().getClassLoader();
|
return this.aspectInstance.getClass().getClassLoader();
|
||||||
}
|
}
|
||||||
|
@ -60,6 +62,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
* @see org.springframework.core.Ordered
|
* @see org.springframework.core.Ordered
|
||||||
* @see #getOrderForAspectClass
|
* @see #getOrderForAspectClass
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
if (this.aspectInstance instanceof Ordered) {
|
if (this.aspectInstance instanceof Ordered) {
|
||||||
return ((Ordered) this.aspectInstance).getOrder();
|
return ((Ordered) this.aspectInstance).getOrder();
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||||
* @return whether the advice should apply to this candidate target class
|
* @return whether the advice should apply to this candidate target class
|
||||||
* @throws IllegalStateException if no {@link #setTypePattern(String)} has been set
|
* @throws IllegalStateException if no {@link #setTypePattern(String)} has been set
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
if (this.aspectJTypePatternMatcher == null) {
|
if (this.aspectJTypePatternMatcher == null) {
|
||||||
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
|
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
|
||||||
|
|
|
@ -111,6 +111,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
* is that aspects written in the code-style (AspectJ language) also have the annotation present
|
* is that aspects written in the code-style (AspectJ language) also have the annotation present
|
||||||
* when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.
|
* when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isAspect(Class<?> clazz) {
|
public boolean isAspect(Class<?> clazz) {
|
||||||
return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
|
return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
|
||||||
}
|
}
|
||||||
|
@ -135,6 +136,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(Class<?> aspectClass) throws AopConfigException {
|
public void validate(Class<?> aspectClass) throws AopConfigException {
|
||||||
// If the parent has the annotation and isn't abstract it's an error
|
// If the parent has the annotation and isn't abstract it's an error
|
||||||
if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null &&
|
if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null &&
|
||||||
|
@ -309,6 +311,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
*/
|
*/
|
||||||
private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {
|
private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameterNames(Method method) {
|
public String[] getParameterNames(Method method) {
|
||||||
if (method.getParameterTypes().length == 0) {
|
if (method.getParameterTypes().length == 0) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
|
@ -330,6 +333,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameterNames(Constructor ctor) {
|
public String[] getParameterNames(Constructor ctor) {
|
||||||
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,12 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getAspectInstance() {
|
public Object getAspectInstance() {
|
||||||
return this.beanFactory.getBean(this.name);
|
return this.beanFactory.getBean(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassLoader getAspectClassLoader() {
|
public ClassLoader getAspectClassLoader() {
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
||||||
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
|
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
|
||||||
|
@ -85,6 +87,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AspectMetadata getAspectMetadata() {
|
public AspectMetadata getAspectMetadata() {
|
||||||
return this.aspectMetadata;
|
return this.aspectMetadata;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +102,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
* @see org.springframework.core.Ordered
|
* @see org.springframework.core.Ordered
|
||||||
* @see org.springframework.core.annotation.Order
|
* @see org.springframework.core.annotation.Order
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
Class<?> type = this.beanFactory.getType(this.name);
|
Class<?> type = this.beanFactory.getType(this.name);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|
|
@ -97,6 +97,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
* The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change
|
* The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change
|
||||||
* depending on the state of the advice.
|
* depending on the state of the advice.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +107,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
* are much richer. In AspectJ terminology, all a return of {@code true}
|
* are much richer. In AspectJ terminology, all a return of {@code true}
|
||||||
* means here is that the aspect is not a SINGLETON.
|
* means here is that the aspect is not a SINGLETON.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON);
|
return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON);
|
||||||
}
|
}
|
||||||
|
@ -120,6 +122,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
/**
|
/**
|
||||||
* Lazily instantiate advice if necessary.
|
* Lazily instantiate advice if necessary.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized Advice getAdvice() {
|
public synchronized Advice getAdvice() {
|
||||||
if (this.instantiatedAdvice == null) {
|
if (this.instantiatedAdvice == null) {
|
||||||
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
|
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
|
||||||
|
@ -127,10 +130,12 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
return this.instantiatedAdvice;
|
return this.instantiatedAdvice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isLazy() {
|
public boolean isLazy() {
|
||||||
return this.lazy;
|
return this.lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized boolean isAdviceInstantiated() {
|
public synchronized boolean isAdviceInstantiated() {
|
||||||
return (this.instantiatedAdvice != null);
|
return (this.instantiatedAdvice != null);
|
||||||
}
|
}
|
||||||
|
@ -149,18 +154,22 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
return this.declaredPointcut;
|
return this.declaredPointcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.aspectInstanceFactory.getOrder();
|
return this.aspectInstanceFactory.getOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getAspectName() {
|
public String getAspectName() {
|
||||||
return this.aspectName;
|
return this.aspectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDeclarationOrder() {
|
public int getDeclarationOrder() {
|
||||||
return this.declarationOrder;
|
return this.declarationOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBeforeAdvice() {
|
public boolean isBeforeAdvice() {
|
||||||
if (this.isBeforeAdvice == null) {
|
if (this.isBeforeAdvice == null) {
|
||||||
determineAdviceType();
|
determineAdviceType();
|
||||||
|
@ -168,6 +177,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
return this.isBeforeAdvice;
|
return this.isBeforeAdvice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAfterAdvice() {
|
public boolean isAfterAdvice() {
|
||||||
if (this.isAfterAdvice == null) {
|
if (this.isAfterAdvice == null) {
|
||||||
determineAdviceType();
|
determineAdviceType();
|
||||||
|
@ -245,6 +255,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
|
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
// This can match only on declared pointcut.
|
// This can match only on declared pointcut.
|
||||||
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
|
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized Object getAspectInstance() {
|
public synchronized Object getAspectInstance() {
|
||||||
if (this.materialized == null) {
|
if (this.materialized == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
@ -57,14 +58,17 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
|
||||||
return (this.materialized != null);
|
return (this.materialized != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassLoader getAspectClassLoader() {
|
public ClassLoader getAspectClassLoader() {
|
||||||
return this.maaif.getAspectClassLoader();
|
return this.maaif.getAspectClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public AspectMetadata getAspectMetadata() {
|
public AspectMetadata getAspectMetadata() {
|
||||||
return this.maaif.getAspectMetadata();
|
return this.maaif.getAspectMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.maaif.getOrder();
|
return this.maaif.getOrder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
new InstanceComparator<Annotation>(
|
new InstanceComparator<Annotation>(
|
||||||
Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class),
|
Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class),
|
||||||
new Converter<Method, Annotation>() {
|
new Converter<Method, Annotation>() {
|
||||||
|
@Override
|
||||||
public Annotation convert(Method method) {
|
public Annotation convert(Method method) {
|
||||||
AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
|
AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
|
||||||
return annotation == null ? null : annotation.getAnnotation();
|
return annotation == null ? null : annotation.getAnnotation();
|
||||||
|
@ -82,6 +83,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}));
|
}));
|
||||||
comparator.addComparator(new ConvertingComparator<Method, String>(
|
comparator.addComparator(new ConvertingComparator<Method, String>(
|
||||||
new Converter<Method, String>() {
|
new Converter<Method, String>() {
|
||||||
|
@Override
|
||||||
public String convert(Method method) {
|
public String convert(Method method) {
|
||||||
return method.getName();
|
return method.getName();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
|
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
|
||||||
final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
|
final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
|
||||||
final String aspectName = maaif.getAspectMetadata().getAspectName();
|
final String aspectName = maaif.getAspectMetadata().getAspectName();
|
||||||
|
@ -128,6 +131,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
private List<Method> getAdvisorMethods(Class<?> aspectClass) {
|
private List<Method> getAdvisorMethods(Class<?> aspectClass) {
|
||||||
final List<Method> methods = new LinkedList<Method>();
|
final List<Method> methods = new LinkedList<Method>();
|
||||||
ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
|
ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
|
||||||
|
@Override
|
||||||
public void doWith(Method method) throws IllegalArgumentException {
|
public void doWith(Method method) throws IllegalArgumentException {
|
||||||
// Exclude pointcuts
|
// Exclude pointcuts
|
||||||
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
|
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
|
||||||
|
@ -164,6 +168,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
|
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
|
||||||
int declarationOrderInAspect, String aspectName) {
|
int declarationOrderInAspect, String aspectName) {
|
||||||
|
|
||||||
|
@ -191,6 +196,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp,
|
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp,
|
||||||
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
|
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
|
||||||
|
|
||||||
|
@ -272,6 +278,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
|
|
||||||
public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
|
public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
|
||||||
super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
|
super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
|
||||||
|
@Override
|
||||||
public void before(Method method, Object[] args, Object target) {
|
public void before(Method method, Object[] args, Object target) {
|
||||||
// Simply instantiate the aspect
|
// Simply instantiate the aspect
|
||||||
aif.getAspectInstance();
|
aif.getAspectInstance();
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final AspectMetadata getAspectMetadata() {
|
public final AspectMetadata getAspectMetadata() {
|
||||||
return this.metadata;
|
return this.metadata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final AspectMetadata getAspectMetadata() {
|
public final AspectMetadata getAspectMetadata() {
|
||||||
return this.metadata;
|
return this.metadata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,11 +131,13 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
|
||||||
this.comparator = comparator;
|
this.comparator = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int compareTo(Object obj) {
|
public int compareTo(Object obj) {
|
||||||
Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor;
|
Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor;
|
||||||
return this.comparator.compare(this.advisor, otherAdvisor);
|
return this.comparator.compare(this.advisor, otherAdvisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int fallbackCompareTo(Object obj) {
|
public int fallbackCompareTo(Object obj) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ class AspectJPrecedenceComparator implements Comparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Object o1, Object o2) {
|
||||||
if (!(o1 instanceof Advisor && o2 instanceof Advisor)) {
|
if (!(o1 instanceof Advisor && o2 instanceof Advisor)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
|
@ -58,6 +58,7 @@ import org.springframework.util.StringUtils;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implements BeanDefinitionDecorator {
|
public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implements BeanDefinitionDecorator {
|
||||||
|
|
||||||
|
@Override
|
||||||
public final BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definitionHolder, ParserContext parserContext) {
|
public final BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definitionHolder, ParserContext parserContext) {
|
||||||
BeanDefinitionRegistry registry = parserContext.getRegistry();
|
BeanDefinitionRegistry registry = parserContext.getRegistry();
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.advisorBeanName;
|
return this.advisorBeanName;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +111,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
|
||||||
return this.beanReferences;
|
return this.beanReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getSource() {
|
public Object getSource() {
|
||||||
return this.advisorDefinition.getSource();
|
return this.advisorDefinition.getSource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport {
|
||||||
* '{@code config}', '{@code spring-configured}', '{@code aspectj-autoproxy}'
|
* '{@code config}', '{@code spring-configured}', '{@code aspectj-autoproxy}'
|
||||||
* and '{@code scoped-proxy}' tags.
|
* and '{@code scoped-proxy}' tags.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
// In 2.0 XSD as well as in 2.1 XSD.
|
// In 2.0 XSD as well as in 2.1 XSD.
|
||||||
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
|
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||||
*/
|
*/
|
||||||
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
|
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
|
@Override
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
|
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
|
||||||
extendBeanDefinition(element, parserContext);
|
extendBeanDefinition(element, parserContext);
|
||||||
|
|
|
@ -95,6 +95,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
private ParseState parseState = new ParseState();
|
private ParseState parseState = new ParseState();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
CompositeComponentDefinition compositeDef =
|
CompositeComponentDefinition compositeDef =
|
||||||
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
|
||||||
this.methodName = methodName;
|
this.methodName = methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
if (!StringUtils.hasText(this.targetBeanName)) {
|
if (!StringUtils.hasText(this.targetBeanName)) {
|
||||||
throw new IllegalArgumentException("Property 'targetBeanName' is required");
|
throw new IllegalArgumentException("Property 'targetBeanName' is required");
|
||||||
|
@ -78,14 +79,17 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Method getObject() throws Exception {
|
public Method getObject() throws Exception {
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<Method> getObjectType() {
|
public Class<Method> getObjectType() {
|
||||||
return Method.class;
|
return Method.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.pointcutBeanName;
|
return this.pointcutBeanName;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +61,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
|
||||||
return new BeanDefinition[] {this.pointcutDefinition};
|
return new BeanDefinition[] {this.pointcutDefinition};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getSource() {
|
public Object getSource() {
|
||||||
return this.pointcutDefinition.getSource();
|
return this.pointcutDefinition.getSource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator {
|
||||||
private static final String PROXY_TARGET_CLASS = "proxy-target-class";
|
private static final String PROXY_TARGET_CLASS = "proxy-target-class";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||||
boolean proxyTargetClass = true;
|
boolean proxyTargetClass = true;
|
||||||
if (node instanceof Element) {
|
if (node instanceof Element) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
|
||||||
this.aspectBeanName = aspectBeanName;
|
this.aspectBeanName = aspectBeanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
if (!StringUtils.hasText(this.aspectBeanName)) {
|
if (!StringUtils.hasText(this.aspectBeanName)) {
|
||||||
|
@ -59,10 +60,12 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
|
||||||
* Look up the aspect bean from the {@link BeanFactory} and returns it.
|
* Look up the aspect bean from the {@link BeanFactory} and returns it.
|
||||||
* @see #setAspectBeanName
|
* @see #setAspectBeanName
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getAspectInstance() {
|
public Object getAspectInstance() {
|
||||||
return this.beanFactory.getBean(this.aspectBeanName);
|
return this.beanFactory.getBean(this.aspectBeanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassLoader getAspectClassLoader() {
|
public ClassLoader getAspectClassLoader() {
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
||||||
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
|
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
|
||||||
|
@ -72,6 +75,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
if (this.beanFactory.isSingleton(this.aspectBeanName) &&
|
if (this.beanFactory.isSingleton(this.aspectBeanName) &&
|
||||||
this.beanFactory.isTypeMatch(this.aspectBeanName, Ordered.class)) {
|
this.beanFactory.isTypeMatch(this.aspectBeanName, Ordered.class)) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
"org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
|
"org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
|
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
|
||||||
RootBeanDefinition def = new RootBeanDefinition();
|
RootBeanDefinition def = new RootBeanDefinition();
|
||||||
|
|
|
@ -50,6 +50,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
|
||||||
private final Map<String, Boolean> eligibleBeans = new ConcurrentHashMap<String, Boolean>(64);
|
private final Map<String, Boolean> eligibleBeans = new ConcurrentHashMap<String, Boolean>(64);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||||
this.beanClassLoader = beanClassLoader;
|
this.beanClassLoader = beanClassLoader;
|
||||||
}
|
}
|
||||||
|
@ -58,15 +59,18 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||||
if (bean instanceof AopInfrastructureBean) {
|
if (bean instanceof AopInfrastructureBean) {
|
||||||
// Ignore AOP infrastructure such as scoped proxies.
|
// Ignore AOP infrastructure such as scoped proxies.
|
||||||
|
|
|
@ -122,6 +122,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
this.proxyClassLoader = classLoader;
|
this.proxyClassLoader = classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||||
if (this.proxyClassLoader == null) {
|
if (this.proxyClassLoader == null) {
|
||||||
this.proxyClassLoader = classLoader;
|
this.proxyClassLoader = classLoader;
|
||||||
|
@ -129,6 +130,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
if (this.target == null) {
|
if (this.target == null) {
|
||||||
throw new IllegalArgumentException("Property 'target' is required");
|
throw new IllegalArgumentException("Property 'target' is required");
|
||||||
|
@ -190,6 +192,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getObject() {
|
public Object getObject() {
|
||||||
if (this.proxy == null) {
|
if (this.proxy == null) {
|
||||||
throw new FactoryBeanNotInitializedException();
|
throw new FactoryBeanNotInitializedException();
|
||||||
|
@ -197,6 +200,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
return this.proxy;
|
return this.proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<?> getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
if (this.proxy != null) {
|
if (this.proxy != null) {
|
||||||
return this.proxy.getClass();
|
return this.proxy.getClass();
|
||||||
|
@ -213,6 +217,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean isSingleton() {
|
public final boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,10 +137,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
setTargetSource(new SingletonTargetSource(target));
|
setTargetSource(new SingletonTargetSource(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTargetSource(TargetSource targetSource) {
|
public void setTargetSource(TargetSource targetSource) {
|
||||||
this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE);
|
this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public TargetSource getTargetSource() {
|
public TargetSource getTargetSource() {
|
||||||
return this.targetSource;
|
return this.targetSource;
|
||||||
}
|
}
|
||||||
|
@ -162,14 +164,17 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
this.targetSource = EmptyTargetSource.forClass(targetClass);
|
this.targetSource = EmptyTargetSource.forClass(targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<?> getTargetClass() {
|
public Class<?> getTargetClass() {
|
||||||
return this.targetSource.getTargetClass();
|
return this.targetSource.getTargetClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setPreFiltered(boolean preFiltered) {
|
public void setPreFiltered(boolean preFiltered) {
|
||||||
this.preFiltered = preFiltered;
|
this.preFiltered = preFiltered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPreFiltered() {
|
public boolean isPreFiltered() {
|
||||||
return this.preFiltered;
|
return this.preFiltered;
|
||||||
}
|
}
|
||||||
|
@ -228,10 +233,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
return this.interfaces.remove(intf);
|
return this.interfaces.remove(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getProxiedInterfaces() {
|
public Class[] getProxiedInterfaces() {
|
||||||
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isInterfaceProxied(Class intf) {
|
public boolean isInterfaceProxied(Class intf) {
|
||||||
for (Class proxyIntf : this.interfaces) {
|
for (Class proxyIntf : this.interfaces) {
|
||||||
if (intf.isAssignableFrom(proxyIntf)) {
|
if (intf.isAssignableFrom(proxyIntf)) {
|
||||||
|
@ -242,15 +249,18 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Advisor[] getAdvisors() {
|
public final Advisor[] getAdvisors() {
|
||||||
return this.advisorArray;
|
return this.advisorArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addAdvisor(Advisor advisor) {
|
public void addAdvisor(Advisor advisor) {
|
||||||
int pos = this.advisors.size();
|
int pos = this.advisors.size();
|
||||||
addAdvisor(pos, advisor);
|
addAdvisor(pos, advisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException {
|
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException {
|
||||||
if (advisor instanceof IntroductionAdvisor) {
|
if (advisor instanceof IntroductionAdvisor) {
|
||||||
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
||||||
|
@ -258,6 +268,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
addAdvisorInternal(pos, advisor);
|
addAdvisorInternal(pos, advisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean removeAdvisor(Advisor advisor) {
|
public boolean removeAdvisor(Advisor advisor) {
|
||||||
int index = indexOf(advisor);
|
int index = indexOf(advisor);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
|
@ -269,6 +280,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeAdvisor(int index) throws AopConfigException {
|
public void removeAdvisor(int index) throws AopConfigException {
|
||||||
if (isFrozen()) {
|
if (isFrozen()) {
|
||||||
throw new AopConfigException("Cannot remove Advisor: Configuration is frozen.");
|
throw new AopConfigException("Cannot remove Advisor: Configuration is frozen.");
|
||||||
|
@ -292,11 +304,13 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
adviceChanged();
|
adviceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int indexOf(Advisor advisor) {
|
public int indexOf(Advisor advisor) {
|
||||||
Assert.notNull(advisor, "Advisor must not be null");
|
Assert.notNull(advisor, "Advisor must not be null");
|
||||||
return this.advisors.indexOf(advisor);
|
return this.advisors.indexOf(advisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException {
|
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException {
|
||||||
Assert.notNull(a, "Advisor a must not be null");
|
Assert.notNull(a, "Advisor a must not be null");
|
||||||
Assert.notNull(b, "Advisor b must not be null");
|
Assert.notNull(b, "Advisor b must not be null");
|
||||||
|
@ -388,6 +402,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addAdvice(Advice advice) throws AopConfigException {
|
public void addAdvice(Advice advice) throws AopConfigException {
|
||||||
int pos = this.advisors.size();
|
int pos = this.advisors.size();
|
||||||
addAdvice(pos, advice);
|
addAdvice(pos, advice);
|
||||||
|
@ -396,6 +411,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
/**
|
/**
|
||||||
* Cannot add introductions this way unless the advice implements IntroductionInfo.
|
* Cannot add introductions this way unless the advice implements IntroductionInfo.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addAdvice(int pos, Advice advice) throws AopConfigException {
|
public void addAdvice(int pos, Advice advice) throws AopConfigException {
|
||||||
Assert.notNull(advice, "Advice must not be null");
|
Assert.notNull(advice, "Advice must not be null");
|
||||||
if (advice instanceof IntroductionInfo) {
|
if (advice instanceof IntroductionInfo) {
|
||||||
|
@ -412,6 +428,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean removeAdvice(Advice advice) throws AopConfigException {
|
public boolean removeAdvice(Advice advice) throws AopConfigException {
|
||||||
int index = indexOf(advice);
|
int index = indexOf(advice);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
|
@ -423,6 +440,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int indexOf(Advice advice) {
|
public int indexOf(Advice advice) {
|
||||||
Assert.notNull(advice, "Advice must not be null");
|
Assert.notNull(advice, "Advice must not be null");
|
||||||
for (int i = 0; i < this.advisors.size(); i++) {
|
for (int i = 0; i < this.advisors.size(); i++) {
|
||||||
|
@ -554,6 +572,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toProxyConfigString() {
|
public String toProxyConfigString() {
|
||||||
return toString();
|
return toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,10 +146,12 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getProxy() {
|
public Object getProxy() {
|
||||||
return getProxy(null);
|
return getProxy(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getProxy(ClassLoader classLoader) {
|
public Object getProxy(ClassLoader classLoader) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource());
|
logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource());
|
||||||
|
@ -386,6 +388,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
Object retVal = methodProxy.invoke(this.target, args);
|
Object retVal = methodProxy.invoke(this.target, args);
|
||||||
return processReturnType(proxy, this.target, method, retVal);
|
return processReturnType(proxy, this.target, method, retVal);
|
||||||
|
@ -405,6 +408,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
try {
|
try {
|
||||||
|
@ -432,6 +436,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.targetSource = targetSource;
|
this.targetSource = targetSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
Object target = this.targetSource.getTarget();
|
Object target = this.targetSource.getTarget();
|
||||||
try {
|
try {
|
||||||
|
@ -456,6 +461,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.targetSource = targetSource;
|
this.targetSource = targetSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
Object target = this.targetSource.getTarget();
|
Object target = this.targetSource.getTarget();
|
||||||
|
@ -485,6 +491,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object loadObject() {
|
public Object loadObject() {
|
||||||
return this.target;
|
return this.target;
|
||||||
}
|
}
|
||||||
|
@ -502,6 +509,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.advised = advised;
|
this.advised = advised;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object loadObject() throws Exception {
|
public Object loadObject() throws Exception {
|
||||||
return this.advised;
|
return this.advised;
|
||||||
}
|
}
|
||||||
|
@ -520,6 +528,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.advised = advised;
|
this.advised = advised;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
|
||||||
Object other = args[0];
|
Object other = args[0];
|
||||||
if (proxy == other) {
|
if (proxy == other) {
|
||||||
|
@ -552,6 +561,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.advised = advised;
|
this.advised = advised;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
|
||||||
return CglibAopProxy.class.hashCode() * 13 + this.advised.getTargetSource().hashCode();
|
return CglibAopProxy.class.hashCode() * 13 + this.advised.getTargetSource().hashCode();
|
||||||
}
|
}
|
||||||
|
@ -575,6 +585,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
|
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
|
||||||
this.targetClass, this.adviceChain, methodProxy);
|
this.targetClass, this.adviceChain, methodProxy);
|
||||||
|
@ -598,6 +609,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
this.advised = advised;
|
this.advised = advised;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
boolean setProxyContext = false;
|
boolean setProxyContext = false;
|
||||||
|
@ -754,6 +766,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
|
||||||
* DynamicUnadvisedInterceptor already considers this.</dd>
|
* DynamicUnadvisedInterceptor already considers this.</dd>
|
||||||
* </dl>
|
* </dl>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int accept(Method method) {
|
public int accept(Method method) {
|
||||||
if (AopUtils.isFinalizeMethod(method)) {
|
if (AopUtils.isFinalizeMethod(method)) {
|
||||||
logger.debug("Found finalize() method - using NO_OVERRIDE");
|
logger.debug("Found finalize() method - using NO_OVERRIDE");
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.springframework.aop.support.MethodMatchers;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable {
|
public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable {
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
||||||
Advised config, Method method, Class targetClass) {
|
Advised config, Method method, Class targetClass) {
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.springframework.aop.SpringProxy;
|
||||||
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||||
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
|
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
|
||||||
Class targetClass = config.getTargetClass();
|
Class targetClass = config.getTargetClass();
|
||||||
|
|
|
@ -106,10 +106,12 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getProxy() {
|
public Object getProxy() {
|
||||||
return getProxy(ClassUtils.getDefaultClassLoader());
|
return getProxy(ClassUtils.getDefaultClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getProxy(ClassLoader classLoader) {
|
public Object getProxy(ClassLoader classLoader) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
|
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
|
||||||
|
@ -147,6 +149,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
* <p>Callers will see exactly the exception thrown by the target,
|
* <p>Callers will see exactly the exception thrown by the target,
|
||||||
* unless a hook method throws an exception.
|
* unless a hook method throws an exception.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
MethodInvocation invocation;
|
MethodInvocation invocation;
|
||||||
Object oldProxy = null;
|
Object oldProxy = null;
|
||||||
|
|
|
@ -218,12 +218,14 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
this.classLoaderConfigured = (classLoader != null);
|
this.classLoaderConfigured = (classLoader != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||||
if (!this.classLoaderConfigured) {
|
if (!this.classLoaderConfigured) {
|
||||||
this.proxyClassLoader = classLoader;
|
this.proxyClassLoader = classLoader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
checkInterceptorNames();
|
checkInterceptorNames();
|
||||||
|
@ -237,6 +239,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* {@code getObject()} for a proxy.
|
* {@code getObject()} for a proxy.
|
||||||
* @return a fresh AOP proxy reflecting the current state of this factory
|
* @return a fresh AOP proxy reflecting the current state of this factory
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getObject() throws BeansException {
|
public Object getObject() throws BeansException {
|
||||||
initializeAdvisorChain();
|
initializeAdvisorChain();
|
||||||
if (isSingleton()) {
|
if (isSingleton()) {
|
||||||
|
@ -257,6 +260,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* a single one), the target bean type, or the TargetSource's target class.
|
* a single one), the target bean type, or the TargetSource's target class.
|
||||||
* @see org.springframework.aop.TargetSource#getTargetClass
|
* @see org.springframework.aop.TargetSource#getTargetClass
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Class<?> getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (this.singletonInstance != null) {
|
if (this.singletonInstance != null) {
|
||||||
|
@ -278,6 +282,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return this.singleton;
|
return this.singleton;
|
||||||
}
|
}
|
||||||
|
@ -638,10 +643,12 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
return beanName;
|
return beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,14 +114,17 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Object getProxy() {
|
public final Object getProxy() {
|
||||||
return this.proxy;
|
return this.proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Object getThis() {
|
public final Object getThis() {
|
||||||
return this.target;
|
return this.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final AccessibleObject getStaticPart() {
|
public final AccessibleObject getStaticPart() {
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
@ -131,19 +134,23 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* May or may not correspond with a method invoked on an underlying
|
* May or may not correspond with a method invoked on an underlying
|
||||||
* implementation of that interface.
|
* implementation of that interface.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final Method getMethod() {
|
public final Method getMethod() {
|
||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final Object[] getArguments() {
|
public final Object[] getArguments() {
|
||||||
return (this.arguments != null ? this.arguments : new Object[0]);
|
return (this.arguments != null ? this.arguments : new Object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setArguments(Object[] arguments) {
|
public void setArguments(Object[] arguments) {
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object proceed() throws Throwable {
|
public Object proceed() throws Throwable {
|
||||||
// We start with an index of -1 and increment early.
|
// We start with an index of -1 and increment early.
|
||||||
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
|
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
|
||||||
|
@ -192,6 +199,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* current interceptor index.
|
* current interceptor index.
|
||||||
* @see java.lang.Object#clone()
|
* @see java.lang.Object#clone()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public MethodInvocation invocableClone() {
|
public MethodInvocation invocableClone() {
|
||||||
Object[] cloneArguments = null;
|
Object[] cloneArguments = null;
|
||||||
if (this.arguments != null) {
|
if (this.arguments != null) {
|
||||||
|
@ -210,6 +218,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* current interceptor index.
|
* current interceptor index.
|
||||||
* @see java.lang.Object#clone()
|
* @see java.lang.Object#clone()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public MethodInvocation invocableClone(Object[] arguments) {
|
public MethodInvocation invocableClone(Object[] arguments) {
|
||||||
// Force initialization of the user attributes Map,
|
// Force initialization of the user attributes Map,
|
||||||
// for having a shared Map reference in the clone.
|
// for having a shared Map reference in the clone.
|
||||||
|
@ -230,6 +239,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setUserAttribute(String key, Object value) {
|
public void setUserAttribute(String key, Object value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (this.userAttributes == null) {
|
if (this.userAttributes == null) {
|
||||||
|
@ -244,6 +254,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getUserAttribute(String key) {
|
public Object getUserAttribute(String key) {
|
||||||
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
|
return (this.userAttributes != null ? this.userAttributes.get(key) : null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,12 @@ public class AdvisorAdapterRegistrationManager implements BeanPostProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
if (bean instanceof AdvisorAdapter){
|
if (bean instanceof AdvisorAdapter){
|
||||||
this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean);
|
this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean);
|
||||||
|
|
|
@ -34,10 +34,12 @@ import org.springframework.aop.AfterReturningAdvice;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable {
|
class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean supportsAdvice(Advice advice) {
|
public boolean supportsAdvice(Advice advice) {
|
||||||
return (advice instanceof AfterReturningAdvice);
|
return (advice instanceof AfterReturningAdvice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodInterceptor getInterceptor(Advisor advisor) {
|
public MethodInterceptor getInterceptor(Advisor advisor) {
|
||||||
AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
|
AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
|
||||||
return new AfterReturningAdviceInterceptor(advice);
|
return new AfterReturningAdviceInterceptor(advice);
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class AfterReturningAdviceInterceptor implements MethodInterceptor, After
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
Object retVal = mi.proceed();
|
Object retVal = mi.proceed();
|
||||||
this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());
|
this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException {
|
public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException {
|
||||||
if (adviceObject instanceof Advisor) {
|
if (adviceObject instanceof Advisor) {
|
||||||
return (Advisor) adviceObject;
|
return (Advisor) adviceObject;
|
||||||
|
@ -74,6 +75,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
|
||||||
throw new UnknownAdviceTypeException(advice);
|
throw new UnknownAdviceTypeException(advice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
|
public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
|
||||||
List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3);
|
List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3);
|
||||||
Advice advice = advisor.getAdvice();
|
Advice advice = advisor.getAdvice();
|
||||||
|
@ -91,6 +93,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
|
||||||
return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
|
return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void registerAdvisorAdapter(AdvisorAdapter adapter) {
|
public void registerAdvisorAdapter(AdvisorAdapter adapter) {
|
||||||
this.adapters.add(adapter);
|
this.adapters.add(adapter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,12 @@ import org.springframework.aop.MethodBeforeAdvice;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class MethodBeforeAdviceAdapter implements AdvisorAdapter, Serializable {
|
class MethodBeforeAdviceAdapter implements AdvisorAdapter, Serializable {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean supportsAdvice(Advice advice) {
|
public boolean supportsAdvice(Advice advice) {
|
||||||
return (advice instanceof MethodBeforeAdvice);
|
return (advice instanceof MethodBeforeAdvice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodInterceptor getInterceptor(Advisor advisor) {
|
public MethodInterceptor getInterceptor(Advisor advisor) {
|
||||||
MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
|
MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
|
||||||
return new MethodBeforeAdviceInterceptor(advice);
|
return new MethodBeforeAdviceInterceptor(advice);
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Seriali
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() );
|
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() );
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
|
|
|
@ -34,10 +34,12 @@ import org.springframework.aop.ThrowsAdvice;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class ThrowsAdviceAdapter implements AdvisorAdapter, Serializable {
|
class ThrowsAdviceAdapter implements AdvisorAdapter, Serializable {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean supportsAdvice(Advice advice) {
|
public boolean supportsAdvice(Advice advice) {
|
||||||
return (advice instanceof ThrowsAdvice);
|
return (advice instanceof ThrowsAdvice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodInterceptor getInterceptor(Advisor advisor) {
|
public MethodInterceptor getInterceptor(Advisor advisor) {
|
||||||
return new ThrowsAdviceInterceptor(advisor.getAdvice());
|
return new ThrowsAdviceInterceptor(advisor.getAdvice());
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
|
|
|
@ -155,6 +155,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final int getOrder() {
|
public final int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
}
|
}
|
||||||
|
@ -232,12 +233,14 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||||
this.classLoaderConfigured = (classLoader != null);
|
this.classLoaderConfigured = (classLoader != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||||
if (!this.classLoaderConfigured) {
|
if (!this.classLoaderConfigured) {
|
||||||
this.proxyClassLoader = classLoader;
|
this.proxyClassLoader = classLoader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
@ -251,21 +254,25 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
|
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
|
||||||
Object cacheKey = getCacheKey(beanClass, beanName);
|
Object cacheKey = getCacheKey(beanClass, beanName);
|
||||||
return this.proxyTypes.get(cacheKey);
|
return this.proxyTypes.get(cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
|
public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
|
||||||
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
||||||
this.earlyProxyReferences.put(cacheKey, Boolean.TRUE);
|
this.earlyProxyReferences.put(cacheKey, Boolean.TRUE);
|
||||||
return wrapIfNecessary(bean, beanName, cacheKey);
|
return wrapIfNecessary(bean, beanName, cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
Object cacheKey = getCacheKey(beanClass, beanName);
|
Object cacheKey = getCacheKey(beanClass, beanName);
|
||||||
|
|
||||||
|
@ -296,16 +303,19 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean postProcessAfterInstantiation(Object bean, String beanName) {
|
public boolean postProcessAfterInstantiation(Object bean, String beanName) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public PropertyValues postProcessPropertyValues(
|
public PropertyValues postProcessPropertyValues(
|
||||||
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
|
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) {
|
||||||
|
|
||||||
return pvs;
|
return pvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
@ -315,6 +325,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig
|
||||||
* identified as one to proxy by the subclass.
|
* identified as one to proxy by the subclass.
|
||||||
* @see #getAdvicesAndAdvisorsForBean
|
* @see #getAdvicesAndAdvisorsForBean
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
Object cacheKey = getCacheKey(bean.getClass(), beanName);
|
||||||
|
|
|
@ -79,6 +79,7 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
|
||||||
return this.advisorBeanNamePrefix;
|
return this.advisorBeanNamePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanName(String name) {
|
public void setBeanName(String name) {
|
||||||
// If no infrastructure bean name prefix has been set, override it.
|
// If no infrastructure bean name prefix has been set, override it.
|
||||||
if (this.advisorBeanNamePrefix == null) {
|
if (this.advisorBeanNamePrefix == null) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
new HashMap<String, DefaultListableBeanFactory>();
|
new HashMap<String, DefaultListableBeanFactory>();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void setBeanFactory(BeanFactory beanFactory) {
|
public final void setBeanFactory(BeanFactory beanFactory) {
|
||||||
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
|
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
|
||||||
throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " +
|
throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " +
|
||||||
|
@ -86,6 +87,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
// Implementation of the TargetSourceCreator interface
|
// Implementation of the TargetSourceCreator interface
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
|
public final TargetSource getTargetSource(Class<?> beanClass, String beanName) {
|
||||||
AbstractBeanFactoryBasedTargetSource targetSource =
|
AbstractBeanFactoryBasedTargetSource targetSource =
|
||||||
createBeanFactoryBasedTargetSource(beanClass, beanName);
|
createBeanFactoryBasedTargetSource(beanClass, beanName);
|
||||||
|
@ -159,6 +161,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
|
||||||
* Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
|
* Destroys the internal BeanFactory on shutdown of the TargetSourceCreator.
|
||||||
* @see #getInternalBeanFactoryForBean
|
* @see #getInternalBeanFactoryForBean
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
synchronized (this.internalBeanFactories) {
|
synchronized (this.internalBeanFactories) {
|
||||||
for (DefaultListableBeanFactory bf : this.internalBeanFactories.values()) {
|
for (DefaultListableBeanFactory bf : this.internalBeanFactories.values()) {
|
||||||
|
|
|
@ -105,6 +105,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||||
* to the {@code invokeUnderTrace} method for handling.
|
* to the {@code invokeUnderTrace} method for handling.
|
||||||
* @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
|
* @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||||
Log logger = getLoggerForInvocation(invocation);
|
Log logger = getLoggerForInvocation(invocation);
|
||||||
if (isInterceptorEnabled(invocation, logger)) {
|
if (isInterceptorEnabled(invocation, logger)) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||||
/**
|
/**
|
||||||
* Set the {@link BeanFactory} to be used when looking up executors by qualifier.
|
* Set the {@link BeanFactory} to be used when looking up executors by qualifier.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,11 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
|
||||||
* @return {@link Future} if the original method returns {@code Future}; {@code null}
|
* @return {@link Future} if the original method returns {@code Future}; {@code null}
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
public Object invoke(final MethodInvocation invocation) throws Throwable {
|
||||||
Future<?> result = this.determineAsyncExecutor(invocation.getMethod()).submit(
|
Future<?> result = this.determineAsyncExecutor(invocation.getMethod()).submit(
|
||||||
new Callable<Object>() {
|
new Callable<Object>() {
|
||||||
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
try {
|
try {
|
||||||
Object result = invocation.proceed();
|
Object result = invocation.proceed();
|
||||||
|
@ -113,6 +115,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return Ordered.HIGHEST_PRECEDENCE;
|
return Ordered.HIGHEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class ConcurrencyThrottleInterceptor extends ConcurrencyThrottleSupport
|
||||||
setConcurrencyLimit(1);
|
setConcurrencyLimit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
|
||||||
beforeAccess();
|
beforeAccess();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -109,6 +109,7 @@ public abstract class ExposeBeanNameAdvisors {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
if (!(mi instanceof ProxyMethodInvocation)) {
|
if (!(mi instanceof ProxyMethodInvocation)) {
|
||||||
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);
|
||||||
|
@ -142,6 +143,7 @@ public abstract class ExposeBeanNameAdvisors {
|
||||||
return super.invoke(mi);
|
return super.invoke(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getBeanName() {
|
public String getBeanName() {
|
||||||
return this.beanName;
|
return this.beanName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered,
|
||||||
private ExposeInvocationInterceptor() {
|
private ExposeInvocationInterceptor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
MethodInvocation oldInvocation = invocation.get();
|
MethodInvocation oldInvocation = invocation.get();
|
||||||
invocation.set(mi);
|
invocation.set(mi);
|
||||||
|
@ -95,6 +96,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return Ordered.HIGHEST_PRECEDENCE + 1;
|
return Ordered.HIGHEST_PRECEDENCE + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,12 @@ public class DefaultScopedObject implements ScopedObject, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getTargetObject() {
|
public Object getTargetObject() {
|
||||||
return this.beanFactory.getBean(this.targetBeanName);
|
return this.beanFactory.getBean(this.targetBeanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeFromScope() {
|
public void removeFromScope() {
|
||||||
this.beanFactory.destroyScopedBean(this.targetBeanName);
|
this.beanFactory.destroyScopedBean(this.targetBeanName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<O
|
||||||
this.scopedTargetSource.setTargetBeanName(targetBeanName);
|
this.scopedTargetSource.setTargetBeanName(targetBeanName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
|
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
|
||||||
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
|
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
|
||||||
|
@ -111,6 +112,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<O
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getObject() {
|
public Object getObject() {
|
||||||
if (this.proxy == null) {
|
if (this.proxy == null) {
|
||||||
throw new FactoryBeanNotInitializedException();
|
throw new FactoryBeanNotInitializedException();
|
||||||
|
@ -118,6 +120,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<O
|
||||||
return this.proxy;
|
return this.proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class<?> getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
if (this.proxy != null) {
|
if (this.proxy != null) {
|
||||||
return this.proxy.getClass();
|
return this.proxy.getClass();
|
||||||
|
@ -128,6 +131,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<O
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
|
||||||
return this.adviceBeanName;
|
return this.adviceBeanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
synchronized (this.adviceMonitor) {
|
synchronized (this.adviceMonitor) {
|
||||||
if (this.advice == null && this.adviceBeanName != null) {
|
if (this.advice == null && this.adviceBeanName != null) {
|
||||||
|
|
|
@ -83,6 +83,7 @@ public abstract class AbstractExpressionPointcut implements ExpressionPointcut,
|
||||||
/**
|
/**
|
||||||
* Return this pointcut's expression.
|
* Return this pointcut's expression.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getExpression() {
|
public String getExpression() {
|
||||||
return this.expression;
|
return this.expression;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public abstract class AbstractGenericPointcutAdvisor extends AbstractPointcutAdv
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
if (this.order != null) {
|
if (this.order != null) {
|
||||||
return this.order;
|
return this.order;
|
||||||
|
@ -55,6 +56,7 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere
|
||||||
return Ordered.LOWEST_PRECEDENCE;
|
return Ordered.LOWEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
|
||||||
* of the target class as well as against the method's declaring class,
|
* of the target class as well as against the method's declaring class,
|
||||||
* plus the name of the method.
|
* plus the name of the method.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
|
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
|
||||||
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
|
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
|
||||||
|
|
|
@ -96,6 +96,7 @@ public abstract class ClassFilters {
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
for (int i = 0; i < this.filters.length; i++) {
|
for (int i = 0; i < this.filters.length; i++) {
|
||||||
if (this.filters[i].matches(clazz)) {
|
if (this.filters[i].matches(clazz)) {
|
||||||
|
@ -130,6 +131,7 @@ public abstract class ClassFilters {
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
for (int i = 0; i < this.filters.length; i++) {
|
for (int i = 0; i < this.filters.length; i++) {
|
||||||
if (!this.filters[i].matches(clazz)) {
|
if (!this.filters[i].matches(clazz)) {
|
||||||
|
|
|
@ -170,10 +170,12 @@ public class ComposablePointcut implements Pointcut, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this.classFilter;
|
return this.classFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
return this.methodMatcher;
|
return this.methodMatcher;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
/**
|
/**
|
||||||
* Subclasses can override this for greater filtering (and performance).
|
* Subclasses can override this for greater filtering (and performance).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,14 +80,17 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
* Subclasses can override this if it's possible to filter out
|
* Subclasses can override this if it's possible to filter out
|
||||||
* some candidate classes.
|
* some candidate classes.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
++this.evaluations;
|
++this.evaluations;
|
||||||
ControlFlow cflow = ControlFlowFactory.createControlFlow();
|
ControlFlow cflow = ControlFlowFactory.createControlFlow();
|
||||||
|
@ -101,10 +105,12 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class DefaultBeanFactoryPointcutAdvisor extends AbstractBeanFactoryPointc
|
||||||
this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE);
|
this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,12 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
this.interfaces.add(intf);
|
this.interfaces.add(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class[] getInterfaces() {
|
||||||
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validateInterfaces() throws IllegalArgumentException {
|
public void validateInterfaces() throws IllegalArgumentException {
|
||||||
for (Class ifc : this.interfaces) {
|
for (Class ifc : this.interfaces) {
|
||||||
if (this.advice instanceof DynamicIntroductionAdvice &&
|
if (this.advice instanceof DynamicIntroductionAdvice &&
|
||||||
|
@ -121,23 +123,28 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple
|
||||||
this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE);
|
this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
|
||||||
* behaviour in around advice. However, subclasses should invoke this
|
* behaviour in around advice. However, subclasses should invoke this
|
||||||
* method, which handles introduced interfaces and forwarding to the target.
|
* method, which handles introduced interfaces and forwarding to the target.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
if (isMethodOnIntroducedInterface(mi)) {
|
if (isMethodOnIntroducedInterface(mi)) {
|
||||||
Object delegate = getIntroductionDelegateFor(mi.getThis());
|
Object delegate = getIntroductionDelegateFor(mi.getThis());
|
||||||
|
|
|
@ -99,6 +99,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
* behaviour in around advice. However, subclasses should invoke this
|
* behaviour in around advice. However, subclasses should invoke this
|
||||||
* method, which handles introduced interfaces and forwarding to the target.
|
* method, which handles introduced interfaces and forwarding to the target.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
if (isMethodOnIntroducedInterface(mi)) {
|
if (isMethodOnIntroducedInterface(mi)) {
|
||||||
// Using the following method rather than direct reflection, we
|
// Using the following method rather than direct reflection, we
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.springframework.aop.MethodMatcher;
|
||||||
*/
|
*/
|
||||||
public abstract class DynamicMethodMatcher implements MethodMatcher {
|
public abstract class DynamicMethodMatcher implements MethodMatcher {
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean isRuntime() {
|
public final boolean isRuntime() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +35,7 @@ public abstract class DynamicMethodMatcher implements MethodMatcher {
|
||||||
* Can override to add preconditions for dynamic matching. This implementation
|
* Can override to add preconditions for dynamic matching. This implementation
|
||||||
* always returns true.
|
* always returns true.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class<?> targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,12 @@ import org.springframework.aop.Pointcut;
|
||||||
*/
|
*/
|
||||||
public abstract class DynamicMethodMatcherPointcut extends DynamicMethodMatcher implements Pointcut {
|
public abstract class DynamicMethodMatcherPointcut extends DynamicMethodMatcher implements Pointcut {
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return ClassFilter.TRUE;
|
return ClassFilter.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final MethodMatcher getMethodMatcher() {
|
public final MethodMatcher getMethodMatcher() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||||
this.publishedInterfaces.remove(intf);
|
this.publishedInterfaces.remove(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class[] getInterfaces() {
|
||||||
return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]);
|
return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,11 +112,13 @@ public abstract class MethodMatchers {
|
||||||
this.mm2 = mm2;
|
this.mm2 = mm2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
||||||
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
|
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
|
||||||
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
|
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
|
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
|
||||||
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
|
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
|
||||||
|
@ -130,10 +132,12 @@ public abstract class MethodMatchers {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
return this.mm1.isRuntime() || this.mm2.isRuntime();
|
return this.mm1.isRuntime() || this.mm2.isRuntime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
|
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
|
||||||
}
|
}
|
||||||
|
@ -216,19 +220,23 @@ public abstract class MethodMatchers {
|
||||||
this.mm2 = mm2;
|
this.mm2 = mm2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
||||||
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
||||||
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
|
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
|
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRuntime() {
|
public boolean isRuntime() {
|
||||||
return this.mm1.isRuntime() || this.mm2.isRuntime();
|
return this.mm1.isRuntime() || this.mm2.isRuntime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class targetClass, Object[] args) {
|
||||||
// Because a dynamic intersection may be composed of a static and dynamic part,
|
// Because a dynamic intersection may be composed of a static and dynamic part,
|
||||||
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
|
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
for (String mappedName : this.mappedNames) {
|
for (String mappedName : this.mappedNames) {
|
||||||
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
|
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class NameMatchMethodPointcutAdvisor extends AbstractGenericPointcutAdvis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this.pointcut;
|
return this.pointcut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ public abstract class Pointcuts {
|
||||||
|
|
||||||
public static SetterPointcut INSTANCE = new SetterPointcut();
|
public static SetterPointcut INSTANCE = new SetterPointcut();
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return method.getName().startsWith("set") &&
|
return method.getName().startsWith("set") &&
|
||||||
method.getParameterTypes().length == 1 &&
|
method.getParameterTypes().length == 1 &&
|
||||||
|
@ -116,6 +117,7 @@ public abstract class Pointcuts {
|
||||||
|
|
||||||
public static GetterPointcut INSTANCE = new GetterPointcut();
|
public static GetterPointcut INSTANCE = new GetterPointcut();
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
return method.getName().startsWith("get") &&
|
return method.getName().startsWith("get") &&
|
||||||
method.getParameterTypes().length == 0;
|
method.getParameterTypes().length == 0;
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor
|
||||||
/**
|
/**
|
||||||
* Initialize the singleton Pointcut held within this Advisor.
|
* Initialize the singleton Pointcut held within this Advisor.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
synchronized (this.pointcutMonitor) {
|
synchronized (this.pointcutMonitor) {
|
||||||
if (this.pointcut == null) {
|
if (this.pointcut == null) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class RootClassFilter implements ClassFilter, Serializable {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class candidate) {
|
public boolean matches(Class candidate) {
|
||||||
return clazz.isAssignableFrom(candidate);
|
return clazz.isAssignableFrom(candidate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,12 @@ import org.springframework.aop.MethodMatcher;
|
||||||
*/
|
*/
|
||||||
public abstract class StaticMethodMatcher implements MethodMatcher {
|
public abstract class StaticMethodMatcher implements MethodMatcher {
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean isRuntime() {
|
public final boolean isRuntime() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
public final boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
// should never be invoked because isRuntime() returns false
|
// should never be invoked because isRuntime() returns false
|
||||||
throw new UnsupportedOperationException("Illegal MethodMatcher usage");
|
throw new UnsupportedOperationException("Illegal MethodMatcher usage");
|
||||||
|
|
|
@ -43,11 +43,13 @@ public abstract class StaticMethodMatcherPointcut extends StaticMethodMatcher im
|
||||||
this.classFilter = classFilter;
|
this.classFilter = classFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this.classFilter;
|
return this.classFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public final MethodMatcher getMethodMatcher() {
|
public final MethodMatcher getMethodMatcher() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMat
|
||||||
this.order = order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
}
|
}
|
||||||
|
@ -71,14 +72,17 @@ public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMat
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
return this.advice;
|
return this.advice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Pointcut getPointcut() {
|
public Pointcut getPointcut() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class AnnotationClassFilter implements ClassFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return (this.checkInherited ?
|
return (this.checkInherited ?
|
||||||
(AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) :
|
(AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) :
|
||||||
|
|
|
@ -90,10 +90,12 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public ClassFilter getClassFilter() {
|
public ClassFilter getClassFilter() {
|
||||||
return this.classFilter;
|
return this.classFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
return this.methodMatcher;
|
return this.methodMatcher;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class targetClass) {
|
||||||
if (method.isAnnotationPresent(this.annotationType)) {
|
if (method.isAnnotationPresent(this.annotationType)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -105,6 +105,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
||||||
* Set the owning BeanFactory. We need to save a reference so that we can
|
* Set the owning BeanFactory. We need to save a reference so that we can
|
||||||
* use the {@code getBean} method on every invocation.
|
* use the {@code getBean} method on every invocation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
if (this.targetBeanName == null) {
|
if (this.targetBeanName == null) {
|
||||||
throw new IllegalStateException("Property'targetBeanName' is required");
|
throw new IllegalStateException("Property'targetBeanName' is required");
|
||||||
|
@ -120,6 +121,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized Class<?> getTargetClass() {
|
public synchronized Class<?> getTargetClass() {
|
||||||
if (this.targetClass == null && this.beanFactory != null) {
|
if (this.targetClass == null && this.beanFactory != null) {
|
||||||
// Determine type of the target bean.
|
// Determine type of the target bean.
|
||||||
|
@ -137,10 +139,12 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
||||||
return this.targetClass;
|
return this.targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void releaseTarget(Object target) throws Exception {
|
public void releaseTarget(Object target) throws Exception {
|
||||||
// Nothing to do here.
|
// Nothing to do here.
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,12 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource {
|
||||||
* a meaningful value when the target is still {@code null}.
|
* a meaningful value when the target is still {@code null}.
|
||||||
* @see #isInitialized()
|
* @see #isInitialized()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized Class<?> getTargetClass() {
|
public synchronized Class<?> getTargetClass() {
|
||||||
return (this.lazyTarget != null ? this.lazyTarget.getClass() : null);
|
return (this.lazyTarget != null ? this.lazyTarget.getClass() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +79,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource {
|
||||||
* creating it on-the-fly if it doesn't exist already.
|
* creating it on-the-fly if it doesn't exist already.
|
||||||
* @see #createObject()
|
* @see #createObject()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized Object getTarget() throws Exception {
|
public synchronized Object getTarget() throws Exception {
|
||||||
if (this.lazyTarget == null) {
|
if (this.lazyTarget == null) {
|
||||||
logger.debug("Initializing lazy target object");
|
logger.debug("Initializing lazy target object");
|
||||||
|
@ -85,6 +88,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource {
|
||||||
return this.lazyTarget;
|
return this.lazyTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void releaseTarget(Object target) throws Exception {
|
public void releaseTarget(Object target) throws Exception {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased
|
||||||
/**
|
/**
|
||||||
* Return the maximum size of the pool.
|
* Return the maximum size of the pool.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getMaxSize() {
|
public int getMaxSize() {
|
||||||
return this.maxSize;
|
return this.maxSize;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +98,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased
|
||||||
* @throws Exception we may need to deal with checked exceptions from pool
|
* @throws Exception we may need to deal with checked exceptions from pool
|
||||||
* APIs, so we're forgiving with our exception signature
|
* APIs, so we're forgiving with our exception signature
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public abstract Object getTarget() throws Exception;
|
public abstract Object getTarget() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -252,10 +252,12 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource
|
||||||
this.pool.returnObject(target);
|
this.pool.returnObject(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getActiveCount() throws UnsupportedOperationException {
|
public int getActiveCount() throws UnsupportedOperationException {
|
||||||
return this.pool.getNumActive();
|
return this.pool.getNumActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getIdleCount() throws UnsupportedOperationException {
|
public int getIdleCount() throws UnsupportedOperationException {
|
||||||
return this.pool.getNumIdle();
|
return this.pool.getNumIdle();
|
||||||
}
|
}
|
||||||
|
@ -264,6 +266,7 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource
|
||||||
/**
|
/**
|
||||||
* Closes the underlying {@code ObjectPool} when destroying this object.
|
* Closes the underlying {@code ObjectPool} when destroying this object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
logger.debug("Closing Commons ObjectPool");
|
logger.debug("Closing Commons ObjectPool");
|
||||||
this.pool.close();
|
this.pool.close();
|
||||||
|
@ -274,21 +277,26 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource
|
||||||
// Implementation of org.apache.commons.pool.PoolableObjectFactory interface
|
// Implementation of org.apache.commons.pool.PoolableObjectFactory interface
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object makeObject() throws BeansException {
|
public Object makeObject() throws BeansException {
|
||||||
return newPrototypeInstance();
|
return newPrototypeInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void destroyObject(Object obj) throws Exception {
|
public void destroyObject(Object obj) throws Exception {
|
||||||
destroyPrototypeInstance(obj);
|
destroyPrototypeInstance(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean validateObject(Object obj) {
|
public boolean validateObject(Object obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void activateObject(Object obj) {
|
public void activateObject(Object obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void passivateObject(Object obj) {
|
public void passivateObject(Object obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue