Remove trailing whitespace in source files
find . -type f -name "*.java" -or -name "*.aj" | \ xargs perl -p -i -e "s/[ \t]*$//g" {} \; Issue: SPR-10127
This commit is contained in:
parent
44a474a014
commit
1762157ad1
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* This class is used only as a "null" argument for Javadoc when comparing
|
* This class is used only as a "null" argument for Javadoc when comparing
|
||||||
* two API files. Javadoc has to have a package, .java or .class file as an
|
* two API files. Javadoc has to have a package, .java or .class file as an
|
||||||
* argument, even though JDiff doesn't use it.
|
* argument, even though JDiff doesn't use it.
|
||||||
*/
|
*/
|
||||||
public class Null {
|
public class Null {
|
||||||
|
|
|
@ -18,14 +18,14 @@ package org.springframework.aop;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface holding AOP <b>advice</b> (action to take at a joinpoint)
|
* Base interface holding AOP <b>advice</b> (action to take at a joinpoint)
|
||||||
* and a filter determining the applicability of the advice (such as
|
* and a filter determining the applicability of the advice (such as
|
||||||
* a pointcut). <i>This interface is not for use by Spring users, but to
|
* a pointcut). <i>This interface is not for use by Spring users, but to
|
||||||
* allow for commonality in support for different types of advice.</i>
|
* allow for commonality in support for different types of advice.</i>
|
||||||
*
|
*
|
||||||
* <p>Spring AOP is based around <b>around advice</b> delivered via method
|
* <p>Spring AOP is based around <b>around advice</b> delivered via method
|
||||||
* <b>interception</b>, compliant with the AOP Alliance interception API.
|
* <b>interception</b>, compliant with the AOP Alliance interception API.
|
||||||
* The Advisor interface allows support for different types of advice,
|
* The Advisor interface allows support for different types of advice,
|
||||||
* such as <b>before</b> and <b>after</b> advice, which need not be
|
* such as <b>before</b> and <b>after</b> advice, which need not be
|
||||||
* implemented using interception.
|
* implemented using interception.
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.springframework.aop;
|
||||||
|
|
||||||
import org.aopalliance.aop.Advice;
|
import org.aopalliance.aop.Advice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subinterface of AOP Alliance Advice that allows additional interfaces
|
* Subinterface of AOP Alliance Advice that allows additional interfaces
|
||||||
* to be implemented by an Advice, and available via a proxy using that
|
* to be implemented by an Advice, and available via a proxy using that
|
||||||
* interceptor. This is a fundamental AOP concept called <b>introduction</b>.
|
* interceptor. This is a fundamental AOP concept called <b>introduction</b>.
|
||||||
|
@ -37,7 +37,7 @@ import org.aopalliance.aop.Advice;
|
||||||
* @see IntroductionAdvisor
|
* @see IntroductionAdvisor
|
||||||
*/
|
*/
|
||||||
public interface DynamicIntroductionAdvice extends Advice {
|
public interface DynamicIntroductionAdvice extends Advice {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this introduction advice implement the given interface?
|
* Does this introduction advice implement the given interface?
|
||||||
* @param intf the interface to check
|
* @param intf the interface to check
|
||||||
|
|
|
@ -30,7 +30,7 @@ package org.springframework.aop;
|
||||||
* @see IntroductionInterceptor
|
* @see IntroductionInterceptor
|
||||||
*/
|
*/
|
||||||
public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
|
public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the filter determining which target classes this introduction
|
* Return the filter determining which target classes this introduction
|
||||||
* should apply to.
|
* should apply to.
|
||||||
|
@ -39,7 +39,7 @@ public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
|
||||||
* @return the class filter
|
* @return the class filter
|
||||||
*/
|
*/
|
||||||
ClassFilter getClassFilter();
|
ClassFilter getClassFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the advised interfaces be implemented by the introduction advice?
|
* Can the advised interfaces be implemented by the introduction advice?
|
||||||
* Invoked before adding an IntroductionAdvisor.
|
* Invoked before adding an IntroductionAdvisor.
|
||||||
|
|
|
@ -29,7 +29,7 @@ package org.springframework.aop;
|
||||||
* @since 1.1.1
|
* @since 1.1.1
|
||||||
*/
|
*/
|
||||||
public interface IntroductionInfo {
|
public interface IntroductionInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the additional interfaces introduced by this Advisor or Advice.
|
* Return the additional interfaces introduced by this Advisor or Advice.
|
||||||
* @return the introduced interfaces
|
* @return the introduced interfaces
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -28,7 +28,7 @@ import java.lang.reflect.Method;
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
public interface MethodBeforeAdvice extends BeforeAdvice {
|
public interface MethodBeforeAdvice extends BeforeAdvice {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback before a given method is invoked.
|
* Callback before a given method is invoked.
|
||||||
* @param method method being invoked
|
* @param method method being invoked
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -24,9 +24,9 @@ import java.io.Serializable;
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
class TrueClassFilter implements ClassFilter, Serializable {
|
class TrueClassFilter implements ClassFilter, Serializable {
|
||||||
|
|
||||||
public static final TrueClassFilter INSTANCE = new TrueClassFilter();
|
public static final TrueClassFilter INSTANCE = new TrueClassFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enforce Singleton pattern.
|
* Enforce Singleton pattern.
|
||||||
*/
|
*/
|
||||||
|
@ -36,7 +36,7 @@ class TrueClassFilter implements ClassFilter, Serializable {
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required to support serialization. Replaces with canonical
|
* Required to support serialization. Replaces with canonical
|
||||||
* instance on deserialization, protecting Singleton pattern.
|
* instance on deserialization, protecting Singleton pattern.
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.lang.reflect.Method;
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
class TrueMethodMatcher implements MethodMatcher, Serializable {
|
class TrueMethodMatcher implements MethodMatcher, Serializable {
|
||||||
|
|
||||||
public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
|
public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enforce Singleton pattern.
|
* Enforce Singleton pattern.
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
|
||||||
// Should never be invoked as isRuntime returns false.
|
// Should never be invoked as isRuntime returns false.
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required to support serialization. Replaces with canonical
|
* Required to support serialization. Replaces with canonical
|
||||||
* instance on deserialization, protecting Singleton pattern.
|
* instance on deserialization, protecting Singleton pattern.
|
||||||
|
@ -55,7 +55,7 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MethodMatcher.TRUE";
|
return "MethodMatcher.TRUE";
|
||||||
|
|
|
@ -24,9 +24,9 @@ import java.io.Serializable;
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
class TruePointcut implements Pointcut, Serializable {
|
class TruePointcut implements Pointcut, Serializable {
|
||||||
|
|
||||||
public static final TruePointcut INSTANCE = new TruePointcut();
|
public static final TruePointcut INSTANCE = new TruePointcut();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enforce Singleton pattern.
|
* Enforce Singleton pattern.
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +40,7 @@ class TruePointcut implements Pointcut, Serializable {
|
||||||
public MethodMatcher getMethodMatcher() {
|
public MethodMatcher getMethodMatcher() {
|
||||||
return MethodMatcher.TRUE;
|
return MethodMatcher.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required to support serialization. Replaces with canonical
|
* Required to support serialization. Replaces with canonical
|
||||||
* instance on deserialization, protecting Singleton pattern.
|
* instance on deserialization, protecting Singleton pattern.
|
||||||
|
|
|
@ -211,7 +211,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
public void setAspectName(String name) {
|
public void setAspectName(String name) {
|
||||||
this.aspectName = name;
|
this.aspectName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAspectName() {
|
public String getAspectName() {
|
||||||
return this.aspectName;
|
return this.aspectName;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
throw new UnsupportedOperationException("Only afterReturning advice can be used to bind a return value");
|
throw new UnsupportedOperationException("Only afterReturning advice can be used to bind a return value");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to hold the returning name at this level for argument binding calculations,
|
* We need to hold the returning name at this level for argument binding calculations,
|
||||||
* this method allows the afterReturning advice subclass to set the name.
|
* this method allows the afterReturning advice subclass to set the name.
|
||||||
*/
|
*/
|
||||||
|
@ -302,7 +302,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception");
|
throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to hold the throwing name at this level for argument binding calculations,
|
* We need to hold the throwing name at this level for argument binding calculations,
|
||||||
* this method allows the afterThrowing advice subclass to set the name.
|
* this method allows the afterThrowing advice subclass to set the name.
|
||||||
*/
|
*/
|
||||||
|
@ -365,11 +365,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||||
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
||||||
numUnboundArgs--;
|
numUnboundArgs--;
|
||||||
}
|
}
|
||||||
else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
|
else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
|
||||||
numUnboundArgs--;
|
numUnboundArgs--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numUnboundArgs > 0) {
|
if (numUnboundArgs > 0) {
|
||||||
// need to bind arguments by name as returned from the pointcut match
|
// need to bind arguments by name as returned from the pointcut match
|
||||||
bindArgumentsByName(numUnboundArgs);
|
bindArgumentsByName(numUnboundArgs);
|
||||||
|
@ -398,7 +398,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean supportsProceedingJoinPoint() {
|
protected boolean supportsProceedingJoinPoint() {
|
||||||
|
@ -409,7 +409,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
|
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
|
||||||
this.joinPointStaticPartArgumentIndex = 0;
|
this.joinPointStaticPartArgumentIndex = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
if (this.argumentNames != null) {
|
if (this.argumentNames != null) {
|
||||||
// We have been able to determine the arg names.
|
// We have been able to determine the arg names.
|
||||||
bindExplicitArguments(numArgumentsExpectingToBind);
|
bindExplicitArguments(numArgumentsExpectingToBind);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalStateException("Advice method [" + this.aspectJAdviceMethod.getName() + "] " +
|
throw new IllegalStateException("Advice method [" + this.aspectJAdviceMethod.getName() + "] " +
|
||||||
"requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " +
|
"requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " +
|
||||||
|
@ -471,9 +471,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
// specified, and find the discovered argument types.
|
// specified, and find the discovered argument types.
|
||||||
if (this.returningName != null) {
|
if (this.returningName != null) {
|
||||||
if (!this.argumentBindings.containsKey(this.returningName)) {
|
if (!this.argumentBindings.containsKey(this.returningName)) {
|
||||||
throw new IllegalStateException("Returning argument name '"
|
throw new IllegalStateException("Returning argument name '"
|
||||||
+ this.returningName + "' was not bound in advice arguments");
|
+ this.returningName + "' was not bound in advice arguments");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Integer index = this.argumentBindings.get(this.returningName);
|
Integer index = this.argumentBindings.get(this.returningName);
|
||||||
this.discoveredReturningType = this.aspectJAdviceMethod.getParameterTypes()[index];
|
this.discoveredReturningType = this.aspectJAdviceMethod.getParameterTypes()[index];
|
||||||
|
@ -482,9 +482,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
if (this.throwingName != null) {
|
if (this.throwingName != null) {
|
||||||
if (!this.argumentBindings.containsKey(this.throwingName)) {
|
if (!this.argumentBindings.containsKey(this.throwingName)) {
|
||||||
throw new IllegalStateException("Throwing argument name '"
|
throw new IllegalStateException("Throwing argument name '"
|
||||||
+ this.throwingName + "' was not bound in advice arguments");
|
+ this.throwingName + "' was not bound in advice arguments");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Integer index = this.argumentBindings.get(this.throwingName);
|
Integer index = this.argumentBindings.get(this.throwingName);
|
||||||
this.discoveredThrowingType = this.aspectJAdviceMethod.getParameterTypes()[index];
|
this.discoveredThrowingType = this.aspectJAdviceMethod.getParameterTypes()[index];
|
||||||
|
@ -525,7 +525,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
pointcutParameterTypes[index] = methodParameterTypes[i];
|
pointcutParameterTypes[index] = methodParameterTypes[i];
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pointcut.setParameterNames(pointcutParameterNames);
|
this.pointcut.setParameterNames(pointcutParameterNames);
|
||||||
this.pointcut.setParameterTypes(pointcutParameterTypes);
|
this.pointcut.setParameterTypes(pointcutParameterTypes);
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
if (this.joinPointArgumentIndex != -1) {
|
if (this.joinPointArgumentIndex != -1) {
|
||||||
adviceInvocationArgs[this.joinPointArgumentIndex] = jp;
|
adviceInvocationArgs[this.joinPointArgumentIndex] = jp;
|
||||||
numBound++;
|
numBound++;
|
||||||
}
|
}
|
||||||
else if (this.joinPointStaticPartArgumentIndex != -1) {
|
else if (this.joinPointStaticPartArgumentIndex != -1) {
|
||||||
adviceInvocationArgs[this.joinPointStaticPartArgumentIndex] = jp.getStaticPart();
|
adviceInvocationArgs[this.joinPointStaticPartArgumentIndex] = jp.getStaticPart();
|
||||||
numBound++;
|
numBound++;
|
||||||
|
@ -582,8 +582,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
|
|
||||||
if (numBound != this.adviceInvocationArgumentCount) {
|
if (numBound != this.adviceInvocationArgumentCount) {
|
||||||
throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount
|
throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount
|
||||||
+ " arguments, but only bound " + numBound + " (JoinPointMatch " +
|
+ " arguments, but only bound " + numBound + " (JoinPointMatch " +
|
||||||
(jpMatch == null ? "was NOT" : "WAS") +
|
(jpMatch == null ? "was NOT" : "WAS") +
|
||||||
" bound in invocation)");
|
" bound in invocation)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
|
||||||
|
|
||||||
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
super(aspectJBeforeAdviceMethod, pointcut, aif);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||||
try {
|
try {
|
||||||
return mi.proceed();
|
return mi.proceed();
|
||||||
|
|
|
@ -259,7 +259,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
ex);
|
ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (BCException ex) {
|
catch (BCException ex) {
|
||||||
logger.debug("PointcutExpression matching rejected target class", ex);
|
logger.debug("PointcutExpression matching rejected target class", ex);
|
||||||
return false;
|
return false;
|
||||||
|
@ -554,7 +554,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
String advisedBeanName = getCurrentProxiedBeanName();
|
String advisedBeanName = getCurrentProxiedBeanName();
|
||||||
if (advisedBeanName == null) { // no proxy creation in progress
|
if (advisedBeanName == null) { // no proxy creation in progress
|
||||||
// abstain; can't return YES, since that will make pointcut with negation fail
|
// abstain; can't return YES, since that will make pointcut with negation fail
|
||||||
return FuzzyBoolean.MAYBE;
|
return FuzzyBoolean.MAYBE;
|
||||||
}
|
}
|
||||||
if (BeanFactoryUtils.isGeneratedBeanName(advisedBeanName)) {
|
if (BeanFactoryUtils.isGeneratedBeanName(advisedBeanName)) {
|
||||||
return FuzzyBoolean.NO;
|
return FuzzyBoolean.NO;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP Advisor that can be used for any AspectJ pointcut expression.
|
* Spring AOP Advisor that can be used for any AspectJ pointcut expression.
|
||||||
*
|
*
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public abstract class AspectJProxyUtils {
|
public abstract class AspectJProxyUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors.
|
* Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors.
|
||||||
* This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching)
|
* This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching)
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.aspectj.bridge.IMessageHandler;
|
||||||
* Implementation of AspectJ's {@link IMessageHandler} interface that
|
* Implementation of AspectJ's {@link IMessageHandler} interface that
|
||||||
* routes AspectJ weaving messages through the same logging system as the
|
* routes AspectJ weaving messages through the same logging system as the
|
||||||
* regular Spring messages.
|
* regular Spring messages.
|
||||||
*
|
*
|
||||||
* <p>Pass the option...
|
* <p>Pass the option...
|
||||||
*
|
*
|
||||||
* <p><code class="code">-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler</code>
|
* <p><code class="code">-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler</code>
|
||||||
|
@ -44,9 +44,9 @@ import org.aspectj.bridge.IMessageHandler;
|
||||||
public class AspectJWeaverMessageHandler implements IMessageHandler {
|
public class AspectJWeaverMessageHandler implements IMessageHandler {
|
||||||
|
|
||||||
private static final String AJ_ID = "[AspectJ] ";
|
private static final String AJ_ID = "[AspectJ] ";
|
||||||
|
|
||||||
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
|
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
|
||||||
|
|
||||||
|
|
||||||
public boolean handleMessage(IMessage message) throws AbortException {
|
public boolean handleMessage(IMessage message) throws AbortException {
|
||||||
Kind messageKind = message.getKind();
|
Kind messageKind = message.getKind();
|
||||||
|
@ -56,39 +56,39 @@ public class AspectJWeaverMessageHandler implements IMessageHandler {
|
||||||
LOGGER.debug(makeMessageFor(message));
|
LOGGER.debug(makeMessageFor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) {
|
if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) {
|
||||||
LOGGER.info(makeMessageFor(message));
|
LOGGER.info(makeMessageFor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isWarnEnabled()) {
|
if (LOGGER.isWarnEnabled()) {
|
||||||
if (messageKind == IMessage.WARNING) {
|
if (messageKind == IMessage.WARNING) {
|
||||||
LOGGER.warn(makeMessageFor(message));
|
LOGGER.warn(makeMessageFor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isErrorEnabled()) {
|
if (LOGGER.isErrorEnabled()) {
|
||||||
if (messageKind == IMessage.ERROR) {
|
if (messageKind == IMessage.ERROR) {
|
||||||
LOGGER.error(makeMessageFor(message));
|
LOGGER.error(makeMessageFor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isFatalEnabled()) {
|
if (LOGGER.isFatalEnabled()) {
|
||||||
if (messageKind == IMessage.ABORT) {
|
if (messageKind == IMessage.ABORT) {
|
||||||
LOGGER.fatal(makeMessageFor(message));
|
LOGGER.fatal(makeMessageFor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeMessageFor(IMessage aMessage) {
|
private String makeMessageFor(IMessage aMessage) {
|
||||||
return AJ_ID + aMessage.getMessage();
|
return AJ_ID + aMessage.getMessage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
* @param defaultImpl the default implementation class
|
* @param defaultImpl the default implementation class
|
||||||
*/
|
*/
|
||||||
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) {
|
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) {
|
||||||
this(interfaceType, typePattern, defaultImpl,
|
this(interfaceType, typePattern, defaultImpl,
|
||||||
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
* @param delegateRef the delegate implementation object
|
* @param delegateRef the delegate implementation object
|
||||||
*/
|
*/
|
||||||
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) {
|
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) {
|
||||||
this(interfaceType, typePattern, delegateRef.getClass(),
|
this(interfaceType, typePattern, delegateRef.getClass(),
|
||||||
new DelegatingIntroductionInterceptor(delegateRef));
|
new DelegatingIntroductionInterceptor(delegateRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ import org.springframework.util.Assert;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, JoinPoint.StaticPart {
|
public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, JoinPoint.StaticPart {
|
||||||
|
|
||||||
private final ProxyMethodInvocation methodInvocation;
|
private final ProxyMethodInvocation methodInvocation;
|
||||||
|
|
||||||
private Object[] defensiveCopyOfArgs;
|
private Object[] defensiveCopyOfArgs;
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class encapsulates some AspectJ internal knowledge that should be
|
* This class encapsulates some AspectJ internal knowledge that should be
|
||||||
* pushed back into the AspectJ project in a future release.
|
* pushed back into the AspectJ project in a future release.
|
||||||
*
|
*
|
||||||
* <p>It relies on implementation specific knowledge in AspectJ to break
|
* <p>It relies on implementation specific knowledge in AspectJ to break
|
||||||
* encapsulation and do something AspectJ was not designed to do: query
|
* encapsulation and do something AspectJ was not designed to do: query
|
||||||
|
@ -137,7 +137,7 @@ class RuntimeTestWalker {
|
||||||
|
|
||||||
public void visit(MatchingContextBasedTest matchingContextTest) {
|
public void visit(MatchingContextBasedTest matchingContextTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getVarType(ReflectionVar v) {
|
protected int getVarType(ReflectionVar v) {
|
||||||
try {
|
try {
|
||||||
Field varTypeField = ReflectionVar.class.getDeclaredField("varType");
|
Field varTypeField = ReflectionVar.class.getDeclaredField("varType");
|
||||||
|
@ -169,7 +169,7 @@ class RuntimeTestWalker {
|
||||||
this.matches = defaultMatches;
|
this.matches = defaultMatches;
|
||||||
this.matchVarType = matchVarType;
|
this.matchVarType = matchVarType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instanceOfMatches(Test test) {
|
public boolean instanceOfMatches(Test test) {
|
||||||
test.accept(this);
|
test.accept(this);
|
||||||
return matches;
|
return matches;
|
||||||
|
@ -236,7 +236,7 @@ class RuntimeTestWalker {
|
||||||
aTest.accept(this);
|
aTest.accept(this);
|
||||||
return this.testsSubtypeSensitiveVars;
|
return this.testsSubtypeSensitiveVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Instanceof i) {
|
public void visit(Instanceof i) {
|
||||||
ReflectionVar v = (ReflectionVar) i.getVar();
|
ReflectionVar v = (ReflectionVar) i.getVar();
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||||
* @see SimpleAspectInstanceFactory
|
* @see SimpleAspectInstanceFactory
|
||||||
*/
|
*/
|
||||||
public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
|
public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
|
|
||||||
private final Object aspectInstance;
|
private final Object aspectInstance;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,11 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a fully configured {@link TypePatternClassFilter} using the
|
* Create a fully configured {@link TypePatternClassFilter} using the
|
||||||
* given type pattern.
|
* given type pattern.
|
||||||
* @param typePattern the type pattern that AspectJ weaver should parse
|
* @param typePattern the type pattern that AspectJ weaver should parse
|
||||||
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code>
|
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code>
|
||||||
* or is recognized as invalid
|
* or is recognized as invalid
|
||||||
*/
|
*/
|
||||||
public TypePatternClassFilter(String typePattern) {
|
public TypePatternClassFilter(String typePattern) {
|
||||||
setTypePattern(typePattern);
|
setTypePattern(typePattern);
|
||||||
|
@ -73,7 +73,7 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||||
* <p>These conventions are established by AspectJ, not Spring AOP.
|
* <p>These conventions are established by AspectJ, not Spring AOP.
|
||||||
* @param typePattern the type pattern that AspectJ weaver should parse
|
* @param typePattern the type pattern that AspectJ weaver should parse
|
||||||
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code>
|
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code>
|
||||||
* or is recognized as invalid
|
* or is recognized as invalid
|
||||||
*/
|
*/
|
||||||
public void setTypePattern(String typePattern) {
|
public void setTypePattern(String typePattern) {
|
||||||
Assert.notNull(typePattern);
|
Assert.notNull(typePattern);
|
||||||
|
|
|
@ -58,7 +58,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory {
|
public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory {
|
||||||
|
|
||||||
protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER =
|
protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER =
|
||||||
new AspectJAnnotationParameterNameDiscoverer();
|
new AspectJAnnotationParameterNameDiscoverer();
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We need to detect this as "code-style" AspectJ aspects should not be
|
* We need to detect this as "code-style" AspectJ aspects should not be
|
||||||
* interpreted by Spring AOP.
|
* interpreted by Spring AOP.
|
||||||
*/
|
*/
|
||||||
private boolean compiledByAjc(Class<?> clazz) {
|
private boolean compiledByAjc(Class<?> clazz) {
|
||||||
// The AJTypeSystem goes to great lengths to provide a uniform appearance between code-style and
|
// The AJTypeSystem goes to great lengths to provide a uniform appearance between code-style and
|
||||||
|
@ -154,11 +154,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) {
|
if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) {
|
||||||
throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " +
|
throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " +
|
||||||
"This is not supported in Spring AOP.");
|
"This is not supported in Spring AOP.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pointcut and advice annotations both have an "argNames" member which contains a
|
* The pointcut and advice annotations both have an "argNames" member which contains a
|
||||||
* comma-separated list of the argument names. We use this (if non-empty) to build the
|
* comma-separated list of the argument names. We use this (if non-empty) to build the
|
||||||
* formal parameters for the pointcut.
|
* formal parameters for the pointcut.
|
||||||
*/
|
*/
|
||||||
|
@ -169,13 +169,13 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
if (pointcutParameterNames != null) {
|
if (pointcutParameterNames != null) {
|
||||||
pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
|
pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
AspectJExpressionPointcut ajexp =
|
AspectJExpressionPointcut ajexp =
|
||||||
new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
|
new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
|
||||||
ajexp.setLocation(annotatedMethod.toString());
|
ajexp.setLocation(annotatedMethod.toString());
|
||||||
return ajexp;
|
return ajexp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the pointcut parameters needed by aspectj based on the given argument names
|
* Create the pointcut parameters needed by aspectj based on the given argument names
|
||||||
* and the argument types that are available from the adviceMethod. Needs to take into
|
* and the argument types that are available from the adviceMethod. Needs to take into
|
||||||
|
@ -326,10 +326,10 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class AspectMetadata {
|
||||||
private final Pointcut perClausePointcut;
|
private final Pointcut perClausePointcut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this aspect as defined to Spring (the bean name) -
|
* The name of this aspect as defined to Spring (the bean name) -
|
||||||
* allows us to determine if two pieces of advice come from the
|
* allows us to determine if two pieces of advice come from the
|
||||||
* same aspect and hence their relative precedence.
|
* same aspect and hence their relative precedence.
|
||||||
*/
|
*/
|
||||||
private String aspectName;
|
private String aspectName;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.springframework.util.ClassUtils;
|
||||||
* backed by a Spring {@link org.springframework.beans.factory.BeanFactory}.
|
* backed by a Spring {@link org.springframework.beans.factory.BeanFactory}.
|
||||||
*
|
*
|
||||||
* <p>Note that this may instantiate multiple times if using a prototype,
|
* <p>Note that this may instantiate multiple times if using a prototype,
|
||||||
* which probably won't give the semantics you expect.
|
* which probably won't give the semantics you expect.
|
||||||
* Use a {@link LazySingletonAspectInstanceFactoryDecorator}
|
* Use a {@link LazySingletonAspectInstanceFactoryDecorator}
|
||||||
* to wrap this to ensure only one new aspect comes back.
|
* to wrap this to ensure only one new aspect comes back.
|
||||||
*
|
*
|
||||||
|
@ -56,7 +56,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name) {
|
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name) {
|
||||||
this(beanFactory, name, beanFactory.getType(name));
|
this(beanFactory, name, beanFactory.getType(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should
|
* Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should
|
||||||
* introspect to create AJType metadata. Use if the BeanFactory may consider the type
|
* introspect to create AJType metadata. Use if the BeanFactory may consider the type
|
||||||
|
|
|
@ -41,23 +41,23 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation {
|
implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation {
|
||||||
|
|
||||||
private final AspectJExpressionPointcut declaredPointcut;
|
private final AspectJExpressionPointcut declaredPointcut;
|
||||||
|
|
||||||
private Pointcut pointcut;
|
private Pointcut pointcut;
|
||||||
|
|
||||||
private final MetadataAwareAspectInstanceFactory aspectInstanceFactory;
|
private final MetadataAwareAspectInstanceFactory aspectInstanceFactory;
|
||||||
|
|
||||||
private final Method method;
|
private final Method method;
|
||||||
|
|
||||||
private final boolean lazy;
|
private final boolean lazy;
|
||||||
|
|
||||||
private final AspectJAdvisorFactory atAspectJAdvisorFactory;
|
private final AspectJAdvisorFactory atAspectJAdvisorFactory;
|
||||||
|
|
||||||
private Advice instantiatedAdvice;
|
private Advice instantiatedAdvice;
|
||||||
|
|
||||||
private int declarationOrder;
|
private int declarationOrder;
|
||||||
|
|
||||||
private String aspectName;
|
private String aspectName;
|
||||||
|
|
||||||
private Boolean isBeforeAdvice;
|
private Boolean isBeforeAdvice;
|
||||||
|
|
||||||
private Boolean isAfterAdvice;
|
private Boolean isAfterAdvice;
|
||||||
|
@ -72,12 +72,12 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
this.aspectInstanceFactory = aif;
|
this.aspectInstanceFactory = aif;
|
||||||
this.declarationOrder = declarationOrderInAspect;
|
this.declarationOrder = declarationOrderInAspect;
|
||||||
this.aspectName = aspectName;
|
this.aspectName = aspectName;
|
||||||
|
|
||||||
if (aif.getAspectMetadata().isLazilyInstantiated()) {
|
if (aif.getAspectMetadata().isLazilyInstantiated()) {
|
||||||
// Static part of the pointcut is a lazy type.
|
// Static part of the pointcut is a lazy type.
|
||||||
Pointcut preInstantiationPointcut =
|
Pointcut preInstantiationPointcut =
|
||||||
Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
|
Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
|
||||||
|
|
||||||
// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
|
// Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
|
||||||
// If it's not a dynamic pointcut, it may be optimized out
|
// If it's not a dynamic pointcut, it may be optimized out
|
||||||
// by the Spring AOP infrastructure after the first evaluation.
|
// by the Spring AOP infrastructure after the first evaluation.
|
||||||
|
@ -109,7 +109,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON);
|
return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the AspectJ AspectMetadata for this advisor.
|
* Return the AspectJ AspectMetadata for this advisor.
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +126,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
}
|
}
|
||||||
return this.instantiatedAdvice;
|
return this.instantiatedAdvice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLazy() {
|
public boolean isLazy() {
|
||||||
return this.lazy;
|
return this.lazy;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
return this.atAspectJAdvisorFactory.getAdvice(
|
return this.atAspectJAdvisorFactory.getAdvice(
|
||||||
this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
|
this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() {
|
public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() {
|
||||||
return this.aspectInstanceFactory;
|
return this.aspectInstanceFactory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, we know we have an AspectJ method.
|
// If we get here, we know we have an AspectJ method.
|
||||||
// Check that it's an AspectJ-annotated class
|
// Check that it's an AspectJ-annotated class
|
||||||
if (!isAspect(candidateAspectClass)) {
|
if (!isAspect(candidateAspectClass)) {
|
||||||
throw new AopConfigException("Advice must be declared inside an aspect type: " +
|
throw new AopConfigException("Advice must be declared inside an aspect type: " +
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Classes enabling AspectJ 5 @Annotated classes to be used in Spring AOP.
|
* Classes enabling AspectJ 5 @Annotated classes to be used in Spring AOP.
|
||||||
*
|
*
|
||||||
* <p>Normally to be used through an AspectJAutoProxyCreator rather than directly.
|
* <p>Normally to be used through an AspectJAutoProxyCreator rather than directly.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,8 +72,8 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
|
||||||
for (Advisor element : advisors) {
|
for (Advisor element : advisors) {
|
||||||
partiallyComparableAdvisors.add(
|
partiallyComparableAdvisors.add(
|
||||||
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR));
|
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort it
|
// sort it
|
||||||
List<PartiallyComparableAdvisorHolder> sorted =
|
List<PartiallyComparableAdvisorHolder> sorted =
|
||||||
(List<PartiallyComparableAdvisorHolder>) PartialOrder.sort(partiallyComparableAdvisors);
|
(List<PartiallyComparableAdvisorHolder>) PartialOrder.sort(partiallyComparableAdvisors);
|
||||||
|
@ -81,13 +81,13 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
|
||||||
// TODO: work harder to give a better error message here.
|
// TODO: work harder to give a better error message here.
|
||||||
throw new IllegalArgumentException("Advice precedence circularity error");
|
throw new IllegalArgumentException("Advice precedence circularity error");
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract results again
|
// extract results again
|
||||||
List<Advisor> result = new LinkedList<Advisor>();
|
List<Advisor> result = new LinkedList<Advisor>();
|
||||||
for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
|
for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
|
||||||
result.add(pcAdvisor.getAdvisor());
|
result.add(pcAdvisor.getAdvisor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,14 +106,14 @@ class AspectJPrecedenceComparator implements Comparator {
|
||||||
boolean oneOrOtherIsAfterAdvice =
|
boolean oneOrOtherIsAfterAdvice =
|
||||||
(AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2));
|
(AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2));
|
||||||
int adviceDeclarationOrderDelta = getAspectDeclarationOrder(advisor1) - getAspectDeclarationOrder(advisor2);
|
int adviceDeclarationOrderDelta = getAspectDeclarationOrder(advisor1) - getAspectDeclarationOrder(advisor2);
|
||||||
|
|
||||||
if (oneOrOtherIsAfterAdvice) {
|
if (oneOrOtherIsAfterAdvice) {
|
||||||
// the advice declared last has higher precedence
|
// the advice declared last has higher precedence
|
||||||
if (adviceDeclarationOrderDelta < 0) {
|
if (adviceDeclarationOrderDelta < 0) {
|
||||||
// advice1 was declared before advice2
|
// advice1 was declared before advice2
|
||||||
// so advice1 has lower precedence
|
// so advice1 has lower precedence
|
||||||
return LOWER_PRECEDENCE;
|
return LOWER_PRECEDENCE;
|
||||||
}
|
}
|
||||||
else if (adviceDeclarationOrderDelta == 0) {
|
else if (adviceDeclarationOrderDelta == 0) {
|
||||||
return SAME_PRECEDENCE;
|
return SAME_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class AspectJPrecedenceComparator implements Comparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAspectDeclarationOrder(Advisor anAdvisor) {
|
private int getAspectDeclarationOrder(Advisor anAdvisor) {
|
||||||
AspectJPrecedenceInformation precedenceInfo =
|
AspectJPrecedenceInformation precedenceInfo =
|
||||||
AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
|
AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
|
||||||
if (precedenceInfo != null) {
|
if (precedenceInfo != null) {
|
||||||
return precedenceInfo.getDeclarationOrder();
|
return precedenceInfo.getDeclarationOrder();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* annotation-style methods, and an AspectJExpressionPointcut: a Spring AOP Pointcut
|
* annotation-style methods, and an AspectJExpressionPointcut: a Spring AOP Pointcut
|
||||||
* implementation that allows use of the AspectJ pointcut expression language with the Spring AOP
|
* implementation that allows use of the AspectJ pointcut expression language with the Spring AOP
|
||||||
* runtime framework.
|
* runtime framework.
|
||||||
*
|
*
|
||||||
* <p>Note that use of this package does <i>not</i> require the use of the <code>ajc</code> compiler
|
* <p>Note that use of this package does <i>not</i> require the use of the <code>ajc</code> compiler
|
||||||
* or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ
|
* or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ
|
||||||
* functionality, with consistent semantics, with the proxy-based Spring AOP framework.
|
* functionality, with consistent semantics, with the proxy-based Spring AOP framework.
|
||||||
|
|
|
@ -60,7 +60,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
// get the root bean name - will be the name of the generated proxy factory bean
|
// get the root bean name - will be the name of the generated proxy factory bean
|
||||||
String existingBeanName = definitionHolder.getBeanName();
|
String existingBeanName = definitionHolder.getBeanName();
|
||||||
BeanDefinition targetDefinition = definitionHolder.getBeanDefinition();
|
BeanDefinition targetDefinition = definitionHolder.getBeanDefinition();
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ParseState} entry representing an advice element.
|
* {@link ParseState} entry representing an advice element.
|
||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ParseState} entry representing an advisor.
|
* {@link ParseState} entry representing an advisor.
|
||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,8 +31,8 @@ import org.springframework.util.Assert;
|
||||||
/**
|
/**
|
||||||
* Utility class for handling registration of AOP auto-proxy creators.
|
* Utility class for handling registration of AOP auto-proxy creators.
|
||||||
*
|
*
|
||||||
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
|
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
|
||||||
* implementations are available. Therefore this class wraps a simple escalation
|
* implementations are available. Therefore this class wraps a simple escalation
|
||||||
* protocol, allowing classes to request a particular auto-proxy creator and know
|
* protocol, allowing classes to request a particular auto-proxy creator and know
|
||||||
* that class, <code>or a subclass thereof</code>, will eventually be resident
|
* that class, <code>or a subclass thereof</code>, will eventually be resident
|
||||||
* in the application context.
|
* in the application context.
|
||||||
|
|
|
@ -93,7 +93,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2;
|
private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2;
|
||||||
|
|
||||||
private ParseState parseState = new ParseState();
|
private ParseState parseState = new ParseState();
|
||||||
|
|
||||||
|
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
CompositeComponentDefinition compositeDef =
|
CompositeComponentDefinition compositeDef =
|
||||||
|
@ -281,10 +281,10 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class);
|
||||||
builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE));
|
builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE));
|
||||||
builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN));
|
builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN));
|
||||||
|
|
||||||
String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL);
|
String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL);
|
||||||
String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF);
|
String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF);
|
||||||
|
|
||||||
if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) {
|
if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) {
|
||||||
builder.addConstructorArgValue(defaultImpl);
|
builder.addConstructorArgValue(defaultImpl);
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
String expression = pointcutElement.getAttribute(EXPRESSION);
|
String expression = pointcutElement.getAttribute(EXPRESSION);
|
||||||
|
|
||||||
AbstractBeanDefinition pointcutDefinition = null;
|
AbstractBeanDefinition pointcutDefinition = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.parseState.push(new PointcutEntry(id));
|
this.parseState.push(new PointcutEntry(id));
|
||||||
pointcutDefinition = createPointcutDefinition(expression);
|
pointcutDefinition = createPointcutDefinition(expression);
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ParseState} entry representing a pointcut.
|
* {@link ParseState} entry representing a pointcut.
|
||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,7 +47,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator {
|
||||||
proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
|
proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the original bean definition as it will be referenced by the scoped proxy
|
// Register the original bean definition as it will be referenced by the scoped proxy
|
||||||
// and is relevant for tooling (validation, navigation).
|
// and is relevant for tooling (validation, navigation).
|
||||||
BeanDefinitionHolder holder =
|
BeanDefinitionHolder holder =
|
||||||
|
|
|
@ -124,7 +124,7 @@ public interface Advised extends TargetClassAware {
|
||||||
*/
|
*/
|
||||||
void addAdvisor(Advisor advisor) throws AopConfigException;
|
void addAdvisor(Advisor advisor) throws AopConfigException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an Advisor at the specified position in the chain.
|
* Add an Advisor at the specified position in the chain.
|
||||||
* @param advisor the advisor to add at the specified position in the chain
|
* @param advisor the advisor to add at the specified position in the chain
|
||||||
* @param pos position in chain (0 is head). Must be valid.
|
* @param pos position in chain (0 is head). Must be valid.
|
||||||
|
|
|
@ -35,7 +35,7 @@ package org.springframework.aop.framework;
|
||||||
*
|
*
|
||||||
* <p>Proxies may or may not allow advice changes to be made.
|
* <p>Proxies may or may not allow advice changes to be made.
|
||||||
* If they do not permit advice changes (for example, because
|
* If they do not permit advice changes (for example, because
|
||||||
* the configuration was frozen) a proxy should throw an
|
* the configuration was frozen) a proxy should throw an
|
||||||
* {@link AopConfigException} on an attempted advice change.
|
* {@link AopConfigException} on an attempted advice change.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
protected final Log logger = LogFactory.getLog(getClass());
|
protected final Log logger = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
private String[] interceptorNames;
|
private String[] interceptorNames;
|
||||||
|
|
||||||
private String targetName;
|
private String targetName;
|
||||||
|
|
||||||
private boolean autodetectInterfaces = true;
|
private boolean autodetectInterfaces = true;
|
||||||
|
@ -543,10 +543,10 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
Advisor advisor = namedBeanToAdvisor(next);
|
Advisor advisor = namedBeanToAdvisor(next);
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Adding advisor with name '" + name + "'");
|
logger.trace("Adding advisor with name '" + name + "'");
|
||||||
}
|
}
|
||||||
addAdvisor(advisor);
|
addAdvisor(advisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a TargetSource to use when creating a proxy. If the target was not
|
* Return a TargetSource to use when creating a proxy. If the target was not
|
||||||
* specified at the end of the interceptorNames list, the TargetSource will be
|
* specified at the end of the interceptorNames list, the TargetSource will be
|
||||||
|
@ -627,24 +627,24 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
private final String beanName;
|
private final String beanName;
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
public PrototypePlaceholderAdvisor(String beanName) {
|
public PrototypePlaceholderAdvisor(String beanName) {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
this.message = "Placeholder for prototype Advisor/Advice with bean name '" + beanName + "'";
|
this.message = "Placeholder for prototype Advisor/Advice with bean name '" + beanName + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBeanName() {
|
public String getBeanName() {
|
||||||
return beanName;
|
return beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Advice getAdvice() {
|
public Advice getAdvice() {
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPerInstance() {
|
public boolean isPerInstance() {
|
||||||
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.message;
|
return this.message;
|
||||||
|
|
|
@ -87,13 +87,13 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.exceptionHandlerMap.isEmpty()) {
|
if (this.exceptionHandlerMap.isEmpty()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"At least one handler method must be found in class [" + throwsAdvice.getClass() + "]");
|
"At least one handler method must be found in class [" + throwsAdvice.getClass() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHandlerMethodCount() {
|
public int getHandlerMethodCount() {
|
||||||
return this.exceptionHandlerMap.size();
|
return this.exceptionHandlerMap.size();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
|
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
|
||||||
Object[] handlerArgs;
|
Object[] handlerArgs;
|
||||||
if (method.getParameterTypes().length == 1) {
|
if (method.getParameterTypes().length == 1) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* its capabilities, don't need to concern themselves with this package.
|
* its capabilities, don't need to concern themselves with this package.
|
||||||
* <br>
|
* <br>
|
||||||
* You may wish to use these adapters to wrap Spring-specific advices, such as MethodBeforeAdvice,
|
* You may wish to use these adapters to wrap Spring-specific advices, such as MethodBeforeAdvice,
|
||||||
* in MethodInterceptor, to allow their use in another AOP framework supporting the AOP Alliance interfaces.
|
* in MethodInterceptor, to allow their use in another AOP framework supporting the AOP Alliance interfaces.
|
||||||
* </br>
|
* </br>
|
||||||
* <br>
|
* <br>
|
||||||
* These adapters do not depend on any other Spring framework classes to allow such usage.
|
* These adapters do not depend on any other Spring framework classes to allow such usage.
|
||||||
|
|
|
@ -94,6 +94,6 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea
|
||||||
@Override
|
@Override
|
||||||
protected boolean isEligibleAdvisorBean(String beanName) {
|
protected boolean isEligibleAdvisorBean(String beanName) {
|
||||||
return (!isUsePrefix() || beanName.startsWith(getAdvisorBeanNamePrefix()));
|
return (!isUsePrefix() || beanName.startsWith(getAdvisorBeanNamePrefix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -30,7 +30,7 @@ import org.springframework.aop.TargetSource;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public interface TargetSourceCreator {
|
public interface TargetSourceCreator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a special TargetSource for the given bean, if any.
|
* Create a special TargetSource for the given bean, if any.
|
||||||
* @param beanClass the class of the bean to create a TargetSource for
|
* @param beanClass the class of the bean to create a TargetSource for
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
*
|
*
|
||||||
* Bean post-processors for use in ApplicationContexts to simplify AOP usage
|
* Bean post-processors for use in ApplicationContexts to simplify AOP usage
|
||||||
* by automatically creating AOP proxies without the need to use a ProxyFactoryBean.
|
* by automatically creating AOP proxies without the need to use a ProxyFactoryBean.
|
||||||
*
|
*
|
||||||
* <p>The various post-processors in this package need only be added to an ApplicationContext
|
* <p>The various post-processors in this package need only be added to an ApplicationContext
|
||||||
* (typically in an XML bean definition document) to automatically proxy selected beans.
|
* (typically in an XML bean definition document) to automatically proxy selected beans.
|
||||||
*
|
*
|
||||||
* <p><b>NB</b>: Automatic auto-proxying is not supported for BeanFactory implementations,
|
* <p><b>NB</b>: Automatic auto-proxying is not supported for BeanFactory implementations,
|
||||||
* as post-processors beans are only automatically detected in application contexts.
|
* as post-processors beans are only automatically detected in application contexts.
|
||||||
* Post-processors can be explicitly registered on a ConfigurableBeanFactory instead.
|
* Post-processors can be explicitly registered on a ConfigurableBeanFactory instead.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.aop.target.ThreadLocalTargetSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenient TargetSourceCreator using bean name prefixes to create one of three
|
* Convenient TargetSourceCreator using bean name prefixes to create one of three
|
||||||
* well-known TargetSource types:
|
* well-known TargetSource types:
|
||||||
* <li>: CommonsPoolTargetSource
|
* <li>: CommonsPoolTargetSource
|
||||||
* <li>% ThreadLocalTargetSource
|
* <li>% ThreadLocalTargetSource
|
||||||
* <li>! PrototypeTargetSource
|
* <li>! PrototypeTargetSource
|
||||||
|
@ -59,5 +59,5 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
*
|
*
|
||||||
* Package containing Spring's basic AOP infrastructure, compliant with the
|
* Package containing Spring's basic AOP infrastructure, compliant with the
|
||||||
* <a href="http://aopalliance.sourceforge.net">AOP Alliance</a> interfaces.
|
* <a href="http://aopalliance.sourceforge.net">AOP Alliance</a> interfaces.
|
||||||
*
|
*
|
||||||
* <p>Spring AOP supports proxying interfaces or classes, introductions, and offers
|
* <p>Spring AOP supports proxying interfaces or classes, introductions, and offers
|
||||||
* static and dynamic pointcuts.
|
* static and dynamic pointcuts.
|
||||||
*
|
*
|
||||||
* <p>Any Spring AOP proxy can be cast to the ProxyConfig AOP configuration interface
|
* <p>Any Spring AOP proxy can be cast to the ProxyConfig AOP configuration interface
|
||||||
* in this package to add or remove interceptors.
|
* in this package to add or remove interceptors.
|
||||||
*
|
*
|
||||||
* <p>The ProxyFactoryBean is a convenient way to create AOP proxies in a BeanFactory
|
* <p>The ProxyFactoryBean is a convenient way to create AOP proxies in a BeanFactory
|
||||||
* or ApplicationContext. However, proxies can be created programmatically using the
|
* or ApplicationContext. However, proxies can be created programmatically using the
|
||||||
* ProxyFactory class.
|
* ProxyFactory class.
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||||
* <p>Subclasses should call the <code>createInvocationTraceName(MethodInvocation)</code>
|
* <p>Subclasses should call the <code>createInvocationTraceName(MethodInvocation)</code>
|
||||||
* method to create a name for the given trace that includes information about the
|
* method to create a name for the given trace that includes information about the
|
||||||
* method invocation under trace along with the prefix and suffix added as appropriate.
|
* method invocation under trace along with the prefix and suffix added as appropriate.
|
||||||
*
|
*
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 1.2.7
|
* @since 1.2.7
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -125,7 +125,7 @@ public abstract class ExposeBeanNameAdvisors {
|
||||||
*/
|
*/
|
||||||
private static class ExposeBeanNameIntroduction extends DelegatingIntroductionInterceptor implements NamedBean {
|
private static class ExposeBeanNameIntroduction extends DelegatingIntroductionInterceptor implements NamedBean {
|
||||||
|
|
||||||
private final String beanName;
|
private final String beanName;
|
||||||
|
|
||||||
public ExposeBeanNameIntroduction(String beanName) {
|
public ExposeBeanNameIntroduction(String beanName) {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.logging.Log;
|
||||||
* and output the stats.
|
* and output the stats.
|
||||||
*
|
*
|
||||||
* <p>This code is inspired by Thierry Templier's blog.
|
* <p>This code is inspired by Thierry Templier's blog.
|
||||||
*
|
*
|
||||||
* @author Dmitriy Kopylenko
|
* @author Dmitriy Kopylenko
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Core Spring AOP interfaces, built on AOP Alliance AOP interoperability interfaces.
|
* Core Spring AOP interfaces, built on AOP Alliance AOP interoperability interfaces.
|
||||||
*
|
*
|
||||||
* <br>Any AOP Alliance MethodInterceptor is usable in Spring.
|
* <br>Any AOP Alliance MethodInterceptor is usable in Spring.
|
||||||
*
|
*
|
||||||
* <br>Spring AOP also offers:
|
* <br>Spring AOP also offers:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Introduction support
|
* <li>Introduction support
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
* <li>Extensibility allowing arbitrary custom advice types to
|
* <li>Extensibility allowing arbitrary custom advice types to
|
||||||
* be plugged in without modifying the core framework.
|
* be plugged in without modifying the core framework.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <br>
|
* <br>
|
||||||
* Spring AOP can be used programmatically or (preferably)
|
* Spring AOP can be used programmatically or (preferably)
|
||||||
* integrated with the Spring IoC container.
|
* integrated with the Spring IoC container.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the {@link ScopedObject} interface.
|
* Default implementation of the {@link ScopedObject} interface.
|
||||||
*
|
*
|
||||||
* <p>Simply delegates the calls to the underlying
|
* <p>Simply delegates the calls to the underlying
|
||||||
* {@link ConfigurableBeanFactory bean factory}
|
* {@link ConfigurableBeanFactory bean factory}
|
||||||
* ({@link ConfigurableBeanFactory#getBean(String)}/
|
* ({@link ConfigurableBeanFactory#getBean(String)}/
|
||||||
|
|
|
@ -49,5 +49,5 @@ public interface ScopedObject extends RawTargetAccess {
|
||||||
* the exact same target object in the target scope).
|
* the exact same target object in the target scope).
|
||||||
*/
|
*/
|
||||||
void removeFromScope();
|
void removeFromScope();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenient proxy factory bean for scoped objects.
|
* Convenient proxy factory bean for scoped objects.
|
||||||
*
|
*
|
||||||
* <p>Proxies created using this factory bean are thread-safe singletons
|
* <p>Proxies created using this factory bean are thread-safe singletons
|
||||||
* and may be injected into shared objects, with transparent scoping behavior.
|
* and may be injected into shared objects, with transparent scoping behavior.
|
||||||
*
|
*
|
||||||
* <p>Proxies returned by this class implement the {@link ScopedObject} interface.
|
* <p>Proxies returned by this class implement the {@link ScopedObject} interface.
|
||||||
* This presently allows for removing the corresponding object from the scope,
|
* This presently allows for removing the corresponding object from the scope,
|
||||||
* seamlessly creating a new instance in the scope on next access.
|
* seamlessly creating a new instance in the scope on next access.
|
||||||
*
|
*
|
||||||
* <p>Please note that the proxies created by this factory are
|
* <p>Please note that the proxies created by this factory are
|
||||||
* <i>class-based</i> proxies by default. This can be customized
|
* <i>class-based</i> proxies by default. This can be customized
|
||||||
* through switching the "proxyTargetClass" property to "false".
|
* through switching the "proxyTargetClass" property to "false".
|
||||||
|
|
|
@ -47,7 +47,7 @@ public abstract class ScopedProxyUtils {
|
||||||
*/
|
*/
|
||||||
public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder definition,
|
public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder definition,
|
||||||
BeanDefinitionRegistry registry, boolean proxyTargetClass) {
|
BeanDefinitionRegistry registry, boolean proxyTargetClass) {
|
||||||
|
|
||||||
String originalBeanName = definition.getBeanName();
|
String originalBeanName = definition.getBeanName();
|
||||||
BeanDefinition targetDefinition = definition.getBeanDefinition();
|
BeanDefinition targetDefinition = definition.getBeanDefinition();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public abstract class ScopedProxyUtils {
|
||||||
// (potentially an inner bean).
|
// (potentially an inner bean).
|
||||||
return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases());
|
return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the bean name that is used within the scoped proxy to reference the target bean.
|
* Generates the bean name that is used within the scoped proxy to reference the target bean.
|
||||||
* @param originalBeanName the original name of bean
|
* @param originalBeanName the original name of bean
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.springframework.util.ClassUtils;
|
||||||
public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable {
|
public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable {
|
||||||
|
|
||||||
private final Advice advice;
|
private final Advice advice;
|
||||||
|
|
||||||
private final Set<Class> interfaces = new HashSet<Class>();
|
private final Set<Class> interfaces = new HashSet<Class>();
|
||||||
|
|
||||||
private int order = Integer.MAX_VALUE;
|
private int order = Integer.MAX_VALUE;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple
|
||||||
*/
|
*/
|
||||||
public DefaultPointcutAdvisor() {
|
public DefaultPointcutAdvisor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a DefaultPointcutAdvisor that matches all methods.
|
* Create a DefaultPointcutAdvisor that matches all methods.
|
||||||
* <p><code>Pointcut.TRUE</code> will be used as Pointcut.
|
* <p><code>Pointcut.TRUE</code> will be used as Pointcut.
|
||||||
|
@ -55,7 +55,7 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple
|
||||||
public DefaultPointcutAdvisor(Advice advice) {
|
public DefaultPointcutAdvisor(Advice advice) {
|
||||||
this(Pointcut.TRUE, advice);
|
this(Pointcut.TRUE, advice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a DefaultPointcutAdvisor, specifying Pointcut and Advice.
|
* Create a DefaultPointcutAdvisor, specifying Pointcut and Advice.
|
||||||
* @param pointcut the Pointcut targeting the Advice
|
* @param pointcut the Pointcut targeting the Advice
|
||||||
|
|
|
@ -53,7 +53,7 @@ import org.springframework.aop.ProxyMethodInvocation;
|
||||||
public class DelegatePerTargetObjectIntroductionInterceptor extends IntroductionInfoSupport
|
public class DelegatePerTargetObjectIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
implements IntroductionInterceptor {
|
implements IntroductionInterceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hold weak references to keys as we don't want to interfere with garbage collection..
|
* Hold weak references to keys as we don't want to interfere with garbage collection..
|
||||||
*/
|
*/
|
||||||
private final Map<Object, Object> delegateMap = new WeakHashMap<Object, Object>();
|
private final Map<Object, Object> delegateMap = new WeakHashMap<Object, Object>();
|
||||||
|
@ -85,12 +85,12 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
|
||||||
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());
|
||||||
|
|
||||||
// Using the following method rather than direct reflection,
|
// Using the following method rather than direct reflection,
|
||||||
// we get correct handling of InvocationTargetException
|
// we get correct handling of InvocationTargetException
|
||||||
// if the introduced method throws an exception.
|
// if the introduced method throws an exception.
|
||||||
Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments());
|
Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments());
|
||||||
|
|
||||||
// Massage return value if possible: if the delegate returned itself,
|
// Massage return value if possible: if the delegate returned itself,
|
||||||
// we really want to return the proxy.
|
// we really want to return the proxy.
|
||||||
if (retVal == delegate && mi instanceof ProxyMethodInvocation) {
|
if (retVal == delegate && mi instanceof ProxyMethodInvocation) {
|
||||||
|
@ -126,7 +126,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object createNewDelegate() {
|
private Object createNewDelegate() {
|
||||||
try {
|
try {
|
||||||
return this.defaultImplType.newInstance();
|
return this.defaultImplType.newInstance();
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.springframework.util.Assert;
|
||||||
* <p>The <code>suppressInterface</code> method can be used to suppress interfaces
|
* <p>The <code>suppressInterface</code> method can be used to suppress interfaces
|
||||||
* implemented by the delegate but which should not be introduced to the owning
|
* implemented by the delegate but which should not be introduced to the owning
|
||||||
* AOP proxy.
|
* AOP proxy.
|
||||||
*
|
*
|
||||||
* <p>An instance of this class is serializable if the delegate is.
|
* <p>An instance of this class is serializable if the delegate is.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
@ -50,7 +50,7 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
implements IntroductionInterceptor {
|
implements IntroductionInterceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object that actually implements the interfaces.
|
* Object that actually implements the interfaces.
|
||||||
* May be "this" if a subclass implements the introduced interfaces.
|
* May be "this" if a subclass implements the introduced interfaces.
|
||||||
|
@ -66,7 +66,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
public DelegatingIntroductionInterceptor(Object delegate) {
|
public DelegatingIntroductionInterceptor(Object delegate) {
|
||||||
init(delegate);
|
init(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new DelegatingIntroductionInterceptor.
|
* Construct a new DelegatingIntroductionInterceptor.
|
||||||
* The delegate will be the subclass, which must implement
|
* The delegate will be the subclass, which must implement
|
||||||
|
@ -91,8 +91,8 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
suppressInterface(IntroductionInterceptor.class);
|
suppressInterface(IntroductionInterceptor.class);
|
||||||
suppressInterface(DynamicIntroductionAdvice.class);
|
suppressInterface(DynamicIntroductionAdvice.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses may need to override this if they want to perform custom
|
* Subclasses may need to override this if they want to perform custom
|
||||||
* behaviour in around advice. However, subclasses should invoke this
|
* behaviour in around advice. However, subclasses should invoke this
|
||||||
|
@ -104,7 +104,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||||
// get correct handling of InvocationTargetException
|
// get correct handling of InvocationTargetException
|
||||||
// if the introduced method throws an exception.
|
// if the introduced method throws an exception.
|
||||||
Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments());
|
Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments());
|
||||||
|
|
||||||
// Massage return value if possible: if the delegate returned itself,
|
// Massage return value if possible: if the delegate returned itself,
|
||||||
// we really want to return the proxy.
|
// we really want to return the proxy.
|
||||||
if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) {
|
if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -38,13 +38,13 @@ import java.util.regex.PatternSyntaxException;
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut {
|
public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled form of the patterns.
|
* Compiled form of the patterns.
|
||||||
*/
|
*/
|
||||||
private Pattern[] compiledPatterns = new Pattern[0];
|
private Pattern[] compiledPatterns = new Pattern[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiled form of the exclusion patterns.
|
* Compiled form of the exclusion patterns.
|
||||||
*/
|
*/
|
||||||
private Pattern[] compiledExclusionPatterns = new Pattern[0];
|
private Pattern[] compiledExclusionPatterns = new Pattern[0];
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -25,11 +25,11 @@ import org.springframework.aop.ClassFilter;
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
*/
|
*/
|
||||||
public class RootClassFilter implements ClassFilter, Serializable {
|
public class RootClassFilter implements ClassFilter, Serializable {
|
||||||
|
|
||||||
private Class clazz;
|
private Class clazz;
|
||||||
|
|
||||||
// TODO inheritance
|
// TODO inheritance
|
||||||
|
|
||||||
public RootClassFilter(Class clazz) {
|
public RootClassFilter(Class clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -22,7 +22,7 @@ import org.springframework.aop.MethodMatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenient abstract superclass for static method matchers, which don't care
|
* Convenient abstract superclass for static method matchers, which don't care
|
||||||
* about arguments at runtime.
|
* about arguments at runtime.
|
||||||
*/
|
*/
|
||||||
public abstract class StaticMethodMatcher implements MethodMatcher {
|
public abstract class StaticMethodMatcher implements MethodMatcher {
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased
|
||||||
* @throws Exception to avoid placing constraints on pooling APIs
|
* @throws Exception to avoid placing constraints on pooling APIs
|
||||||
*/
|
*/
|
||||||
protected abstract void createPool() throws Exception;
|
protected abstract void createPool() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquire an object from the pool.
|
* Acquire an object from the pool.
|
||||||
* @return an object from the pool
|
* @return an object from the pool
|
||||||
|
@ -98,7 +98,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased
|
||||||
* APIs, so we're forgiving with our exception signature
|
* APIs, so we're forgiving with our exception signature
|
||||||
*/
|
*/
|
||||||
public abstract Object getTarget() throws Exception;
|
public abstract Object getTarget() throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the given object to the pool.
|
* Return the given object to the pool.
|
||||||
* @param target object that must have been acquired from the pool
|
* @param target object that must have been acquired from the pool
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.springframework.core.Constants;
|
||||||
* properties are explictly not mirrored because the implementation of
|
* properties are explictly not mirrored because the implementation of
|
||||||
* <code>PoolableObjectFactory</code> used by this class does not implement
|
* <code>PoolableObjectFactory</code> used by this class does not implement
|
||||||
* meaningful validation. All exposed Commons Pool properties use the corresponding
|
* meaningful validation. All exposed Commons Pool properties use the corresponding
|
||||||
* Commons Pool defaults: for example,
|
* Commons Pool defaults: for example,
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -58,11 +58,11 @@ public class SingletonTargetSource implements TargetSource, Serializable {
|
||||||
public Class<?> getTargetClass() {
|
public Class<?> getTargetClass() {
|
||||||
return this.target.getClass();
|
return this.target.getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getTarget() {
|
public Object getTarget() {
|
||||||
return this.target;
|
return this.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseTarget(Object target) {
|
public void releaseTarget(Object target) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.springframework.core.NamedThreadLocal;
|
||||||
*/
|
*/
|
||||||
public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource
|
public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource
|
||||||
implements ThreadLocalTargetSourceStats, DisposableBean {
|
implements ThreadLocalTargetSourceStats, DisposableBean {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ThreadLocal holding the target associated with the current
|
* ThreadLocal holding the target associated with the current
|
||||||
* thread. Unlike most ThreadLocals, which are static, this variable
|
* thread. Unlike most ThreadLocals, which are static, this variable
|
||||||
|
@ -62,9 +62,9 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource
|
||||||
* Set of managed targets, enabling us to keep track of the targets we've created.
|
* Set of managed targets, enabling us to keep track of the targets we've created.
|
||||||
*/
|
*/
|
||||||
private final Set<Object> targetSet = new HashSet<Object>();
|
private final Set<Object> targetSet = new HashSet<Object>();
|
||||||
|
|
||||||
private int invocationCount;
|
private int invocationCount;
|
||||||
|
|
||||||
private int hitCount;
|
private int hitCount;
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose of targets if necessary; clear ThreadLocal.
|
* Dispose of targets if necessary; clear ThreadLocal.
|
||||||
* @see #destroyPrototypeInstance
|
* @see #destroyPrototypeInstance
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2005 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -23,7 +23,7 @@ package org.springframework.aop.target;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public interface ThreadLocalTargetSourceStats {
|
public interface ThreadLocalTargetSourceStats {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of client invocations.
|
* Return the number of client invocations.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2006 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
|
@ -36,7 +36,7 @@ public final class AspectJAdviceParameterNameDiscoverAnnotationTests
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@interface MyAnnotation {}
|
@interface MyAnnotation {}
|
||||||
|
|
||||||
public void pjpAndAnAnnotation(ProceedingJoinPoint pjp, MyAnnotation ann) {}
|
public void pjpAndAnAnnotation(ProceedingJoinPoint pjp, MyAnnotation ann) {}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -247,7 +247,7 @@ public class AspectJAdviceParameterNameDiscovererTests {
|
||||||
public void testReferenceBindingWithAlternateTokenizations() {
|
public void testReferenceBindingWithAlternateTokenizations() {
|
||||||
assertParameterNames(getMethod("onePrimitive"),"call(bar *) && somepc(foo)",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"call(bar *) && somepc(foo)",new String[] {"foo"});
|
||||||
assertParameterNames(getMethod("onePrimitive"),"somepc ( foo )",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"somepc ( foo )",new String[] {"foo"});
|
||||||
assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"});
|
assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -44,7 +44,7 @@ import test.beans.subpkg.DeepBean;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class AspectJExpressionPointcutTests {
|
public final class AspectJExpressionPointcutTests {
|
||||||
|
|
||||||
public static final String MATCH_ALL_METHODS = "execution(* *(..))";
|
public static final String MATCH_ALL_METHODS = "execution(* *(..))";
|
||||||
|
|
||||||
private Method getAge;
|
private Method getAge;
|
||||||
|
@ -54,8 +54,8 @@ public final class AspectJExpressionPointcutTests {
|
||||||
private Method setSomeNumber;
|
private Method setSomeNumber;
|
||||||
|
|
||||||
private Method isPostProcessed;
|
private Method isPostProcessed;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws NoSuchMethodException {
|
public void setUp() throws NoSuchMethodException {
|
||||||
getAge = TestBean.class.getMethod("getAge", (Class<?>[])null);
|
getAge = TestBean.class.getMethod("getAge", (Class<?>[])null);
|
||||||
|
@ -63,7 +63,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
setSomeNumber = TestBean.class.getMethod("setSomeNumber", new Class[]{Number.class});
|
setSomeNumber = TestBean.class.getMethod("setSomeNumber", new Class[]{Number.class});
|
||||||
isPostProcessed = TestBean.class.getMethod("isPostProcessed", (Class[]) null);
|
isPostProcessed = TestBean.class.getMethod("isPostProcessed", (Class[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchExplicit() {
|
public void testMatchExplicit() {
|
||||||
String expression = "execution(int test.beans.TestBean.getAge())";
|
String expression = "execution(int test.beans.TestBean.getAge())";
|
||||||
|
@ -100,60 +100,60 @@ public final class AspectJExpressionPointcutTests {
|
||||||
assertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.class));
|
assertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThis() throws SecurityException, NoSuchMethodException{
|
public void testThis() throws SecurityException, NoSuchMethodException{
|
||||||
testThisOrTarget("this");
|
testThisOrTarget("this");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTarget() throws SecurityException, NoSuchMethodException {
|
public void testTarget() throws SecurityException, NoSuchMethodException {
|
||||||
testThisOrTarget("target");
|
testThisOrTarget("target");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OtherIOther implements IOther {
|
public static class OtherIOther implements IOther {
|
||||||
|
|
||||||
public void absquatulate() {
|
public void absquatulate() {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This and target are equivalent. Really instanceof pointcuts.
|
* This and target are equivalent. Really instanceof pointcuts.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @param which this or target
|
* @param which this or target
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
*/
|
*/
|
||||||
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
|
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
|
||||||
String matchesTestBean = which + "(test.beans.TestBean)";
|
String matchesTestBean = which + "(test.beans.TestBean)";
|
||||||
String matchesIOther = which + "(test.beans.IOther)";
|
String matchesIOther = which + "(test.beans.IOther)";
|
||||||
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
|
||||||
testBeanPc.setExpression(matchesTestBean);
|
testBeanPc.setExpression(matchesTestBean);
|
||||||
|
|
||||||
AspectJExpressionPointcut iOtherPc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut iOtherPc = new AspectJExpressionPointcut();
|
||||||
iOtherPc.setExpression(matchesIOther);
|
iOtherPc.setExpression(matchesIOther);
|
||||||
|
|
||||||
assertTrue(testBeanPc.matches(TestBean.class));
|
assertTrue(testBeanPc.matches(TestBean.class));
|
||||||
assertTrue(testBeanPc.matches(getAge, TestBean.class));
|
assertTrue(testBeanPc.matches(getAge, TestBean.class));
|
||||||
assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
||||||
OtherIOther.class));
|
OtherIOther.class));
|
||||||
|
|
||||||
assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
||||||
OtherIOther.class));
|
OtherIOther.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
|
public void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
|
||||||
testWithinPackage(false);
|
testWithinPackage(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
||||||
testWithinPackage(true);
|
testWithinPackage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
|
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
|
||||||
String withinBeansPackage = "within(test.beans.";
|
String withinBeansPackage = "within(test.beans.";
|
||||||
// Subpackages are matched by **
|
// Subpackages are matched by **
|
||||||
|
@ -163,7 +163,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
withinBeansPackage = withinBeansPackage + "*)";
|
withinBeansPackage = withinBeansPackage + "*)";
|
||||||
AspectJExpressionPointcut withinBeansPc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut withinBeansPc = new AspectJExpressionPointcut();
|
||||||
withinBeansPc.setExpression(withinBeansPackage);
|
withinBeansPc.setExpression(withinBeansPackage);
|
||||||
|
|
||||||
assertTrue(withinBeansPc.matches(TestBean.class));
|
assertTrue(withinBeansPc.matches(TestBean.class));
|
||||||
assertTrue(withinBeansPc.matches(getAge, TestBean.class));
|
assertTrue(withinBeansPc.matches(getAge, TestBean.class));
|
||||||
assertEquals(matchSubpackages, withinBeansPc.matches(DeepBean.class));
|
assertEquals(matchSubpackages, withinBeansPc.matches(DeepBean.class));
|
||||||
|
@ -173,7 +173,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class<?>[])null),
|
||||||
OtherIOther.class));
|
OtherIOther.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFriendlyErrorOnNoLocationClassMatching() {
|
public void testFriendlyErrorOnNoLocationClassMatching() {
|
||||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||||
|
@ -185,7 +185,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
assertTrue(ex.getMessage().indexOf("expression") != -1);
|
assertTrue(ex.getMessage().indexOf("expression") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFriendlyErrorOnNoLocation2ArgMatching() {
|
public void testFriendlyErrorOnNoLocation2ArgMatching() {
|
||||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||||
|
@ -197,7 +197,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
assertTrue(ex.getMessage().indexOf("expression") != -1);
|
assertTrue(ex.getMessage().indexOf("expression") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFriendlyErrorOnNoLocation3ArgMatching() {
|
public void testFriendlyErrorOnNoLocation3ArgMatching() {
|
||||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||||
|
@ -210,7 +210,7 @@ public final class AspectJExpressionPointcutTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchWithArgs() throws Exception {
|
public void testMatchWithArgs() throws Exception {
|
||||||
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||||
|
@ -329,19 +329,19 @@ public final class AspectJExpressionPointcutTests {
|
||||||
@Test
|
@Test
|
||||||
public void testAndSubstitution() {
|
public void testAndSubstitution() {
|
||||||
Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
|
Pointcut pc = getPointcut("execution(* *(..)) and args(String)");
|
||||||
PointcutExpression expr =
|
PointcutExpression expr =
|
||||||
((AspectJExpressionPointcut) pc).getPointcutExpression();
|
((AspectJExpressionPointcut) pc).getPointcutExpression();
|
||||||
assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
|
assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleAndSubstitutions() {
|
public void testMultipleAndSubstitutions() {
|
||||||
Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
|
Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
|
||||||
PointcutExpression expr =
|
PointcutExpression expr =
|
||||||
((AspectJExpressionPointcut) pc).getPointcutExpression();
|
((AspectJExpressionPointcut) pc).getPointcutExpression();
|
||||||
assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());
|
assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pointcut getPointcut(String expression) {
|
private Pointcut getPointcut(String expression) {
|
||||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||||
pointcut.setExpression(expression);
|
pointcut.setExpression(expression);
|
||||||
|
|
|
@ -34,8 +34,8 @@ public final class BeanNamePointcutMatchingTests {
|
||||||
public void testMatchingPointcuts() {
|
public void testMatchingPointcuts() {
|
||||||
assertMatch("someName", "bean(someName)");
|
assertMatch("someName", "bean(someName)");
|
||||||
|
|
||||||
// Spring bean names are less restrictive compared to AspectJ names (methods, types etc.)
|
// Spring bean names are less restrictive compared to AspectJ names (methods, types etc.)
|
||||||
// MVC Controller-kind
|
// MVC Controller-kind
|
||||||
assertMatch("someName/someOtherName", "bean(someName/someOtherName)");
|
assertMatch("someName/someOtherName", "bean(someName/someOtherName)");
|
||||||
assertMatch("someName/foo/someOtherName", "bean(someName/*/someOtherName)");
|
assertMatch("someName/foo/someOtherName", "bean(someName/*/someOtherName)");
|
||||||
assertMatch("someName/foo/bar/someOtherName", "bean(someName/*/someOtherName)");
|
assertMatch("someName/foo/bar/someOtherName", "bean(someName/*/someOtherName)");
|
||||||
|
@ -58,9 +58,9 @@ public final class BeanNamePointcutMatchingTests {
|
||||||
// Or, and, not expressions
|
// Or, and, not expressions
|
||||||
assertMatch("someName", "bean(someName) || bean(someOtherName)");
|
assertMatch("someName", "bean(someName) || bean(someOtherName)");
|
||||||
assertMatch("someOtherName", "bean(someName) || bean(someOtherName)");
|
assertMatch("someOtherName", "bean(someName) || bean(someOtherName)");
|
||||||
|
|
||||||
assertMatch("someName", "!bean(someOtherName)");
|
assertMatch("someName", "!bean(someOtherName)");
|
||||||
|
|
||||||
assertMatch("someName", "bean(someName) || !bean(someOtherName)");
|
assertMatch("someName", "bean(someName) || !bean(someOtherName)");
|
||||||
assertMatch("someName", "bean(someName) && !bean(someOtherName)");
|
assertMatch("someName", "bean(someName) && !bean(someOtherName)");
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,31 +72,31 @@ public final class MethodInvocationProceedingJoinPointTests {
|
||||||
final Object raw = new TestBean();
|
final Object raw = new TestBean();
|
||||||
// Will be set by advice during a method call
|
// Will be set by advice during a method call
|
||||||
final int newAge = 23;
|
final int newAge = 23;
|
||||||
|
|
||||||
ProxyFactory pf = new ProxyFactory(raw);
|
ProxyFactory pf = new ProxyFactory(raw);
|
||||||
pf.setExposeProxy(true);
|
pf.setExposeProxy(true);
|
||||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||||
pf.addAdvice(new MethodBeforeAdvice() {
|
pf.addAdvice(new MethodBeforeAdvice() {
|
||||||
private int depth;
|
private int depth;
|
||||||
|
|
||||||
public void before(Method method, Object[] args, Object target) throws Throwable {
|
public void before(Method method, Object[] args, Object target) throws Throwable {
|
||||||
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
|
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
|
||||||
assertTrue("Method named in toString", jp.toString().contains(method.getName()));
|
assertTrue("Method named in toString", jp.toString().contains(method.getName()));
|
||||||
// Ensure that these don't cause problems
|
// Ensure that these don't cause problems
|
||||||
jp.toShortString();
|
jp.toShortString();
|
||||||
jp.toLongString();
|
jp.toLongString();
|
||||||
|
|
||||||
assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget());
|
assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget());
|
||||||
assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget()));
|
assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget()));
|
||||||
|
|
||||||
ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis();
|
ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis();
|
||||||
assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis()));
|
assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis()));
|
||||||
|
|
||||||
assertNotSame(target, thisProxy);
|
assertNotSame(target, thisProxy);
|
||||||
|
|
||||||
// Check getting again doesn't cause a problem
|
// Check getting again doesn't cause a problem
|
||||||
assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis());
|
assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis());
|
||||||
|
|
||||||
// Try reentrant call--will go through this advice.
|
// Try reentrant call--will go through this advice.
|
||||||
// Be sure to increment depth to avoid infinite recursion
|
// Be sure to increment depth to avoid infinite recursion
|
||||||
if (depth++ == 0) {
|
if (depth++ == 0) {
|
||||||
|
@ -109,10 +109,10 @@ public final class MethodInvocationProceedingJoinPointTests {
|
||||||
|
|
||||||
assertSame(AopContext.currentProxy(), thisProxy);
|
assertSame(AopContext.currentProxy(), thisProxy);
|
||||||
assertSame(target, raw);
|
assertSame(target, raw);
|
||||||
|
|
||||||
assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName());
|
assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName());
|
||||||
assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers());
|
assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers());
|
||||||
|
|
||||||
MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature();
|
MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature();
|
||||||
assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature());
|
assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature());
|
||||||
assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint());
|
assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint());
|
||||||
|
@ -146,7 +146,7 @@ public final class MethodInvocationProceedingJoinPointTests {
|
||||||
catch (UnsupportedOperationException ex) {
|
catch (UnsupportedOperationException ex) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sloc.getFileName();
|
sloc.getFileName();
|
||||||
fail("Can't get file name");
|
fail("Can't get file name");
|
||||||
|
@ -191,7 +191,7 @@ public final class MethodInvocationProceedingJoinPointTests {
|
||||||
// it serves our purpose here
|
// it serves our purpose here
|
||||||
JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method);
|
JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method);
|
||||||
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
|
JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
|
||||||
|
|
||||||
assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString());
|
assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString());
|
||||||
assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString());
|
assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString());
|
||||||
assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString());
|
assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString());
|
||||||
|
|
|
@ -38,37 +38,37 @@ public final class TigerAspectJAdviceParameterNameDiscovererTests
|
||||||
public void testAtTarget() {
|
public void testAtTarget() {
|
||||||
assertParameterNames(getMethod("oneAnnotation"),"@target(a)",new String[]{"a"});
|
assertParameterNames(getMethod("oneAnnotation"),"@target(a)",new String[]{"a"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAtArgs() {
|
public void testAtArgs() {
|
||||||
assertParameterNames(getMethod("oneAnnotation"),"@args(a)",new String[]{"a"});
|
assertParameterNames(getMethod("oneAnnotation"),"@args(a)",new String[]{"a"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAtWithin() {
|
public void testAtWithin() {
|
||||||
assertParameterNames(getMethod("oneAnnotation"),"@within(a)",new String[]{"a"});
|
assertParameterNames(getMethod("oneAnnotation"),"@within(a)",new String[]{"a"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAtWithincode() {
|
public void testAtWithincode() {
|
||||||
assertParameterNames(getMethod("oneAnnotation"),"@withincode(a)",new String[]{"a"});
|
assertParameterNames(getMethod("oneAnnotation"),"@withincode(a)",new String[]{"a"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAtAnnotation() {
|
public void testAtAnnotation() {
|
||||||
assertParameterNames(getMethod("oneAnnotation"),"@annotation(a)",new String[]{"a"});
|
assertParameterNames(getMethod("oneAnnotation"),"@annotation(a)",new String[]{"a"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAmbiguousAnnotationTwoVars() {
|
public void testAmbiguousAnnotationTwoVars() {
|
||||||
assertException(getMethod("twoAnnotations"),"@annotation(a) && @this(x)",AmbiguousBindingException.class,
|
assertException(getMethod("twoAnnotations"),"@annotation(a) && @this(x)",AmbiguousBindingException.class,
|
||||||
"Found 2 potential annotation variable(s), and 2 potential argument slots");
|
"Found 2 potential annotation variable(s), and 2 potential argument slots");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAmbiguousAnnotationOneVar() {
|
public void testAmbiguousAnnotationOneVar() {
|
||||||
assertException(getMethod("oneAnnotation"),"@annotation(a) && @this(x)",IllegalArgumentException.class,
|
assertException(getMethod("oneAnnotation"),"@annotation(a) && @this(x)",IllegalArgumentException.class,
|
||||||
"Found 2 candidate annotation binding variables but only one potential argument binding slot");
|
"Found 2 candidate annotation binding variables but only one potential argument binding slot");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,7 +32,7 @@ import test.annotation.transaction.Tx;
|
||||||
import test.beans.TestBean;
|
import test.beans.TestBean;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java5-specific {@link AspectJExpressionPointcutTests}.
|
* Java5-specific {@link AspectJExpressionPointcutTests}.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
@ -54,10 +54,10 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
methodsOnHasGeneric.put(m.getName(), m);
|
methodsOnHasGeneric.put(m.getName(), m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class HasGeneric {
|
public static class HasGeneric {
|
||||||
|
|
||||||
public void setFriends(List<TestBean> friends) {
|
public void setFriends(List<TestBean> friends) {
|
||||||
}
|
}
|
||||||
public void setEnemies(List<TestBean> enemies) {
|
public void setEnemies(List<TestBean> enemies) {
|
||||||
|
@ -73,20 +73,20 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
String expression = "execution(* set*(java.util.List<test.beans.TestBean>) )";
|
String expression = "execution(* set*(java.util.List<test.beans.TestBean>) )";
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(expression);
|
ajexp.setExpression(expression);
|
||||||
|
|
||||||
// TODO this will currently map, would be nice for optimization
|
// TODO this will currently map, would be nice for optimization
|
||||||
//assertTrue(ajexp.matches(HasGeneric.class));
|
//assertTrue(ajexp.matches(HasGeneric.class));
|
||||||
//assertFalse(ajexp.matches(TestBean.class));
|
//assertFalse(ajexp.matches(TestBean.class));
|
||||||
|
|
||||||
Method takesGenericList = methodsOnHasGeneric.get("setFriends");
|
Method takesGenericList = methodsOnHasGeneric.get("setFriends");
|
||||||
assertTrue(ajexp.matches(takesGenericList, HasGeneric.class));
|
assertTrue(ajexp.matches(takesGenericList, HasGeneric.class));
|
||||||
assertTrue(ajexp.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class));
|
assertTrue(ajexp.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class));
|
||||||
assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPartners"), HasGeneric.class));
|
assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPartners"), HasGeneric.class));
|
||||||
assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class));
|
assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class));
|
||||||
|
|
||||||
assertFalse(ajexp.matches(getAge, TestBean.class));
|
assertFalse(ajexp.matches(getAge, TestBean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchVarargs() throws SecurityException, NoSuchMethodException {
|
public void testMatchVarargs() throws SecurityException, NoSuchMethodException {
|
||||||
class MyTemplate {
|
class MyTemplate {
|
||||||
|
@ -94,20 +94,20 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String expression = "execution(int *.*(String, Object...))";
|
String expression = "execution(int *.*(String, Object...))";
|
||||||
AspectJExpressionPointcut jdbcVarArgs = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut jdbcVarArgs = new AspectJExpressionPointcut();
|
||||||
jdbcVarArgs.setExpression(expression);
|
jdbcVarArgs.setExpression(expression);
|
||||||
|
|
||||||
// TODO: the expression above no longer matches Object[]
|
// TODO: the expression above no longer matches Object[]
|
||||||
// assertFalse(jdbcVarArgs.matches(
|
// assertFalse(jdbcVarArgs.matches(
|
||||||
// JdbcTemplate.class.getMethod("queryForInt", String.class, Object[].class),
|
// JdbcTemplate.class.getMethod("queryForInt", String.class, Object[].class),
|
||||||
// JdbcTemplate.class));
|
// JdbcTemplate.class));
|
||||||
|
|
||||||
assertTrue(jdbcVarArgs.matches(
|
assertTrue(jdbcVarArgs.matches(
|
||||||
MyTemplate.class.getMethod("queryForInt", String.class, Object[].class),
|
MyTemplate.class.getMethod("queryForInt", String.class, Object[].class),
|
||||||
MyTemplate.class));
|
MyTemplate.class));
|
||||||
|
|
||||||
Method takesGenericList = methodsOnHasGeneric.get("setFriends");
|
Method takesGenericList = methodsOnHasGeneric.get("setFriends");
|
||||||
assertFalse(jdbcVarArgs.matches(takesGenericList, HasGeneric.class));
|
assertFalse(jdbcVarArgs.matches(takesGenericList, HasGeneric.class));
|
||||||
assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class));
|
assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class));
|
||||||
|
@ -115,44 +115,44 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class));
|
assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class));
|
||||||
assertFalse(jdbcVarArgs.matches(getAge, TestBean.class));
|
assertFalse(jdbcVarArgs.matches(getAge, TestBean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException {
|
public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "@within(test.annotation.transaction.Tx)";
|
String expression = "@within(test.annotation.transaction.Tx)";
|
||||||
testMatchAnnotationOnClass(expression);
|
testMatchAnnotationOnClass(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException {
|
public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "within(@test.annotation.transaction.Tx *)";
|
String expression = "within(@test.annotation.transaction.Tx *)";
|
||||||
testMatchAnnotationOnClass(expression);
|
testMatchAnnotationOnClass(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
|
public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "within(@(test.annotation..*) *)";
|
String expression = "within(@(test.annotation..*) *)";
|
||||||
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
|
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||||
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
|
assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class),
|
||||||
TestBean.class));
|
TestBean.class));
|
||||||
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
||||||
SpringAnnotated.class));
|
SpringAnnotated.class));
|
||||||
|
|
||||||
expression = "within(@(test.annotation.transaction..*) *)";
|
expression = "within(@(test.annotation.transaction..*) *)";
|
||||||
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
|
AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||||
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null),
|
||||||
SpringAnnotated.class));
|
SpringAnnotated.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException {
|
public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "within(@(test.annotation.transaction.*) *)";
|
String expression = "within(@(test.annotation.transaction.*) *)";
|
||||||
testMatchAnnotationOnClass(expression);
|
testMatchAnnotationOnClass(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AspectJExpressionPointcut testMatchAnnotationOnClass(String expression) throws SecurityException, NoSuchMethodException {
|
private AspectJExpressionPointcut testMatchAnnotationOnClass(String expression) throws SecurityException, NoSuchMethodException {
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(expression);
|
ajexp.setExpression(expression);
|
||||||
|
|
||||||
assertFalse(ajexp.matches(getAge, TestBean.class));
|
assertFalse(ajexp.matches(getAge, TestBean.class));
|
||||||
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
||||||
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
||||||
|
@ -160,13 +160,13 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
return ajexp;
|
return ajexp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException {
|
public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(expression);
|
ajexp.setExpression(expression);
|
||||||
|
|
||||||
assertFalse(ajexp.matches(getAge, TestBean.class));
|
assertFalse(ajexp.matches(getAge, TestBean.class));
|
||||||
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
||||||
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
||||||
|
@ -174,13 +174,13 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
assertTrue(ajexp.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
assertTrue(ajexp.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
||||||
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException {
|
public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "execution(@(test.annotation..*) * *(..))";
|
String expression = "execution(@(test.annotation..*) * *(..))";
|
||||||
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
|
||||||
anySpringMethodAnnotation.setExpression(expression);
|
anySpringMethodAnnotation.setExpression(expression);
|
||||||
|
|
||||||
assertFalse(anySpringMethodAnnotation.matches(getAge, TestBean.class));
|
assertFalse(anySpringMethodAnnotation.matches(getAge, TestBean.class));
|
||||||
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
||||||
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
||||||
|
@ -194,43 +194,43 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
|
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
|
||||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||||
|
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
|
|
||||||
assertTrue(takesSpringAnnotatedArgument2.matches(
|
assertTrue(takesSpringAnnotatedArgument2.matches(
|
||||||
ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class),
|
ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class),
|
||||||
ProcessesSpringAnnotatedParameters.class));
|
ProcessesSpringAnnotatedParameters.class));
|
||||||
|
|
||||||
// True because it maybeMatches with potential argument subtypes
|
// True because it maybeMatches with potential argument subtypes
|
||||||
assertTrue(takesSpringAnnotatedArgument2.matches(
|
assertTrue(takesSpringAnnotatedArgument2.matches(
|
||||||
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
|
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
|
||||||
ProcessesSpringAnnotatedParameters.class));
|
ProcessesSpringAnnotatedParameters.class));
|
||||||
|
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(
|
assertFalse(takesSpringAnnotatedArgument2.matches(
|
||||||
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
|
ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class),
|
||||||
ProcessesSpringAnnotatedParameters.class,
|
ProcessesSpringAnnotatedParameters.class,
|
||||||
new Object[] { new TestBean(), new BeanA()})
|
new Object[] { new TestBean(), new BeanA()})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException {
|
public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException {
|
||||||
String expression = "execution(* *(*, @(test..*) *))";
|
String expression = "execution(* *(*, @(test..*) *))";
|
||||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||||
|
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class));
|
||||||
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class));
|
||||||
|
|
||||||
assertTrue(takesSpringAnnotatedArgument2.matches(
|
assertTrue(takesSpringAnnotatedArgument2.matches(
|
||||||
ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class),
|
ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class),
|
||||||
ProcessesSpringAnnotatedParameters.class));
|
ProcessesSpringAnnotatedParameters.class));
|
||||||
|
@ -267,7 +267,7 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class BeanA {
|
static class BeanA {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public final class TigerAspectJExpressionPointcutTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Tx
|
@Tx
|
||||||
static class BeanB {
|
static class BeanB {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
|
|
||||||
// Test with default class loader first...
|
// Test with default class loader first...
|
||||||
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl");
|
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl");
|
||||||
|
|
||||||
// Then try again with a different class loader on the target...
|
// Then try again with a different class loader on the target...
|
||||||
SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader());
|
SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader());
|
||||||
// Make sure the interface is loaded from the parent class loader
|
// Make sure the interface is loaded from the parent class loader
|
||||||
|
@ -102,7 +102,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
}
|
}
|
||||||
assertEquals(1, logAdvice.getCountThrows());
|
assertEquals(1, logAdvice.getCountThrows());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SimpleThrowawayClassLoader extends OverridingClassLoader {
|
public static class SimpleThrowawayClassLoader extends OverridingClassLoader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TestException extends RuntimeException {
|
public static class TestException extends RuntimeException {
|
||||||
|
|
||||||
public TestException(String string) {
|
public TestException(String string) {
|
||||||
|
@ -129,11 +129,11 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
@Inherited
|
@Inherited
|
||||||
public static @interface Log {
|
public static @interface Log {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface TestService {
|
public static interface TestService {
|
||||||
public String sayHello();
|
public String sayHello();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log
|
@Log
|
||||||
public static class TestServiceImpl implements TestService{
|
public static class TestServiceImpl implements TestService{
|
||||||
public String sayHello() {
|
public String sayHello() {
|
||||||
|
@ -142,11 +142,11 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {
|
public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice {
|
||||||
|
|
||||||
private int countBefore = 0;
|
private int countBefore = 0;
|
||||||
|
|
||||||
private int countThrows = 0;
|
private int countThrows = 0;
|
||||||
|
|
||||||
public void before(Method method, Object[] objects, Object o) throws Throwable {
|
public void before(Method method, Object[] objects, Object o) throws Throwable {
|
||||||
countBefore++;
|
countBefore++;
|
||||||
}
|
}
|
||||||
|
@ -163,12 +163,12 @@ public class TrickyAspectJPointcutExpressionTests {
|
||||||
public int getCountThrows() {
|
public int getCountThrows() {
|
||||||
return countThrows;
|
return countThrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
countThrows = 0;
|
countThrows = 0;
|
||||||
countBefore = 0;
|
countBefore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public final class TypePatternClassFilterTests {
|
||||||
assertFalse("Must be excluded: not subclass", tpcf.matches(IOther.class));
|
assertFalse("Must be excluded: not subclass", tpcf.matches(IOther.class));
|
||||||
assertFalse("Must be excluded: not subclass", tpcf.matches(DefaultListableBeanFactory.class));
|
assertFalse("Must be excluded: not subclass", tpcf.matches(DefaultListableBeanFactory.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAndOrNotReplacement() {
|
public void testAndOrNotReplacement() {
|
||||||
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
|
TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String");
|
||||||
|
@ -75,7 +75,7 @@ public final class TypePatternClassFilterTests {
|
||||||
assertFalse("matches Double",tpcf.matches(Double.class));
|
assertFalse("matches Double",tpcf.matches(Double.class));
|
||||||
tpcf = new TypePatternClassFilter("java.lang.Number+ and not java.lang.Float");
|
tpcf = new TypePatternClassFilter("java.lang.Number+ and not java.lang.Float");
|
||||||
assertFalse("matches Float",tpcf.matches(Float.class));
|
assertFalse("matches Float",tpcf.matches(Float.class));
|
||||||
assertTrue("matches Double",tpcf.matches(Double.class));
|
assertTrue("matches Double",tpcf.matches(Double.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
|
|
|
@ -76,7 +76,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
* @return the fixture
|
* @return the fixture
|
||||||
*/
|
*/
|
||||||
protected abstract AspectJAdvisorFactory getFixture();
|
protected abstract AspectJAdvisorFactory getFixture();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRejectsPerCflowAspect() {
|
public void testRejectsPerCflowAspect() {
|
||||||
|
@ -88,7 +88,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
assertTrue(ex.getMessage().indexOf("PERCFLOW") != -1);
|
assertTrue(ex.getMessage().indexOf("PERCFLOW") != -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRejectsPerCflowBelowAspect() {
|
public void testRejectsPerCflowBelowAspect() {
|
||||||
try {
|
try {
|
||||||
|
@ -105,11 +105,11 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
int realAge = 65;
|
int realAge = 65;
|
||||||
target.setAge(realAge);
|
target.setAge(realAge);
|
||||||
TestBean itb = (TestBean) createProxy(target,
|
TestBean itb = (TestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean")),
|
||||||
TestBean.class);
|
TestBean.class);
|
||||||
assertEquals("Around advice must NOT apply", realAge, itb.getAge());
|
assertEquals("Around advice must NOT apply", realAge, itb.getAge());
|
||||||
|
|
||||||
Advised advised = (Advised) itb;
|
Advised advised = (Advised) itb;
|
||||||
SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
|
SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1];
|
||||||
assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
||||||
|
@ -121,10 +121,10 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
// Check that the perclause pointcut is valid
|
// Check that the perclause pointcut is valid
|
||||||
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
||||||
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
||||||
|
|
||||||
// Hit the method in the per clause to instantiate the aspect
|
// Hit the method in the per clause to instantiate the aspect
|
||||||
itb.getSpouse();
|
itb.getSpouse();
|
||||||
|
|
||||||
assertTrue(maaif.isMaterialized());
|
assertTrue(maaif.isMaterialized());
|
||||||
|
|
||||||
assertEquals("Around advice must apply", 0, itb.getAge());
|
assertEquals("Around advice must apply", 0, itb.getAge());
|
||||||
|
@ -190,11 +190,11 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
int realAge = 65;
|
int realAge = 65;
|
||||||
target.setAge(realAge);
|
target.setAge(realAge);
|
||||||
TestBean itb = (TestBean) createProxy(target,
|
TestBean itb = (TestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerThisAspect(), "someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerThisAspect(), "someBean")),
|
||||||
TestBean.class);
|
TestBean.class);
|
||||||
assertEquals("Around advice must NOT apply", realAge, itb.getAge());
|
assertEquals("Around advice must NOT apply", realAge, itb.getAge());
|
||||||
|
|
||||||
Advised advised = (Advised) itb;
|
Advised advised = (Advised) itb;
|
||||||
// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
|
// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
|
||||||
assertEquals(4, advised.getAdvisors().length);
|
assertEquals(4, advised.getAdvisors().length);
|
||||||
|
@ -208,30 +208,30 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
// Check that the perclause pointcut is valid
|
// Check that the perclause pointcut is valid
|
||||||
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
||||||
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
||||||
|
|
||||||
// Hit the method in the per clause to instantiate the aspect
|
// Hit the method in the per clause to instantiate the aspect
|
||||||
itb.getSpouse();
|
itb.getSpouse();
|
||||||
|
|
||||||
assertTrue(maaif.isMaterialized());
|
assertTrue(maaif.isMaterialized());
|
||||||
|
|
||||||
assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
|
assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
|
||||||
|
|
||||||
assertEquals("Around advice must apply", 0, itb.getAge());
|
assertEquals("Around advice must apply", 0, itb.getAge());
|
||||||
assertEquals("Around advice must apply", 1, itb.getAge());
|
assertEquals("Around advice must apply", 1, itb.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerTypeWithinAspect() throws SecurityException, NoSuchMethodException {
|
public void testPerTypeWithinAspect() throws SecurityException, NoSuchMethodException {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
int realAge = 65;
|
int realAge = 65;
|
||||||
target.setAge(realAge);
|
target.setAge(realAge);
|
||||||
PerTypeWithinAspectInstanceFactory aif = new PerTypeWithinAspectInstanceFactory();
|
PerTypeWithinAspectInstanceFactory aif = new PerTypeWithinAspectInstanceFactory();
|
||||||
TestBean itb = (TestBean) createProxy(target,
|
TestBean itb = (TestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(aif),
|
getFixture().getAdvisors(aif),
|
||||||
TestBean.class);
|
TestBean.class);
|
||||||
assertEquals("No method calls", 0, aif.getInstantiationCount());
|
assertEquals("No method calls", 0, aif.getInstantiationCount());
|
||||||
assertEquals("Around advice must now apply", 0, itb.getAge());
|
assertEquals("Around advice must now apply", 0, itb.getAge());
|
||||||
|
|
||||||
Advised advised = (Advised) itb;
|
Advised advised = (Advised) itb;
|
||||||
// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
|
// Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors
|
||||||
assertEquals(4, advised.getAdvisors().length);
|
assertEquals(4, advised.getAdvisors().length);
|
||||||
|
@ -245,19 +245,19 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
// Check that the perclause pointcut is valid
|
// Check that the perclause pointcut is valid
|
||||||
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));
|
||||||
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut());
|
||||||
|
|
||||||
// Hit the method in the per clause to instantiate the aspect
|
// Hit the method in the per clause to instantiate the aspect
|
||||||
itb.getSpouse();
|
itb.getSpouse();
|
||||||
|
|
||||||
assertTrue(maaif.isMaterialized());
|
assertTrue(maaif.isMaterialized());
|
||||||
|
|
||||||
assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
|
assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null));
|
||||||
|
|
||||||
assertEquals("Around advice must still apply", 1, itb.getAge());
|
assertEquals("Around advice must still apply", 1, itb.getAge());
|
||||||
assertEquals("Around advice must still apply", 2, itb.getAge());
|
assertEquals("Around advice must still apply", 2, itb.getAge());
|
||||||
|
|
||||||
TestBean itb2 = (TestBean) createProxy(target,
|
TestBean itb2 = (TestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(aif),
|
getFixture().getAdvisors(aif),
|
||||||
TestBean.class);
|
TestBean.class);
|
||||||
assertEquals(1, aif.getInstantiationCount());
|
assertEquals(1, aif.getInstantiationCount());
|
||||||
assertEquals("Around advice be independent for second instance", 0, itb2.getAge());
|
assertEquals("Around advice be independent for second instance", 0, itb2.getAge());
|
||||||
|
@ -282,20 +282,20 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
@Test
|
@Test
|
||||||
public void testNamedPointcutFromAspectLibraryWithBinding() {
|
public void testNamedPointcutFromAspectLibraryWithBinding() {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new NamedPointcutAspectFromLibraryWithBinding(),"someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new NamedPointcutAspectFromLibraryWithBinding(),"someBean")),
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
itb.setAge(10);
|
itb.setAge(10);
|
||||||
assertEquals("Around advice must apply", 20, itb.getAge());
|
assertEquals("Around advice must apply", 20, itb.getAge());
|
||||||
assertEquals(20,target.getAge());
|
assertEquals(20,target.getAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testNamedPointcuts(Object aspectInstance) {
|
private void testNamedPointcuts(Object aspectInstance) {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
int realAge = 65;
|
int realAge = 65;
|
||||||
target.setAge(realAge);
|
target.setAge(realAge);
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspectInstance,"someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspectInstance,"someBean")),
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
assertEquals("Around advice must apply", -1, itb.getAge());
|
assertEquals("Around advice must apply", -1, itb.getAge());
|
||||||
assertEquals(realAge, target.getAge());
|
assertEquals(realAge, target.getAge());
|
||||||
|
@ -304,8 +304,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
@Test
|
@Test
|
||||||
public void testBindingWithSingleArg() {
|
public void testBindingWithSingleArg() {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new BindingAspectWithSingleArg(),"someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new BindingAspectWithSingleArg(),"someBean")),
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
itb.setAge(10);
|
itb.setAge(10);
|
||||||
assertEquals("Around advice must apply", 20, itb.getAge());
|
assertEquals("Around advice must apply", 20, itb.getAge());
|
||||||
|
@ -315,10 +315,10 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
@Test
|
@Test
|
||||||
public void testBindingWithMultipleArgsDifferentlyOrdered() {
|
public void testBindingWithMultipleArgsDifferentlyOrdered() {
|
||||||
ManyValuedArgs target = new ManyValuedArgs();
|
ManyValuedArgs target = new ManyValuedArgs();
|
||||||
ManyValuedArgs mva = (ManyValuedArgs) createProxy(target,
|
ManyValuedArgs mva = (ManyValuedArgs) createProxy(target,
|
||||||
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ManyValuedArgs(),"someBean")),
|
getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ManyValuedArgs(),"someBean")),
|
||||||
ManyValuedArgs.class);
|
ManyValuedArgs.class);
|
||||||
|
|
||||||
String a = "a";
|
String a = "a";
|
||||||
int b = 12;
|
int b = 12;
|
||||||
int c = 25;
|
int c = 25;
|
||||||
|
@ -327,7 +327,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
String expectedResult = a + b+ c + d + e;
|
String expectedResult = a + b+ c + d + e;
|
||||||
assertEquals(expectedResult, mva.mungeArgs(a, b, c, d, e));
|
assertEquals(expectedResult, mva.mungeArgs(a, b, c, d, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this case the introduction will be made.
|
* In this case the introduction will be made.
|
||||||
*/
|
*/
|
||||||
|
@ -344,7 +344,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
assertFalse(lockable.locked());
|
assertFalse(lockable.locked());
|
||||||
lockable.lock();
|
lockable.lock();
|
||||||
assertTrue(lockable.locked());
|
assertTrue(lockable.locked());
|
||||||
|
|
||||||
NotLockable notLockable2Target = new NotLockable();
|
NotLockable notLockable2Target = new NotLockable();
|
||||||
NotLockable notLockable2 = (NotLockable) createProxy(notLockable2Target,
|
NotLockable notLockable2 = (NotLockable) createProxy(notLockable2Target,
|
||||||
getFixture().getAdvisors(
|
getFixture().getAdvisors(
|
||||||
|
@ -363,17 +363,17 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
}
|
}
|
||||||
assertTrue(lockable2.locked());
|
assertTrue(lockable2.locked());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntroductionAdvisorExcludedFromTargetImplementingInterface() {
|
public void testIntroductionAdvisorExcludedFromTargetImplementingInterface() {
|
||||||
assertTrue(AopUtils.findAdvisorsThatCanApply(
|
assertTrue(AopUtils.findAdvisorsThatCanApply(
|
||||||
getFixture().getAdvisors(
|
getFixture().getAdvisors(
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(
|
new SingletonMetadataAwareAspectInstanceFactory(
|
||||||
new MakeLockable(),"someBean")),
|
new MakeLockable(),"someBean")),
|
||||||
CannotBeUnlocked.class).isEmpty());
|
CannotBeUnlocked.class).isEmpty());
|
||||||
assertEquals(2, AopUtils.findAdvisorsThatCanApply(getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")), NotLockable.class).size());
|
assertEquals(2, AopUtils.findAdvisorsThatCanApply(getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")), NotLockable.class).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntroductionOnTargetImplementingInterface() {
|
public void testIntroductionOnTargetImplementingInterface() {
|
||||||
CannotBeUnlocked target = new CannotBeUnlocked();
|
CannotBeUnlocked target = new CannotBeUnlocked();
|
||||||
|
@ -398,7 +398,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testIntroductionOnTargetExcludedByTypePattern() {
|
public void testIntroductionOnTargetExcludedByTypePattern() {
|
||||||
|
@ -415,7 +415,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
@Test
|
@Test
|
||||||
public void testIntroductionBasedOnAnnotationMatch_Spr5307() {
|
public void testIntroductionBasedOnAnnotationMatch_Spr5307() {
|
||||||
AnnotatedTarget target = new AnnotatedTargetImpl();
|
AnnotatedTarget target = new AnnotatedTargetImpl();
|
||||||
|
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(
|
List<Advisor> advisors = getFixture().getAdvisors(
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(new MakeAnnotatedTypeModifiable(),"someBean"));
|
new SingletonMetadataAwareAspectInstanceFactory(new MakeAnnotatedTypeModifiable(),"someBean"));
|
||||||
Object proxy = createProxy(target,
|
Object proxy = createProxy(target,
|
||||||
|
@ -430,19 +430,19 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
// TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed...
|
// TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed...
|
||||||
public void XtestIntroductionWithArgumentBinding() {
|
public void XtestIntroductionWithArgumentBinding() {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(
|
List<Advisor> advisors = getFixture().getAdvisors(
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(new MakeITestBeanModifiable(),"someBean"));
|
new SingletonMetadataAwareAspectInstanceFactory(new MakeITestBeanModifiable(),"someBean"));
|
||||||
advisors.addAll(getFixture().getAdvisors(
|
advisors.addAll(getFixture().getAdvisors(
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")));
|
new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")));
|
||||||
|
|
||||||
Modifiable modifiable = (Modifiable) createProxy(target,
|
Modifiable modifiable = (Modifiable) createProxy(target,
|
||||||
advisors,
|
advisors,
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
assertTrue(modifiable instanceof Modifiable);
|
assertTrue(modifiable instanceof Modifiable);
|
||||||
Lockable lockable = (Lockable) modifiable;
|
Lockable lockable = (Lockable) modifiable;
|
||||||
assertFalse(lockable.locked());
|
assertFalse(lockable.locked());
|
||||||
|
|
||||||
ITestBean itb = (ITestBean) modifiable;
|
ITestBean itb = (ITestBean) modifiable;
|
||||||
assertFalse(modifiable.isModified());
|
assertFalse(modifiable.isModified());
|
||||||
int oldAge = itb.getAge();
|
int oldAge = itb.getAge();
|
||||||
|
@ -454,7 +454,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
assertFalse("Setting same value does not modify", modifiable.isModified());
|
assertFalse("Setting same value does not modify", modifiable.isModified());
|
||||||
itb.setName("And now for something completely different");
|
itb.setName("And now for something completely different");
|
||||||
assertTrue(modifiable.isModified());
|
assertTrue(modifiable.isModified());
|
||||||
|
|
||||||
lockable.lock();
|
lockable.lock();
|
||||||
assertTrue(lockable.locked());
|
assertTrue(lockable.locked());
|
||||||
try {
|
try {
|
||||||
|
@ -474,8 +474,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
UnsupportedOperationException expectedException = new UnsupportedOperationException();
|
UnsupportedOperationException expectedException = new UnsupportedOperationException();
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean"));
|
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean"));
|
||||||
assertEquals("One advice method was found", 1, advisors.size());
|
assertEquals("One advice method was found", 1, advisors.size());
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
advisors,
|
advisors,
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
try {
|
try {
|
||||||
itb.getAge();
|
itb.getAge();
|
||||||
|
@ -485,7 +485,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
assertSame(expectedException, ex);
|
assertSame(expectedException, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO document this behaviour.
|
// TODO document this behaviour.
|
||||||
// Is it different AspectJ behaviour, at least for checked exceptions?
|
// Is it different AspectJ behaviour, at least for checked exceptions?
|
||||||
@Test
|
@Test
|
||||||
|
@ -494,8 +494,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
RemoteException expectedException = new RemoteException();
|
RemoteException expectedException = new RemoteException();
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean"));
|
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean"));
|
||||||
assertEquals("One advice method was found", 1, advisors.size());
|
assertEquals("One advice method was found", 1, advisors.size());
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
advisors,
|
advisors,
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
try {
|
try {
|
||||||
itb.getAge();
|
itb.getAge();
|
||||||
|
@ -505,7 +505,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
assertSame(expectedException, ex.getCause());
|
assertSame(expectedException, ex.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object createProxy(Object target, List<Advisor> advisors, Class<?>... interfaces) {
|
protected Object createProxy(Object target, List<Advisor> advisors, Class<?>... interfaces) {
|
||||||
ProxyFactory pf = new ProxyFactory(target);
|
ProxyFactory pf = new ProxyFactory(target);
|
||||||
if (interfaces.length > 1 || interfaces[0].isInterface()) {
|
if (interfaces.length > 1 || interfaces[0].isInterface()) {
|
||||||
|
@ -533,8 +533,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
TwoAdviceAspect twoAdviceAspect = new TwoAdviceAspect();
|
TwoAdviceAspect twoAdviceAspect = new TwoAdviceAspect();
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(twoAdviceAspect,"someBean"));
|
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(twoAdviceAspect,"someBean"));
|
||||||
assertEquals("Two advice methods found", 2, advisors.size());
|
assertEquals("Two advice methods found", 2, advisors.size());
|
||||||
ITestBean itb = (ITestBean) createProxy(target,
|
ITestBean itb = (ITestBean) createProxy(target,
|
||||||
advisors,
|
advisors,
|
||||||
ITestBean.class);
|
ITestBean.class);
|
||||||
itb.setName("");
|
itb.setName("");
|
||||||
assertEquals(0, itb.getAge());
|
assertEquals(0, itb.getAge());
|
||||||
|
@ -549,8 +549,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
|
|
||||||
ExceptionHandling afterReturningAspect = new ExceptionHandling();
|
ExceptionHandling afterReturningAspect = new ExceptionHandling();
|
||||||
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(afterReturningAspect,"someBean"));
|
List<Advisor> advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(afterReturningAspect,"someBean"));
|
||||||
Echo echo = (Echo) createProxy(target,
|
Echo echo = (Echo) createProxy(target,
|
||||||
advisors,
|
advisors,
|
||||||
Echo.class);
|
Echo.class);
|
||||||
assertEquals(0, afterReturningAspect.successCount);
|
assertEquals(0, afterReturningAspect.successCount);
|
||||||
assertEquals("", echo.echo(""));
|
assertEquals("", echo.echo(""));
|
||||||
|
@ -886,45 +886,45 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
abstract class AbstractMakeModifiable {
|
abstract class AbstractMakeModifiable {
|
||||||
|
|
||||||
public interface MutableModifable extends Modifiable {
|
public interface MutableModifable extends Modifiable {
|
||||||
void markDirty();
|
void markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ModifiableImpl implements MutableModifable {
|
public static class ModifiableImpl implements MutableModifable {
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
public void acceptChanges() {
|
public void acceptChanges() {
|
||||||
modified = false;
|
modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markDirty() {
|
public void markDirty() {
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(value="execution(void set*(*)) && this(modifiable) && args(newValue)",
|
@Before(value="execution(void set*(*)) && this(modifiable) && args(newValue)",
|
||||||
argNames="modifiable,newValue")
|
argNames="modifiable,newValue")
|
||||||
public void recordModificationIfSetterArgumentDiffersFromOldValue(JoinPoint jp,
|
public void recordModificationIfSetterArgumentDiffersFromOldValue(JoinPoint jp,
|
||||||
MutableModifable mixin, Object newValue) {
|
MutableModifable mixin, Object newValue) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the mixin to check and, if necessary, change,
|
* We use the mixin to check and, if necessary, change,
|
||||||
* modification status. We need the JoinPoint to get the
|
* modification status. We need the JoinPoint to get the
|
||||||
* setter method. We use newValue for comparison.
|
* setter method. We use newValue for comparison.
|
||||||
* We try to invoke the getter if possible.
|
* We try to invoke the getter if possible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mixin.isModified()) {
|
if (mixin.isModified()) {
|
||||||
// Already changed, don't need to change again
|
// Already changed, don't need to change again
|
||||||
//System.out.println("changed");
|
//System.out.println("changed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the current raw value, by invoking the corresponding setter
|
// Find the current raw value, by invoking the corresponding setter
|
||||||
Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod());
|
Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod());
|
||||||
boolean modified = true;
|
boolean modified = true;
|
||||||
|
@ -946,12 +946,12 @@ abstract class AbstractMakeModifiable {
|
||||||
mixin.markDirty();
|
mixin.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Method getGetterFromSetter(Method setter) {
|
private Method getGetterFromSetter(Method setter) {
|
||||||
String getterName = setter.getName().replaceFirst("set", "get");
|
String getterName = setter.getName().replaceFirst("set", "get");
|
||||||
try {
|
try {
|
||||||
return setter.getDeclaringClass().getMethod(getterName, (Class[]) null);
|
return setter.getDeclaringClass().getMethod(getterName, (Class[]) null);
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException ex) {
|
catch (NoSuchMethodException ex) {
|
||||||
// must be write only
|
// must be write only
|
||||||
return null;
|
return null;
|
||||||
|
@ -968,7 +968,7 @@ abstract class AbstractMakeModifiable {
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
class MakeITestBeanModifiable extends AbstractMakeModifiable {
|
class MakeITestBeanModifiable extends AbstractMakeModifiable {
|
||||||
|
|
||||||
@DeclareParents(value = "test.beans.ITestBean+",
|
@DeclareParents(value = "test.beans.ITestBean+",
|
||||||
defaultImpl=ModifiableImpl.class)
|
defaultImpl=ModifiableImpl.class)
|
||||||
public static MutableModifable mixin;
|
public static MutableModifable mixin;
|
||||||
|
@ -982,7 +982,7 @@ class MakeITestBeanModifiable extends AbstractMakeModifiable {
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable {
|
class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable {
|
||||||
|
|
||||||
@DeclareParents(value = "(@org.springframework.aop.aspectj.annotation.Measured *)",
|
@DeclareParents(value = "(@org.springframework.aop.aspectj.annotation.Measured *)",
|
||||||
// @DeclareParents(value = "(@Measured *)", // this would be a nice alternative...
|
// @DeclareParents(value = "(@Measured *)", // this would be a nice alternative...
|
||||||
defaultImpl=DefaultLockable.class)
|
defaultImpl=DefaultLockable.class)
|
||||||
|
@ -996,11 +996,11 @@ class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable {
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
class MakeLockable {
|
class MakeLockable {
|
||||||
|
|
||||||
@DeclareParents(value = "org.springframework..*",
|
@DeclareParents(value = "org.springframework..*",
|
||||||
defaultImpl=DefaultLockable.class)
|
defaultImpl=DefaultLockable.class)
|
||||||
public static Lockable mixin;
|
public static Lockable mixin;
|
||||||
|
|
||||||
@Before(value="execution(void set*(*)) && this(mixin)", argNames="mixin")
|
@Before(value="execution(void set*(*)) && this(mixin)", argNames="mixin")
|
||||||
public void checkNotLocked(
|
public void checkNotLocked(
|
||||||
Lockable mixin) // Bind to arg
|
Lockable mixin) // Bind to arg
|
||||||
|
@ -1043,9 +1043,9 @@ class CannotBeUnlocked implements Lockable, Comparable<Object> {
|
||||||
interface Modifiable {
|
interface Modifiable {
|
||||||
|
|
||||||
boolean isModified();
|
boolean isModified();
|
||||||
|
|
||||||
void acceptChanges();
|
void acceptChanges();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1057,14 +1057,14 @@ interface AnnotatedTarget {
|
||||||
|
|
||||||
@Measured
|
@Measured
|
||||||
class AnnotatedTargetImpl implements AnnotatedTarget {
|
class AnnotatedTargetImpl implements AnnotatedTarget {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@interface Measured {}
|
@interface Measured {}
|
||||||
|
|
||||||
class NotLockable {
|
class NotLockable {
|
||||||
|
|
||||||
private int intValue;
|
private int intValue;
|
||||||
|
|
||||||
public int getIntValue() {
|
public int getIntValue() {
|
||||||
|
@ -1097,5 +1097,5 @@ class PerThisAspect {
|
||||||
public void countSetter() {
|
public void countSetter() {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ArgumentBindingTests {
|
||||||
TestBean tb = new TestBean();
|
TestBean tb = new TestBean();
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||||
proxyFactory.addAspect(NamedPointcutWithArgs.class);
|
proxyFactory.addAspect(NamedPointcutWithArgs.class);
|
||||||
|
|
||||||
ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy();
|
ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy();
|
||||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public final class ArgumentBindingTests {
|
||||||
TransactionalBean tb = new TransactionalBean();
|
TransactionalBean tb = new TransactionalBean();
|
||||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||||
proxyFactory.addAspect(PointcutWithAnnotationArgument.class);
|
proxyFactory.addAspect(PointcutWithAnnotationArgument.class);
|
||||||
|
|
||||||
ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy();
|
ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy();
|
||||||
proxiedTestBean.doInTransaction(); // should throw
|
proxiedTestBean.doInTransaction(); // should throw
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,56 +29,56 @@ import test.beans.TestBean;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class AspectJPointcutAdvisorTests {
|
public final class AspectJPointcutAdvisorTests {
|
||||||
|
|
||||||
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
|
private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleton() throws SecurityException, NoSuchMethodException {
|
public void testSingleton() throws SecurityException, NoSuchMethodException {
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||||
|
|
||||||
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
|
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"),
|
new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"),
|
||||||
TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean");
|
TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean");
|
||||||
assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
|
assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
|
||||||
assertFalse(ajpa.isPerInstance());
|
assertFalse(ajpa.isPerInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerTarget() throws SecurityException, NoSuchMethodException {
|
public void testPerTarget() throws SecurityException, NoSuchMethodException {
|
||||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||||
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
|
||||||
|
|
||||||
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
|
InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp,
|
||||||
new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
|
new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean");
|
||||||
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
|
assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut());
|
||||||
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
|
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut);
|
||||||
assertTrue(ajpa.isPerInstance());
|
assertTrue(ajpa.isPerInstance());
|
||||||
|
|
||||||
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
|
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class));
|
||||||
assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
|
assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
|
||||||
TestBean.class.getMethod("getAge", (Class[]) null),
|
TestBean.class.getMethod("getAge", (Class[]) null),
|
||||||
TestBean.class));
|
TestBean.class));
|
||||||
|
|
||||||
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
|
assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(
|
||||||
TestBean.class.getMethod("getSpouse", (Class[]) null),
|
TestBean.class.getMethod("getSpouse", (Class[]) null),
|
||||||
TestBean.class));
|
TestBean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=AopConfigException.class)
|
@Test(expected=AopConfigException.class)
|
||||||
public void testPerCflowTarget() {
|
public void testPerCflowTarget() {
|
||||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
|
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=AopConfigException.class)
|
@Test(expected=AopConfigException.class)
|
||||||
public void testPerCflowBelowTarget() {
|
public void testPerCflowBelowTarget() {
|
||||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
|
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testIllegalInstantiationModel(Class<?> c) throws AopConfigException {
|
private void testIllegalInstantiationModel(Class<?> c) throws AopConfigException {
|
||||||
new AspectMetadata(c,"someBean");
|
new AspectMetadata(c,"someBean");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -37,7 +37,7 @@ public final class AspectMetadataTests {
|
||||||
public void testNotAnAspect() {
|
public void testNotAnAspect() {
|
||||||
new AspectMetadata(String.class,"someBean");
|
new AspectMetadata(String.class,"someBean");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingletonAspect() {
|
public void testSingletonAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean");
|
||||||
|
@ -45,7 +45,7 @@ public final class AspectMetadataTests {
|
||||||
assertSame(Pointcut.TRUE, am.getPerClausePointcut());
|
assertSame(Pointcut.TRUE, am.getPerClausePointcut());
|
||||||
assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind());
|
assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerTargetAspect() {
|
public void testPerTargetAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean");
|
||||||
|
@ -53,7 +53,7 @@ public final class AspectMetadataTests {
|
||||||
assertNotSame(Pointcut.TRUE, am.getPerClausePointcut());
|
assertNotSame(Pointcut.TRUE, am.getPerClausePointcut());
|
||||||
assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind());
|
assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerThisAspect() {
|
public void testPerThisAspect() {
|
||||||
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
|
AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean");
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.springframework.aop.aspectj.annotation;
|
package org.springframework.aop.aspectj.annotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for ReflectiveAtAspectJAdvisorFactory.
|
* Tests for ReflectiveAtAspectJAdvisorFactory.
|
||||||
* Tests are inherited: we only set the test fixture here.
|
* Tests are inherited: we only set the test fixture here.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
|
|
@ -42,9 +42,9 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||||
public final class AspectJPrecedenceComparatorTests {
|
public final class AspectJPrecedenceComparatorTests {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Specification for the comparator (as defined in the
|
* Specification for the comparator (as defined in the
|
||||||
* AspectJPrecedenceComparator class)
|
* AspectJPrecedenceComparator class)
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Orders AspectJ advice/advisors by invocation order.
|
* Orders AspectJ advice/advisors by invocation order.
|
||||||
* </p>
|
* </p>
|
||||||
|
|
|
@ -43,18 +43,18 @@ import test.parsing.CollectingReaderEventListener;
|
||||||
public final class AopNamespaceHandlerEventTests {
|
public final class AopNamespaceHandlerEventTests {
|
||||||
|
|
||||||
private static final Class<?> CLASS = AopNamespaceHandlerEventTests.class;
|
private static final Class<?> CLASS = AopNamespaceHandlerEventTests.class;
|
||||||
|
|
||||||
private static final Resource CONTEXT = qualifiedResource(CLASS, "context.xml");
|
private static final Resource CONTEXT = qualifiedResource(CLASS, "context.xml");
|
||||||
private static final Resource POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "pointcutEvents.xml");
|
private static final Resource POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "pointcutEvents.xml");
|
||||||
private static final Resource POINTCUT_REF_CONTEXT = qualifiedResource(CLASS, "pointcutRefEvents.xml");
|
private static final Resource POINTCUT_REF_CONTEXT = qualifiedResource(CLASS, "pointcutRefEvents.xml");
|
||||||
private static final Resource DIRECT_POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "directPointcutEvents.xml");
|
private static final Resource DIRECT_POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "directPointcutEvents.xml");
|
||||||
|
|
||||||
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||||
|
|
||||||
private XmlBeanDefinitionReader reader;
|
private XmlBeanDefinitionReader reader;
|
||||||
|
|
||||||
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class AopNamespaceHandlerPointcutErrorTests {
|
public final class AopNamespaceHandlerPointcutErrorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicatePointcutConfig() {
|
public void testDuplicatePointcutConfig() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the <aop:config/> element can be used as a top level element.
|
* Tests that the <aop:config/> element can be used as a top level element.
|
||||||
*
|
*
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class TopLevelAopTagTests {
|
public final class TopLevelAopTagTests {
|
||||||
|
|
||||||
private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml");
|
private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -35,7 +35,7 @@ import test.beans.TestBean;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class AopProxyUtilsTests {
|
public final class AopProxyUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteProxiedInterfacesWorksWithNull() {
|
public void testCompleteProxiedInterfacesWorksWithNull() {
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
|
@ -45,7 +45,7 @@ public final class AopProxyUtilsTests {
|
||||||
assertTrue(ifaces.contains(Advised.class));
|
assertTrue(ifaces.contains(Advised.class));
|
||||||
assertTrue(ifaces.contains(SpringProxy.class));
|
assertTrue(ifaces.contains(SpringProxy.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteProxiedInterfacesWorksWithNullOpaque() {
|
public void testCompleteProxiedInterfacesWorksWithNullOpaque() {
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
|
@ -53,7 +53,7 @@ public final class AopProxyUtilsTests {
|
||||||
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
||||||
assertEquals(1, completedInterfaces.length);
|
assertEquals(1, completedInterfaces.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteProxiedInterfacesAdvisedNotIncluded() {
|
public void testCompleteProxiedInterfacesAdvisedNotIncluded() {
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
|
@ -61,14 +61,14 @@ public final class AopProxyUtilsTests {
|
||||||
as.addInterface(Comparable.class);
|
as.addInterface(Comparable.class);
|
||||||
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
||||||
assertEquals(4, completedInterfaces.length);
|
assertEquals(4, completedInterfaces.length);
|
||||||
|
|
||||||
// Can't assume ordering for others, so use a list
|
// Can't assume ordering for others, so use a list
|
||||||
List<?> l = Arrays.asList(completedInterfaces);
|
List<?> l = Arrays.asList(completedInterfaces);
|
||||||
assertTrue(l.contains(Advised.class));
|
assertTrue(l.contains(Advised.class));
|
||||||
assertTrue(l.contains(ITestBean.class));
|
assertTrue(l.contains(ITestBean.class));
|
||||||
assertTrue(l.contains(Comparable.class));
|
assertTrue(l.contains(Comparable.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteProxiedInterfacesAdvisedIncluded() {
|
public void testCompleteProxiedInterfacesAdvisedIncluded() {
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
|
@ -77,14 +77,14 @@ public final class AopProxyUtilsTests {
|
||||||
as.addInterface(Advised.class);
|
as.addInterface(Advised.class);
|
||||||
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
||||||
assertEquals(4, completedInterfaces.length);
|
assertEquals(4, completedInterfaces.length);
|
||||||
|
|
||||||
// Can't assume ordering for others, so use a list
|
// Can't assume ordering for others, so use a list
|
||||||
List<?> l = Arrays.asList(completedInterfaces);
|
List<?> l = Arrays.asList(completedInterfaces);
|
||||||
assertTrue(l.contains(Advised.class));
|
assertTrue(l.contains(Advised.class));
|
||||||
assertTrue(l.contains(ITestBean.class));
|
assertTrue(l.contains(ITestBean.class));
|
||||||
assertTrue(l.contains(Comparable.class));
|
assertTrue(l.contains(Comparable.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompleteProxiedInterfacesAdvisedNotIncludedOpaque() {
|
public void testCompleteProxiedInterfacesAdvisedNotIncludedOpaque() {
|
||||||
AdvisedSupport as = new AdvisedSupport();
|
AdvisedSupport as = new AdvisedSupport();
|
||||||
|
@ -93,7 +93,7 @@ public final class AopProxyUtilsTests {
|
||||||
as.addInterface(Comparable.class);
|
as.addInterface(Comparable.class);
|
||||||
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
|
||||||
assertEquals(3, completedInterfaces.length);
|
assertEquals(3, completedInterfaces.length);
|
||||||
|
|
||||||
// Can't assume ordering for others, so use a list
|
// Can't assume ordering for others, so use a list
|
||||||
List<?> l = Arrays.asList(completedInterfaces);
|
List<?> l = Arrays.asList(completedInterfaces);
|
||||||
assertFalse(l.contains(Advised.class));
|
assertFalse(l.contains(Advised.class));
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -25,9 +25,9 @@ import test.beans.TestBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Benchmarks for introductions.
|
* Benchmarks for introductions.
|
||||||
*
|
*
|
||||||
* NOTE: No assertions!
|
* NOTE: No assertions!
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -34,7 +34,7 @@ import test.beans.TestBean;
|
||||||
* @since 14.03.2003
|
* @since 14.03.2003
|
||||||
*/
|
*/
|
||||||
public final class MethodInvocationTests {
|
public final class MethodInvocationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidInvocation() throws Throwable {
|
public void testValidInvocation() throws Throwable {
|
||||||
Method m = Object.class.getMethod("hashCode", (Class[]) null);
|
Method m = Object.class.getMethod("hashCode", (Class[]) null);
|
||||||
|
@ -52,7 +52,7 @@ public final class MethodInvocationTests {
|
||||||
Object rv = invocation.proceed();
|
Object rv = invocation.proceed();
|
||||||
assertTrue("correct response", rv == returnValue);
|
assertTrue("correct response", rv == returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toString on target can cause failure.
|
* toString on target can cause failure.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.springframework.core.io.Resource;
|
||||||
* @since 03.09.2004
|
* @since 03.09.2004
|
||||||
*/
|
*/
|
||||||
public final class PrototypeTargetTests {
|
public final class PrototypeTargetTests {
|
||||||
|
|
||||||
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml");
|
private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -64,7 +64,7 @@ public final class ProxyFactoryTests {
|
||||||
assertEquals(1, pf.indexOf(advisor));
|
assertEquals(1, pf.indexOf(advisor));
|
||||||
assertEquals(-1, advised.indexOf(new DefaultPointcutAdvisor(null)));
|
assertEquals(-1, advised.indexOf(new DefaultPointcutAdvisor(null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveAdvisorByReference() {
|
public void testRemoveAdvisorByReference() {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
@ -84,7 +84,7 @@ public final class ProxyFactoryTests {
|
||||||
assertEquals(2, nop.getCount());
|
assertEquals(2, nop.getCount());
|
||||||
assertFalse(pf.removeAdvisor(new DefaultPointcutAdvisor(null)));
|
assertFalse(pf.removeAdvisor(new DefaultPointcutAdvisor(null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveAdvisorByIndex() {
|
public void testRemoveAdvisorByIndex() {
|
||||||
TestBean target = new TestBean();
|
TestBean target = new TestBean();
|
||||||
|
@ -113,7 +113,7 @@ public final class ProxyFactoryTests {
|
||||||
assertEquals(1, cba.getCalls());
|
assertEquals(1, cba.getCalls());
|
||||||
assertEquals(2, nop.getCount());
|
assertEquals(2, nop.getCount());
|
||||||
assertEquals(3, nop2.getCount());
|
assertEquals(3, nop2.getCount());
|
||||||
|
|
||||||
// Check out of bounds
|
// Check out of bounds
|
||||||
try {
|
try {
|
||||||
pf.removeAdvisor(-1);
|
pf.removeAdvisor(-1);
|
||||||
|
@ -121,14 +121,14 @@ public final class ProxyFactoryTests {
|
||||||
catch (AopConfigException ex) {
|
catch (AopConfigException ex) {
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pf.removeAdvisor(2);
|
pf.removeAdvisor(2);
|
||||||
}
|
}
|
||||||
catch (AopConfigException ex) {
|
catch (AopConfigException ex) {
|
||||||
// Ok
|
// Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(5, proxied.getAge());
|
assertEquals(5, proxied.getAge());
|
||||||
assertEquals(4, nop2.getCount());
|
assertEquals(4, nop2.getCount());
|
||||||
}
|
}
|
||||||
|
@ -191,17 +191,17 @@ public final class ProxyFactoryTests {
|
||||||
assertEquals("Found correct number of interfaces", 3, factory.getProxiedInterfaces().length);
|
assertEquals("Found correct number of interfaces", 3, factory.getProxiedInterfaces().length);
|
||||||
ITestBean tb = (ITestBean) factory.getProxy();
|
ITestBean tb = (ITestBean) factory.getProxy();
|
||||||
assertThat("Picked up secondary interface", tb, instanceOf(IOther.class));
|
assertThat("Picked up secondary interface", tb, instanceOf(IOther.class));
|
||||||
|
|
||||||
raw.setAge(25);
|
raw.setAge(25);
|
||||||
assertTrue(tb.getAge() == raw.getAge());
|
assertTrue(tb.getAge() == raw.getAge());
|
||||||
|
|
||||||
long t = 555555L;
|
long t = 555555L;
|
||||||
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);
|
TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t);
|
||||||
|
|
||||||
Class<?>[] oldProxiedInterfaces = factory.getProxiedInterfaces();
|
Class<?>[] oldProxiedInterfaces = factory.getProxiedInterfaces();
|
||||||
|
|
||||||
factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class));
|
||||||
|
|
||||||
Class<?>[] newProxiedInterfaces = factory.getProxiedInterfaces();
|
Class<?>[] newProxiedInterfaces = factory.getProxiedInterfaces();
|
||||||
assertEquals("Advisor proxies one more interface after introduction", oldProxiedInterfaces.length + 1, newProxiedInterfaces.length);
|
assertEquals("Advisor proxies one more interface after introduction", oldProxiedInterfaces.length + 1, newProxiedInterfaces.length);
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public final class ProxyFactoryTests {
|
||||||
// Shouldn't fail;
|
// Shouldn't fail;
|
||||||
((IOther) ts).absquatulate();
|
((IOther) ts).absquatulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterceptorInclusionMethods() {
|
public void testInterceptorInclusionMethods() {
|
||||||
class MyInterceptor implements MethodInterceptor {
|
class MyInterceptor implements MethodInterceptor {
|
||||||
|
@ -218,7 +218,7 @@ public final class ProxyFactoryTests {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NopInterceptor di = new NopInterceptor();
|
NopInterceptor di = new NopInterceptor();
|
||||||
NopInterceptor diUnused = new NopInterceptor();
|
NopInterceptor diUnused = new NopInterceptor();
|
||||||
ProxyFactory factory = new ProxyFactory(new TestBean());
|
ProxyFactory factory = new ProxyFactory(new TestBean());
|
||||||
|
@ -228,7 +228,7 @@ public final class ProxyFactoryTests {
|
||||||
assertTrue(!factory.adviceIncluded(diUnused));
|
assertTrue(!factory.adviceIncluded(diUnused));
|
||||||
assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 1);
|
assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 1);
|
||||||
assertTrue(factory.countAdvicesOfType(MyInterceptor.class) == 0);
|
assertTrue(factory.countAdvicesOfType(MyInterceptor.class) == 0);
|
||||||
|
|
||||||
factory.addAdvice(0, diUnused);
|
factory.addAdvice(0, diUnused);
|
||||||
assertTrue(factory.adviceIncluded(diUnused));
|
assertTrue(factory.adviceIncluded(diUnused));
|
||||||
assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 2);
|
assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 2);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class DebugInterceptorTests {
|
||||||
@Test
|
@Test
|
||||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||||
Log log = createMock(Log.class);
|
Log log = createMock(Log.class);
|
||||||
|
|
||||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||||
|
|
||||||
expect(log.isTraceEnabled()).andReturn(true);
|
expect(log.isTraceEnabled()).andReturn(true);
|
||||||
|
@ -56,7 +56,7 @@ public final class DebugInterceptorTests {
|
||||||
@Test
|
@Test
|
||||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||||
Log log = createMock(Log.class);
|
Log log = createMock(Log.class);
|
||||||
|
|
||||||
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
MethodInvocation methodInvocation = createMock(MethodInvocation.class);
|
||||||
|
|
||||||
expect(log.isTraceEnabled()).andReturn(true);
|
expect(log.isTraceEnabled()).andReturn(true);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -30,20 +30,20 @@ import test.beans.TestBean;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class ExposeBeanNameAdvisorsTests {
|
public final class ExposeBeanNameAdvisorsTests {
|
||||||
|
|
||||||
private class RequiresBeanNameBoundTestBean extends TestBean {
|
private class RequiresBeanNameBoundTestBean extends TestBean {
|
||||||
private final String beanName;
|
private final String beanName;
|
||||||
|
|
||||||
public RequiresBeanNameBoundTestBean(String beanName) {
|
public RequiresBeanNameBoundTestBean(String beanName) {
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAge() {
|
public int getAge() {
|
||||||
assertEquals(beanName, ExposeBeanNameAdvisors.getBeanName());
|
assertEquals(beanName, ExposeBeanNameAdvisors.getBeanName());
|
||||||
return super.getAge();
|
return super.getAge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIntroduction() {
|
public void testNoIntroduction() {
|
||||||
String beanName = "foo";
|
String beanName = "foo";
|
||||||
|
@ -52,12 +52,12 @@ public final class ExposeBeanNameAdvisorsTests {
|
||||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||||
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
|
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
|
||||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||||
|
|
||||||
assertFalse("No introduction", proxy instanceof NamedBean);
|
assertFalse("No introduction", proxy instanceof NamedBean);
|
||||||
// Requires binding
|
// Requires binding
|
||||||
proxy.getAge();
|
proxy.getAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithIntroduction() {
|
public void testWithIntroduction() {
|
||||||
String beanName = "foo";
|
String beanName = "foo";
|
||||||
|
@ -66,11 +66,11 @@ public final class ExposeBeanNameAdvisorsTests {
|
||||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||||
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
|
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
|
||||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||||
|
|
||||||
assertTrue("Introduction was made", proxy instanceof NamedBean);
|
assertTrue("Introduction was made", proxy instanceof NamedBean);
|
||||||
// Requires binding
|
// Requires binding
|
||||||
proxy.getAge();
|
proxy.getAge();
|
||||||
|
|
||||||
NamedBean nb = (NamedBean) proxy;
|
NamedBean nb = (NamedBean) proxy;
|
||||||
assertEquals("Name returned correctly", beanName, nb.getBeanName());
|
assertEquals("Name returned correctly", beanName, nb.getBeanName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2008 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -29,12 +29,12 @@ import test.beans.TestBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-XML tests are in AbstractAopProxyTests
|
* Non-XML tests are in AbstractAopProxyTests
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class ExposeInvocationInterceptorTests {
|
public final class ExposeInvocationInterceptorTests {
|
||||||
|
|
||||||
private static final Resource CONTEXT =
|
private static final Resource CONTEXT =
|
||||||
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml");
|
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml");
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ abstract class ExposedInvocationTestBean extends TestBean {
|
||||||
assertions(invocation);
|
assertions(invocation);
|
||||||
super.absquatulate();
|
super.absquatulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void assertions(MethodInvocation invocation);
|
protected abstract void assertions(MethodInvocation invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ abstract class ExposedInvocationTestBean extends TestBean {
|
||||||
class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
|
class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
|
||||||
protected void assertions(MethodInvocation invocation) {
|
protected void assertions(MethodInvocation invocation) {
|
||||||
assertTrue(invocation.getThis() == this);
|
assertTrue(invocation.getThis() == this);
|
||||||
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
|
||||||
ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass()));
|
ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.springframework.core.io.Resource;
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class ScopedProxyAutowireTests {
|
public final class ScopedProxyAutowireTests {
|
||||||
|
|
||||||
private static final Class<?> CLASS = ScopedProxyAutowireTests.class;
|
private static final Class<?> CLASS = ScopedProxyAutowireTests.class;
|
||||||
|
|
||||||
private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireTrue.xml");
|
private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireTrue.xml");
|
||||||
private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireFalse.xml");
|
private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireFalse.xml");
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue