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