Restore *.aj whitespace

The removal of whitespace to the *.aj files made in 1762157 cause
NoSuchMethodError for code compiled against previous versions of
spring-aspects due to a bug in AspectJ (see SPR-10178 for details).

This commit reverts all the whitespace changes made in 1762157 which
resolves the NoSuchMethodErrors.

Issue: SPR-10178
This commit is contained in:
Rob Winch 2013-01-15 15:29:28 -06:00
parent e44b4b831e
commit 6888a6f286
13 changed files with 129 additions and 145 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.beans.factory.aspectj; package org.springframework.beans.factory.aspectj;
import org.aspectj.lang.annotation.SuppressAjWarnings; import org.aspectj.lang.annotation.SuppressAjWarnings;
@ -23,12 +23,12 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
* Abstract superaspect for AspectJ aspects that can perform Dependency * Abstract superaspect for AspectJ aspects that can perform Dependency
* Injection on objects, however they may be created. Define the beanCreation() * Injection on objects, however they may be created. Define the beanCreation()
* pointcut in subaspects. * pointcut in subaspects.
* *
* <p>Subaspects may also need a metadata resolution strategy, in the * <p>Subaspects may also need a metadata resolution strategy, in the
* {@code BeanWiringInfoResolver} interface. The default implementation * <code>BeanWiringInfoResolver</code> interface. The default implementation
* looks for a bean with the same name as the FQN. This is the default name * looks for a bean with the same name as the FQN. This is the default name
* of a bean in a Spring container if the id value is not supplied explicitly. * of a bean in a Spring container if the id value is not supplied explicitly.
* *
* @author Rob Harrop * @author Rob Harrop
* @author Rod Johnson * @author Rod Johnson
* @author Adrian Colyer * @author Adrian Colyer
@ -62,7 +62,7 @@ public abstract aspect AbstractBeanConfigurerAspect extends BeanConfigurerSuppor
/** /**
* The initialization of a new object. * The initialization of a new object.
* *
* <p>WARNING: Although this pointcut is non-abstract for backwards * <p>WARNING: Although this pointcut is non-abstract for backwards
* compatibility reasons, it is meant to be overridden to select * compatibility reasons, it is meant to be overridden to select
* initialization of any configurable bean. * initialization of any configurable bean.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.SuppressAjWarnings;
/** /**
* Abstract base aspect that can perform Dependency * Abstract base aspect that can perform Dependency
* Injection on objects, however they may be created. * Injection on objects, however they may be created.
* *
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @since 2.5.2 * @since 2.5.2
*/ */
@ -29,26 +29,26 @@ public abstract aspect AbstractDependencyInjectionAspect {
/** /**
* Select construction join points for objects to inject dependencies * Select construction join points for objects to inject dependencies
*/ */
public abstract pointcut beanConstruction(Object bean); public abstract pointcut beanConstruction(Object bean);
/** /**
* Select deserialization join points for objects to inject dependencies * Select deserialization join points for objects to inject dependencies
*/ */
public abstract pointcut beanDeserialization(Object bean); public abstract pointcut beanDeserialization(Object bean);
/** /**
* Select join points in a configurable bean * Select join points in a configurable bean
*/ */
public abstract pointcut inConfigurableBean(); public abstract pointcut inConfigurableBean();
/** /**
* Select join points in beans to be configured prior to construction? * Select join points in beans to be configured prior to construction?
* By default, use post-construction injection matching the default in the Configurable annotation. * By default, use post-construction injection matching the default in the Configurable annotation.
*/ */
public pointcut preConstructionConfiguration() : if(false); public pointcut preConstructionConfiguration() : if(false);
/** /**
* Select the most-specific initialization join point * Select the most-specific initialization join point
* (most concrete class) for the initialization of an instance. * (most concrete class) for the initialization of an instance.
*/ */
public pointcut mostSpecificSubTypeConstruction() : public pointcut mostSpecificSubTypeConstruction() :
@ -58,25 +58,25 @@ public abstract aspect AbstractDependencyInjectionAspect {
* Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection * Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection
*/ */
public abstract pointcut leastSpecificSuperTypeConstruction(); public abstract pointcut leastSpecificSuperTypeConstruction();
/** /**
* Configure the bean * Configure the bean
*/ */
public abstract void configureBean(Object bean); public abstract void configureBean(Object bean);
private pointcut preConstructionCondition() : private pointcut preConstructionCondition() :
leastSpecificSuperTypeConstruction() && preConstructionConfiguration(); leastSpecificSuperTypeConstruction() && preConstructionConfiguration();
private pointcut postConstructionCondition() : private pointcut postConstructionCondition() :
mostSpecificSubTypeConstruction() && !preConstructionConfiguration(); mostSpecificSubTypeConstruction() && !preConstructionConfiguration();
/** /**
* Pre-construction configuration. * Pre-construction configuration.
*/ */
@SuppressAjWarnings("adviceDidNotMatch") @SuppressAjWarnings("adviceDidNotMatch")
before(Object bean) : before(Object bean) :
beanConstruction(bean) && preConstructionCondition() && inConfigurableBean() { beanConstruction(bean) && preConstructionCondition() && inConfigurableBean() {
configureBean(bean); configureBean(bean);
} }
@ -84,18 +84,18 @@ public abstract aspect AbstractDependencyInjectionAspect {
* Post-construction configuration. * Post-construction configuration.
*/ */
@SuppressAjWarnings("adviceDidNotMatch") @SuppressAjWarnings("adviceDidNotMatch")
after(Object bean) returning : after(Object bean) returning :
beanConstruction(bean) && postConstructionCondition() && inConfigurableBean() { beanConstruction(bean) && postConstructionCondition() && inConfigurableBean() {
configureBean(bean); configureBean(bean);
} }
/** /**
* Post-deserialization configuration. * Post-deserialization configuration.
*/ */
@SuppressAjWarnings("adviceDidNotMatch") @SuppressAjWarnings("adviceDidNotMatch")
after(Object bean) returning : after(Object bean) returning :
beanDeserialization(bean) && inConfigurableBean() { beanDeserialization(bean) && inConfigurableBean() {
configureBean(bean); configureBean(bean);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,36 +26,36 @@ import java.io.Serializable;
* upon deserialization. Subaspects need to simply provide definition for the configureBean() method. This * upon deserialization. Subaspects need to simply provide definition for the configureBean() method. This
* method may be implemented without relying on Spring container if so desired. * method may be implemented without relying on Spring container if so desired.
* </p> * </p>
* <p> * <p>
* There are two cases that needs to be handled: * There are two cases that needs to be handled:
* <ol> * <ol>
* <li>Normal object creation via the '{@code new}' operator: this is * <li>Normal object creation via the '<code>new</code>' operator: this is
* taken care of by advising {@code initialization()} join points.</li> * taken care of by advising <code>initialization()</code> join points.</li>
* <li>Object creation through deserialization: since no constructor is * <li>Object creation through deserialization: since no constructor is
* invoked during deserialization, the aspect needs to advise a method that a * invoked during deserialization, the aspect needs to advise a method that a
* deserialization mechanism is going to invoke. Ideally, we should not * deserialization mechanism is going to invoke. Ideally, we should not
* require user classes to implement any specific method. This implies that * require user classes to implement any specific method. This implies that
* we need to <i>introduce</i> the chosen method. We should also handle the cases * we need to <i>introduce</i> the chosen method. We should also handle the cases
* where the chosen method is already implemented in classes (in which case, * where the chosen method is already implemented in classes (in which case,
* the user's implementation for that method should take precedence over the * the user's implementation for that method should take precedence over the
* introduced implementation). There are a few choices for the chosen method: * introduced implementation). There are a few choices for the chosen method:
* <ul> * <ul>
* <li>readObject(ObjectOutputStream): Java requires that the method must be * <li>readObject(ObjectOutputStream): Java requires that the method must be
* {@code private}. Since aspects cannot introduce a private member, * <code>private</p>. Since aspects cannot introduce a private member,
* while preserving its name, this option is ruled out.</li> * while preserving its name, this option is ruled out.</li>
* <li>readResolve(): Java doesn't pose any restriction on an access specifier. * <li>readResolve(): Java doesn't pose any restriction on an access specifier.
* Problem solved! There is one (minor) limitation of this approach in * Problem solved! There is one (minor) limitation of this approach in
* that if a user class already has this method, that method must be * that if a user class already has this method, that method must be
* {@code public}. However, this shouldn't be a big burden, since * <code>public</code>. However, this shouldn't be a big burden, since
* use cases that need classes to implement readResolve() (custom enums, * use cases that need classes to implement readResolve() (custom enums,
* for example) are unlikely to be marked as &#64;Configurable, and * for example) are unlikely to be marked as &#64;Configurable, and
* in any case asking to make that method {@code public} should not * in any case asking to make that method <code>public</code> should not
* pose any undue burden.</li> * pose any undue burden.</li>
* </ul> * </ul>
* The minor collaboration needed by user classes (i.e., that the * The minor collaboration needed by user classes (i.e., that the
* implementation of {@code readResolve()}, if any, must be * implementation of <code>readResolve()</code>, if any, must be
* {@code public}) can be lifted as well if we were to use an * <code>public</code>) can be lifted as well if we were to use an
* experimental feature in AspectJ - the {@code hasmethod()} PCD.</li> * experimental feature in AspectJ - the <code>hasmethod()</code> PCD.</li>
* </ol> * </ol>
* <p> * <p>
@ -63,7 +63,7 @@ import java.io.Serializable;
* is to use a 'declare parents' statement another aspect (a subaspect of this aspect would be a logical choice) * is to use a 'declare parents' statement another aspect (a subaspect of this aspect would be a logical choice)
* that declares the classes that need to be configured by supplying the {@link ConfigurableObject} interface. * that declares the classes that need to be configured by supplying the {@link ConfigurableObject} interface.
* </p> * </p>
* *
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @since 2.5.2 * @since 2.5.2
*/ */
@ -71,8 +71,8 @@ public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends
/** /**
* Select initialization join point as object construction * Select initialization join point as object construction
*/ */
public pointcut beanConstruction(Object bean) : public pointcut beanConstruction(Object bean) :
initialization(ConfigurableObject+.new(..)) && this(bean); initialization(ConfigurableObject+.new(..)) && this(bean);
/** /**
* Select deserialization join point made available through ITDs for ConfigurableDeserializationSupport * Select deserialization join point made available through ITDs for ConfigurableDeserializationSupport
@ -80,40 +80,40 @@ public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends
public pointcut beanDeserialization(Object bean) : public pointcut beanDeserialization(Object bean) :
execution(Object ConfigurableDeserializationSupport+.readResolve()) && execution(Object ConfigurableDeserializationSupport+.readResolve()) &&
this(bean); this(bean);
public pointcut leastSpecificSuperTypeConstruction() : initialization(ConfigurableObject.new(..)); public pointcut leastSpecificSuperTypeConstruction() : initialization(ConfigurableObject.new(..));
// Implementation to support re-injecting dependencies once an object is deserialized // Implementation to support re-injecting dependencies once an object is deserialized
/** /**
* Declare any class implementing Serializable and ConfigurableObject as also implementing * Declare any class implementing Serializable and ConfigurableObject as also implementing
* ConfigurableDeserializationSupport. This allows us to introduce the readResolve() * ConfigurableDeserializationSupport. This allows us to introduce the readResolve()
* method and select it with the beanDeserialization() pointcut. * method and select it with the beanDeserialization() pointcut.
* *
* <p>Here is an improved version that uses the hasmethod() pointcut and lifts * <p>Here is an improved version that uses the hasmethod() pointcut and lifts
* even the minor requirement on user classes: * even the minor requirement on user classes:
* *
* <pre class="code">declare parents: ConfigurableObject+ Serializable+ * <pre class="code">declare parents: ConfigurableObject+ Serializable+
* && !hasmethod(Object readResolve() throws ObjectStreamException) * && !hasmethod(Object readResolve() throws ObjectStreamException)
* implements ConfigurableDeserializationSupport; * implements ConfigurableDeserializationSupport;
* </pre> * </pre>
*/ */
declare parents: declare parents:
ConfigurableObject+ && Serializable+ implements ConfigurableDeserializationSupport; ConfigurableObject+ && Serializable+ implements ConfigurableDeserializationSupport;
/** /**
* A marker interface to which the {@code readResolve()} is introduced. * A marker interface to which the <code>readResolve()</code> is introduced.
*/ */
static interface ConfigurableDeserializationSupport extends Serializable { static interface ConfigurableDeserializationSupport extends Serializable {
} }
/** /**
* Introduce the {@code readResolve()} method so that we can advise its * Introduce the <code>readResolve()</code> method so that we can advise its
* execution to configure the object. * execution to configure the object.
* *
* <p>Note if a method with the same signature already exists in a * <p>Note if a method with the same signature already exists in a
* {@code Serializable} class of ConfigurableObject type, * <code>Serializable</code> class of ConfigurableObject type,
* that implementation will take precedence (a good thing, since we are * that implementation will take precedence (a good thing, since we are
* merely interested in an opportunity to detect deserialization.) * merely interested in an opportunity to detect deserialization.)
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
* annotation to identify which classes need autowiring. * annotation to identify which classes need autowiring.
* *
* <p>The bean name to look up will be taken from the * <p>The bean name to look up will be taken from the
* {@code &#64;Configurable} annotation if specified, otherwise the * <code>&#64;Configurable</code> annotation if specified, otherwise the
* default bean name to look up will be the FQN of the class being configured. * default bean name to look up will be the FQN of the class being configured.
* *
* @author Rod Johnson * @author Rod Johnson
@ -43,7 +43,7 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
* @see org.springframework.beans.factory.annotation.Configurable * @see org.springframework.beans.factory.annotation.Configurable
* @see org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver * @see org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver
*/ */
public aspect AnnotationBeanConfigurerAspect public aspect AnnotationBeanConfigurerAspect
extends AbstractInterfaceDrivenDependencyInjectionAspect extends AbstractInterfaceDrivenDependencyInjectionAspect
implements BeanFactoryAware, InitializingBean, DisposableBean { implements BeanFactoryAware, InitializingBean, DisposableBean {
@ -51,7 +51,7 @@ public aspect AnnotationBeanConfigurerAspect
public pointcut inConfigurableBean() : @this(Configurable); public pointcut inConfigurableBean() : @this(Configurable);
public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*); public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*);
declare parents: @Configurable * implements ConfigurableObject; declare parents: @Configurable * implements ConfigurableObject;
@ -80,10 +80,10 @@ public aspect AnnotationBeanConfigurerAspect
private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction()); private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction());
/* /*
* This declaration shouldn't be needed, * This declaration shouldn't be needed,
* except for an AspectJ bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=214559) * except for an AspectJ bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=214559)
*/ */
declare parents: @Configurable Serializable+ declare parents: @Configurable Serializable+
implements ConfigurableDeserializationSupport; implements ConfigurableDeserializationSupport;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,38 +17,38 @@ package org.springframework.beans.factory.aspectj;
/** /**
* Generic-based dependency injection aspect. * Generic-based dependency injection aspect.
* <p> * <p>
* This aspect allows users to implement efficient, type-safe dependency injection without * This aspect allows users to implement efficient, type-safe dependency injection without
* the use of the &#64;Configurable annotation. * the use of the &#64;Configurable annotation.
* *
* The subaspect of this aspect doesn't need to include any AOP constructs. * The subaspect of this aspect doesn't need to include any AOP constructs.
* For example, here is a subaspect that configures the {@code PricingStrategyClient} objects. * For example, here is a subaspect that configures the <code>PricingStrategyClient</code> objects.
* <pre> * <pre>
* aspect PricingStrategyDependencyInjectionAspect * aspect PricingStrategyDependencyInjectionAspect
* extends GenericInterfaceDrivenDependencyInjectionAspect<PricingStrategyClient> { * extends GenericInterfaceDrivenDependencyInjectionAspect<PricingStrategyClient> {
* private PricingStrategy pricingStrategy; * private PricingStrategy pricingStrategy;
* *
* public void configure(PricingStrategyClient bean) { * public void configure(PricingStrategyClient bean) {
* bean.setPricingStrategy(pricingStrategy); * bean.setPricingStrategy(pricingStrategy);
* }
*
* public void setPricingStrategy(PricingStrategy pricingStrategy) {
* this.pricingStrategy = pricingStrategy;
* } * }
*
* public void setPricingStrategy(PricingStrategy pricingStrategy) {
* this.pricingStrategy = pricingStrategy;
* }
* } * }
* </pre> * </pre>
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @since 3.0.0 * @since 3.0.0
*/ */
public abstract aspect GenericInterfaceDrivenDependencyInjectionAspect<I> extends AbstractInterfaceDrivenDependencyInjectionAspect { public abstract aspect GenericInterfaceDrivenDependencyInjectionAspect<I> extends AbstractInterfaceDrivenDependencyInjectionAspect {
declare parents: I implements ConfigurableObject; declare parents: I implements ConfigurableObject;
public pointcut inConfigurableBean() : within(I+); public pointcut inConfigurableBean() : within(I+);
public final void configureBean(Object bean) { public final void configureBean(Object bean) {
configure((I)bean); configure((I)bean);
} }
// Unfortunately, erasure used with generics won't allow to use the same named method // Unfortunately, erasure used with generics won't allow to use the same named method
protected abstract void configure(I bean); protected abstract void configure(I bean);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
} }
}; };
return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs()); return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
} }
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,9 +23,9 @@ import java.util.List;
/** /**
* Abstract aspect to enable mocking of methods picked out by a pointcut. * Abstract aspect to enable mocking of methods picked out by a pointcut.
* Sub-aspects must define the mockStaticsTestMethod() pointcut to * Sub-aspects must define the mockStaticsTestMethod() pointcut to
* indicate call stacks when mocking should be triggered, and the * indicate call stacks when mocking should be triggered, and the
* methodToMock() pointcut to pick out a method invocations to mock. * methodToMock() pointcut to pick out a method invocations to mock.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Ramnivas Laddad * @author Ramnivas Laddad
*/ */
@ -42,7 +42,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
// Represents a list of expected calls to static entity methods // Represents a list of expected calls to static entity methods
// Public to allow inserted code to access: is this normal?? // Public to allow inserted code to access: is this normal??
public class Expectations { public class Expectations {
// Represents an expected call to a static entity method // Represents an expected call to a static entity method
private class Call { private class Call {
private final String signature; private final String signature;
@ -50,21 +50,21 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
private Object responseObject; // return value or throwable private Object responseObject; // return value or throwable
private CallResponse responseType = CallResponse.nothing; private CallResponse responseType = CallResponse.nothing;
public Call(String name, Object[] args) { public Call(String name, Object[] args) {
this.signature = name; this.signature = name;
this.args = args; this.args = args;
} }
public boolean hasResponseSpecified() { public boolean hasResponseSpecified() {
return responseType != CallResponse.nothing; return responseType != CallResponse.nothing;
} }
public void setReturnVal(Object retVal) { public void setReturnVal(Object retVal) {
this.responseObject = retVal; this.responseObject = retVal;
responseType = CallResponse.return_; responseType = CallResponse.return_;
} }
public void setThrow(Throwable throwable) { public void setThrow(Throwable throwable) {
this.responseObject = throwable; this.responseObject = throwable;
responseType = CallResponse.throw_; responseType = CallResponse.throw_;
@ -89,7 +89,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
} }
} }
} }
private List<Call> calls = new LinkedList<Call>(); private List<Call> calls = new LinkedList<Call>();
// Calls already verified // Calls already verified
@ -101,12 +101,12 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
+ " calls, received " + verified); + " calls, received " + verified);
} }
} }
/** /**
* Validate the call and provide the expected return value * Validate the call and provide the expected return value
* @param lastSig * @param lastSig
* @param args * @param args
* @return the return value * @return
*/ */
public Object respond(String lastSig, Object[] args) { public Object respond(String lastSig, Object[] args) {
Call call = nextCall(); Call call = nextCall();
@ -114,7 +114,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
if (responseType == CallResponse.return_) { if (responseType == CallResponse.return_) {
return call.returnValue(lastSig, args); return call.returnValue(lastSig, args);
} else if(responseType == CallResponse.throw_) { } else if(responseType == CallResponse.throw_) {
return call.throwException(lastSig, args); return (RuntimeException)call.throwException(lastSig, args);
} else if(responseType == CallResponse.nothing) { } else if(responseType == CallResponse.nothing) {
// do nothing // do nothing
} }
@ -175,7 +175,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth
return expectations.respond(thisJoinPointStaticPart.toLongString(), thisJoinPoint.getArgs()); return expectations.respond(thisJoinPointStaticPart.toLongString(), thisJoinPoint.getArgs());
} }
} }
public void expectReturnInternal(Object retVal) { public void expectReturnInternal(Object retVal) {
if (!recording) { if (!recording) {
throw new IllegalStateException("Not recording: Cannot set return value"); throw new IllegalStateException("Not recording: Cannot set return value");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,16 +18,16 @@ package org.springframework.mock.staticmock;
/** /**
* Annotation-based aspect to use in test build to enable mocking static methods * Annotation-based aspect to use in test build to enable mocking static methods
* on JPA-annotated {@code @Entity} classes, as used by Roo for finders. * on JPA-annotated <code>@Entity</code> classes, as used by Roo for finders.
* *
* <p>Mocking will occur in the call stack of any method in a class (typically a test class) * <p>Mocking will occur in the call stack of any method in a class (typically a test class)
* that is annotated with the @MockStaticEntityMethods annotation. * that is annotated with the @MockStaticEntityMethods annotation.
* *
* <p>Also provides static methods to simplify the programming model for * <p>Also provides static methods to simplify the programming model for
* entering playback mode and setting expected return values. * entering playback mode and setting expected return values.
* *
* <p>Usage: * <p>Usage:
* <ol> * <ol>
* <li>Annotate a test class with @MockStaticEntityMethods. * <li>Annotate a test class with @MockStaticEntityMethods.
* <li>In each test method, AnnotationDrivenStaticEntityMockingControl will begin in recording mode. * <li>In each test method, AnnotationDrivenStaticEntityMockingControl will begin in recording mode.
* Invoke static methods on Entity classes, with each recording-mode invocation * Invoke static methods on Entity classes, with each recording-mode invocation
@ -37,20 +37,20 @@ package org.springframework.mock.staticmock;
* <li>Call the code you wish to test that uses the static methods. Verification will * <li>Call the code you wish to test that uses the static methods. Verification will
* occur automatically. * occur automatically.
* </ol> * </ol>
* *
* @author Rod Johnson * @author Rod Johnson
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @see MockStaticEntityMethods * @see MockStaticEntityMethods
*/ */
public aspect AnnotationDrivenStaticEntityMockingControl extends AbstractMethodMockingControl { public aspect AnnotationDrivenStaticEntityMockingControl extends AbstractMethodMockingControl {
/** /**
* Stop recording mock calls and enter playback state * Stop recording mock calls and enter playback state
*/ */
public static void playback() { public static void playback() {
AnnotationDrivenStaticEntityMockingControl.aspectOf().playbackInternal(); AnnotationDrivenStaticEntityMockingControl.aspectOf().playbackInternal();
} }
public static void expectReturn(Object retVal) { public static void expectReturn(Object retVal) {
AnnotationDrivenStaticEntityMockingControl.aspectOf().expectReturnInternal(retVal); AnnotationDrivenStaticEntityMockingControl.aspectOf().expectReturnInternal(retVal);
} }

View File

@ -1,19 +1,3 @@
/*
* Copyright 2002-2012 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.orm.jpa.aspectj; package org.springframework.orm.jpa.aspectj;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -25,14 +9,14 @@ import org.springframework.dao.DataAccessException;
import org.springframework.orm.jpa.EntityManagerFactoryUtils; import org.springframework.orm.jpa.EntityManagerFactoryUtils;
public aspect JpaExceptionTranslatorAspect { public aspect JpaExceptionTranslatorAspect {
pointcut entityManagerCall(): call(* EntityManager.*(..)) || call(* EntityManagerFactory.*(..)) || call(* EntityTransaction.*(..)) || call(* Query.*(..)); pointcut entityManagerCall(): call(* EntityManager.*(..)) || call(* EntityManagerFactory.*(..)) || call(* EntityTransaction.*(..)) || call(* Query.*(..));
after() throwing(RuntimeException re): entityManagerCall() { after() throwing(RuntimeException re): entityManagerCall() {
DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(re); DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(re);
if (dex != null) { if (dex != null) {
throw dex; throw dex;
} else { } else {
throw re; throw re;
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import org.springframework.core.task.AsyncTaskExecutor;
/** /**
* Abstract aspect that routes selected methods asynchronously. * Abstract aspect that routes selected methods asynchronously.
* *
* <p>This aspect needs to be injected with an implementation of * <p>This aspect needs to be injected with an implementation of
* {@link Executor} to activate it for a specific thread pool. * {@link Executor} to activate it for a specific thread pool.
* Otherwise it will simply delegate all calls synchronously. * Otherwise it will simply delegate all calls synchronously.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.springframework.transaction.interceptor.TransactionAttributeSource;
/** /**
* Abstract superaspect for AspectJ transaction aspects. Concrete * Abstract superaspect for AspectJ transaction aspects. Concrete
* subaspects will implement the {@code transactionalMethodExecution()} * subaspects will implement the <code>transactionalMethodExecution()</code>
* pointcut using a strategy such as Java 5 annotations. * pointcut using a strategy such as Java 5 annotations.
* *
* <p>Suitable for use inside or outside the Spring IoC container. * <p>Suitable for use inside or outside the Spring IoC container.
@ -66,7 +66,7 @@ public abstract aspect AbstractTransactionAspect extends TransactionAspectSuppor
@SuppressAjWarnings("adviceDidNotMatch") @SuppressAjWarnings("adviceDidNotMatch")
after(Object txObject) throwing(Throwable t) : transactionalMethodExecution(txObject) { after(Object txObject) throwing(Throwable t) : transactionalMethodExecution(txObject) {
try { try {
completeTransactionAfterThrowing(TransactionAspectSupport.currentTransactionInfo(), t); completeTransactionAfterThrowing(TransactionAspectSupport.currentTransactionInfo(), t);
} }
catch (Throwable t2) { catch (Throwable t2) {
logger.error("Failed to close transaction after throwing in a transactional method", t2); logger.error("Failed to close transaction after throwing in a transactional method", t2);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2013 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,17 +21,17 @@ import org.springframework.transaction.annotation.Transactional;
/** /**
* Concrete AspectJ transaction aspect using Spring's @Transactional annotation. * Concrete AspectJ transaction aspect using Spring's @Transactional annotation.
* *
* <p>When using this aspect, you <i>must</i> annotate the implementation class * <p>When using this aspect, you <i>must</i> annotate the implementation class
* (and/or methods within that class), <i>not</i> the interface (if any) that * (and/or methods within that class), <i>not</i> the interface (if any) that
* the class implements. AspectJ follows Java's rule that annotations on * the class implements. AspectJ follows Java's rule that annotations on
* interfaces are <i>not</i> inherited. * interfaces are <i>not</i> inherited.
* *
* <p>An @Transactional annotation on a class specifies the default transaction * <p>An @Transactional annotation on a class specifies the default transaction
* semantics for the execution of any <b>public</b> operation in the class. * semantics for the execution of any <b>public</b> operation in the class.
* *
* <p>An @Transactional annotation on a method within the class overrides the * <p>An @Transactional annotation on a method within the class overrides the
* default transaction semantics given by the class annotation (if present). * default transaction semantics given by the class annotation (if present).
* Any method may be annotated (regardless of visibility). * Any method may be annotated (regardless of visibility).
* Annotating non-public methods directly is the only way * Annotating non-public methods directly is the only way
* to get transaction demarcation for the execution of such operations. * to get transaction demarcation for the execution of such operations.
@ -57,7 +57,7 @@ public aspect AnnotationTransactionAspect extends AbstractTransactionAspect {
execution(public * ((@Transactional *)+).*(..)) && within(@Transactional *); execution(public * ((@Transactional *)+).*(..)) && within(@Transactional *);
/** /**
* Matches the execution of any method with the * Matches the execution of any method with the
* Transactional annotation. * Transactional annotation.
*/ */
private pointcut executionOfTransactionalMethod() : private pointcut executionOfTransactionalMethod() :
@ -66,7 +66,7 @@ public aspect AnnotationTransactionAspect extends AbstractTransactionAspect {
/** /**
* Definition of pointcut from super aspect - matched join points * Definition of pointcut from super aspect - matched join points
* will have Spring transaction management applied. * will have Spring transaction management applied.
*/ */
protected pointcut transactionalMethodExecution(Object txObject) : protected pointcut transactionalMethodExecution(Object txObject) :
(executionOfAnyPublicMethodInAtTransactionalType() (executionOfAnyPublicMethodInAtTransactionalType()
|| executionOfTransactionalMethod() ) || executionOfTransactionalMethod() )