Merge branch 'cleanup-master' into master

* cleanup-master: (36 commits)
  Update Apache license headers for affected sources
  Add @Override annotations to main sources
  Update main source and target JDK compatibility
  Update Apache license headers for affected sources
  Ignore performance-sensitive tests by default
  Introduce 'spring-build-junit' subproject
  Replace EasyMock with Mockito in test sources
  Add @Override annotations to test sources
  Update test source and target JDK compatibility
  Update -Xlint compiler warning output
  Fix various compiler warnings in spring-context
  Fix "unnecessary @SuppressWarnings" warnings
  Fix [rawtypes] compiler warnings
  Fix [dep-ann] warnings with @Deprecated
  Fix [cast] compiler warnings
  Fix [serial] compiler warnings
  Fix [varargs] compiler warnings
  Fix warnings due to unused import statements
  Replace <code> with {@code} throughout Javadoc
  Fix various Javadoc warnings
  ...
This commit is contained in:
Chris Beams
2012-12-28 23:58:15 +01:00
3822 changed files with 35913 additions and 29288 deletions

6
.gitignore vendored
View File

@@ -10,7 +10,7 @@ integration-repo
ivy-cache ivy-cache
jxl.log jxl.log
jmx.log jmx.log
spring-jdbc/derby.log derby.log
spring-test/test-output/ spring-test/test-output/
.gradle .gradle
build build
@@ -19,8 +19,10 @@ build
argfile* argfile*
pom.xml pom.xml
# IDEA metadata and output dirs # IDEA artifacts and output dirs
*.iml *.iml
*.ipr *.ipr
*.iws *.iws
out out
test-output
atlassian-ide-plugin.xml

View File

@@ -47,17 +47,13 @@ future pull requests as well, simply so the Spring Framework team knows
immediately that this process is complete. immediately that this process is complete.
## Create your branch from `master` ## Create your branch from `3.2.x`
At any given time, Spring Framework's `master` branch represents the version If your pull request addresses a bug or improvement, please create your branch
currently under development. For example, if 3.1.1 was the latest Spring Spring Framework's `3.2.x` branch. `master` is reserved for work on new features
Framework release, `master` represents 3.2.0 development, and the `3.1.x` for the next major version of the framework. Rest assured that if your pull
branch represents 3.1.2 development. request is accepted and merged into `3.2.x`, these changes will also eventually
be merged into `master`.
Create your topic branch to be submitted as a pull request from `master`. The
Spring team will consider your pull request for backporting to maintenance
versions (e.g. 3.1.2) on a case-by-case basis; you don't need to worry about
submitting anything for backporting.
## Use short branch names ## Use short branch names

View File

@@ -16,6 +16,14 @@ configure(allprojects) {
ext.slf4jVersion = "1.6.1" ext.slf4jVersion = "1.6.1"
ext.gradleScriptDir = "${rootProject.projectDir}/gradle" ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
if (rootProject.hasProperty("VERSION_QUALIFIER")) {
def qualifier = rootProject.getProperty("VERSION_QUALIFIER")
if (qualifier.startsWith("SPR-")) { // topic branch, e.g. SPR-1234
// replace 3.2.0.BUILD-SNAPSHOT for 3.2.0.SPR-1234-SNAPSHOT
version = version.replace('BUILD', qualifier)
}
}
apply plugin: "propdeps" apply plugin: "propdeps"
apply plugin: "java" apply plugin: "java"
apply plugin: "propdeps-eclipse" apply plugin: "propdeps-eclipse"
@@ -24,10 +32,35 @@ configure(allprojects) {
group = "org.springframework" group = "org.springframework"
sourceCompatibility=1.5 compileJava {
targetCompatibility=1.5 sourceCompatibility=1.6
targetCompatibility=1.6
}
compileTestJava {
sourceCompatibility=1.7
targetCompatibility=1.7
}
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:none"] [compileJava, compileTestJava]*.options*.compilerArgs = [
"-Xlint:serial",
"-Xlint:varargs",
"-Xlint:cast",
"-Xlint:classfile",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
"-Xlint:finally",
"-Xlint:overrides",
"-Xlint:path",
"-Xlint:processing",
"-Xlint:static",
"-Xlint:try",
"-Xlint:-options", // intentionally disabled
"-Xlint:-fallthrough", // intentionally disabled
"-Xlint:-rawtypes", // TODO enable and fix warnings
"-Xlint:-deprecation", // TODO enable and fix warnings
"-Xlint:-unchecked" // TODO enable and fix warnings
]
sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"] sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"]
@@ -41,7 +74,7 @@ configure(allprojects) {
dependencies { dependencies {
testCompile("junit:junit:${junitVersion}") testCompile("junit:junit:${junitVersion}")
testCompile("org.hamcrest:hamcrest-all:1.3") testCompile("org.hamcrest:hamcrest-all:1.3")
testCompile("org.easymock:easymock:${easymockVersion}") testCompile("org.mockito:mockito-core:1.9.5")
} }
ext.javadocLinks = [ ext.javadocLinks = [
@@ -67,7 +100,17 @@ configure(allprojects) {
] as String[] ] as String[]
} }
configure(subprojects) { subproject -> configure(allprojects.findAll{it.name in ["spring", "spring-jms", "spring-orm",
"spring-orm-hibernate4", "spring-oxm", "spring-struts", "spring-test",
"spring-test-mvc", "spring-tx", "spring-web", "spring-webmvc",
"spring-webmvc-portlet", "spring-webmvc-tiles3"]}) {
dependencies {
testCompile("org.easymock:easymock:${easymockVersion}")
testCompile "org.easymock:easymockclassextension:${easymockVersion}"
}
}
configure(subprojects - project(":spring-build-junit")) { subproject ->
apply plugin: "merge" apply plugin: "merge"
apply from: "${gradleScriptDir}/publish-maven.gradle" apply from: "${gradleScriptDir}/publish-maven.gradle"
@@ -116,6 +159,34 @@ configure(subprojects) { subproject ->
} }
} }
configure(allprojects - project(":spring-build-junit")) {
dependencies {
testCompile(project(":spring-build-junit"))
}
eclipse.classpath.file.whenMerged { classpath ->
classpath.entries.find{it.path == "/spring-build-junit"}.exported = false
}
test.systemProperties.put("testGroups", properties.get("testGroups"))
}
project("spring-build-junit") {
description = "Build-time JUnit dependencies and utilities"
// NOTE: This is an internal project and is not published.
dependencies {
compile("commons-logging:commons-logging:1.1.1")
compile("junit:junit:${junitVersion}")
compile("org.hamcrest:hamcrest-all:1.3")
compile("org.easymock:easymock:${easymockVersion}")
}
// Don't actually generate any artifacts
configurations.archives.artifacts.clear()
}
project("spring-core") { project("spring-core") {
description = "Spring Core" description = "Spring Core"
@@ -297,7 +368,6 @@ project("spring-tx") {
optional("javax.resource:connector-api:1.5") optional("javax.resource:connector-api:1.5")
optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1") optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1")
optional("javax.ejb:ejb-api:3.0") optional("javax.ejb:ejb-api:3.0")
testCompile "org.easymock:easymockclassextension:${easymockVersion}"
testCompile("javax.persistence:persistence-api:1.0") testCompile("javax.persistence:persistence-api:1.0")
testCompile("org.aspectj:aspectjweaver:${aspectjVersion}") testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
} }
@@ -306,6 +376,14 @@ project("spring-tx") {
project("spring-oxm") { project("spring-oxm") {
description = "Spring Object/XML Marshalling" description = "Spring Object/XML Marshalling"
apply from: "oxm.gradle" apply from: "oxm.gradle"
compileTestJava {
// necessary to avoid java.lang.VerifyError on jibx compilation
// see http://jira.codehaus.org/browse/JIBX-465
sourceCompatibility=1.6
targetCompatibility=1.6
}
dependencies { dependencies {
compile(project(":spring-beans")) compile(project(":spring-beans"))
compile(project(":spring-core")) compile(project(":spring-core"))
@@ -335,10 +413,11 @@ project("spring-jms") {
compile(project(":spring-tx")) compile(project(":spring-tx"))
optional(project(":spring-oxm")) optional(project(":spring-oxm"))
compile("aopalliance:aopalliance:1.0") compile("aopalliance:aopalliance:1.0")
optional("org.codehaus.jackson:jackson-mapper-asl:1.4.2")
provided("org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1") provided("org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1")
optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1") optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1")
optional("javax.resource:connector-api:1.5") optional("javax.resource:connector-api:1.5")
optional("org.codehaus.jackson:jackson-mapper-asl:1.4.2")
optional("com.fasterxml.jackson.core:jackson-databind:2.0.1")
} }
} }
@@ -430,6 +509,14 @@ project("spring-web") {
project("spring-orm") { project("spring-orm") {
description = "Spring Object/Relational Mapping" description = "Spring Object/Relational Mapping"
compileTestJava {
// necessary to avoid java.lang.VerifyError on toplink compilation
// TODO: remove this block when we remove toplink
sourceCompatibility=1.6
targetCompatibility=1.6
}
dependencies { dependencies {
compile("aopalliance:aopalliance:1.0") compile("aopalliance:aopalliance:1.0")
optional("org.hibernate:hibernate-core:3.3.2.GA") optional("org.hibernate:hibernate-core:3.3.2.GA")
@@ -628,7 +715,6 @@ project("spring-test-mvc") {
testCompile("javax.activation:activation:1.1") testCompile("javax.activation:activation:1.1")
testCompile("javax.mail:mail:1.4") testCompile("javax.mail:mail:1.4")
testCompile("javax.xml.bind:jaxb-api:2.2.6") testCompile("javax.xml.bind:jaxb-api:2.2.6")
testCompile("org.easymock:easymockclassextension:${easymockVersion}")
testCompile("org.apache.tiles:tiles-request-api:1.0.1") testCompile("org.apache.tiles:tiles-request-api:1.0.1")
testCompile("org.apache.tiles:tiles-api:3.0.1") testCompile("org.apache.tiles:tiles-api:3.0.1")
testCompile("org.apache.tiles:tiles-core:3.0.1") { testCompile("org.apache.tiles:tiles-core:3.0.1") {

View File

@@ -1,6 +1,6 @@
/** /**
* This class is used only as a "null" argument for Javadoc when comparing * This class is used only as a "null" argument for Javadoc when comparing
* two API files. Javadoc has to have a package, .java or .class file as an * two API files. Javadoc has to have a package, .java or .class file as an
* argument, even though JDiff doesn't use it. * argument, even though JDiff doesn't use it.
*/ */
public class Null { public class Null {

View File

@@ -1,10 +1,10 @@
The following has been tested against Intellij IDEA 11.0.1 The following has been tested against Intellij IDEA 12.0
## Steps ## Steps
_Within your locally cloned spring-framework working directory:_ _Within your locally cloned spring-framework working directory:_
1. Generate IDEA metadata with `./gradlew cleanIdea idea` 1. Generate IDEA metadata with `./gradlew :spring-oxm:compileTestJava cleanIdea idea`
2. Import into IDEA as usual 2. Import into IDEA as usual
3. Set the Project JDK as appropriate 3. Set the Project JDK as appropriate
4. Add git support 4. Add git support
@@ -12,21 +12,21 @@ _Within your locally cloned spring-framework working directory:_
## Known issues ## Known issues
1. MockServletContext and friends will fail to compile in spring-web. To fix this, uncheck the 'export' setting for all servlet-api and tomcat-servlet-api jars. The problem is that spring-web needs Servlet 2.5, but it's picking up Servlet 3.0 from projects that it depends on. 1. `spring-aspects` does not compile out of the box due to references to aspect types unknown to IDEA.
2. spring-context will fail to build because there's a duplicate instance of GroovyMessenger in spring-context/src/test/java/org/springframework/scripting/groovy/Messenger.groovy. The solution to this is not known. It's not a problem on Eclipse, because Eclipse doesn't automatically compile .groovy files like IDEA (apparently) does. See http://youtrack.jetbrains.com/issue/IDEA-64446 for details. In the meantime, you may want to
exclude `spring-aspects` from the overall project to avoid compilation errors.
There are no other known problems at this time. Please add to this list, and if you're ambitious, consider playing with the Gradle IDEA generation DSL to fix these problems automatically, e.g.: 2. While all JUnit tests pass from the command line with Gradle, many will fail when run from IDEA.
Resolving this is a work in progress. If attempting to run all JUnit tests from within IDEA, you will
* http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaProject.html likely need to set the following VM options to avoid out of memory errors:
* http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html -XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m
* http://gradle.org/docs/current/groovydoc/org/gradle/plugins/ide/idea/model/IdeaModule.html
## Tips ## Tips
In any case, please do not check in your own generated .iml, .ipr, or .iws files. You'll notice these files are already intentionally in .gitignore. The same policy goes for eclipse metadata. In any case, please do not check in your own generated .iml, .ipr, or .iws files.
You'll notice these files are already intentionally in .gitignore. The same policy goes for eclipse metadata.
## FAQ ## FAQ
Q. What about IDEA's own [Gradle support](http://confluence.jetbrains.net/display/IDEADEV/Gradle+integration)? Q. What about IDEA's own [Gradle support](http://confluence.jetbrains.net/display/IDEADEV/Gradle+integration)?
A. Unknown. Please report back if you try it and it goes well for you. A. Keep an eye on http://youtrack.jetbrains.com/issue/IDEA-53476

View File

@@ -22,3 +22,4 @@ include "spring-web"
include "spring-webmvc" include "spring-webmvc"
include "spring-webmvc-portlet" include "spring-webmvc-portlet"
include "spring-webmvc-tiles3" include "spring-webmvc-tiles3"
include "spring-build-junit"

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,14 +18,14 @@ package org.springframework.aop;
import org.aopalliance.aop.Advice; import org.aopalliance.aop.Advice;
/** /**
* Base interface holding AOP <b>advice</b> (action to take at a joinpoint) * Base interface holding AOP <b>advice</b> (action to take at a joinpoint)
* and a filter determining the applicability of the advice (such as * and a filter determining the applicability of the advice (such as
* a pointcut). <i>This interface is not for use by Spring users, but to * a pointcut). <i>This interface is not for use by Spring users, but to
* allow for commonality in support for different types of advice.</i> * allow for commonality in support for different types of advice.</i>
* *
* <p>Spring AOP is based around <b>around advice</b> delivered via method * <p>Spring AOP is based around <b>around advice</b> delivered via method
* <b>interception</b>, compliant with the AOP Alliance interception API. * <b>interception</b>, compliant with the AOP Alliance interception API.
* The Advisor interface allows support for different types of advice, * The Advisor interface allows support for different types of advice,
* such as <b>before</b> and <b>after</b> advice, which need not be * such as <b>before</b> and <b>after</b> advice, which need not be
* implemented using interception. * implemented using interception.
@@ -50,7 +50,7 @@ public interface Advisor {
* (for example, creating a mixin) or shared with all instances of * (for example, creating a mixin) or shared with all instances of
* the advised class obtained from the same Spring bean factory. * the advised class obtained from the same Spring bean factory.
* <p><b>Note that this method is not currently used by the framework.</b> * <p><b>Note that this method is not currently used by the framework.</b>
* Typical Advisor implementations always return <code>true</code>. * Typical Advisor implementations always return {@code true}.
* Use singleton/prototype bean definitions or appropriate programmatic * Use singleton/prototype bean definitions or appropriate programmatic
* proxy creation to ensure that Advisors have the correct lifecycle model. * proxy creation to ensure that Advisors have the correct lifecycle model.
* @return whether this advice is associated with a particular target instance * @return whether this advice is associated with a particular target instance

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -33,7 +33,7 @@ public interface AfterReturningAdvice extends AfterAdvice {
* @param returnValue the value returned by the method, if any * @param returnValue the value returned by the method, if any
* @param method method being invoked * @param method method being invoked
* @param args arguments to the method * @param args arguments to the method
* @param target target of the method invocation. May be <code>null</code>. * @param target target of the method invocation. May be {@code null}.
* @throws Throwable if this object wishes to abort the call. * @throws Throwable if this object wishes to abort the call.
* Any exception thrown will be returned to the caller if it's * Any exception thrown will be returned to the caller if it's
* allowed by the method signature. Otherwise the exception * allowed by the method signature. Otherwise the exception

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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,6 +25,7 @@ import org.springframework.core.NestedRuntimeException;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public class AopInvocationException extends NestedRuntimeException { public class AopInvocationException extends NestedRuntimeException {
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,7 +18,7 @@ package org.springframework.aop;
import org.aopalliance.aop.Advice; import org.aopalliance.aop.Advice;
/** /**
* Subinterface of AOP Alliance Advice that allows additional interfaces * Subinterface of AOP Alliance Advice that allows additional interfaces
* to be implemented by an Advice, and available via a proxy using that * to be implemented by an Advice, and available via a proxy using that
* interceptor. This is a fundamental AOP concept called <b>introduction</b>. * interceptor. This is a fundamental AOP concept called <b>introduction</b>.
@@ -37,7 +37,7 @@ import org.aopalliance.aop.Advice;
* @see IntroductionAdvisor * @see IntroductionAdvisor
*/ */
public interface DynamicIntroductionAdvice extends Advice { public interface DynamicIntroductionAdvice extends Advice {
/** /**
* Does this introduction advice implement the given interface? * Does this introduction advice implement the given interface?
* @param intf the interface to check * @param intf the interface to check

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -30,7 +30,7 @@ package org.springframework.aop;
* @see IntroductionInterceptor * @see IntroductionInterceptor
*/ */
public interface IntroductionAdvisor extends Advisor, IntroductionInfo { public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
/** /**
* Return the filter determining which target classes this introduction * Return the filter determining which target classes this introduction
* should apply to. * should apply to.
@@ -39,7 +39,7 @@ public interface IntroductionAdvisor extends Advisor, IntroductionInfo {
* @return the class filter * @return the class filter
*/ */
ClassFilter getClassFilter(); ClassFilter getClassFilter();
/** /**
* Can the advised interfaces be implemented by the introduction advice? * Can the advised interfaces be implemented by the introduction advice?
* Invoked before adding an IntroductionAdvisor. * Invoked before adding an IntroductionAdvisor.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -33,10 +33,10 @@ public interface IntroductionAwareMethodMatcher extends MethodMatcher {
* instead of the 2-arg {@link #matches(java.lang.reflect.Method, Class)} method * instead of the 2-arg {@link #matches(java.lang.reflect.Method, Class)} method
* if the caller supports the extended IntroductionAwareMethodMatcher interface. * if the caller supports the extended IntroductionAwareMethodMatcher interface.
* @param method the candidate method * @param method the candidate method
* @param targetClass the target class (may be <code>null</code>, in which case * @param targetClass the target class (may be {@code null}, in which case
* the candidate class must be taken to be the method's declaring class) * the candidate class must be taken to be the method's declaring class)
* @param hasIntroductions <code>true</code> if the object on whose behalf we are * @param hasIntroductions {@code true} if the object on whose behalf we are
* asking is the subject on one or more introductions; <code>false</code> otherwise * asking is the subject on one or more introductions; {@code false} otherwise
* @return whether or not this method matches statically * @return whether or not this method matches statically
*/ */
boolean matches(Method method, Class targetClass, boolean hasIntroductions); boolean matches(Method method, Class targetClass, boolean hasIntroductions);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -29,7 +29,7 @@ package org.springframework.aop;
* @since 1.1.1 * @since 1.1.1
*/ */
public interface IntroductionInfo { public interface IntroductionInfo {
/** /**
* Return the additional interfaces introduced by this Advisor or Advice. * Return the additional interfaces introduced by this Advisor or Advice.
* @return the introduced interfaces * @return the introduced interfaces

View File

@@ -1,12 +1,12 @@
/* /*
* Copyright 2002-2005 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,12 +28,12 @@ import java.lang.reflect.Method;
* @author Rod Johnson * @author Rod Johnson
*/ */
public interface MethodBeforeAdvice extends BeforeAdvice { public interface MethodBeforeAdvice extends BeforeAdvice {
/** /**
* Callback before a given method is invoked. * Callback before a given method is invoked.
* @param method method being invoked * @param method method being invoked
* @param args arguments to the method * @param args arguments to the method
* @param target target of the method invocation. May be <code>null</code>. * @param target target of the method invocation. May be {@code null}.
* @throws Throwable if this object wishes to abort the call. * @throws Throwable if this object wishes to abort the call.
* Any exception thrown will be returned to the caller if it's * Any exception thrown will be returned to the caller if it's
* allowed by the method signature. Otherwise the exception * allowed by the method signature. Otherwise the exception

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,15 +26,15 @@ import java.lang.reflect.Method;
* also makes arguments for a particular call available, and any effects of running * also makes arguments for a particular call available, and any effects of running
* previous advice applying to the joinpoint. * previous advice applying to the joinpoint.
* *
* <p>If an implementation returns <code>false</code> from its {@link #isRuntime()} * <p>If an implementation returns {@code false} from its {@link #isRuntime()}
* method, evaluation can be performed statically, and the result will be the same * method, evaluation can be performed statically, and the result will be the same
* for all invocations of this method, whatever their arguments. This means that * for all invocations of this method, whatever their arguments. This means that
* if the {@link #isRuntime()} method returns <code>false</code>, the 3-arg * if the {@link #isRuntime()} method returns {@code false}, the 3-arg
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method will never be invoked. * {@link #matches(java.lang.reflect.Method, Class, Object[])} method will never be invoked.
* *
* <p>If an implementation returns <code>true</code> from its 2-arg * <p>If an implementation returns {@code true} from its 2-arg
* {@link #matches(java.lang.reflect.Method, Class)} method and its {@link #isRuntime()} method * {@link #matches(java.lang.reflect.Method, Class)} method and its {@link #isRuntime()} method
* returns <code>true</code>, the 3-arg {@link #matches(java.lang.reflect.Method, Class, Object[])} * returns {@code true}, the 3-arg {@link #matches(java.lang.reflect.Method, Class, Object[])}
* method will be invoked <i>immediately before each potential execution of the related advice</i>, * method will be invoked <i>immediately before each potential execution of the related advice</i>,
* to decide whether the advice should run. All previous advice, such as earlier interceptors * to decide whether the advice should run. All previous advice, such as earlier interceptors
* in an interceptor chain, will have run, so any state changes they have produced in * in an interceptor chain, will have run, so any state changes they have produced in
@@ -49,11 +49,11 @@ public interface MethodMatcher {
/** /**
* Perform static checking whether the given method matches. If this * Perform static checking whether the given method matches. If this
* returns <code>false</code> or if the {@link #isRuntime()} method * returns {@code false} or if the {@link #isRuntime()} method
* returns <code>false</code>, no runtime check (i.e. no. * returns {@code false}, no runtime check (i.e. no.
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call) will be made. * {@link #matches(java.lang.reflect.Method, Class, Object[])} call) will be made.
* @param method the candidate method * @param method the candidate method
* @param targetClass the target class (may be <code>null</code>, in which case * @param targetClass the target class (may be {@code null}, in which case
* the candidate class must be taken to be the method's declaring class) * the candidate class must be taken to be the method's declaring class)
* @return whether or not this method matches statically * @return whether or not this method matches statically
*/ */
@@ -62,7 +62,7 @@ public interface MethodMatcher {
/** /**
* Is this MethodMatcher dynamic, that is, must a final call be made on the * Is this MethodMatcher dynamic, that is, must a final call be made on the
* {@link #matches(java.lang.reflect.Method, Class, Object[])} method at * {@link #matches(java.lang.reflect.Method, Class, Object[])} method at
* runtime even if the 2-arg matches method returns <code>true</code>? * runtime even if the 2-arg matches method returns {@code true}?
* <p>Can be invoked when an AOP proxy is created, and need not be invoked * <p>Can be invoked when an AOP proxy is created, and need not be invoked
* again before each method invocation, * again before each method invocation,
* @return whether or not a runtime match via the 3-arg * @return whether or not a runtime match via the 3-arg
@@ -75,12 +75,12 @@ public interface MethodMatcher {
* Check whether there a runtime (dynamic) match for this method, * Check whether there a runtime (dynamic) match for this method,
* which must have matched statically. * which must have matched statically.
* <p>This method is invoked only if the 2-arg matches method returns * <p>This method is invoked only if the 2-arg matches method returns
* <code>true</code> for the given method and target class, and if the * {@code true} for the given method and target class, and if the
* {@link #isRuntime()} method returns <code>true</code>. Invoked * {@link #isRuntime()} method returns {@code true}. Invoked
* immediately before potential running of the advice, after any * immediately before potential running of the advice, after any
* advice earlier in the advice chain has run. * advice earlier in the advice chain has run.
* @param method the candidate method * @param method the candidate method
* @param targetClass the target class (may be <code>null</code>, in which case * @param targetClass the target class (may be {@code null}, in which case
* the candidate class must be taken to be the method's declaring class) * the candidate class must be taken to be the method's declaring class)
* @param args arguments to the method * @param args arguments to the method
* @return whether there's a runtime match * @return whether there's a runtime match

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -34,13 +34,13 @@ public interface Pointcut {
/** /**
* Return the ClassFilter for this pointcut. * Return the ClassFilter for this pointcut.
* @return the ClassFilter (never <code>null</code>) * @return the ClassFilter (never {@code null})
*/ */
ClassFilter getClassFilter(); ClassFilter getClassFilter();
/** /**
* Return the MethodMatcher for this pointcut. * Return the MethodMatcher for this pointcut.
* @return the MethodMatcher (never <code>null</code>) * @return the MethodMatcher (never {@code null})
*/ */
MethodMatcher getMethodMatcher(); MethodMatcher getMethodMatcher();

View File

@@ -1,12 +1,12 @@
/* /*
* Copyright 2002-2005 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -40,22 +40,22 @@ public interface ProxyMethodInvocation extends MethodInvocation {
Object getProxy(); Object getProxy();
/** /**
* Create a clone of this object. If cloning is done before <code>proceed()</code> * Create a clone of this object. If cloning is done before {@code proceed()}
* is invoked on this object, <code>proceed()</code> can be invoked once per clone * is invoked on this object, {@code proceed()} can be invoked once per clone
* to invoke the joinpoint (and the rest of the advice chain) more than once. * to invoke the joinpoint (and the rest of the advice chain) more than once.
* @return an invocable clone of this invocation. * @return an invocable clone of this invocation.
* <code>proceed()</code> can be called once per clone. * {@code proceed()} can be called once per clone.
*/ */
MethodInvocation invocableClone(); MethodInvocation invocableClone();
/** /**
* Create a clone of this object. If cloning is done before <code>proceed()</code> * Create a clone of this object. If cloning is done before {@code proceed()}
* is invoked on this object, <code>proceed()</code> can be invoked once per clone * is invoked on this object, {@code proceed()} can be invoked once per clone
* to invoke the joinpoint (and the rest of the advice chain) more than once. * to invoke the joinpoint (and the rest of the advice chain) more than once.
* @param arguments the arguments that the cloned invocation is supposed to use, * @param arguments the arguments that the cloned invocation is supposed to use,
* overriding the original arguments * overriding the original arguments
* @return an invocable clone of this invocation. * @return an invocable clone of this invocation.
* <code>proceed()</code> can be called once per clone. * {@code proceed()} can be called once per clone.
*/ */
MethodInvocation invocableClone(Object[] arguments); MethodInvocation invocableClone(Object[] arguments);
@@ -71,14 +71,14 @@ public interface ProxyMethodInvocation extends MethodInvocation {
* <p>Such attributes are not used within the AOP framework itself. They are * <p>Such attributes are not used within the AOP framework itself. They are
* just kept as part of the invocation object, for use in special interceptors. * just kept as part of the invocation object, for use in special interceptors.
* @param key the name of the attribute * @param key the name of the attribute
* @param value the value of the attribute, or <code>null</code> to reset it * @param value the value of the attribute, or {@code null} to reset it
*/ */
void setUserAttribute(String key, Object value); void setUserAttribute(String key, Object value);
/** /**
* Return the value of the specified user attribute. * Return the value of the specified user attribute.
* @param key the name of the attribute * @param key the name of the attribute
* @return the value of the attribute, or <code>null</code> if not set * @return the value of the attribute, or {@code null} if not set
* @see #setUserAttribute * @see #setUserAttribute
*/ */
Object getUserAttribute(String key); Object getUserAttribute(String key);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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 @@ public interface TargetClassAware {
/** /**
* Return the target class behind the implementing object * Return the target class behind the implementing object
* (typically a proxy configuration or an actual proxy). * (typically a proxy configuration or an actual proxy).
* @return the target Class, or <code>null</code> if not known * @return the target Class, or {@code null} if not known
*/ */
Class<?> getTargetClass(); Class<?> getTargetClass();

View File

@@ -1,5 +1,5 @@
/*< /*<
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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,16 +17,16 @@
package org.springframework.aop; package org.springframework.aop;
/** /**
* A <code>TargetSource</code> is used to obtain the current "target" of * A {@code TargetSource} is used to obtain the current "target" of
* an AOP invocation, which will be invoked via reflection if no around * an AOP invocation, which will be invoked via reflection if no around
* advice chooses to end the interceptor chain itself. * advice chooses to end the interceptor chain itself.
* *
* <p>If a <code>TargetSource</code> is "static", it will always return * <p>If a {@code TargetSource} is "static", it will always return
* the same target, allowing optimizations in the AOP framework. Dynamic * the same target, allowing optimizations in the AOP framework. Dynamic
* target sources can support pooling, hot swapping, etc. * target sources can support pooling, hot swapping, etc.
* *
* <p>Application developers don't usually need to work with * <p>Application developers don't usually need to work with
* <code>TargetSources</code> directly: this is an AOP framework interface. * {@code TargetSources} directly: this is an AOP framework interface.
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@@ -34,11 +34,12 @@ public interface TargetSource extends TargetClassAware {
/** /**
* Return the type of targets returned by this {@link TargetSource}. * Return the type of targets returned by this {@link TargetSource}.
* <p>Can return <code>null</code>, although certain usages of a * <p>Can return {@code null}, although certain usages of a
* <code>TargetSource</code> might just work with a predetermined * {@code TargetSource} might just work with a predetermined
* target class. * target class.
* @return the type of targets returned by this {@link TargetSource} * @return the type of targets returned by this {@link TargetSource}
*/ */
@Override
Class<?> getTargetClass(); Class<?> getTargetClass();
/** /**
@@ -46,7 +47,7 @@ public interface TargetSource extends TargetClassAware {
* <p>In that case, there will be no need to invoke * <p>In that case, there will be no need to invoke
* {@link #releaseTarget(Object)}, and the AOP framework can cache * {@link #releaseTarget(Object)}, and the AOP framework can cache
* the return value of {@link #getTarget()}. * the return value of {@link #getTarget()}.
* @return <code>true</code> if the target is immutable * @return {@code true} if the target is immutable
* @see #getTarget * @see #getTarget
*/ */
boolean isStatic(); boolean isStatic();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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,24 +23,26 @@ import java.io.Serializable;
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@SuppressWarnings("serial")
class TrueClassFilter implements ClassFilter, Serializable { class TrueClassFilter implements ClassFilter, Serializable {
public static final TrueClassFilter INSTANCE = new TrueClassFilter(); public static final TrueClassFilter INSTANCE = new TrueClassFilter();
/** /**
* Enforce Singleton pattern. * Enforce Singleton pattern.
*/ */
private TrueClassFilter() { private TrueClassFilter() {
} }
@Override
public boolean matches(Class clazz) { public boolean matches(Class clazz) {
return true; return true;
} }
/** /**
* Required to support serialization. Replaces with canonical * Required to support serialization. Replaces with canonical
* instance on deserialization, protecting Singleton pattern. * instance on deserialization, protecting Singleton pattern.
* Alternative to overriding <code>equals()</code>. * Alternative to overriding {@code equals()}.
*/ */
private Object readResolve() { private Object readResolve() {
return INSTANCE; return INSTANCE;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -24,38 +24,42 @@ import java.lang.reflect.Method;
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@SuppressWarnings("serial")
class TrueMethodMatcher implements MethodMatcher, Serializable { class TrueMethodMatcher implements MethodMatcher, Serializable {
public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher(); public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher();
/** /**
* Enforce Singleton pattern. * Enforce Singleton pattern.
*/ */
private TrueMethodMatcher() { private TrueMethodMatcher() {
} }
@Override
public boolean isRuntime() { public boolean isRuntime() {
return false; return false;
} }
@Override
public boolean matches(Method method, Class targetClass) { public boolean matches(Method method, Class targetClass) {
return true; return true;
} }
@Override
public boolean matches(Method method, Class targetClass, Object[] args) { public boolean matches(Method method, Class targetClass, Object[] args) {
// Should never be invoked as isRuntime returns false. // Should never be invoked as isRuntime returns false.
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/** /**
* Required to support serialization. Replaces with canonical * Required to support serialization. Replaces with canonical
* instance on deserialization, protecting Singleton pattern. * instance on deserialization, protecting Singleton pattern.
* Alternative to overriding <code>equals()</code>. * Alternative to overriding {@code equals()}.
*/ */
private Object readResolve() { private Object readResolve() {
return INSTANCE; return INSTANCE;
} }
@Override @Override
public String toString() { public String toString() {
return "MethodMatcher.TRUE"; return "MethodMatcher.TRUE";

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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,28 +23,31 @@ import java.io.Serializable;
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@SuppressWarnings("serial")
class TruePointcut implements Pointcut, Serializable { class TruePointcut implements Pointcut, Serializable {
public static final TruePointcut INSTANCE = new TruePointcut(); public static final TruePointcut INSTANCE = new TruePointcut();
/** /**
* Enforce Singleton pattern. * Enforce Singleton pattern.
*/ */
private TruePointcut() { private TruePointcut() {
} }
@Override
public ClassFilter getClassFilter() { public ClassFilter getClassFilter() {
return ClassFilter.TRUE; return ClassFilter.TRUE;
} }
@Override
public MethodMatcher getMethodMatcher() { public MethodMatcher getMethodMatcher() {
return MethodMatcher.TRUE; return MethodMatcher.TRUE;
} }
/** /**
* Required to support serialization. Replaces with canonical * Required to support serialization. Replaces with canonical
* instance on deserialization, protecting Singleton pattern. * instance on deserialization, protecting Singleton pattern.
* Alternative to overriding <code>equals()</code>. * Alternative to overriding {@code equals()}.
*/ */
private Object readResolve() { private Object readResolve() {
return INSTANCE; return INSTANCE;

View File

@@ -203,6 +203,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
return this.aspectInstanceFactory.getAspectClassLoader(); return this.aspectInstanceFactory.getAspectClassLoader();
} }
@Override
public int getOrder() { public int getOrder() {
return this.aspectInstanceFactory.getOrder(); return this.aspectInstanceFactory.getOrder();
} }
@@ -211,7 +212,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
public void setAspectName(String name) { public void setAspectName(String name) {
this.aspectName = name; this.aspectName = name;
} }
@Override
public String getAspectName() { public String getAspectName() {
return this.aspectName; return this.aspectName;
} }
@@ -223,6 +225,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
this.declarationOrder = order; this.declarationOrder = order;
} }
@Override
public int getDeclarationOrder() { public int getDeclarationOrder() {
return this.declarationOrder; return this.declarationOrder;
} }
@@ -268,7 +271,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
throw new UnsupportedOperationException("Only afterReturning advice can be used to bind a return value"); throw new UnsupportedOperationException("Only afterReturning advice can be used to bind a return value");
} }
/** /**
* We need to hold the returning name at this level for argument binding calculations, * We need to hold the returning name at this level for argument binding calculations,
* this method allows the afterReturning advice subclass to set the name. * this method allows the afterReturning advice subclass to set the name.
*/ */
@@ -302,7 +305,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception"); throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception");
} }
/** /**
* We need to hold the throwing name at this level for argument binding calculations, * We need to hold the throwing name at this level for argument binding calculations,
* this method allows the afterThrowing advice subclass to set the name. * this method allows the afterThrowing advice subclass to set the name.
*/ */
@@ -347,8 +350,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
* on subsequent advice invocations can be as fast as possible. * on subsequent advice invocations can be as fast as possible.
* <p>If the first argument is of type JoinPoint or ProceedingJoinPoint then we * <p>If the first argument is of type JoinPoint or ProceedingJoinPoint then we
* pass a JoinPoint in that position (ProceedingJoinPoint for around advice). * pass a JoinPoint in that position (ProceedingJoinPoint for around advice).
* <p>If the first argument is of type <code>JoinPoint.StaticPart</code> * <p>If the first argument is of type {@code JoinPoint.StaticPart}
* then we pass a <code>JoinPoint.StaticPart</code> in that position. * then we pass a {@code JoinPoint.StaticPart} in that position.
* <p>Remaining arguments have to be bound by pointcut evaluation at * <p>Remaining arguments have to be bound by pointcut evaluation at
* a given join point. We will get back a map from argument name to * a given join point. We will get back a map from argument name to
* value. We need to calculate which advice parameter needs to be bound * value. We need to calculate which advice parameter needs to be bound
@@ -365,11 +368,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes(); Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) { if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
numUnboundArgs--; numUnboundArgs--;
} }
else if (maybeBindJoinPointStaticPart(parameterTypes[0])) { else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
numUnboundArgs--; numUnboundArgs--;
} }
if (numUnboundArgs > 0) { if (numUnboundArgs > 0) {
// need to bind arguments by name as returned from the pointcut match // need to bind arguments by name as returned from the pointcut match
bindArgumentsByName(numUnboundArgs); bindArgumentsByName(numUnboundArgs);
@@ -398,7 +401,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
} }
else { else {
return false; return false;
} }
} }
protected boolean supportsProceedingJoinPoint() { protected boolean supportsProceedingJoinPoint() {
@@ -409,7 +412,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) { if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
this.joinPointStaticPartArgumentIndex = 0; this.joinPointStaticPartArgumentIndex = 0;
return true; return true;
} }
else { else {
return false; return false;
} }
@@ -422,7 +425,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
if (this.argumentNames != null) { if (this.argumentNames != null) {
// We have been able to determine the arg names. // We have been able to determine the arg names.
bindExplicitArguments(numArgumentsExpectingToBind); bindExplicitArguments(numArgumentsExpectingToBind);
} }
else { else {
throw new IllegalStateException("Advice method [" + this.aspectJAdviceMethod.getName() + "] " + throw new IllegalStateException("Advice method [" + this.aspectJAdviceMethod.getName() + "] " +
"requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " + "requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " +
@@ -471,9 +474,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
// specified, and find the discovered argument types. // specified, and find the discovered argument types.
if (this.returningName != null) { if (this.returningName != null) {
if (!this.argumentBindings.containsKey(this.returningName)) { if (!this.argumentBindings.containsKey(this.returningName)) {
throw new IllegalStateException("Returning argument name '" throw new IllegalStateException("Returning argument name '"
+ this.returningName + "' was not bound in advice arguments"); + this.returningName + "' was not bound in advice arguments");
} }
else { else {
Integer index = this.argumentBindings.get(this.returningName); Integer index = this.argumentBindings.get(this.returningName);
this.discoveredReturningType = this.aspectJAdviceMethod.getParameterTypes()[index]; this.discoveredReturningType = this.aspectJAdviceMethod.getParameterTypes()[index];
@@ -482,9 +485,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
} }
if (this.throwingName != null) { if (this.throwingName != null) {
if (!this.argumentBindings.containsKey(this.throwingName)) { if (!this.argumentBindings.containsKey(this.throwingName)) {
throw new IllegalStateException("Throwing argument name '" throw new IllegalStateException("Throwing argument name '"
+ this.throwingName + "' was not bound in advice arguments"); + this.throwingName + "' was not bound in advice arguments");
} }
else { else {
Integer index = this.argumentBindings.get(this.throwingName); Integer index = this.argumentBindings.get(this.throwingName);
this.discoveredThrowingType = this.aspectJAdviceMethod.getParameterTypes()[index]; this.discoveredThrowingType = this.aspectJAdviceMethod.getParameterTypes()[index];
@@ -525,7 +528,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
pointcutParameterTypes[index] = methodParameterTypes[i]; pointcutParameterTypes[index] = methodParameterTypes[i];
index++; index++;
} }
this.pointcut.setParameterNames(pointcutParameterNames); this.pointcut.setParameterNames(pointcutParameterNames);
this.pointcut.setParameterTypes(pointcutParameterTypes); this.pointcut.setParameterTypes(pointcutParameterTypes);
} }
@@ -549,7 +552,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
if (this.joinPointArgumentIndex != -1) { if (this.joinPointArgumentIndex != -1) {
adviceInvocationArgs[this.joinPointArgumentIndex] = jp; adviceInvocationArgs[this.joinPointArgumentIndex] = jp;
numBound++; numBound++;
} }
else if (this.joinPointStaticPartArgumentIndex != -1) { else if (this.joinPointStaticPartArgumentIndex != -1) {
adviceInvocationArgs[this.joinPointStaticPartArgumentIndex] = jp.getStaticPart(); adviceInvocationArgs[this.joinPointStaticPartArgumentIndex] = jp.getStaticPart();
numBound++; numBound++;
@@ -582,8 +585,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
if (numBound != this.adviceInvocationArgumentCount) { if (numBound != this.adviceInvocationArgumentCount) {
throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount
+ " arguments, but only bound " + numBound + " (JoinPointMatch " + + " arguments, but only bound " + numBound + " (JoinPointMatch " +
(jpMatch == null ? "was NOT" : "WAS") + (jpMatch == null ? "was NOT" : "WAS") +
" bound in invocation)"); " bound in invocation)");
} }
@@ -678,6 +681,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
this.adviceMethod = adviceMethod; this.adviceMethod = adviceMethod;
} }
@Override
public boolean matches(Method method, Class targetClass) { public boolean matches(Method method, Class targetClass) {
return !this.adviceMethod.equals(method); return !this.adviceMethod.equals(method);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -34,13 +34,13 @@ public interface AspectInstanceFactory extends Ordered {
/** /**
* Create an instance of this factory's aspect. * Create an instance of this factory's aspect.
* @return the aspect instance (never <code>null</code>) * @return the aspect instance (never {@code null})
*/ */
Object getAspectInstance(); Object getAspectInstance();
/** /**
* Expose the aspect class loader that this factory uses. * Expose the aspect class loader that this factory uses.
* @return the aspect class loader (never <code>null</code>) * @return the aspect class loader (never {@code null})
*/ */
ClassLoader getAspectClassLoader(); ClassLoader getAspectClassLoader();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -36,82 +36,82 @@ import org.springframework.util.StringUtils;
/** /**
* {@link ParameterNameDiscoverer} implementation that tries to deduce parameter names * {@link ParameterNameDiscoverer} implementation that tries to deduce parameter names
* for an advice method from the pointcut expression, returning, and throwing clauses. * for an advice method from the pointcut expression, returning, and throwing clauses.
* If an unambiguous interpretation is not available, it returns <code>null</code>. * If an unambiguous interpretation is not available, it returns {@code null}.
* *
* <p>This class interprets arguments in the following way: * <p>This class interprets arguments in the following way:
* <ol> * <ol>
* <li>If the first parameter of the method is of type {@link JoinPoint} * <li>If the first parameter of the method is of type {@link JoinPoint}
* or {@link ProceedingJoinPoint}, it is assumed to be for passing * or {@link ProceedingJoinPoint}, it is assumed to be for passing
* <code>thisJoinPoint</code> to the advice, and the parameter name will * {@code thisJoinPoint} to the advice, and the parameter name will
* be assigned the value <code>"thisJoinPoint"</code>.</li> * be assigned the value {@code "thisJoinPoint"}.</li>
* <li>If the first parameter of the method is of type * <li>If the first parameter of the method is of type
* <code>JoinPoint.StaticPart</code>, it is assumed to be for passing * {@code JoinPoint.StaticPart}, it is assumed to be for passing
* <code>"thisJoinPointStaticPart"</code> to the advice, and the parameter name * {@code "thisJoinPointStaticPart"} to the advice, and the parameter name
* will be assigned the value <code>"thisJoinPointStaticPart"</code>.</li> * will be assigned the value {@code "thisJoinPointStaticPart"}.</li>
* <li>If a {@link #setThrowingName(String) throwingName} has been set, and * <li>If a {@link #setThrowingName(String) throwingName} has been set, and
* there are no unbound arguments of type <code>Throwable+</code>, then an * there are no unbound arguments of type {@code Throwable+}, then an
* {@link IllegalArgumentException} is raised. If there is more than one * {@link IllegalArgumentException} is raised. If there is more than one
* unbound argument of type <code>Throwable+</code>, then an * unbound argument of type {@code Throwable+}, then an
* {@link AmbiguousBindingException} is raised. If there is exactly one * {@link AmbiguousBindingException} is raised. If there is exactly one
* unbound argument of type <code>Throwable+</code>, then the corresponding * unbound argument of type {@code Throwable+}, then the corresponding
* parameter name is assigned the value &lt;throwingName&gt;.</li> * parameter name is assigned the value &lt;throwingName&gt;.</li>
* <li>If there remain unbound arguments, then the pointcut expression is * <li>If there remain unbound arguments, then the pointcut expression is
* examined. Let <code>a</code> be the number of annotation-based pointcut * examined. Let {@code a} be the number of annotation-based pointcut
* expressions (&#64;annotation, &#64;this, &#64;target, &#64;args, * expressions (&#64;annotation, &#64;this, &#64;target, &#64;args,
* &#64;within, &#64;withincode) that are used in binding form. Usage in * &#64;within, &#64;withincode) that are used in binding form. Usage in
* binding form has itself to be deduced: if the expression inside the * binding form has itself to be deduced: if the expression inside the
* pointcut is a single string literal that meets Java variable name * pointcut is a single string literal that meets Java variable name
* conventions it is assumed to be a variable name. If <code>a</code> is * conventions it is assumed to be a variable name. If {@code a} is
* zero we proceed to the next stage. If <code>a</code> &gt; 1 then an * zero we proceed to the next stage. If {@code a} &gt; 1 then an
* <code>AmbiguousBindingException</code> is raised. If <code>a</code> == 1, * {@code AmbiguousBindingException} is raised. If {@code a} == 1,
* and there are no unbound arguments of type <code>Annotation+</code>, * and there are no unbound arguments of type {@code Annotation+},
* then an <code>IllegalArgumentException</code> is raised. if there is * then an {@code IllegalArgumentException} is raised. if there is
* exactly one such argument, then the corresponding parameter name is * exactly one such argument, then the corresponding parameter name is
* assigned the value from the pointcut expression.</li> * assigned the value from the pointcut expression.</li>
* <li>If a returningName has been set, and there are no unbound arguments * <li>If a returningName has been set, and there are no unbound arguments
* then an <code>IllegalArgumentException</code> is raised. If there is * then an {@code IllegalArgumentException} is raised. If there is
* more than one unbound argument then an * more than one unbound argument then an
* <code>AmbiguousBindingException</code> is raised. If there is exactly * {@code AmbiguousBindingException} is raised. If there is exactly
* one unbound argument then the corresponding parameter name is assigned * one unbound argument then the corresponding parameter name is assigned
* the value &lt;returningName&gt;.</li> * the value &lt;returningName&gt;.</li>
* <li>If there remain unbound arguments, then the pointcut expression is * <li>If there remain unbound arguments, then the pointcut expression is
* examined once more for <code>this</code>, <code>target</code>, and * examined once more for {@code this}, {@code target}, and
* <code>args</code> pointcut expressions used in the binding form (binding * {@code args} pointcut expressions used in the binding form (binding
* forms are deduced as described for the annotation based pointcuts). If * forms are deduced as described for the annotation based pointcuts). If
* there remains more than one unbound argument of a primitive type (which * there remains more than one unbound argument of a primitive type (which
* can only be bound in <code>args</code>) then an * can only be bound in {@code args}) then an
* <code>AmbiguousBindingException</code> is raised. If there is exactly * {@code AmbiguousBindingException} is raised. If there is exactly
* one argument of a primitive type, then if exactly one <code>args</code> * one argument of a primitive type, then if exactly one {@code args}
* bound variable was found, we assign the corresponding parameter name * bound variable was found, we assign the corresponding parameter name
* the variable name. If there were no <code>args</code> bound variables * the variable name. If there were no {@code args} bound variables
* found an <code>IllegalStateException</code> is raised. If there are * found an {@code IllegalStateException} is raised. If there are
* multiple <code>args</code> bound variables, an * multiple {@code args} bound variables, an
* <code>AmbiguousBindingException</code> is raised. At this point, if * {@code AmbiguousBindingException} is raised. At this point, if
* there remains more than one unbound argument we raise an * there remains more than one unbound argument we raise an
* <code>AmbiguousBindingException</code>. If there are no unbound arguments * {@code AmbiguousBindingException}. If there are no unbound arguments
* remaining, we are done. If there is exactly one unbound argument * remaining, we are done. If there is exactly one unbound argument
* remaining, and only one candidate variable name unbound from * remaining, and only one candidate variable name unbound from
* <code>this</code>, <code>target</code>, or <code>args</code>, it is * {@code this}, {@code target}, or {@code args}, it is
* assigned as the corresponding parameter name. If there are multiple * assigned as the corresponding parameter name. If there are multiple
* possibilities, an <code>AmbiguousBindingException</code> is raised.</li> * possibilities, an {@code AmbiguousBindingException} is raised.</li>
* </ol> * </ol>
* *
* <p>The behavior on raising an <code>IllegalArgumentException</code> or * <p>The behavior on raising an {@code IllegalArgumentException} or
* <code>AmbiguousBindingException</code> is configurable to allow this discoverer * {@code AmbiguousBindingException} is configurable to allow this discoverer
* to be used as part of a chain-of-responsibility. By default the condition will * to be used as part of a chain-of-responsibility. By default the condition will
* be logged and the <code>getParameterNames(..)</code> method will simply return * be logged and the {@code getParameterNames(..)} method will simply return
* <code>null</code>. If the {@link #setRaiseExceptions(boolean) raiseExceptions} * {@code null}. If the {@link #setRaiseExceptions(boolean) raiseExceptions}
* property is set to <code>true</code>, the conditions will be thrown as * property is set to {@code true}, the conditions will be thrown as
* <code>IllegalArgumentException</code> and <code>AmbiguousBindingException</code>, * {@code IllegalArgumentException} and {@code AmbiguousBindingException},
* respectively. * respectively.
* *
* <p>Was that perfectly clear? ;) * <p>Was that perfectly clear? ;)
* *
* <p>Short version: If an unambiguous binding can be deduced, then it is. * <p>Short version: If an unambiguous binding can be deduced, then it is.
* If the advice requirements cannot possibly be satisfied, then <code>null</code> * If the advice requirements cannot possibly be satisfied, then {@code null}
* is returned. By setting the {@link #setRaiseExceptions(boolean) raiseExceptions} * is returned. By setting the {@link #setRaiseExceptions(boolean) raiseExceptions}
* property to <code>true</code>, descriptive exceptions will be thrown instead of * property to {@code true}, descriptive exceptions will be thrown instead of
* returning <code>null</code> in the case that the parameter names cannot be discovered. * returning {@code null} in the case that the parameter names cannot be discovered.
* *
* @author Adrian Colyer * @author Adrian Colyer
* @since 2.0 * @since 2.0
@@ -191,14 +191,14 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
/** /**
* Indicate whether {@link IllegalArgumentException} and {@link AmbiguousBindingException} * Indicate whether {@link IllegalArgumentException} and {@link AmbiguousBindingException}
* must be thrown as appropriate in the case of failing to deduce advice parameter names. * must be thrown as appropriate in the case of failing to deduce advice parameter names.
* @param raiseExceptions <code>true</code> if exceptions are to be thrown * @param raiseExceptions {@code true} if exceptions are to be thrown
*/ */
public void setRaiseExceptions(boolean raiseExceptions) { public void setRaiseExceptions(boolean raiseExceptions) {
this.raiseExceptions = raiseExceptions; this.raiseExceptions = raiseExceptions;
} }
/** /**
* If <code>afterReturning</code> advice binds the return value, the * If {@code afterReturning} advice binds the return value, the
* returning variable name must be specified. * returning variable name must be specified.
* @param returningName the name of the returning variable * @param returningName the name of the returning variable
*/ */
@@ -207,7 +207,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
/** /**
* If <code>afterThrowing</code> advice binds the thrown value, the * If {@code afterThrowing} advice binds the thrown value, the
* throwing variable name must be specified. * throwing variable name must be specified.
* @param throwingName the name of the throwing variable * @param throwingName the name of the throwing variable
*/ */
@@ -222,6 +222,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* @param method the target {@link Method} * @param method the target {@link Method}
* @return the parameter names * @return the parameter names
*/ */
@Override
public String[] getParameterNames(Method method) { public String[] getParameterNames(Method method) {
this.argumentTypes = method.getParameterTypes(); this.argumentTypes = method.getParameterTypes();
this.numberOfRemainingUnboundArguments = this.argumentTypes.length; this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
@@ -305,10 +306,11 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
/** /**
* An advice method can never be a constructor in Spring. * An advice method can never be a constructor in Spring.
* @return <code>null</code> * @return {@code null}
* @throws UnsupportedOperationException if * @throws UnsupportedOperationException if
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to <code>true</code> * {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
*/ */
@Override
public String[] getParameterNames(Constructor ctor) { public String[] getParameterNames(Constructor ctor) {
if (this.raiseExceptions) { if (this.raiseExceptions) {
throw new UnsupportedOperationException("An advice method can never be a constructor"); throw new UnsupportedOperationException("An advice method can never be a constructor");
@@ -493,7 +495,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
/** /**
* Given an args pointcut body (could be <code>args</code> or <code>at_args</code>), * Given an args pointcut body (could be {@code args} or {@code at_args}),
* add any candidate variable names to the given list. * add any candidate variable names to the given list.
*/ */
private void maybeExtractVariableNamesFromArgs(String argsSpec, List<String> varNames) { private void maybeExtractVariableNamesFromArgs(String argsSpec, List<String> varNames) {
@@ -700,7 +702,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
// 1 primitive arg, and one candidate... // 1 primitive arg, and one candidate...
for (int i = 0; i < this.argumentTypes.length; i++) { for (int i = 0; i < this.argumentTypes.length; i++) {
if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) { if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) {
bindParameterName(i, (String) varNames.get(0)); bindParameterName(i, varNames.get(0));
break; break;
} }
} }
@@ -726,7 +728,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
/* /*
* Return <code>true</code> if the given argument type is a subclass * Return {@code true} if the given argument type is a subclass
* of the given supertype. * of the given supertype.
*/ */
private boolean isSubtypeOf(Class supertype, int argumentNumber) { private boolean isSubtypeOf(Class supertype, int argumentNumber) {
@@ -755,7 +757,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
/* /*
* Find the argument index with the given type, and bind the given * Find the argument index with the given type, and bind the given
* <code>varName</code> in that position. * {@code varName} in that position.
*/ */
private void findAndBind(Class argumentType, String varName) { private void findAndBind(Class argumentType, String varName) {
for (int i = 0; i < this.argumentTypes.length; i++) { for (int i = 0; i < this.argumentTypes.length; i++) {
@@ -790,6 +792,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* Thrown in response to an ambiguous binding being detected when * Thrown in response to an ambiguous binding being detected when
* trying to resolve a method's parameter names. * trying to resolve a method's parameter names.
*/ */
@SuppressWarnings("serial")
public static class AmbiguousBindingException extends RuntimeException { public static class AmbiguousBindingException extends RuntimeException {
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -36,7 +36,8 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
super(aspectJBeforeAdviceMethod, pointcut, aif); super(aspectJBeforeAdviceMethod, pointcut, aif);
} }
@Override
public Object invoke(MethodInvocation mi) throws Throwable { public Object invoke(MethodInvocation mi) throws Throwable {
try { try {
return mi.proceed(); return mi.proceed();
@@ -46,10 +47,12 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI
} }
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
return false; return false;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
return true; return true;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -40,10 +40,12 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
super(aspectJBeforeAdviceMethod, pointcut, aif); super(aspectJBeforeAdviceMethod, pointcut, aif);
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
return false; return false;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
return true; return true;
} }
@@ -53,6 +55,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
setReturningNameNoCheck(name); setReturningNameNoCheck(name);
} }
@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
if (shouldInvokeOnReturnValueOf(method, returnValue)) { if (shouldInvokeOnReturnValueOf(method, returnValue)) {
invokeAdviceMethod(getJoinPointMatch(), returnValue, null); invokeAdviceMethod(getJoinPointMatch(), returnValue, null);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -37,10 +37,12 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
super(aspectJBeforeAdviceMethod, pointcut, aif); super(aspectJBeforeAdviceMethod, pointcut, aif);
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
return false; return false;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
return true; return true;
} }
@@ -50,6 +52,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
setThrowingNameNoCheck(name); setThrowingNameNoCheck(name);
} }
@Override
public Object invoke(MethodInvocation mi) throws Throwable { public Object invoke(MethodInvocation mi) throws Throwable {
try { try {
return mi.proceed(); return mi.proceed();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.aop.BeforeAdvice;
public abstract class AspectJAopUtils { public abstract class AspectJAopUtils {
/** /**
* Return <code>true</code> if the advisor is a form of before advice. * Return {@code true} if the advisor is a form of before advice.
*/ */
public static boolean isBeforeAdvice(Advisor anAdvisor) { public static boolean isBeforeAdvice(Advisor anAdvisor) {
AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor);
@@ -43,7 +43,7 @@ public abstract class AspectJAopUtils {
} }
/** /**
* Return <code>true</code> if the advisor is a form of after advice. * Return {@code true} if the advisor is a form of after advice.
*/ */
public static boolean isAfterAdvice(Advisor anAdvisor) { public static boolean isAfterAdvice(Advisor anAdvisor) {
AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor);
@@ -56,7 +56,7 @@ public abstract class AspectJAopUtils {
/** /**
* Return the AspectJPrecedenceInformation provided by this advisor or its advice. * Return the AspectJPrecedenceInformation provided by this advisor or its advice.
* If neither the advisor nor the advice have precedence information, this method * If neither the advisor nor the advice have precedence information, this method
* will return <code>null</code>. * will return {@code null}.
*/ */
public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) { public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) {
if (anAdvisor instanceof AspectJPrecedenceInformation) { if (anAdvisor instanceof AspectJPrecedenceInformation) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -41,10 +41,12 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
super(aspectJAroundAdviceMethod, pointcut, aif); super(aspectJAroundAdviceMethod, pointcut, aif);
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
return false; return false;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
return false; return false;
} }
@@ -55,6 +57,7 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method
} }
@Override
public Object invoke(MethodInvocation mi) throws Throwable { public Object invoke(MethodInvocation mi) throws Throwable {
if (!(mi instanceof ProxyMethodInvocation)) { if (!(mi instanceof ProxyMethodInvocation)) {
throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -76,6 +76,7 @@ import org.springframework.util.StringUtils;
* @author Dave Syer * @author Dave Syer
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public class AspectJExpressionPointcut extends AbstractExpressionPointcut public class AspectJExpressionPointcut extends AbstractExpressionPointcut
implements ClassFilter, IntroductionAwareMethodMatcher, BeanFactoryAware { implements ClassFilter, IntroductionAwareMethodMatcher, BeanFactoryAware {
@@ -154,16 +155,19 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
this.pointcutParameterTypes = types; this.pointcutParameterTypes = types;
} }
@Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
} }
@Override
public ClassFilter getClassFilter() { public ClassFilter getClassFilter() {
checkReadyToMatch(); checkReadyToMatch();
return this; return this;
} }
@Override
public MethodMatcher getMethodMatcher() { public MethodMatcher getMethodMatcher() {
checkReadyToMatch(); checkReadyToMatch();
return this; return this;
@@ -223,9 +227,9 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
/** /**
* If a pointcut expression has been specified in XML, the user cannot * If a pointcut expression has been specified in XML, the user cannot
* write <code>and</code> as "&&" (though &amp;&amp; will work). * write {@code and} as "&&" (though &amp;&amp; will work).
* We also allow <code>and</code> between two pointcut sub-expressions. * We also allow {@code and} between two pointcut sub-expressions.
* <p>This method converts back to <code>&&</code> for the AspectJ pointcut parser. * <p>This method converts back to {@code &&} for the AspectJ pointcut parser.
*/ */
private String replaceBooleanOperators(String pcExpr) { private String replaceBooleanOperators(String pcExpr) {
String result = StringUtils.replace(pcExpr, " and ", " && "); String result = StringUtils.replace(pcExpr, " and ", " && ");
@@ -243,6 +247,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
return this.pointcutExpression; return this.pointcutExpression;
} }
@Override
public boolean matches(Class targetClass) { public boolean matches(Class targetClass) {
checkReadyToMatch(); checkReadyToMatch();
try { try {
@@ -259,13 +264,14 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
ex); ex);
return false; return false;
} }
} }
catch (BCException ex) { catch (BCException ex) {
logger.debug("PointcutExpression matching rejected target class", ex); logger.debug("PointcutExpression matching rejected target class", ex);
return false; return false;
} }
} }
@Override
public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) { public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) {
checkReadyToMatch(); checkReadyToMatch();
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass); Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
@@ -286,15 +292,18 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
} }
@Override
public boolean matches(Method method, Class targetClass) { public boolean matches(Method method, Class targetClass) {
return matches(method, targetClass, false); return matches(method, targetClass, false);
} }
@Override
public boolean isRuntime() { public boolean isRuntime() {
checkReadyToMatch(); checkReadyToMatch();
return this.pointcutExpression.mayNeedDynamicTest(); return this.pointcutExpression.mayNeedDynamicTest();
} }
@Override
public boolean matches(Method method, Class targetClass, Object[] args) { public boolean matches(Method method, Class targetClass, Object[] args) {
checkReadyToMatch(); checkReadyToMatch();
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method); ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
@@ -494,10 +503,10 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
/** /**
* Handler for the Spring-specific <code>bean()</code> pointcut designator * Handler for the Spring-specific {@code bean()} pointcut designator
* extension to AspectJ. * extension to AspectJ.
* <p>This handler must be added to each pointcut object that needs to * <p>This handler must be added to each pointcut object that needs to
* handle the <code>bean()</code> PCD. Matching context is obtained * handle the {@code bean()} PCD. Matching context is obtained
* automatically by examining a thread local variable and therefore a matching * automatically by examining a thread local variable and therefore a matching
* context need not be set on the pointcut. * context need not be set on the pointcut.
*/ */
@@ -505,10 +514,12 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
private static final String BEAN_DESIGNATOR_NAME = "bean"; private static final String BEAN_DESIGNATOR_NAME = "bean";
@Override
public String getDesignatorName() { public String getDesignatorName() {
return BEAN_DESIGNATOR_NAME; return BEAN_DESIGNATOR_NAME;
} }
@Override
public ContextBasedMatcher parse(String expression) { public ContextBasedMatcher parse(String expression) {
return new BeanNameContextMatcher(expression); return new BeanNameContextMatcher(expression);
} }
@@ -530,22 +541,27 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
this.expressionPattern = new NamePattern(expression); this.expressionPattern = new NamePattern(expression);
} }
@Override
public boolean couldMatchJoinPointsInType(Class someClass) { public boolean couldMatchJoinPointsInType(Class someClass) {
return (contextMatch(someClass) == FuzzyBoolean.YES); return (contextMatch(someClass) == FuzzyBoolean.YES);
} }
@Override
public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) { public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) {
return (contextMatch(someClass) == FuzzyBoolean.YES); return (contextMatch(someClass) == FuzzyBoolean.YES);
} }
@Override
public boolean matchesDynamically(MatchingContext context) { public boolean matchesDynamically(MatchingContext context) {
return true; return true;
} }
@Override
public FuzzyBoolean matchesStatically(MatchingContext context) { public FuzzyBoolean matchesStatically(MatchingContext context) {
return contextMatch(null); return contextMatch(null);
} }
@Override
public boolean mayNeedDynamicTest() { public boolean mayNeedDynamicTest() {
return false; return false;
} }
@@ -554,7 +570,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
String advisedBeanName = getCurrentProxiedBeanName(); String advisedBeanName = getCurrentProxiedBeanName();
if (advisedBeanName == null) { // no proxy creation in progress if (advisedBeanName == null) { // no proxy creation in progress
// abstain; can't return YES, since that will make pointcut with negation fail // abstain; can't return YES, since that will make pointcut with negation fail
return FuzzyBoolean.MAYBE; return FuzzyBoolean.MAYBE;
} }
if (BeanFactoryUtils.isGeneratedBeanName(advisedBeanName)) { if (BeanFactoryUtils.isGeneratedBeanName(advisedBeanName)) {
return FuzzyBoolean.NO; return FuzzyBoolean.NO;
@@ -610,18 +626,22 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
this.other = other; this.other = other;
} }
@Override
public boolean alwaysMatches() { public boolean alwaysMatches() {
return primary.alwaysMatches(); return primary.alwaysMatches();
} }
@Override
public boolean maybeMatches() { public boolean maybeMatches() {
return primary.maybeMatches(); return primary.maybeMatches();
} }
@Override
public boolean neverMatches() { public boolean neverMatches() {
return primary.neverMatches(); return primary.neverMatches();
} }
@Override
public JoinPointMatch matchesJoinPoint(Object thisObject, public JoinPointMatch matchesJoinPoint(Object thisObject,
Object targetObject, Object[] args) { Object targetObject, Object[] args) {
try { try {
@@ -631,6 +651,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
} }
} }
@Override
public void setMatchingContext(MatchingContext aMatchContext) { public void setMatchingContext(MatchingContext aMatchContext) {
primary.setMatchingContext(aMatchContext); primary.setMatchingContext(aMatchContext);
other.setMatchingContext(aMatchContext); other.setMatchingContext(aMatchContext);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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,15 +21,17 @@ import org.springframework.aop.support.AbstractGenericPointcutAdvisor;
/** /**
* Spring AOP Advisor that can be used for any AspectJ pointcut expression. * Spring AOP Advisor that can be used for any AspectJ pointcut expression.
* *
* @author Rob Harrop * @author Rob Harrop
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor { public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor {
private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@Override
public Pointcut getPointcut() { public Pointcut getPointcut() {
return this.pointcut; return this.pointcut;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -35,14 +35,17 @@ public class AspectJMethodBeforeAdvice extends AbstractAspectJAdvice implements
super(aspectJBeforeAdviceMethod, pointcut, aif); super(aspectJBeforeAdviceMethod, pointcut, aif);
} }
@Override
public void before(Method method, Object[] args, Object target) throws Throwable { public void before(Method method, Object[] args, Object target) throws Throwable {
invokeAdviceMethod(getJoinPointMatch(), null, null); invokeAdviceMethod(getJoinPointMatch(), null, null);
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
return true; return true;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
return false; return false;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -56,18 +56,22 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
} }
@Override
public boolean isPerInstance() { public boolean isPerInstance() {
return true; return true;
} }
@Override
public Advice getAdvice() { public Advice getAdvice() {
return this.advice; return this.advice;
} }
@Override
public Pointcut getPointcut() { public Pointcut getPointcut() {
return this.pointcut; return this.pointcut;
} }
@Override
public int getOrder() { public int getOrder() {
if (this.order != null) { if (this.order != null) {
return this.order; return this.order;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -30,14 +30,14 @@ import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
* @since 2.0 * @since 2.0
*/ */
public abstract class AspectJProxyUtils { public abstract class AspectJProxyUtils {
/** /**
* Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors. * Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors.
* This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching) * This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching)
* and make available the current AspectJ JoinPoint. The call will have no effect if there are no * and make available the current AspectJ JoinPoint. The call will have no effect if there are no
* AspectJ advisors in the advisor chain. * AspectJ advisors in the advisor chain.
* @param advisors Advisors available * @param advisors Advisors available
* @return <code>true</code> if any special {@link Advisor Advisors} were added, otherwise <code>false</code>. * @return {@code true} if any special {@link Advisor Advisors} were added, otherwise {@code false}.
*/ */
public static boolean makeAdvisorChainAspectJCapableIfNecessary(List<Advisor> advisors) { public static boolean makeAdvisorChainAspectJCapableIfNecessary(List<Advisor> advisors) {
// Don't add advisors to an empty list; may indicate that proxying is just not required // Don't add advisors to an empty list; may indicate that proxying is just not required

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -27,13 +27,13 @@ import org.aspectj.bridge.IMessageHandler;
* Implementation of AspectJ's {@link IMessageHandler} interface that * Implementation of AspectJ's {@link IMessageHandler} interface that
* routes AspectJ weaving messages through the same logging system as the * routes AspectJ weaving messages through the same logging system as the
* regular Spring messages. * regular Spring messages.
* *
* <p>Pass the option... * <p>Pass the option...
* *
* <p><code class="code">-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler</code> * <p><code class="code">-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler</code>
* *
* <p>to the weaver; for example, specifying the following in a * <p>to the weaver; for example, specifying the following in a
* "<code>META-INF/aop.xml</code> file: * "{@code META-INF/aop.xml} file:
* *
* <p><code class="code">&lt;weaver options="..."/&gt;</code> * <p><code class="code">&lt;weaver options="..."/&gt;</code>
* *
@@ -44,10 +44,11 @@ import org.aspectj.bridge.IMessageHandler;
public class AspectJWeaverMessageHandler implements IMessageHandler { public class AspectJWeaverMessageHandler implements IMessageHandler {
private static final String AJ_ID = "[AspectJ] "; private static final String AJ_ID = "[AspectJ] ";
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver");
@Override
public boolean handleMessage(IMessage message) throws AbortException { public boolean handleMessage(IMessage message) throws AbortException {
Kind messageKind = message.getKind(); Kind messageKind = message.getKind();
@@ -56,52 +57,55 @@ public class AspectJWeaverMessageHandler implements IMessageHandler {
LOGGER.debug(makeMessageFor(message)); LOGGER.debug(makeMessageFor(message));
return true; return true;
} }
} }
if (LOGGER.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) { if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) {
LOGGER.info(makeMessageFor(message)); LOGGER.info(makeMessageFor(message));
return true; return true;
} }
} }
if (LOGGER.isWarnEnabled()) { if (LOGGER.isWarnEnabled()) {
if (messageKind == IMessage.WARNING) { if (messageKind == IMessage.WARNING) {
LOGGER.warn(makeMessageFor(message)); LOGGER.warn(makeMessageFor(message));
return true; return true;
} }
} }
if (LOGGER.isErrorEnabled()) { if (LOGGER.isErrorEnabled()) {
if (messageKind == IMessage.ERROR) { if (messageKind == IMessage.ERROR) {
LOGGER.error(makeMessageFor(message)); LOGGER.error(makeMessageFor(message));
return true; return true;
} }
} }
if (LOGGER.isFatalEnabled()) { if (LOGGER.isFatalEnabled()) {
if (messageKind == IMessage.ABORT) { if (messageKind == IMessage.ABORT) {
LOGGER.fatal(makeMessageFor(message)); LOGGER.fatal(makeMessageFor(message));
return true; return true;
} }
} }
return false; return false;
} }
private String makeMessageFor(IMessage aMessage) { private String makeMessageFor(IMessage aMessage) {
return AJ_ID + aMessage.getMessage(); return AJ_ID + aMessage.getMessage();
} }
@Override
public boolean isIgnoring(Kind messageKind) { public boolean isIgnoring(Kind messageKind) {
// We want to see everything, and allow configuration of log levels dynamically. // We want to see everything, and allow configuration of log levels dynamically.
return false; return false;
} }
@Override
public void dontIgnore(Kind messageKind) { public void dontIgnore(Kind messageKind) {
// We weren't ignoring anything anyway... // We weren't ignoring anything anyway...
} }
@Override
public void ignore(Kind kind) { public void ignore(Kind kind) {
// We weren't ignoring anything anyway... // We weren't ignoring anything anyway...
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -48,7 +48,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
* @param defaultImpl the default implementation class * @param defaultImpl the default implementation class
*/ */
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) { public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) {
this(interfaceType, typePattern, defaultImpl, this(interfaceType, typePattern, defaultImpl,
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
} }
@@ -59,7 +59,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
* @param delegateRef the delegate implementation object * @param delegateRef the delegate implementation object
*/ */
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) { public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) {
this(interfaceType, typePattern, delegateRef.getClass(), this(interfaceType, typePattern, delegateRef.getClass(),
new DelegatingIntroductionInterceptor(delegateRef)); new DelegatingIntroductionInterceptor(delegateRef));
} }
@@ -77,6 +77,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
// Excludes methods implemented. // Excludes methods implemented.
ClassFilter exclusion = new ClassFilter() { ClassFilter exclusion = new ClassFilter() {
@Override
public boolean matches(Class clazz) { public boolean matches(Class clazz) {
return !(introducedInterface.isAssignableFrom(clazz)); return !(introducedInterface.isAssignableFrom(clazz));
} }
@@ -87,22 +88,27 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
} }
@Override
public ClassFilter getClassFilter() { public ClassFilter getClassFilter() {
return this.typePatternClassFilter; return this.typePatternClassFilter;
} }
@Override
public void validateInterfaces() throws IllegalArgumentException { public void validateInterfaces() throws IllegalArgumentException {
// Do nothing // Do nothing
} }
@Override
public boolean isPerInstance() { public boolean isPerInstance() {
return true; return true;
} }
@Override
public Advice getAdvice() { public Advice getAdvice() {
return this.advice; return this.advice;
} }
@Override
public Class[] getInterfaces() { public Class[] getInterfaces() {
return new Class[] {this.introducedInterface}; return new Class[] {this.introducedInterface};
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -34,11 +34,11 @@ import org.springframework.util.Assert;
* Implementation of AspectJ ProceedingJoinPoint interface * Implementation of AspectJ ProceedingJoinPoint interface
* wrapping an AOP Alliance MethodInvocation. * wrapping an AOP Alliance MethodInvocation.
* *
* <p><b>Note</b>: the <code>getThis()</code> method returns the current Spring AOP proxy. * <p><b>Note</b>: the {@code getThis()} method returns the current Spring AOP proxy.
* The <code>getTarget()</code> method returns the current Spring AOP target (which may be * The {@code getTarget()} method returns the current Spring AOP target (which may be
* <code>null</code> if there is no target), and is a plain POJO without any advice. * {@code null} if there is no target), and is a plain POJO without any advice.
* <b>If you want to call the object and have the advice take effect, use * <b>If you want to call the object and have the advice take effect, use
* <code>getThis()</code>.</b> A common example is casting the object to an * {@code getThis()}.</b> A common example is casting the object to an
* introduced interface in the implementation of an introduction. * introduced interface in the implementation of an introduction.
* *
* <p>Of course there is no such distinction between target and proxy in AspectJ. * <p>Of course there is no such distinction between target and proxy in AspectJ.
@@ -50,7 +50,7 @@ import org.springframework.util.Assert;
* @since 2.0 * @since 2.0
*/ */
public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, JoinPoint.StaticPart { public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, JoinPoint.StaticPart {
private final ProxyMethodInvocation methodInvocation; private final ProxyMethodInvocation methodInvocation;
private Object[] defensiveCopyOfArgs; private Object[] defensiveCopyOfArgs;
@@ -72,14 +72,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
this.methodInvocation = methodInvocation; this.methodInvocation = methodInvocation;
} }
@Override
public void set$AroundClosure(AroundClosure aroundClosure) { public void set$AroundClosure(AroundClosure aroundClosure) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public Object proceed() throws Throwable { public Object proceed() throws Throwable {
return this.methodInvocation.invocableClone().proceed(); return this.methodInvocation.invocableClone().proceed();
} }
@Override
public Object proceed(Object[] arguments) throws Throwable { public Object proceed(Object[] arguments) throws Throwable {
Assert.notNull(arguments, "Argument array passed to proceed cannot be null"); Assert.notNull(arguments, "Argument array passed to proceed cannot be null");
if (arguments.length != this.methodInvocation.getArguments().length) { if (arguments.length != this.methodInvocation.getArguments().length) {
@@ -92,19 +95,22 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
} }
/** /**
* Returns the Spring AOP proxy. Cannot be <code>null</code>. * Returns the Spring AOP proxy. Cannot be {@code null}.
*/ */
@Override
public Object getThis() { public Object getThis() {
return this.methodInvocation.getProxy(); return this.methodInvocation.getProxy();
} }
/** /**
* Returns the Spring AOP target. May be <code>null</code> if there is no target. * Returns the Spring AOP target. May be {@code null} if there is no target.
*/ */
@Override
public Object getTarget() { public Object getTarget() {
return this.methodInvocation.getThis(); return this.methodInvocation.getThis();
} }
@Override
public Object[] getArgs() { public Object[] getArgs() {
if (this.defensiveCopyOfArgs == null) { if (this.defensiveCopyOfArgs == null) {
Object[] argsSource = this.methodInvocation.getArguments(); Object[] argsSource = this.methodInvocation.getArguments();
@@ -114,6 +120,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return this.defensiveCopyOfArgs; return this.defensiveCopyOfArgs;
} }
@Override
public Signature getSignature() { public Signature getSignature() {
if (this.signature == null) { if (this.signature == null) {
this.signature = new MethodSignatureImpl(); this.signature = new MethodSignatureImpl();
@@ -121,6 +128,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return signature; return signature;
} }
@Override
public SourceLocation getSourceLocation() { public SourceLocation getSourceLocation() {
if (this.sourceLocation == null) { if (this.sourceLocation == null) {
this.sourceLocation = new SourceLocationImpl(); this.sourceLocation = new SourceLocationImpl();
@@ -128,23 +136,28 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return this.sourceLocation; return this.sourceLocation;
} }
@Override
public String getKind() { public String getKind() {
return ProceedingJoinPoint.METHOD_EXECUTION; return ProceedingJoinPoint.METHOD_EXECUTION;
} }
@Override
public int getId() { public int getId() {
// TODO: It's just an adapter but returning 0 might still have side effects... // TODO: It's just an adapter but returning 0 might still have side effects...
return 0; return 0;
} }
@Override
public JoinPoint.StaticPart getStaticPart() { public JoinPoint.StaticPart getStaticPart() {
return this; return this;
} }
@Override
public String toShortString() { public String toShortString() {
return "execution(" + getSignature().toShortString() + ")"; return "execution(" + getSignature().toShortString() + ")";
} }
@Override
public String toLongString() { public String toLongString() {
return "execution(" + getSignature().toLongString() + ")"; return "execution(" + getSignature().toLongString() + ")";
} }
@@ -161,34 +174,42 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
private volatile String[] parameterNames; private volatile String[] parameterNames;
@Override
public String getName() { public String getName() {
return methodInvocation.getMethod().getName(); return methodInvocation.getMethod().getName();
} }
@Override
public int getModifiers() { public int getModifiers() {
return methodInvocation.getMethod().getModifiers(); return methodInvocation.getMethod().getModifiers();
} }
@Override
public Class getDeclaringType() { public Class getDeclaringType() {
return methodInvocation.getMethod().getDeclaringClass(); return methodInvocation.getMethod().getDeclaringClass();
} }
@Override
public String getDeclaringTypeName() { public String getDeclaringTypeName() {
return methodInvocation.getMethod().getDeclaringClass().getName(); return methodInvocation.getMethod().getDeclaringClass().getName();
} }
@Override
public Class getReturnType() { public Class getReturnType() {
return methodInvocation.getMethod().getReturnType(); return methodInvocation.getMethod().getReturnType();
} }
@Override
public Method getMethod() { public Method getMethod() {
return methodInvocation.getMethod(); return methodInvocation.getMethod();
} }
@Override
public Class[] getParameterTypes() { public Class[] getParameterTypes() {
return methodInvocation.getMethod().getParameterTypes(); return methodInvocation.getMethod().getParameterTypes();
} }
@Override
public String[] getParameterNames() { public String[] getParameterNames() {
if (this.parameterNames == null) { if (this.parameterNames == null) {
this.parameterNames = (new LocalVariableTableParameterNameDiscoverer()).getParameterNames(getMethod()); this.parameterNames = (new LocalVariableTableParameterNameDiscoverer()).getParameterNames(getMethod());
@@ -196,14 +217,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return this.parameterNames; return this.parameterNames;
} }
@Override
public Class[] getExceptionTypes() { public Class[] getExceptionTypes() {
return methodInvocation.getMethod().getExceptionTypes(); return methodInvocation.getMethod().getExceptionTypes();
} }
@Override
public String toShortString() { public String toShortString() {
return toString(false, false, false, false); return toString(false, false, false, false);
} }
@Override
public String toLongString() { public String toLongString() {
return toString(true, true, true, true); return toString(true, true, true, true);
} }
@@ -267,6 +291,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
*/ */
private class SourceLocationImpl implements SourceLocation { private class SourceLocationImpl implements SourceLocation {
@Override
public Class getWithinType() { public Class getWithinType() {
if (methodInvocation.getThis() == null) { if (methodInvocation.getThis() == null) {
throw new UnsupportedOperationException("No source location joinpoint available: target is null"); throw new UnsupportedOperationException("No source location joinpoint available: target is null");
@@ -274,14 +299,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return methodInvocation.getThis().getClass(); return methodInvocation.getThis().getClass();
} }
@Override
public String getFileName() { public String getFileName() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public int getLine() { public int getLine() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public int getColumn() { public int getColumn() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -39,12 +39,12 @@ import org.springframework.util.ReflectionUtils;
/** /**
* This class encapsulates some AspectJ internal knowledge that should be * This class encapsulates some AspectJ internal knowledge that should be
* pushed back into the AspectJ project in a future release. * pushed back into the AspectJ project in a future release.
* *
* <p>It relies on implementation specific knowledge in AspectJ to break * <p>It relies on implementation specific knowledge in AspectJ to break
* encapsulation and do something AspectJ was not designed to do: query * encapsulation and do something AspectJ was not designed to do: query
* the types of runtime tests that will be performed. The code here should * the types of runtime tests that will be performed. The code here should
* migrate to <code>ShadowMatch.getVariablesInvolvedInRuntimeTest()</code> * migrate to {@code ShadowMatch.getVariablesInvolvedInRuntimeTest()}
* or some similar operation. * or some similar operation.
* *
* <p>See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=151593"/>. * <p>See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=151593"/>.
@@ -106,38 +106,47 @@ class RuntimeTestWalker {
protected static final int AT_TARGET_VAR = 4; protected static final int AT_TARGET_VAR = 4;
protected static final int AT_ANNOTATION_VAR = 8; protected static final int AT_ANNOTATION_VAR = 8;
@Override
public void visit(And e) { public void visit(And e) {
e.getLeft().accept(this); e.getLeft().accept(this);
e.getRight().accept(this); e.getRight().accept(this);
} }
@Override
public void visit(Or e) { public void visit(Or e) {
e.getLeft().accept(this); e.getLeft().accept(this);
e.getRight().accept(this); e.getRight().accept(this);
} }
@Override
public void visit(Not e) { public void visit(Not e) {
e.getBody().accept(this); e.getBody().accept(this);
} }
@Override
public void visit(Instanceof i) { public void visit(Instanceof i) {
} }
@Override
public void visit(Literal literal) { public void visit(Literal literal) {
} }
@Override
public void visit(Call call) { public void visit(Call call) {
} }
@Override
public void visit(FieldGetCall fieldGetCall) { public void visit(FieldGetCall fieldGetCall) {
} }
@Override
public void visit(HasAnnotation hasAnnotation) { public void visit(HasAnnotation hasAnnotation) {
} }
@Override
public void visit(MatchingContextBasedTest matchingContextTest) { public void visit(MatchingContextBasedTest matchingContextTest) {
} }
protected int getVarType(ReflectionVar v) { protected int getVarType(ReflectionVar v) {
try { try {
Field varTypeField = ReflectionVar.class.getDeclaredField("varType"); Field varTypeField = ReflectionVar.class.getDeclaredField("varType");
@@ -169,7 +178,7 @@ class RuntimeTestWalker {
this.matches = defaultMatches; this.matches = defaultMatches;
this.matchVarType = matchVarType; this.matchVarType = matchVarType;
} }
public boolean instanceOfMatches(Test test) { public boolean instanceOfMatches(Test test) {
test.accept(this); test.accept(this);
return matches; return matches;
@@ -236,7 +245,7 @@ class RuntimeTestWalker {
aTest.accept(this); aTest.accept(this);
return this.testsSubtypeSensitiveVars; return this.testsSubtypeSensitiveVars;
} }
@Override @Override
public void visit(Instanceof i) { public void visit(Instanceof i) {
ReflectionVar v = (ReflectionVar) i.getVar(); ReflectionVar v = (ReflectionVar) i.getVar();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -42,13 +42,14 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
} }
/** /**
* Return the specified aspect class (never <code>null</code>). * Return the specified aspect class (never {@code null}).
*/ */
public final Class getAspectClass() { public final Class getAspectClass() {
return this.aspectClass; return this.aspectClass;
} }
@Override
public final Object getAspectInstance() { public final Object getAspectInstance() {
try { try {
return this.aspectClass.newInstance(); return this.aspectClass.newInstance();
@@ -61,6 +62,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
} }
} }
@Override
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
return this.aspectClass.getClassLoader(); return this.aspectClass.getClassLoader();
} }
@@ -73,6 +75,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
* @see org.springframework.core.Ordered * @see org.springframework.core.Ordered
* @see #getOrderForAspectClass * @see #getOrderForAspectClass
*/ */
@Override
public int getOrder() { public int getOrder() {
return getOrderForAspectClass(this.aspectClass); return getOrderForAspectClass(this.aspectClass);
} }
@@ -81,7 +84,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
* Determine a fallback order for the case that the aspect instance * Determine a fallback order for the case that the aspect instance
* does not express an instance-specific order through implementing * does not express an instance-specific order through implementing
* the {@link org.springframework.core.Ordered} interface. * the {@link org.springframework.core.Ordered} interface.
* <p>The default implementation simply returns <code>Ordered.LOWEST_PRECEDENCE</code>. * <p>The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}.
* @param aspectClass the aspect class * @param aspectClass the aspect class
*/ */
protected int getOrderForAspectClass(Class<?> aspectClass) { protected int getOrderForAspectClass(Class<?> aspectClass) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
* @see SimpleAspectInstanceFactory * @see SimpleAspectInstanceFactory
*/ */
public class SingletonAspectInstanceFactory implements AspectInstanceFactory { public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
private final Object aspectInstance; private final Object aspectInstance;
@@ -44,10 +44,12 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
} }
@Override
public final Object getAspectInstance() { public final Object getAspectInstance() {
return this.aspectInstance; return this.aspectInstance;
} }
@Override
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
return this.aspectInstance.getClass().getClassLoader(); return this.aspectInstance.getClass().getClassLoader();
} }
@@ -60,6 +62,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
* @see org.springframework.core.Ordered * @see org.springframework.core.Ordered
* @see #getOrderForAspectClass * @see #getOrderForAspectClass
*/ */
@Override
public int getOrder() { public int getOrder() {
if (this.aspectInstance instanceof Ordered) { if (this.aspectInstance instanceof Ordered) {
return ((Ordered) this.aspectInstance).getOrder(); return ((Ordered) this.aspectInstance).getOrder();
@@ -71,7 +74,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory {
* Determine a fallback order for the case that the aspect instance * Determine a fallback order for the case that the aspect instance
* does not express an instance-specific order through implementing * does not express an instance-specific order through implementing
* the {@link org.springframework.core.Ordered} interface. * the {@link org.springframework.core.Ordered} interface.
* <p>The default implementation simply returns <code>Ordered.LOWEST_PRECEDENCE</code>. * <p>The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}.
* @param aspectClass the aspect class * @param aspectClass the aspect class
*/ */
protected int getOrderForAspectClass(Class<?> aspectClass) { protected int getOrderForAspectClass(Class<?> aspectClass) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -47,11 +47,11 @@ public class TypePatternClassFilter implements ClassFilter {
} }
/** /**
* Create a fully configured {@link TypePatternClassFilter} using the * Create a fully configured {@link TypePatternClassFilter} using the
* given type pattern. * given type pattern.
* @param typePattern the type pattern that AspectJ weaver should parse * @param typePattern the type pattern that AspectJ weaver should parse
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code> * @throws IllegalArgumentException if the supplied {@code typePattern} is {@code null}
* or is recognized as invalid * or is recognized as invalid
*/ */
public TypePatternClassFilter(String typePattern) { public TypePatternClassFilter(String typePattern) {
setTypePattern(typePattern); setTypePattern(typePattern);
@@ -68,12 +68,12 @@ public class TypePatternClassFilter implements ClassFilter {
* <code class="code"> * <code class="code">
* org.springframework.beans.ITestBean+ * org.springframework.beans.ITestBean+
* </code> * </code>
* This will match the <code>ITestBean</code> interface and any class * This will match the {@code ITestBean} interface and any class
* that implements it. * that implements it.
* <p>These conventions are established by AspectJ, not Spring AOP. * <p>These conventions are established by AspectJ, not Spring AOP.
* @param typePattern the type pattern that AspectJ weaver should parse * @param typePattern the type pattern that AspectJ weaver should parse
* @throws IllegalArgumentException if the supplied <code>typePattern</code> is <code>null</code> * @throws IllegalArgumentException if the supplied {@code typePattern} is {@code null}
* or is recognized as invalid * or is recognized as invalid
*/ */
public void setTypePattern(String typePattern) { public void setTypePattern(String typePattern) {
Assert.notNull(typePattern); Assert.notNull(typePattern);
@@ -93,6 +93,7 @@ public class TypePatternClassFilter implements ClassFilter {
* @return whether the advice should apply to this candidate target class * @return whether the advice should apply to this candidate target class
* @throws IllegalStateException if no {@link #setTypePattern(String)} has been set * @throws IllegalStateException if no {@link #setTypePattern(String)} has been set
*/ */
@Override
public boolean matches(Class clazz) { public boolean matches(Class clazz) {
if (this.aspectJTypePatternMatcher == null) { if (this.aspectJTypePatternMatcher == null) {
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter."); throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
@@ -102,9 +103,9 @@ public class TypePatternClassFilter implements ClassFilter {
/** /**
* If a type pattern has been specified in XML, the user cannot * If a type pattern has been specified in XML, the user cannot
* write <code>and</code> as "&&" (though &amp;&amp; will work). * write {@code and} as "&&" (though &amp;&amp; will work).
* We also allow <code>and</code> between two sub-expressions. * We also allow {@code and} between two sub-expressions.
* <p>This method converts back to <code>&&</code> for the AspectJ pointcut parser. * <p>This method converts back to {@code &&} for the AspectJ pointcut parser.
*/ */
private String replaceBooleanOperators(String pcExpr) { private String replaceBooleanOperators(String pcExpr) {
pcExpr = StringUtils.replace(pcExpr," and "," && "); pcExpr = StringUtils.replace(pcExpr," and "," && ");

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -58,7 +58,7 @@ import org.springframework.util.StringUtils;
* @since 2.0 * @since 2.0
*/ */
public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory { public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory {
protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER = protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER =
new AspectJAnnotationParameterNameDiscoverer(); new AspectJAnnotationParameterNameDiscoverer();
@@ -111,6 +111,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
* is that aspects written in the code-style (AspectJ language) also have the annotation present * is that aspects written in the code-style (AspectJ language) also have the annotation present
* when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP. * when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.
*/ */
@Override
public boolean isAspect(Class<?> clazz) { public boolean isAspect(Class<?> clazz) {
return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz)); return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
} }
@@ -121,7 +122,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
/** /**
* We need to detect this as "code-style" AspectJ aspects should not be * We need to detect this as "code-style" AspectJ aspects should not be
* interpreted by Spring AOP. * interpreted by Spring AOP.
*/ */
private boolean compiledByAjc(Class<?> clazz) { private boolean compiledByAjc(Class<?> clazz) {
// The AJTypeSystem goes to great lengths to provide a uniform appearance between code-style and // The AJTypeSystem goes to great lengths to provide a uniform appearance between code-style and
@@ -135,6 +136,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
return false; return false;
} }
@Override
public void validate(Class<?> aspectClass) throws AopConfigException { public void validate(Class<?> aspectClass) throws AopConfigException {
// If the parent has the annotation and isn't abstract it's an error // If the parent has the annotation and isn't abstract it's an error
if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null && if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null &&
@@ -154,11 +156,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) { if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) {
throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " +
"This is not supported in Spring AOP."); "This is not supported in Spring AOP.");
} }
} }
/** /**
* The pointcut and advice annotations both have an "argNames" member which contains a * The pointcut and advice annotations both have an "argNames" member which contains a
* comma-separated list of the argument names. We use this (if non-empty) to build the * comma-separated list of the argument names. We use this (if non-empty) to build the
* formal parameters for the pointcut. * formal parameters for the pointcut.
*/ */
@@ -169,13 +171,13 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
if (pointcutParameterNames != null) { if (pointcutParameterNames != null) {
pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod); pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod);
} }
AspectJExpressionPointcut ajexp = AspectJExpressionPointcut ajexp =
new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes); new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes);
ajexp.setLocation(annotatedMethod.toString()); ajexp.setLocation(annotatedMethod.toString());
return ajexp; return ajexp;
} }
/** /**
* Create the pointcut parameters needed by aspectj based on the given argument names * Create the pointcut parameters needed by aspectj based on the given argument names
* and the argument types that are available from the adviceMethod. Needs to take into * and the argument types that are available from the adviceMethod. Needs to take into
@@ -309,6 +311,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
*/ */
private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer { private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer {
@Override
public String[] getParameterNames(Method method) { public String[] getParameterNames(Method method) {
if (method.getParameterTypes().length == 0) { if (method.getParameterTypes().length == 0) {
return new String[0]; return new String[0];
@@ -326,10 +329,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
return names; return names;
} }
else { else {
return null; return null;
} }
} }
@Override
public String[] getParameterNames(Constructor ctor) { public String[] getParameterNames(Constructor ctor) {
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice"); throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
* @since 2.0 * @since 2.0
* @see org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory * @see org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory
*/ */
@SuppressWarnings("serial")
public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorAutoProxyCreator { public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorAutoProxyCreator {
private List<Pattern> includePatterns; private List<Pattern> includePatterns;
@@ -103,7 +104,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA
/** /**
* Check whether the given aspect bean is eligible for auto-proxying. * Check whether the given aspect bean is eligible for auto-proxying.
* <p>If no &lt;aop:include&gt; elements were used then "includePatterns" will be * <p>If no &lt;aop:include&gt; elements were used then "includePatterns" will be
* <code>null</code> and all beans are included. If "includePatterns" is non-null, * {@code null} and all beans are included. If "includePatterns" is non-null,
* then one of the patterns must match. * then one of the patterns must match.
*/ */
protected boolean isEligibleAspectBean(String beanName) { protected boolean isEligibleAspectBean(String beanName) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -40,7 +40,7 @@ public interface AspectJAdvisorFactory {
/** /**
* Determine whether or not the given class is an aspect, as reported * Determine whether or not the given class is an aspect, as reported
* by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}. * by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}.
* <p>Will simply return <code>false</code> if the supposed aspect is * <p>Will simply return {@code false} if the supposed aspect is
* invalid (such as an extension of a concrete aspect class). * invalid (such as an extension of a concrete aspect class).
* Will return true for some aspects that Spring AOP cannot process, * Will return true for some aspects that Spring AOP cannot process,
* such as those with unsupported instantiation models. * such as those with unsupported instantiation models.
@@ -75,7 +75,7 @@ public interface AspectJAdvisorFactory {
* @param aif the aspect instance factory * @param aif the aspect instance factory
* @param declarationOrderInAspect the declaration order within the aspect * @param declarationOrderInAspect the declaration order within the aspect
* @param aspectName the name of the aspect * @param aspectName the name of the aspect
* @return <code>null</code> if the method is not an AspectJ advice method * @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not * or if it is a pointcut that will be used by other advice but will not
* create a Spring advice in its own right * create a Spring advice in its own right
*/ */
@@ -89,7 +89,7 @@ public interface AspectJAdvisorFactory {
* @param aif the aspect instance factory * @param aif the aspect instance factory
* @param declarationOrderInAspect the declaration order within the aspect * @param declarationOrderInAspect the declaration order within the aspect
* @param aspectName the name of the aspect * @param aspectName the name of the aspect
* @return <code>null</code> if the method is not an AspectJ advice method * @return {@code null} if the method is not an AspectJ advice method
* or if it is a pointcut that will be used by other advice but will not * or if it is a pointcut that will be used by other advice but will not
* create a Spring advice in its own right * create a Spring advice in its own right
* @see org.springframework.aop.aspectj.AspectJAroundAdvice * @see org.springframework.aop.aspectj.AspectJAroundAdvice

View File

@@ -46,6 +46,7 @@ import org.springframework.util.ClassUtils;
* @see #getProxy(ClassLoader) * @see #getProxy(ClassLoader)
* @see org.springframework.aop.framework.ProxyFactory * @see org.springframework.aop.framework.ProxyFactory
*/ */
@SuppressWarnings("serial")
public class AspectJProxyFactory extends ProxyCreatorSupport { public class AspectJProxyFactory extends ProxyCreatorSupport {
/** Cache for singleton aspect instances */ /** Cache for singleton aspect instances */
@@ -72,7 +73,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
} }
/** /**
* Create a new <code>AspectJProxyFactory</code>. * Create a new {@code AspectJProxyFactory}.
* No target, only interfaces. Must add interceptors. * No target, only interfaces. Must add interceptors.
*/ */
public AspectJProxyFactory(Class[] interfaces) { public AspectJProxyFactory(Class[] interfaces) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -55,8 +55,8 @@ public class AspectMetadata {
private final Pointcut perClausePointcut; private final Pointcut perClausePointcut;
/** /**
* The name of this aspect as defined to Spring (the bean name) - * The name of this aspect as defined to Spring (the bean name) -
* allows us to determine if two pieces of advice come from the * allows us to determine if two pieces of advice come from the
* same aspect and hence their relative precedence. * same aspect and hence their relative precedence.
*/ */
private String aspectName; private String aspectName;
@@ -109,7 +109,7 @@ public class AspectMetadata {
} }
/** /**
* Extract contents from String of form <code>pertarget(contents)</code>. * Extract contents from String of form {@code pertarget(contents)}.
*/ */
private String findPerClause(Class<?> aspectClass) { private String findPerClause(Class<?> aspectClass) {
// TODO when AspectJ provides this, we can remove this hack. Hence we don't // TODO when AspectJ provides this, we can remove this hack. Hence we don't
@@ -144,7 +144,7 @@ public class AspectMetadata {
/** /**
* Return a Spring pointcut expression for a singleton aspect. * Return a Spring pointcut expression for a singleton aspect.
* (e.g. <code>Pointcut.TRUE</code> if it's a singleton). * (e.g. {@code Pointcut.TRUE} if it's a singleton).
*/ */
public Pointcut getPerClausePointcut() { public Pointcut getPerClausePointcut() {
return this.perClausePointcut; return this.perClausePointcut;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -27,7 +27,7 @@ import org.springframework.util.ClassUtils;
* backed by a Spring {@link org.springframework.beans.factory.BeanFactory}. * backed by a Spring {@link org.springframework.beans.factory.BeanFactory}.
* *
* <p>Note that this may instantiate multiple times if using a prototype, * <p>Note that this may instantiate multiple times if using a prototype,
* which probably won't give the semantics you expect. * which probably won't give the semantics you expect.
* Use a {@link LazySingletonAspectInstanceFactoryDecorator} * Use a {@link LazySingletonAspectInstanceFactoryDecorator}
* to wrap this to ensure only one new aspect comes back. * to wrap this to ensure only one new aspect comes back.
* *
@@ -56,7 +56,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name) { public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name) {
this(beanFactory, name, beanFactory.getType(name)); this(beanFactory, name, beanFactory.getType(name));
} }
/** /**
* Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should * Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should
* introspect to create AJType metadata. Use if the BeanFactory may consider the type * introspect to create AJType metadata. Use if the BeanFactory may consider the type
@@ -72,10 +72,12 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
} }
@Override
public Object getAspectInstance() { public Object getAspectInstance() {
return this.beanFactory.getBean(this.name); return this.beanFactory.getBean(this.name);
} }
@Override
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) { if (this.beanFactory instanceof ConfigurableBeanFactory) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
@@ -85,6 +87,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
} }
} }
@Override
public AspectMetadata getAspectMetadata() { public AspectMetadata getAspectMetadata() {
return this.aspectMetadata; return this.aspectMetadata;
} }
@@ -99,6 +102,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
* @see org.springframework.core.Ordered * @see org.springframework.core.Ordered
* @see org.springframework.core.annotation.Order * @see org.springframework.core.annotation.Order
*/ */
@Override
public int getOrder() { public int getOrder() {
Class<?> type = this.beanFactory.getType(this.name); Class<?> type = this.beanFactory.getType(this.name);
if (type != null) { if (type != null) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -41,23 +41,23 @@ class InstantiationModelAwarePointcutAdvisorImpl
implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation { implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation {
private final AspectJExpressionPointcut declaredPointcut; private final AspectJExpressionPointcut declaredPointcut;
private Pointcut pointcut; private Pointcut pointcut;
private final MetadataAwareAspectInstanceFactory aspectInstanceFactory; private final MetadataAwareAspectInstanceFactory aspectInstanceFactory;
private final Method method; private final Method method;
private final boolean lazy; private final boolean lazy;
private final AspectJAdvisorFactory atAspectJAdvisorFactory; private final AspectJAdvisorFactory atAspectJAdvisorFactory;
private Advice instantiatedAdvice; private Advice instantiatedAdvice;
private int declarationOrder; private int declarationOrder;
private String aspectName; private String aspectName;
private Boolean isBeforeAdvice; private Boolean isBeforeAdvice;
private Boolean isAfterAdvice; private Boolean isAfterAdvice;
@@ -72,12 +72,12 @@ class InstantiationModelAwarePointcutAdvisorImpl
this.aspectInstanceFactory = aif; this.aspectInstanceFactory = aif;
this.declarationOrder = declarationOrderInAspect; this.declarationOrder = declarationOrderInAspect;
this.aspectName = aspectName; this.aspectName = aspectName;
if (aif.getAspectMetadata().isLazilyInstantiated()) { if (aif.getAspectMetadata().isLazilyInstantiated()) {
// Static part of the pointcut is a lazy type. // Static part of the pointcut is a lazy type.
Pointcut preInstantiationPointcut = Pointcut preInstantiationPointcut =
Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut); Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut);
// Make it dynamic: must mutate from pre-instantiation to post-instantiation state. // Make it dynamic: must mutate from pre-instantiation to post-instantiation state.
// If it's not a dynamic pointcut, it may be optimized out // If it's not a dynamic pointcut, it may be optimized out
// by the Spring AOP infrastructure after the first evaluation. // by the Spring AOP infrastructure after the first evaluation.
@@ -97,19 +97,21 @@ class InstantiationModelAwarePointcutAdvisorImpl
* The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change * The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change
* depending on the state of the advice. * depending on the state of the advice.
*/ */
@Override
public Pointcut getPointcut() { public Pointcut getPointcut() {
return this.pointcut; return this.pointcut;
} }
/** /**
* This is only of interest for Spring AOP: AspectJ instantiation semantics * This is only of interest for Spring AOP: AspectJ instantiation semantics
* are much richer. In AspectJ terminology, all a return of <code>true</code> * are much richer. In AspectJ terminology, all a return of {@code true}
* means here is that the aspect is not a SINGLETON. * means here is that the aspect is not a SINGLETON.
*/ */
@Override
public boolean isPerInstance() { public boolean isPerInstance() {
return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON);
} }
/** /**
* Return the AspectJ AspectMetadata for this advisor. * Return the AspectJ AspectMetadata for this advisor.
*/ */
@@ -120,17 +122,20 @@ class InstantiationModelAwarePointcutAdvisorImpl
/** /**
* Lazily instantiate advice if necessary. * Lazily instantiate advice if necessary.
*/ */
@Override
public synchronized Advice getAdvice() { public synchronized Advice getAdvice() {
if (this.instantiatedAdvice == null) { if (this.instantiatedAdvice == null) {
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut); this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
} }
return this.instantiatedAdvice; return this.instantiatedAdvice;
} }
@Override
public boolean isLazy() { public boolean isLazy() {
return this.lazy; return this.lazy;
} }
@Override
public synchronized boolean isAdviceInstantiated() { public synchronized boolean isAdviceInstantiated() {
return (this.instantiatedAdvice != null); return (this.instantiatedAdvice != null);
} }
@@ -140,7 +145,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
return this.atAspectJAdvisorFactory.getAdvice( return this.atAspectJAdvisorFactory.getAdvice(
this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName); this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
} }
public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() { public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() {
return this.aspectInstanceFactory; return this.aspectInstanceFactory;
} }
@@ -149,18 +154,22 @@ class InstantiationModelAwarePointcutAdvisorImpl
return this.declaredPointcut; return this.declaredPointcut;
} }
@Override
public int getOrder() { public int getOrder() {
return this.aspectInstanceFactory.getOrder(); return this.aspectInstanceFactory.getOrder();
} }
@Override
public String getAspectName() { public String getAspectName() {
return this.aspectName; return this.aspectName;
} }
@Override
public int getDeclarationOrder() { public int getDeclarationOrder() {
return this.declarationOrder; return this.declarationOrder;
} }
@Override
public boolean isBeforeAdvice() { public boolean isBeforeAdvice() {
if (this.isBeforeAdvice == null) { if (this.isBeforeAdvice == null) {
determineAdviceType(); determineAdviceType();
@@ -168,6 +177,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
return this.isBeforeAdvice; return this.isBeforeAdvice;
} }
@Override
public boolean isAfterAdvice() { public boolean isAfterAdvice() {
if (this.isAfterAdvice == null) { if (this.isAfterAdvice == null) {
determineAdviceType(); determineAdviceType();
@@ -245,6 +255,7 @@ class InstantiationModelAwarePointcutAdvisorImpl
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass); this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
} }
@Override
public boolean matches(Method method, Class targetClass, Object[] args) { public boolean matches(Method method, Class targetClass, Object[] args) {
// This can match only on declared pointcut. // This can match only on declared pointcut.
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)); return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -42,6 +42,7 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
} }
@Override
public synchronized Object getAspectInstance() { public synchronized Object getAspectInstance() {
if (this.materialized == null) { if (this.materialized == null) {
synchronized (this) { synchronized (this) {
@@ -57,14 +58,17 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar
return (this.materialized != null); return (this.materialized != null);
} }
@Override
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
return this.maaif.getAspectClassLoader(); return this.maaif.getAspectClassLoader();
} }
@Override
public AspectMetadata getAspectMetadata() { public AspectMetadata getAspectMetadata() {
return this.maaif.getAspectMetadata(); return this.maaif.getAspectMetadata();
} }
@Override
public int getOrder() { public int getOrder() {
return this.maaif.getOrder(); return this.maaif.getOrder();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,6 +26,7 @@ import org.springframework.aop.framework.AopConfigException;
* @author Rod Johnson * @author Rod Johnson
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public class NotAnAtAspectException extends AopConfigException { public class NotAnAtAspectException extends AopConfigException {
private Class<?> nonAspectClass; private Class<?> nonAspectClass;

View File

@@ -75,6 +75,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
new InstanceComparator<Annotation>( new InstanceComparator<Annotation>(
Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class), Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class),
new Converter<Method, Annotation>() { new Converter<Method, Annotation>() {
@Override
public Annotation convert(Method method) { public Annotation convert(Method method) {
AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); AspectJAnnotation<?> annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method);
return annotation == null ? null : annotation.getAnnotation(); return annotation == null ? null : annotation.getAnnotation();
@@ -82,6 +83,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
})); }));
comparator.addComparator(new ConvertingComparator<Method, String>( comparator.addComparator(new ConvertingComparator<Method, String>(
new Converter<Method, String>() { new Converter<Method, String>() {
@Override
public String convert(Method method) { public String convert(Method method) {
return method.getName(); return method.getName();
} }
@@ -90,6 +92,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
} }
@Override
public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) { public List<Advisor> getAdvisors(MetadataAwareAspectInstanceFactory maaif) {
final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass(); final Class<?> aspectClass = maaif.getAspectMetadata().getAspectClass();
final String aspectName = maaif.getAspectMetadata().getAspectName(); final String aspectName = maaif.getAspectMetadata().getAspectName();
@@ -128,6 +131,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
private List<Method> getAdvisorMethods(Class<?> aspectClass) { private List<Method> getAdvisorMethods(Class<?> aspectClass) {
final List<Method> methods = new LinkedList<Method>(); final List<Method> methods = new LinkedList<Method>();
ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() { ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
@Override
public void doWith(Method method) throws IllegalArgumentException { public void doWith(Method method) throws IllegalArgumentException {
// Exclude pointcuts // Exclude pointcuts
if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) { if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) {
@@ -144,7 +148,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
* for the given introduction field. * for the given introduction field.
* <p>Resulting Advisors will need to be evaluated for targets. * <p>Resulting Advisors will need to be evaluated for targets.
* @param introductionField the field to introspect * @param introductionField the field to introspect
* @return <code>null</code> if not an Advisor * @return {@code null} if not an Advisor
*/ */
private Advisor getDeclareParentsAdvisor(Field introductionField) { private Advisor getDeclareParentsAdvisor(Field introductionField) {
DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class); DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class);
@@ -164,6 +168,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
} }
@Override
public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif, public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif,
int declarationOrderInAspect, String aspectName) { int declarationOrderInAspect, String aspectName) {
@@ -191,6 +196,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
} }
@Override
public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp, public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp,
MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) { MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) {
@@ -203,7 +209,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return null; return null;
} }
// If we get here, we know we have an AspectJ method. // If we get here, we know we have an AspectJ method.
// Check that it's an AspectJ-annotated class // Check that it's an AspectJ-annotated class
if (!isAspect(candidateAspectClass)) { if (!isAspect(candidateAspectClass)) {
throw new AopConfigException("Advice must be declared inside an aspect type: " + throw new AopConfigException("Advice must be declared inside an aspect type: " +
@@ -272,6 +278,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) { public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() { super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
@Override
public void before(Method method, Object[] args, Object target) { public void before(Method method, Object[] args, Object target) {
// Simply instantiate the aspect // Simply instantiate the aspect
aif.getAspectInstance(); aif.getAspectInstance();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -45,6 +45,7 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan
} }
@Override
public final AspectMetadata getAspectMetadata() { public final AspectMetadata getAspectMetadata() {
return this.metadata; return this.metadata;
} }
@@ -53,7 +54,7 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan
* Determine a fallback order for the case that the aspect instance * Determine a fallback order for the case that the aspect instance
* does not express an instance-specific order through implementing * does not express an instance-specific order through implementing
* the {@link org.springframework.core.Ordered} interface. * the {@link org.springframework.core.Ordered} interface.
* <p>The default implementation simply returns <code>Ordered.LOWEST_PRECEDENCE</code>. * <p>The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}.
* @param aspectClass the aspect class * @param aspectClass the aspect class
*/ */
@Override @Override

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -47,6 +47,7 @@ public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspect
} }
@Override
public final AspectMetadata getAspectMetadata() { public final AspectMetadata getAspectMetadata() {
return this.metadata; return this.metadata;
} }
@@ -54,7 +55,7 @@ public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspect
/** /**
* Check whether the aspect class carries an * Check whether the aspect class carries an
* {@link org.springframework.core.annotation.Order} annotation, * {@link org.springframework.core.annotation.Order} annotation,
* falling back to <code>Ordered.LOWEST_PRECEDENCE</code>. * falling back to {@code Ordered.LOWEST_PRECEDENCE}.
* @see org.springframework.core.annotation.Order * @see org.springframework.core.annotation.Order
*/ */
@Override @Override

View File

@@ -2,7 +2,7 @@
/** /**
* *
* Classes enabling AspectJ 5 @Annotated classes to be used in Spring AOP. * Classes enabling AspectJ 5 @Annotated classes to be used in Spring AOP.
* *
* <p>Normally to be used through an AspectJAutoProxyCreator rather than directly. * <p>Normally to be used through an AspectJAutoProxyCreator rather than directly.
* *
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -43,6 +43,7 @@ import org.springframework.util.ClassUtils;
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @since 2.0 * @since 2.0
*/ */
@SuppressWarnings("serial")
public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator { public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {
private static final Comparator DEFAULT_PRECEDENCE_COMPARATOR = new AspectJPrecedenceComparator(); private static final Comparator DEFAULT_PRECEDENCE_COMPARATOR = new AspectJPrecedenceComparator();
@@ -72,22 +73,22 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
for (Advisor element : advisors) { for (Advisor element : advisors) {
partiallyComparableAdvisors.add( partiallyComparableAdvisors.add(
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR)); new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR));
} }
// sort it // sort it
List<PartiallyComparableAdvisorHolder> sorted = List<PartiallyComparableAdvisorHolder> sorted =
(List<PartiallyComparableAdvisorHolder>) PartialOrder.sort(partiallyComparableAdvisors); PartialOrder.sort(partiallyComparableAdvisors);
if (sorted == null) { if (sorted == null) {
// TODO: work harder to give a better error message here. // TODO: work harder to give a better error message here.
throw new IllegalArgumentException("Advice precedence circularity error"); throw new IllegalArgumentException("Advice precedence circularity error");
} }
// extract results again // extract results again
List<Advisor> result = new LinkedList<Advisor>(); List<Advisor> result = new LinkedList<Advisor>();
for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) { for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
result.add(pcAdvisor.getAdvisor()); result.add(pcAdvisor.getAdvisor());
} }
return result; return result;
} }
@@ -130,11 +131,13 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
this.comparator = comparator; this.comparator = comparator;
} }
@Override
public int compareTo(Object obj) { public int compareTo(Object obj) {
Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor; Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor;
return this.comparator.compare(this.advisor, otherAdvisor); return this.comparator.compare(this.advisor, otherAdvisor);
} }
@Override
public int fallbackCompareTo(Object obj) { public int fallbackCompareTo(Object obj) {
return 0; return 0;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -27,15 +27,15 @@ import org.springframework.util.Assert;
/** /**
* Orders AspectJ advice/advisors by precedence (<i>not</i> invocation order). * Orders AspectJ advice/advisors by precedence (<i>not</i> invocation order).
* *
* <p>Given two pieces of advice, <code>a</code> and <code>b</code>: * <p>Given two pieces of advice, {@code a} and {@code b}:
* <ul> * <ul>
* <li>if <code>a</code> and <code>b</code> are defined in different * <li>if {@code a} and {@code b} are defined in different
* aspects, then the advice in the aspect with the lowest order * aspects, then the advice in the aspect with the lowest order
* value has the highest precedence</li> * value has the highest precedence</li>
* <li>if <code>a</code> and <code>b</code> are defined in the same * <li>if {@code a} and {@code b} are defined in the same
* aspect, then if one of <code>a</code> or <code>b</code> is a form of * aspect, then if one of {@code a} or {@code b} is a form of
* after advice, then the advice declared last in the aspect has the * after advice, then the advice declared last in the aspect has the
* highest precedence. If neither <code>a</code> nor <code>b</code> is a * highest precedence. If neither {@code a} nor {@code b} is a
* form of after advice, then the advice declared first in the aspect has * form of after advice, then the advice declared first in the aspect has
* the highest precedence.</li> * the highest precedence.</li>
* </ul> * </ul>
@@ -76,6 +76,7 @@ class AspectJPrecedenceComparator implements Comparator {
} }
@Override
public int compare(Object o1, Object o2) { public int compare(Object o1, Object o2) {
if (!(o1 instanceof Advisor && o2 instanceof Advisor)) { if (!(o1 instanceof Advisor && o2 instanceof Advisor)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -106,14 +107,14 @@ class AspectJPrecedenceComparator implements Comparator {
boolean oneOrOtherIsAfterAdvice = boolean oneOrOtherIsAfterAdvice =
(AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2)); (AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2));
int adviceDeclarationOrderDelta = getAspectDeclarationOrder(advisor1) - getAspectDeclarationOrder(advisor2); int adviceDeclarationOrderDelta = getAspectDeclarationOrder(advisor1) - getAspectDeclarationOrder(advisor2);
if (oneOrOtherIsAfterAdvice) { if (oneOrOtherIsAfterAdvice) {
// the advice declared last has higher precedence // the advice declared last has higher precedence
if (adviceDeclarationOrderDelta < 0) { if (adviceDeclarationOrderDelta < 0) {
// advice1 was declared before advice2 // advice1 was declared before advice2
// so advice1 has lower precedence // so advice1 has lower precedence
return LOWER_PRECEDENCE; return LOWER_PRECEDENCE;
} }
else if (adviceDeclarationOrderDelta == 0) { else if (adviceDeclarationOrderDelta == 0) {
return SAME_PRECEDENCE; return SAME_PRECEDENCE;
} }
@@ -153,7 +154,7 @@ class AspectJPrecedenceComparator implements Comparator {
} }
private int getAspectDeclarationOrder(Advisor anAdvisor) { private int getAspectDeclarationOrder(Advisor anAdvisor) {
AspectJPrecedenceInformation precedenceInfo = AspectJPrecedenceInformation precedenceInfo =
AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor); AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor);
if (precedenceInfo != null) { if (precedenceInfo != null) {
return precedenceInfo.getDeclarationOrder(); return precedenceInfo.getDeclarationOrder();

View File

@@ -1,12 +1,11 @@
/** /**
* *
* AspectJ integration package. Includes Spring AOP advice implementations for AspectJ 5 * AspectJ integration package. Includes Spring AOP advice implementations for AspectJ 5
* annotation-style methods, and an AspectJExpressionPointcut: a Spring AOP Pointcut * annotation-style methods, and an AspectJExpressionPointcut: a Spring AOP Pointcut
* implementation that allows use of the AspectJ pointcut expression language with the Spring AOP * implementation that allows use of the AspectJ pointcut expression language with the Spring AOP
* runtime framework. * runtime framework.
* *
* <p>Note that use of this package does <i>not</i> require the use of the <code>ajc</code> compiler * <p>Note that use of this package does <i>not</i> require the use of the {@code ajc} compiler
* or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ * or AspectJ load-time weaver. It is intended to enable the use of a valuable subset of AspectJ
* functionality, with consistent semantics, with the proxy-based Spring AOP framework. * functionality, with consistent semantics, with the proxy-based Spring AOP framework.
* *

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -40,7 +40,7 @@ import org.springframework.util.StringUtils;
* to the resulting bean. * to the resulting bean.
* *
* <p>This base class controls the creation of the {@link ProxyFactoryBean} bean definition * <p>This base class controls the creation of the {@link ProxyFactoryBean} bean definition
* and wraps the original as an inner-bean definition for the <code>target</code> property * and wraps the original as an inner-bean definition for the {@code target} property
* of {@link ProxyFactoryBean}. * of {@link ProxyFactoryBean}.
* *
* <p>Chaining is correctly handled, ensuring that only one {@link ProxyFactoryBean} definition * <p>Chaining is correctly handled, ensuring that only one {@link ProxyFactoryBean} definition
@@ -48,7 +48,7 @@ import org.springframework.util.StringUtils;
* already created the {@link org.springframework.aop.framework.ProxyFactoryBean} then the * already created the {@link org.springframework.aop.framework.ProxyFactoryBean} then the
* interceptor is simply added to the existing definition. * interceptor is simply added to the existing definition.
* *
* <p>Subclasses have only to create the <code>BeanDefinition</code> to the interceptor that * <p>Subclasses have only to create the {@code BeanDefinition} to the interceptor that
* they wish to add. * they wish to add.
* *
* @author Rob Harrop * @author Rob Harrop
@@ -58,9 +58,10 @@ import org.springframework.util.StringUtils;
*/ */
public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implements BeanDefinitionDecorator { public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implements BeanDefinitionDecorator {
@Override
public final BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definitionHolder, ParserContext parserContext) { public final BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definitionHolder, ParserContext parserContext) {
BeanDefinitionRegistry registry = parserContext.getRegistry(); BeanDefinitionRegistry registry = parserContext.getRegistry();
// get the root bean name - will be the name of the generated proxy factory bean // get the root bean name - will be the name of the generated proxy factory bean
String existingBeanName = definitionHolder.getBeanName(); String existingBeanName = definitionHolder.getBeanName();
BeanDefinition targetDefinition = definitionHolder.getBeanDefinition(); BeanDefinition targetDefinition = definitionHolder.getBeanDefinition();
@@ -118,7 +119,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement
} }
/** /**
* Subclasses should implement this method to return the <code>BeanDefinition</code> * Subclasses should implement this method to return the {@code BeanDefinition}
* for the interceptor they wish to apply to the bean being decorated. * for the interceptor they wish to apply to the bean being decorated.
*/ */
protected abstract BeanDefinition createInterceptorDefinition(Node node); protected abstract BeanDefinition createInterceptorDefinition(Node node);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
/** /**
* {@link ParseState} entry representing an advice element. * {@link ParseState} entry representing an advice element.
* *
* @author Mark Fisher * @author Mark Fisher
* @since 2.0 * @since 2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.util.Assert;
/** /**
* {@link org.springframework.beans.factory.parsing.ComponentDefinition} * {@link org.springframework.beans.factory.parsing.ComponentDefinition}
* that bridges the gap between the advisor bean definition configured * that bridges the gap between the advisor bean definition configured
* by the <code>&lt;aop:advisor&gt;</code> tag and the component definition * by the {@code &lt;aop:advisor&gt;} tag and the component definition
* infrastructure. * infrastructure.
* *
* @author Rob Harrop * @author Rob Harrop
@@ -91,6 +91,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
} }
@Override
public String getName() { public String getName() {
return this.advisorBeanName; return this.advisorBeanName;
} }
@@ -110,6 +111,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition {
return this.beanReferences; return this.beanReferences;
} }
@Override
public Object getSource() { public Object getSource() {
return this.advisorDefinition.getSource(); return this.advisorDefinition.getSource();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
/** /**
* {@link ParseState} entry representing an advisor. * {@link ParseState} entry representing an advisor.
* *
* @author Mark Fisher * @author Mark Fisher
* @since 2.0 * @since 2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -31,10 +31,10 @@ import org.springframework.util.Assert;
/** /**
* Utility class for handling registration of AOP auto-proxy creators. * Utility class for handling registration of AOP auto-proxy creators.
* *
* <p>Only a single auto-proxy creator can be registered yet multiple concrete * <p>Only a single auto-proxy creator can be registered yet multiple concrete
* implementations are available. Therefore this class wraps a simple escalation * implementations are available. Therefore this class wraps a simple escalation
* protocol, allowing classes to request a particular auto-proxy creator and know * protocol, allowing classes to request a particular auto-proxy creator and know
* that class, <code>or a subclass thereof</code>, will eventually be resident * that class, {@code or a subclass thereof}, will eventually be resident
* in the application context. * in the application context.
* *
* @author Rob Harrop * @author Rob Harrop

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,21 +21,21 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport; import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/** /**
* <code>NamespaceHandler</code> for the <code>aop</code> namespace. * {@code NamespaceHandler} for the {@code aop} namespace.
* *
* <p>Provides a {@link org.springframework.beans.factory.xml.BeanDefinitionParser} for the * <p>Provides a {@link org.springframework.beans.factory.xml.BeanDefinitionParser} for the
* <code>&lt;aop:config&gt;</code> tag. A <code>config</code> tag can include nested * {@code &lt;aop:config&gt;} tag. A {@code config} tag can include nested
* <code>pointcut</code>, <code>advisor</code> and <code>aspect</code> tags. * {@code pointcut}, {@code advisor} and {@code aspect} tags.
* *
* <p>The <code>pointcut</code> tag allows for creation of named * <p>The {@code pointcut} tag allows for creation of named
* {@link AspectJExpressionPointcut} beans using a simple syntax: * {@link AspectJExpressionPointcut} beans using a simple syntax:
* <pre class="code"> * <pre class="code">
* &lt;aop:pointcut id=&quot;getNameCalls&quot; expression=&quot;execution(* *..ITestBean.getName(..))&quot;/&gt; * &lt;aop:pointcut id=&quot;getNameCalls&quot; expression=&quot;execution(* *..ITestBean.getName(..))&quot;/&gt;
* </pre> * </pre>
* *
* <p>Using the <code>advisor</code> tag you can configure an {@link org.springframework.aop.Advisor} * <p>Using the {@code advisor} tag you can configure an {@link org.springframework.aop.Advisor}
* and have it applied to all relevant beans in you {@link org.springframework.beans.factory.BeanFactory} * and have it applied to all relevant beans in you {@link org.springframework.beans.factory.BeanFactory}
* automatically. The <code>advisor</code> tag supports both in-line and referenced * automatically. The {@code advisor} tag supports both in-line and referenced
* {@link org.springframework.aop.Pointcut Pointcuts}: * {@link org.springframework.aop.Pointcut Pointcuts}:
* *
* <pre class="code"> * <pre class="code">
@@ -56,9 +56,10 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport {
/** /**
* Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the * Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the
* '<code>config</code>', '<code>spring-configured</code>', '<code>aspectj-autoproxy</code>' * '{@code config}', '{@code spring-configured}', '{@code aspectj-autoproxy}'
* and '<code>scoped-proxy</code>' tags. * and '{@code scoped-proxy}' tags.
*/ */
@Override
public void init() { public void init() {
// In 2.0 XSD as well as in 2.1 XSD. // In 2.0 XSD as well as in 2.1 XSD.
registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser()); registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.beans.factory.xml.ParserContext;
/** /**
* Utility class for handling registration of auto-proxy creators used internally * Utility class for handling registration of auto-proxy creators used internally
* by the '<code>aop</code>' namespace tags. * by the '{@code aop}' namespace tags.
* *
* <p>Only a single auto-proxy creator can be registered and multiple tags may wish * <p>Only a single auto-proxy creator can be registered and multiple tags may wish
* to register different concrete implementations. As such this class delegates to * to register different concrete implementations. As such this class delegates to
@@ -42,12 +42,12 @@ import org.springframework.beans.factory.xml.ParserContext;
public abstract class AopNamespaceUtils { public abstract class AopNamespaceUtils {
/** /**
* The <code>proxy-target-class</code> attribute as found on AOP-related XML tags. * The {@code proxy-target-class} attribute as found on AOP-related XML tags.
*/ */
public static final String PROXY_TARGET_CLASS_ATTRIBUTE = "proxy-target-class"; public static final String PROXY_TARGET_CLASS_ATTRIBUTE = "proxy-target-class";
/** /**
* The <code>expose-proxy</code> attribute as found on AOP-related XML tags. * The {@code expose-proxy} attribute as found on AOP-related XML tags.
*/ */
private static final String EXPOSE_PROXY_ATTRIBUTE = "expose-proxy"; private static final String EXPOSE_PROXY_ATTRIBUTE = "expose-proxy";

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
/** /**
* {@link BeanDefinitionParser} for the <code>aspectj-autoproxy</code> tag, * {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag,
* enabling the automatic application of @AspectJ-style aspects found in * enabling the automatic application of @AspectJ-style aspects found in
* the {@link org.springframework.beans.factory.BeanFactory}. * the {@link org.springframework.beans.factory.BeanFactory}.
* *
@@ -37,6 +37,7 @@ import org.springframework.beans.factory.xml.ParserContext;
*/ */
class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser { class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) { public BeanDefinition parse(Element element, ParserContext parserContext) {
AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element); AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
extendBeanDefinition(element, parserContext); extendBeanDefinition(element, parserContext);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -49,7 +49,7 @@ import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils; import org.springframework.util.xml.DomUtils;
/** /**
* {@link BeanDefinitionParser} for the <code>&lt;aop:config&gt;</code> tag. * {@link BeanDefinitionParser} for the {@code &lt;aop:config&gt;} tag.
* *
* @author Rob Harrop * @author Rob Harrop
* @author Juergen Hoeller * @author Juergen Hoeller
@@ -93,8 +93,9 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2; private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2;
private ParseState parseState = new ParseState(); private ParseState parseState = new ParseState();
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) { public BeanDefinition parse(Element element, ParserContext parserContext) {
CompositeComponentDefinition compositeDef = CompositeComponentDefinition compositeDef =
new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
@@ -122,8 +123,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
/** /**
* Configures the auto proxy creator needed to support the {@link BeanDefinition BeanDefinitions} * Configures the auto proxy creator needed to support the {@link BeanDefinition BeanDefinitions}
* created by the '<code>&lt;aop:config/&gt;</code>' tag. Will force class proxying if the * created by the '{@code &lt;aop:config/&gt;}' tag. Will force class proxying if the
* '<code>proxy-target-class</code>' attribute is set to '<code>true</code>'. * '{@code proxy-target-class}' attribute is set to '{@code true}'.
* @see AopNamespaceUtils * @see AopNamespaceUtils
*/ */
private void configureAutoProxyCreator(ParserContext parserContext, Element element) { private void configureAutoProxyCreator(ParserContext parserContext, Element element) {
@@ -131,7 +132,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Parses the supplied <code>&lt;advisor&gt;</code> element and registers the resulting * Parses the supplied {@code &lt;advisor&gt;} element and registers the resulting
* {@link org.springframework.aop.Advisor} and any resulting {@link org.springframework.aop.Pointcut} * {@link org.springframework.aop.Advisor} and any resulting {@link org.springframework.aop.Pointcut}
* with the supplied {@link BeanDefinitionRegistry}. * with the supplied {@link BeanDefinitionRegistry}.
*/ */
@@ -168,7 +169,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
/** /**
* Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong>
* parse any associated '<code>pointcut</code>' or '<code>pointcut-ref</code>' attributes. * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes.
*/ */
private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) {
RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
@@ -257,9 +258,9 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Return <code>true</code> if the supplied node describes an advice type. May be one of: * Return {@code true} if the supplied node describes an advice type. May be one of:
* '<code>before</code>', '<code>after</code>', '<code>after-returning</code>', * '{@code before}', '{@code after}', '{@code after-returning}',
* '<code>after-throwing</code>' or '<code>around</code>'. * '{@code after-throwing}' or '{@code around}'.
*/ */
private boolean isAdviceNode(Node aNode, ParserContext parserContext) { private boolean isAdviceNode(Node aNode, ParserContext parserContext) {
if (!(aNode instanceof Element)) { if (!(aNode instanceof Element)) {
@@ -273,7 +274,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Parse a '<code>declare-parents</code>' element and register the appropriate * Parse a '{@code declare-parents}' element and register the appropriate
* DeclareParentsAdvisor with the BeanDefinitionRegistry encapsulated in the * DeclareParentsAdvisor with the BeanDefinitionRegistry encapsulated in the
* supplied ParserContext. * supplied ParserContext.
*/ */
@@ -281,10 +282,10 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class);
builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE)); builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE));
builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN)); builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN));
String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL); String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL);
String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF); String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF);
if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) { if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) {
builder.addConstructorArgValue(defaultImpl); builder.addConstructorArgValue(defaultImpl);
} }
@@ -304,8 +305,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Parses one of '<code>before</code>', '<code>after</code>', '<code>after-returning</code>', * Parses one of '{@code before}', '{@code after}', '{@code after-returning}',
* '<code>after-throwing</code>' or '<code>around</code>' and registers the resulting * '{@code after-throwing}' or '{@code around}' and registers the resulting
* BeanDefinition with the supplied BeanDefinitionRegistry. * BeanDefinition with the supplied BeanDefinitionRegistry.
* @return the generated advice RootBeanDefinition * @return the generated advice RootBeanDefinition
*/ */
@@ -427,7 +428,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Parses the supplied <code>&lt;pointcut&gt;</code> and registers the resulting * Parses the supplied {@code &lt;pointcut&gt;} and registers the resulting
* Pointcut with the BeanDefinitionRegistry. * Pointcut with the BeanDefinitionRegistry.
*/ */
private AbstractBeanDefinition parsePointcut(Element pointcutElement, ParserContext parserContext) { private AbstractBeanDefinition parsePointcut(Element pointcutElement, ParserContext parserContext) {
@@ -435,7 +436,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
String expression = pointcutElement.getAttribute(EXPRESSION); String expression = pointcutElement.getAttribute(EXPRESSION);
AbstractBeanDefinition pointcutDefinition = null; AbstractBeanDefinition pointcutDefinition = null;
try { try {
this.parseState.push(new PointcutEntry(id)); this.parseState.push(new PointcutEntry(id));
pointcutDefinition = createPointcutDefinition(expression); pointcutDefinition = createPointcutDefinition(expression);
@@ -460,8 +461,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
/** /**
* Parses the <code>pointcut</code> or <code>pointcut-ref</code> attributes of the supplied * Parses the {@code pointcut} or {@code pointcut-ref} attributes of the supplied
* {@link Element} and add a <code>pointcut</code> property as appropriate. Generates a * {@link Element} and add a {@code pointcut} property as appropriate. Generates a
* {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if necessary * {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if necessary
* and returns its bean name, otherwise returns the bean name of the referred pointcut. * and returns its bean name, otherwise returns the bean name of the referred pointcut.
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -57,6 +57,7 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
this.methodName = methodName; this.methodName = methodName;
} }
@Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
if (!StringUtils.hasText(this.targetBeanName)) { if (!StringUtils.hasText(this.targetBeanName)) {
throw new IllegalArgumentException("Property 'targetBeanName' is required"); throw new IllegalArgumentException("Property 'targetBeanName' is required");
@@ -78,14 +79,17 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
} }
@Override
public Method getObject() throws Exception { public Method getObject() throws Exception {
return this.method; return this.method;
} }
@Override
public Class<Method> getObjectType() { public Class<Method> getObjectType() {
return Method.class; return Method.class;
} }
@Override
public boolean isSingleton() { public boolean isSingleton() {
return true; return true;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -46,6 +46,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
} }
@Override
public String getName() { public String getName() {
return this.pointcutBeanName; return this.pointcutBeanName;
} }
@@ -60,6 +61,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition {
return new BeanDefinition[] {this.pointcutDefinition}; return new BeanDefinition[] {this.pointcutDefinition};
} }
@Override
public Object getSource() { public Object getSource() {
return this.pointcutDefinition.getSource(); return this.pointcutDefinition.getSource();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.parsing.ParseState;
/** /**
* {@link ParseState} entry representing a pointcut. * {@link ParseState} entry representing a pointcut.
* *
* @author Mark Fisher * @author Mark Fisher
* @since 2.0 * @since 2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.xml.ParserContext;
/** /**
* {@link BeanDefinitionDecorator} responsible for parsing the * {@link BeanDefinitionDecorator} responsible for parsing the
* <code>&lt;aop:scoped-proxy/&gt;</code> tag. * {@code &lt;aop:scoped-proxy/&gt;} tag.
* *
* @author Rob Harrop * @author Rob Harrop
* @author Juergen Hoeller * @author Juergen Hoeller
@@ -39,6 +39,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator {
private static final String PROXY_TARGET_CLASS = "proxy-target-class"; private static final String PROXY_TARGET_CLASS = "proxy-target-class";
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
boolean proxyTargetClass = true; boolean proxyTargetClass = true;
if (node instanceof Element) { if (node instanceof Element) {
@@ -47,7 +48,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator {
proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)); proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
} }
} }
// Register the original bean definition as it will be referenced by the scoped proxy // Register the original bean definition as it will be referenced by the scoped proxy
// and is relevant for tooling (validation, navigation). // and is relevant for tooling (validation, navigation).
BeanDefinitionHolder holder = BeanDefinitionHolder holder =

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -47,6 +47,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
this.aspectBeanName = aspectBeanName; this.aspectBeanName = aspectBeanName;
} }
@Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
if (!StringUtils.hasText(this.aspectBeanName)) { if (!StringUtils.hasText(this.aspectBeanName)) {
@@ -59,10 +60,12 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
* Look up the aspect bean from the {@link BeanFactory} and returns it. * Look up the aspect bean from the {@link BeanFactory} and returns it.
* @see #setAspectBeanName * @see #setAspectBeanName
*/ */
@Override
public Object getAspectInstance() { public Object getAspectInstance() {
return this.beanFactory.getBean(this.aspectBeanName); return this.beanFactory.getBean(this.aspectBeanName);
} }
@Override
public ClassLoader getAspectClassLoader() { public ClassLoader getAspectClassLoader() {
if (this.beanFactory instanceof ConfigurableBeanFactory) { if (this.beanFactory instanceof ConfigurableBeanFactory) {
return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader();
@@ -72,6 +75,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
} }
} }
@Override
public int getOrder() { public int getOrder() {
if (this.beanFactory.isSingleton(this.aspectBeanName) && if (this.beanFactory.isSingleton(this.aspectBeanName) &&
this.beanFactory.isTypeMatch(this.aspectBeanName, Ordered.class)) { this.beanFactory.isTypeMatch(this.aspectBeanName, Ordered.class)) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 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.
@@ -50,6 +50,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser {
"org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"; "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) { public BeanDefinition parse(Element element, ParserContext parserContext) {
if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) { if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
RootBeanDefinition def = new RootBeanDefinition(); RootBeanDefinition def = new RootBeanDefinition();

View File

@@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.2 * @since 3.2
*/ */
@SuppressWarnings("serial")
public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
implements BeanPostProcessor, BeanClassLoaderAware, Ordered { implements BeanPostProcessor, BeanClassLoaderAware, Ordered {
@@ -49,6 +50,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
private final Map<String, Boolean> eligibleBeans = new ConcurrentHashMap<String, Boolean>(64); private final Map<String, Boolean> eligibleBeans = new ConcurrentHashMap<String, Boolean>(64);
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) { public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader; this.beanClassLoader = beanClassLoader;
} }
@@ -57,15 +59,18 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
this.order = order; this.order = order;
} }
@Override
public int getOrder() { public int getOrder() {
return this.order; return this.order;
} }
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean; return bean;
} }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof AopInfrastructureBean) { if (bean instanceof AopInfrastructureBean) {
// Ignore AOP infrastructure such as scoped proxies. // Ignore AOP infrastructure such as scoped proxies.
@@ -93,7 +98,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
/** /**
* Check whether the given bean is eligible for advising with this * Check whether the given bean is eligible for advising with this
* post-processor's {@link Advisor}. * post-processor's {@link Advisor}.
* <p>Implements caching of <code>canApply</code> results per bean name. * <p>Implements caching of {@code canApply} results per bean name.
* @param bean the bean instance * @param bean the bean instance
* @param beanName the name of the bean * @param beanName the name of the bean
* @see AopUtils#canApply(Advisor, Class) * @see AopUtils#canApply(Advisor, Class)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 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.
@@ -122,6 +122,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
} }
@Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(ClassLoader classLoader) {
if (this.proxyClassLoader == null) { if (this.proxyClassLoader == null) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
@@ -129,6 +130,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
} }
@Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
if (this.target == null) { if (this.target == null) {
throw new IllegalArgumentException("Property 'target' is required"); throw new IllegalArgumentException("Property 'target' is required");
@@ -190,6 +192,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
} }
@Override
public Object getObject() { public Object getObject() {
if (this.proxy == null) { if (this.proxy == null) {
throw new FactoryBeanNotInitializedException(); throw new FactoryBeanNotInitializedException();
@@ -197,6 +200,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
return this.proxy; return this.proxy;
} }
@Override
public Class<?> getObjectType() { public Class<?> getObjectType() {
if (this.proxy != null) { if (this.proxy != null) {
return this.proxy.getClass(); return this.proxy.getClass();
@@ -213,6 +217,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
return null; return null;
} }
@Override
public final boolean isSingleton() { public final boolean isSingleton() {
return true; return true;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -77,7 +77,7 @@ public interface Advised extends TargetClassAware {
* Set whether the proxy should be exposed by the AOP framework as a * Set whether the proxy should be exposed by the AOP framework as a
* ThreadLocal for retrieval via the AopContext class. This is useful * ThreadLocal for retrieval via the AopContext class. This is useful
* if an advised object needs to call another advised method on itself. * if an advised object needs to call another advised method on itself.
* (If it uses <code>this</code>, the invocation will not be advised). * (If it uses {@code this}, the invocation will not be advised).
* <p>Default is "false", for optimal performance. * <p>Default is "false", for optimal performance.
*/ */
void setExposeProxy(boolean exposeProxy); void setExposeProxy(boolean exposeProxy);
@@ -85,7 +85,7 @@ public interface Advised extends TargetClassAware {
/** /**
* Return whether the factory should expose the proxy as a ThreadLocal. * Return whether the factory should expose the proxy as a ThreadLocal.
* This can be necessary if a target object needs to invoke a method on itself * This can be necessary if a target object needs to invoke a method on itself
* benefitting from advice. (If it invokes a method on <code>this</code> no advice * benefitting from advice. (If it invokes a method on {@code this} no advice
* will apply.) Getting the proxy is analogous to an EJB calling getEJBObject(). * will apply.) Getting the proxy is analogous to an EJB calling getEJBObject().
* @see AopContext * @see AopContext
*/ */
@@ -110,7 +110,7 @@ public interface Advised extends TargetClassAware {
/** /**
* Return the advisors applying to this proxy. * Return the advisors applying to this proxy.
* @return a list of Advisors applying to this proxy (never <code>null</code>) * @return a list of Advisors applying to this proxy (never {@code null})
*/ */
Advisor[] getAdvisors(); Advisor[] getAdvisors();
@@ -124,7 +124,7 @@ public interface Advised extends TargetClassAware {
*/ */
void addAdvisor(Advisor advisor) throws AopConfigException; void addAdvisor(Advisor advisor) throws AopConfigException;
/** /**
* Add an Advisor at the specified position in the chain. * Add an Advisor at the specified position in the chain.
* @param advisor the advisor to add at the specified position in the chain * @param advisor the advisor to add at the specified position in the chain
* @param pos position in chain (0 is head). Must be valid. * @param pos position in chain (0 is head). Must be valid.
@@ -135,7 +135,7 @@ public interface Advised extends TargetClassAware {
/** /**
* Remove the given advisor. * Remove the given advisor.
* @param advisor the advisor to remove * @param advisor the advisor to remove
* @return <code>true</code> if the advisor was removed; <code>false</code> * @return {@code true} if the advisor was removed; {@code false}
* if the advisor was not found and hence could not be removed * if the advisor was not found and hence could not be removed
*/ */
boolean removeAdvisor(Advisor advisor); boolean removeAdvisor(Advisor advisor);
@@ -165,7 +165,7 @@ public interface Advised extends TargetClassAware {
* @param a the advisor to replace * @param a the advisor to replace
* @param b the advisor to replace it with * @param b the advisor to replace it with
* @return whether it was replaced. If the advisor wasn't found in the * @return whether it was replaced. If the advisor wasn't found in the
* list of advisors, this method returns <code>false</code> and does nothing. * list of advisors, this method returns {@code false} and does nothing.
* @throws AopConfigException in case of invalid advice * @throws AopConfigException in case of invalid advice
*/ */
boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException; boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException;
@@ -174,9 +174,9 @@ public interface Advised extends TargetClassAware {
/** /**
* Add the given AOP Alliance advice to the tail of the advice (interceptor) chain. * Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.
* <p>This will be wrapped in a DefaultPointcutAdvisor with a pointcut that always * <p>This will be wrapped in a DefaultPointcutAdvisor with a pointcut that always
* applies, and returned from the <code>getAdvisors()</code> method in this wrapped form. * applies, and returned from the {@code getAdvisors()} method in this wrapped form.
* <p>Note that the given advice will apply to all invocations on the proxy, * <p>Note that the given advice will apply to all invocations on the proxy,
* even to the <code>toString()</code> method! Use appropriate advice implementations * even to the {@code toString()} method! Use appropriate advice implementations
* or specify appropriate pointcuts to apply to a narrower set of methods. * or specify appropriate pointcuts to apply to a narrower set of methods.
* @param advice advice to add to the tail of the chain * @param advice advice to add to the tail of the chain
* @throws AopConfigException in case of invalid advice * @throws AopConfigException in case of invalid advice
@@ -191,7 +191,7 @@ public interface Advised extends TargetClassAware {
* with a pointcut that always applies, and returned from the {@link #getAdvisors()} * with a pointcut that always applies, and returned from the {@link #getAdvisors()}
* method in this wrapped form. * method in this wrapped form.
* <p>Note: The given advice will apply to all invocations on the proxy, * <p>Note: The given advice will apply to all invocations on the proxy,
* even to the <code>toString()</code> method! Use appropriate advice implementations * even to the {@code toString()} method! Use appropriate advice implementations
* or specify appropriate pointcuts to apply to a narrower set of methods. * or specify appropriate pointcuts to apply to a narrower set of methods.
* @param pos index from 0 (head) * @param pos index from 0 (head)
* @param advice advice to add at the specified position in the advice chain * @param advice advice to add at the specified position in the advice chain
@@ -202,8 +202,8 @@ public interface Advised extends TargetClassAware {
/** /**
* Remove the Advisor containing the given advice. * Remove the Advisor containing the given advice.
* @param advice the advice to remove * @param advice the advice to remove
* @return <code>true</code> of the advice was found and removed; * @return {@code true} of the advice was found and removed;
* <code>false</code> if there was no such advice * {@code false} if there was no such advice
*/ */
boolean removeAdvice(Advice advice); boolean removeAdvice(Advice advice);
@@ -219,7 +219,7 @@ public interface Advised extends TargetClassAware {
/** /**
* As <code>toString()</code> will normally be delegated to the target, * As {@code toString()} will normally be delegated to the target,
* this returns the equivalent for the AOP proxy. * this returns the equivalent for the AOP proxy.
* @return a string description of the proxy configuration * @return a string description of the proxy configuration
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -137,10 +137,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
setTargetSource(new SingletonTargetSource(target)); setTargetSource(new SingletonTargetSource(target));
} }
@Override
public void setTargetSource(TargetSource targetSource) { public void setTargetSource(TargetSource targetSource) {
this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE); this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE);
} }
@Override
public TargetSource getTargetSource() { public TargetSource getTargetSource() {
return this.targetSource; return this.targetSource;
} }
@@ -162,14 +164,17 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
this.targetSource = EmptyTargetSource.forClass(targetClass); this.targetSource = EmptyTargetSource.forClass(targetClass);
} }
@Override
public Class<?> getTargetClass() { public Class<?> getTargetClass() {
return this.targetSource.getTargetClass(); return this.targetSource.getTargetClass();
} }
@Override
public void setPreFiltered(boolean preFiltered) { public void setPreFiltered(boolean preFiltered) {
this.preFiltered = preFiltered; this.preFiltered = preFiltered;
} }
@Override
public boolean isPreFiltered() { public boolean isPreFiltered() {
return this.preFiltered; return this.preFiltered;
} }
@@ -184,7 +189,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
/** /**
* Return the advisor chain factory to use (never <code>null</code>). * Return the advisor chain factory to use (never {@code null}).
*/ */
public AdvisorChainFactory getAdvisorChainFactory() { public AdvisorChainFactory getAdvisorChainFactory() {
return this.advisorChainFactory; return this.advisorChainFactory;
@@ -221,17 +226,19 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* Remove a proxied interface. * Remove a proxied interface.
* <p>Does nothing if the given interface isn't proxied. * <p>Does nothing if the given interface isn't proxied.
* @param intf the interface to remove from the proxy * @param intf the interface to remove from the proxy
* @return <code>true</code> if the interface was removed; <code>false</code> * @return {@code true} if the interface was removed; {@code false}
* if the interface was not found and hence could not be removed * if the interface was not found and hence could not be removed
*/ */
public boolean removeInterface(Class intf) { public boolean removeInterface(Class intf) {
return this.interfaces.remove(intf); return this.interfaces.remove(intf);
} }
@Override
public Class[] getProxiedInterfaces() { public Class[] getProxiedInterfaces() {
return this.interfaces.toArray(new Class[this.interfaces.size()]); return this.interfaces.toArray(new Class[this.interfaces.size()]);
} }
@Override
public boolean isInterfaceProxied(Class intf) { public boolean isInterfaceProxied(Class intf) {
for (Class proxyIntf : this.interfaces) { for (Class proxyIntf : this.interfaces) {
if (intf.isAssignableFrom(proxyIntf)) { if (intf.isAssignableFrom(proxyIntf)) {
@@ -242,15 +249,18 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
@Override
public final Advisor[] getAdvisors() { public final Advisor[] getAdvisors() {
return this.advisorArray; return this.advisorArray;
} }
@Override
public void addAdvisor(Advisor advisor) { public void addAdvisor(Advisor advisor) {
int pos = this.advisors.size(); int pos = this.advisors.size();
addAdvisor(pos, advisor); addAdvisor(pos, advisor);
} }
@Override
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException { public void addAdvisor(int pos, Advisor advisor) throws AopConfigException {
if (advisor instanceof IntroductionAdvisor) { if (advisor instanceof IntroductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor); validateIntroductionAdvisor((IntroductionAdvisor) advisor);
@@ -258,6 +268,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
addAdvisorInternal(pos, advisor); addAdvisorInternal(pos, advisor);
} }
@Override
public boolean removeAdvisor(Advisor advisor) { public boolean removeAdvisor(Advisor advisor) {
int index = indexOf(advisor); int index = indexOf(advisor);
if (index == -1) { if (index == -1) {
@@ -269,6 +280,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
} }
@Override
public void removeAdvisor(int index) throws AopConfigException { public void removeAdvisor(int index) throws AopConfigException {
if (isFrozen()) { if (isFrozen()) {
throw new AopConfigException("Cannot remove Advisor: Configuration is frozen."); throw new AopConfigException("Cannot remove Advisor: Configuration is frozen.");
@@ -292,11 +304,13 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
adviceChanged(); adviceChanged();
} }
@Override
public int indexOf(Advisor advisor) { public int indexOf(Advisor advisor) {
Assert.notNull(advisor, "Advisor must not be null"); Assert.notNull(advisor, "Advisor must not be null");
return this.advisors.indexOf(advisor); return this.advisors.indexOf(advisor);
} }
@Override
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException { public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException {
Assert.notNull(a, "Advisor a must not be null"); Assert.notNull(a, "Advisor a must not be null");
Assert.notNull(b, "Advisor b must not be null"); Assert.notNull(b, "Advisor b must not be null");
@@ -388,6 +402,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
@Override
public void addAdvice(Advice advice) throws AopConfigException { public void addAdvice(Advice advice) throws AopConfigException {
int pos = this.advisors.size(); int pos = this.advisors.size();
addAdvice(pos, advice); addAdvice(pos, advice);
@@ -396,6 +411,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
/** /**
* Cannot add introductions this way unless the advice implements IntroductionInfo. * Cannot add introductions this way unless the advice implements IntroductionInfo.
*/ */
@Override
public void addAdvice(int pos, Advice advice) throws AopConfigException { public void addAdvice(int pos, Advice advice) throws AopConfigException {
Assert.notNull(advice, "Advice must not be null"); Assert.notNull(advice, "Advice must not be null");
if (advice instanceof IntroductionInfo) { if (advice instanceof IntroductionInfo) {
@@ -412,6 +428,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
} }
@Override
public boolean removeAdvice(Advice advice) throws AopConfigException { public boolean removeAdvice(Advice advice) throws AopConfigException {
int index = indexOf(advice); int index = indexOf(advice);
if (index == -1) { if (index == -1) {
@@ -423,6 +440,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
} }
@Override
public int indexOf(Advice advice) { public int indexOf(Advice advice) {
Assert.notNull(advice, "Advice must not be null"); Assert.notNull(advice, "Advice must not be null");
for (int i = 0; i < this.advisors.size(); i++) { for (int i = 0; i < this.advisors.size(); i++) {
@@ -554,6 +572,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
} }
@Override
public String toProxyConfigString() { public String toProxyConfigString() {
return toString(); return toString();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2012 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.
@@ -24,6 +24,7 @@ import org.springframework.core.NestedRuntimeException;
* @author Rod Johnson * @author Rod Johnson
* @since 13.03.2003 * @since 13.03.2003
*/ */
@SuppressWarnings("serial")
public class AopConfigException extends NestedRuntimeException { public class AopConfigException extends NestedRuntimeException {
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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,9 +21,9 @@ import org.springframework.core.NamedThreadLocal;
/** /**
* Class containing static methods used to obtain information about the current AOP invocation. * Class containing static methods used to obtain information about the current AOP invocation.
* *
* <p>The <code>currentProxy()</code> method is usable if the AOP framework is configured to * <p>The {@code currentProxy()} method is usable if the AOP framework is configured to
* expose the current proxy (not the default). It returns the AOP proxy in use. Target objects * expose the current proxy (not the default). It returns the AOP proxy in use. Target objects
* or advice can use this to make advised calls, in the same way as <code>getEJBObject()</code> * or advice can use this to make advised calls, in the same way as {@code getEJBObject()}
* can be used in EJBs. They can also use it to find advice configuration. * can be used in EJBs. They can also use it to find advice configuration.
* *
* <p>Spring's AOP framework does not expose proxies by default, as there is a performance cost * <p>Spring's AOP framework does not expose proxies by default, as there is a performance cost
@@ -42,7 +42,7 @@ public abstract class AopContext {
/** /**
* ThreadLocal holder for AOP proxy associated with this thread. * ThreadLocal holder for AOP proxy associated with this thread.
* Will contain <code>null</code> unless the "exposeProxy" property on * Will contain {@code null} unless the "exposeProxy" property on
* the controlling proxy configuration has been set to "true". * the controlling proxy configuration has been set to "true".
* @see ProxyConfig#setExposeProxy * @see ProxyConfig#setExposeProxy
*/ */
@@ -53,7 +53,7 @@ public abstract class AopContext {
* Try to return the current AOP proxy. This method is usable only if the * Try to return the current AOP proxy. This method is usable only if the
* calling method has been invoked via AOP, and the AOP framework has been set * calling method has been invoked via AOP, and the AOP framework has been set
* to expose proxies. Otherwise, this method will throw an IllegalStateException. * to expose proxies. Otherwise, this method will throw an IllegalStateException.
* @return Object the current AOP proxy (never returns <code>null</code>) * @return Object the current AOP proxy (never returns {@code null})
* @throws IllegalStateException if the proxy cannot be found, because the * @throws IllegalStateException if the proxy cannot be found, because the
* method was invoked outside an AOP invocation context, or because the * method was invoked outside an AOP invocation context, or because the
* AOP framework has not been configured to expose the proxy * AOP framework has not been configured to expose the proxy
@@ -68,10 +68,10 @@ public abstract class AopContext {
} }
/** /**
* Make the given proxy available via the <code>currentProxy()</code> method. * Make the given proxy available via the {@code currentProxy()} method.
* <p>Note that the caller should be careful to keep the old value as appropriate. * <p>Note that the caller should be careful to keep the old value as appropriate.
* @param proxy the proxy to expose (or <code>null</code> to reset it) * @param proxy the proxy to expose (or {@code null} to reset it)
* @return the old proxy, which may be <code>null</code> if none was bound * @return the old proxy, which may be {@code null} if none was bound
* @see #currentProxy() * @see #currentProxy()
*/ */
static Object setCurrentProxy(Object proxy) { static Object setCurrentProxy(Object proxy) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -33,20 +33,20 @@ public interface AopProxy {
* Create a new proxy object. * Create a new proxy object.
* <p>Uses the AopProxy's default class loader (if necessary for proxy creation): * <p>Uses the AopProxy's default class loader (if necessary for proxy creation):
* usually, the thread context class loader. * usually, the thread context class loader.
* @return the new proxy object (never <code>null</code>) * @return the new proxy object (never {@code null})
* @see java.lang.Thread#getContextClassLoader() * @see Thread#getContextClassLoader()
*/ */
Object getProxy(); Object getProxy();
/** /**
* Create a new proxy object. * Create a new proxy object.
* <p>Uses the given class loader (if necessary for proxy creation). * <p>Uses the given class loader (if necessary for proxy creation).
* <code>null</code> will simply be passed down and thus lead to the low-level * {@code null} will simply be passed down and thus lead to the low-level
* proxy facility's default, which is usually different from the default chosen * proxy facility's default, which is usually different from the default chosen
* by the AopProxy implementation's {@link #getProxy()} method. * by the AopProxy implementation's {@link #getProxy()} method.
* @param classLoader the class loader to create the proxy with * @param classLoader the class loader to create the proxy with
* (or <code>null</code> for the low-level proxy facility's default) * (or {@code null} for the low-level proxy facility's default)
* @return the new proxy object (never <code>null</code>) * @return the new proxy object (never {@code null})
*/ */
Object getProxy(ClassLoader classLoader); Object getProxy(ClassLoader classLoader);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -35,7 +35,7 @@ package org.springframework.aop.framework;
* *
* <p>Proxies may or may not allow advice changes to be made. * <p>Proxies may or may not allow advice changes to be made.
* If they do not permit advice changes (for example, because * If they do not permit advice changes (for example, because
* the configuration was frozen) a proxy should throw an * the configuration was frozen) a proxy should throw an
* {@link AopConfigException} on an attempted advice change. * {@link AopConfigException} on an attempted advice change.
* *
* @author Rod Johnson * @author Rod Johnson

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -44,9 +44,9 @@ public abstract class AopProxyUtils {
* as long as possible without side effects, that is, just for singleton targets. * as long as possible without side effects, that is, just for singleton targets.
* @param candidate the instance to check (might be an AOP proxy) * @param candidate the instance to check (might be an AOP proxy)
* @return the target class (or the plain class of the given object as fallback; * @return the target class (or the plain class of the given object as fallback;
* never <code>null</code>) * never {@code null})
* @see org.springframework.aop.TargetClassAware#getTargetClass() * @see org.springframework.aop.TargetClassAware#getTargetClass()
* @see org.springframework.aop.framework.Advised#getTargetSource() * @see Advised#getTargetSource()
*/ */
public static Class<?> ultimateTargetClass(Object candidate) { public static Class<?> ultimateTargetClass(Object candidate) {
Assert.notNull(candidate, "Candidate object must not be null"); Assert.notNull(candidate, "Candidate object must not be null");
@@ -112,7 +112,7 @@ public abstract class AopProxyUtils {
* i.e. all non-Advised interfaces that the proxy implements. * i.e. all non-Advised interfaces that the proxy implements.
* @param proxy the proxy to analyze (usually a JDK dynamic proxy) * @param proxy the proxy to analyze (usually a JDK dynamic proxy)
* @return all user-specified interfaces that the proxy implements, * @return all user-specified interfaces that the proxy implements,
* in the original order (never <code>null</code> or empty) * in the original order (never {@code null} or empty)
* @see Advised * @see Advised
*/ */
public static Class[] proxiedUserInterfaces(Object proxy) { public static Class[] proxiedUserInterfaces(Object proxy) {

View File

@@ -146,10 +146,12 @@ final class CglibAopProxy implements AopProxy, Serializable {
} }
@Override
public Object getProxy() { public Object getProxy() {
return getProxy(null); return getProxy(null);
} }
@Override
public Object getProxy(ClassLoader classLoader) { public Object getProxy(ClassLoader classLoader) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource()); logger.debug("Creating CGLIB proxy: target source is " + this.advised.getTargetSource());
@@ -234,7 +236,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
} }
/** /**
* Checks to see whether the supplied <code>Class</code> has already been validated and * Checks to see whether the supplied {@code Class} has already been validated and
* validates it if not. * validates it if not.
*/ */
private void validateClassIfNecessary(Class<?> proxySuperClass) { private void validateClassIfNecessary(Class<?> proxySuperClass) {
@@ -249,7 +251,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
} }
/** /**
* Checks for final methods on the <code>Class</code> and writes warnings to the log * Checks for final methods on the {@code Class} and writes warnings to the log
* for each one found. * for each one found.
*/ */
private void doValidateClass(Class<?> proxySuperClass) { private void doValidateClass(Class<?> proxySuperClass) {
@@ -376,7 +378,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
* Method interceptor used for static targets with no advice chain. The call * Method interceptor used for static targets with no advice chain. The call
* is passed directly back to the target. Used when the proxy needs to be * is passed directly back to the target. Used when the proxy needs to be
* exposed and it can't be determined that the method won't return * exposed and it can't be determined that the method won't return
* <code>this</code>. * {@code this}.
*/ */
private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable { private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable {
@@ -386,6 +388,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.target = target; this.target = target;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object retVal = methodProxy.invoke(this.target, args); Object retVal = methodProxy.invoke(this.target, args);
return processReturnType(proxy, this.target, method, retVal); return processReturnType(proxy, this.target, method, retVal);
@@ -405,6 +408,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.target = target; this.target = target;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object oldProxy = null; Object oldProxy = null;
try { try {
@@ -432,6 +436,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.targetSource = targetSource; this.targetSource = targetSource;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object target = this.targetSource.getTarget(); Object target = this.targetSource.getTarget();
try { try {
@@ -456,6 +461,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.targetSource = targetSource; this.targetSource = targetSource;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object oldProxy = null; Object oldProxy = null;
Object target = this.targetSource.getTarget(); Object target = this.targetSource.getTarget();
@@ -485,6 +491,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.target = target; this.target = target;
} }
@Override
public Object loadObject() { public Object loadObject() {
return this.target; return this.target;
} }
@@ -502,6 +509,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.advised = advised; this.advised = advised;
} }
@Override
public Object loadObject() throws Exception { public Object loadObject() throws Exception {
return this.advised; return this.advised;
} }
@@ -509,7 +517,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
/** /**
* Dispatcher for the <code>equals</code> method. * Dispatcher for the {@code equals} method.
* Ensures that the method call is always handled by this class. * Ensures that the method call is always handled by this class.
*/ */
private static class EqualsInterceptor implements MethodInterceptor, Serializable { private static class EqualsInterceptor implements MethodInterceptor, Serializable {
@@ -520,6 +528,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.advised = advised; this.advised = advised;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
Object other = args[0]; Object other = args[0];
if (proxy == other) { if (proxy == other) {
@@ -541,7 +550,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
/** /**
* Dispatcher for the <code>hashCode</code> method. * Dispatcher for the {@code hashCode} method.
* Ensures that the method call is always handled by this class. * Ensures that the method call is always handled by this class.
*/ */
private static class HashCodeInterceptor implements MethodInterceptor, Serializable { private static class HashCodeInterceptor implements MethodInterceptor, Serializable {
@@ -552,6 +561,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.advised = advised; this.advised = advised;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) {
return CglibAopProxy.class.hashCode() * 13 + this.advised.getTargetSource().hashCode(); return CglibAopProxy.class.hashCode() * 13 + this.advised.getTargetSource().hashCode();
} }
@@ -575,6 +585,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.targetClass = targetClass; this.targetClass = targetClass;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args, MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
this.targetClass, this.adviceChain, methodProxy); this.targetClass, this.adviceChain, methodProxy);
@@ -598,6 +609,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
this.advised = advised; this.advised = advised;
} }
@Override
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
Object oldProxy = null; Object oldProxy = null;
boolean setProxyContext = false; boolean setProxyContext = false;
@@ -609,7 +621,7 @@ final class CglibAopProxy implements AopProxy, Serializable {
oldProxy = AopContext.setCurrentProxy(proxy); oldProxy = AopContext.setCurrentProxy(proxy);
setProxyContext = true; setProxyContext = true;
} }
// May be <code>null</code>. Get as late as possible to minimize the time we // May be null Get as late as possible to minimize the time we
// "own" the target, in case it comes from a pool. // "own" the target, in case it comes from a pool.
target = getTarget(); target = getTarget();
if (target != null) { if (target != null) {
@@ -745,15 +757,16 @@ final class CglibAopProxy implements AopProxy, Serializable {
* invoke the advice chain. Otherwise a DyanmicAdvisedInterceptor is * invoke the advice chain. Otherwise a DyanmicAdvisedInterceptor is
* used.</dd> * used.</dd>
* <dt>For non-advised methods:</dt> * <dt>For non-advised methods:</dt>
* <dd>Where it can be determined that the method will not return <code>this</code> * <dd>Where it can be determined that the method will not return {@code this}
* or when <code>ProxyFactory.getExposeProxy()</code> returns <code>false</code>, * or when {@code ProxyFactory.getExposeProxy()} returns {@code false},
* then a Dispatcher is used. For static targets, the StaticDispatcher is used; * then a Dispatcher is used. For static targets, the StaticDispatcher is used;
* and for dynamic targets, a DynamicUnadvisedInterceptor is used. * and for dynamic targets, a DynamicUnadvisedInterceptor is used.
* If it possible for the method to return <code>this</code> then a * If it possible for the method to return {@code this} then a
* StaticUnadvisedInterceptor is used for static targets - the * StaticUnadvisedInterceptor is used for static targets - the
* DynamicUnadvisedInterceptor already considers this.</dd> * DynamicUnadvisedInterceptor already considers this.</dd>
* </dl> * </dl>
*/ */
@Override
public int accept(Method method) { public int accept(Method method) {
if (AopUtils.isFinalizeMethod(method)) { if (AopUtils.isFinalizeMethod(method)) {
logger.debug("Found finalize() method - using NO_OVERRIDE"); logger.debug("Found finalize() method - using NO_OVERRIDE");

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -43,8 +43,10 @@ import org.springframework.aop.support.MethodMatchers;
* @author Adrian Colyer * @author Adrian Colyer
* @since 2.0.3 * @since 2.0.3
*/ */
@SuppressWarnings("serial")
public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable { public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable {
@Override
public List<Object> getInterceptorsAndDynamicInterceptionAdvice( public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
Advised config, Method method, Class targetClass) { Advised config, Method method, Class targetClass) {

View File

@@ -45,9 +45,11 @@ import org.springframework.aop.SpringProxy;
* @see AdvisedSupport#setProxyTargetClass * @see AdvisedSupport#setProxyTargetClass
* @see AdvisedSupport#setInterfaces * @see AdvisedSupport#setInterfaces
*/ */
@SuppressWarnings("serial")
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable { public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
@Override
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException { public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) { if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
Class targetClass = config.getTargetClass(); Class targetClass = config.getTargetClass();

View File

@@ -106,10 +106,12 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
} }
@Override
public Object getProxy() { public Object getProxy() {
return getProxy(ClassUtils.getDefaultClassLoader()); return getProxy(ClassUtils.getDefaultClassLoader());
} }
@Override
public Object getProxy(ClassLoader classLoader) { public Object getProxy(ClassLoader classLoader) {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource()); logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
@@ -143,10 +145,11 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
/** /**
* Implementation of <code>InvocationHandler.invoke</code>. * Implementation of {@code InvocationHandler.invoke}.
* <p>Callers will see exactly the exception thrown by the target, * <p>Callers will see exactly the exception thrown by the target,
* unless a hook method throws an exception. * unless a hook method throws an exception.
*/ */
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
MethodInvocation invocation; MethodInvocation invocation;
Object oldProxy = null; Object oldProxy = null;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -112,7 +112,7 @@ public class ProxyConfig implements Serializable {
* Set whether the proxy should be exposed by the AOP framework as a * Set whether the proxy should be exposed by the AOP framework as a
* ThreadLocal for retrieval via the AopContext class. This is useful * ThreadLocal for retrieval via the AopContext class. This is useful
* if an advised object needs to call another advised method on itself. * if an advised object needs to call another advised method on itself.
* (If it uses <code>this</code>, the invocation will not be advised). * (If it uses {@code this}, the invocation will not be advised).
* <p>Default is "false", in order to avoid unnecessary extra interception. * <p>Default is "false", in order to avoid unnecessary extra interception.
* This means that no guarantees are provided that AopContext access will * This means that no guarantees are provided that AopContext access will
* work consistently within any method of the advised object. * work consistently within any method of the advised object.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* @since 2.0.3 * @since 2.0.3
* @see #createAopProxy() * @see #createAopProxy()
*/ */
@SuppressWarnings("serial")
public class ProxyCreatorSupport extends AdvisedSupport { public class ProxyCreatorSupport extends AdvisedSupport {
private AopProxyFactory aopProxyFactory; private AopProxyFactory aopProxyFactory;
@@ -95,7 +96,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
/** /**
* Subclasses should call this to get a new AOP proxy. They should <b>not</b> * Subclasses should call this to get a new AOP proxy. They should <b>not</b>
* create an AOP proxy with <code>this</code> as an argument. * create an AOP proxy with {@code this} as an argument.
*/ */
protected final synchronized AopProxy createAopProxy() { protected final synchronized AopProxy createAopProxy() {
if (!this.active) { if (!this.active) {

View File

@@ -32,6 +32,7 @@ import org.springframework.util.ClassUtils;
* @author Rob Harrop * @author Rob Harrop
* @since 14.03.2003 * @since 14.03.2003
*/ */
@SuppressWarnings("serial")
public class ProxyFactory extends ProxyCreatorSupport { public class ProxyFactory extends ProxyCreatorSupport {
/** /**
@@ -74,7 +75,7 @@ public class ProxyFactory extends ProxyCreatorSupport {
} }
/** /**
* Create a ProxyFactory for the specified <code>TargetSource</code>, * Create a ProxyFactory for the specified {@code TargetSource},
* making the proxy implement the specified interface. * making the proxy implement the specified interface.
* @param proxyInterface the interface that the proxy should implement * @param proxyInterface the interface that the proxy should implement
* @param targetSource the TargetSource that the proxy should invoke * @param targetSource the TargetSource that the proxy should invoke
@@ -103,7 +104,7 @@ public class ProxyFactory extends ProxyCreatorSupport {
* or removed interfaces. Can add and remove interceptors. * or removed interfaces. Can add and remove interceptors.
* <p>Uses the given class loader (if necessary for proxy creation). * <p>Uses the given class loader (if necessary for proxy creation).
* @param classLoader the class loader to create the proxy with * @param classLoader the class loader to create the proxy with
* (or <code>null</code> for the low-level proxy facility's default) * (or {@code null} for the low-level proxy facility's default)
* @return the proxy object * @return the proxy object
*/ */
public Object getProxy(ClassLoader classLoader) { public Object getProxy(ClassLoader classLoader) {
@@ -127,7 +128,7 @@ public class ProxyFactory extends ProxyCreatorSupport {
} }
/** /**
* Create a proxy for the specified <code>TargetSource</code>, * Create a proxy for the specified {@code TargetSource},
* implementing the specified interface. * implementing the specified interface.
* @param proxyInterface the interface that the proxy should implement * @param proxyInterface the interface that the proxy should implement
* @param targetSource the TargetSource that the proxy should invoke * @param targetSource the TargetSource that the proxy should invoke
@@ -140,8 +141,8 @@ public class ProxyFactory extends ProxyCreatorSupport {
} }
/** /**
* Create a proxy for the specified <code>TargetSource</code> that extends * Create a proxy for the specified {@code TargetSource} that extends
* the target class of the <code>TargetSource</code>. * the target class of the {@code TargetSource}.
* @param targetSource the TargetSource that the proxy should invoke * @param targetSource the TargetSource that the proxy should invoke
* @return the proxy object * @return the proxy object
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -88,6 +88,7 @@ import org.springframework.util.ObjectUtils;
* @see org.springframework.aop.Advisor * @see org.springframework.aop.Advisor
* @see Advised * @see Advised
*/ */
@SuppressWarnings("serial")
public class ProxyFactoryBean extends ProxyCreatorSupport public class ProxyFactoryBean extends ProxyCreatorSupport
implements FactoryBean<Object>, BeanClassLoaderAware, BeanFactoryAware { implements FactoryBean<Object>, BeanClassLoaderAware, BeanFactoryAware {
@@ -100,7 +101,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());
private String[] interceptorNames; private String[] interceptorNames;
private String targetName; private String targetName;
private boolean autodetectInterfaces = true; private boolean autodetectInterfaces = true;
@@ -217,12 +218,14 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
this.classLoaderConfigured = (classLoader != null); this.classLoaderConfigured = (classLoader != null);
} }
@Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setBeanClassLoader(ClassLoader classLoader) {
if (!this.classLoaderConfigured) { if (!this.classLoaderConfigured) {
this.proxyClassLoader = classLoader; this.proxyClassLoader = classLoader;
} }
} }
@Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
checkInterceptorNames(); checkInterceptorNames();
@@ -233,9 +236,10 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* Return a proxy. Invoked when clients obtain beans from this factory bean. * Return a proxy. Invoked when clients obtain beans from this factory bean.
* Create an instance of the AOP proxy to be returned by this factory. * Create an instance of the AOP proxy to be returned by this factory.
* The instance will be cached for a singleton, and create on each call to * The instance will be cached for a singleton, and create on each call to
* <code>getObject()</code> for a proxy. * {@code getObject()} for a proxy.
* @return a fresh AOP proxy reflecting the current state of this factory * @return a fresh AOP proxy reflecting the current state of this factory
*/ */
@Override
public Object getObject() throws BeansException { public Object getObject() throws BeansException {
initializeAdvisorChain(); initializeAdvisorChain();
if (isSingleton()) { if (isSingleton()) {
@@ -256,6 +260,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* a single one), the target bean type, or the TargetSource's target class. * a single one), the target bean type, or the TargetSource's target class.
* @see org.springframework.aop.TargetSource#getTargetClass * @see org.springframework.aop.TargetSource#getTargetClass
*/ */
@Override
public Class<?> getObjectType() { public Class<?> getObjectType() {
synchronized (this) { synchronized (this) {
if (this.singletonInstance != null) { if (this.singletonInstance != null) {
@@ -277,6 +282,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
} }
} }
@Override
public boolean isSingleton() { public boolean isSingleton() {
return this.singleton; return this.singleton;
} }
@@ -351,7 +357,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
/** /**
* Return the proxy object to expose. * Return the proxy object to expose.
* <p>The default implementation uses a <code>getProxy</code> call with * <p>The default implementation uses a {@code getProxy} call with
* the factory's bean class loader. Can be overridden to specify a * the factory's bean class loader. Can be overridden to specify a
* custom class loader. * custom class loader.
* @param aopProxy the prepared AopProxy instance to get the proxy from * @param aopProxy the prepared AopProxy instance to get the proxy from
@@ -392,7 +398,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
* which concludes the interceptorNames list, is an Advisor or Advice, * which concludes the interceptorNames list, is an Advisor or Advice,
* or may be a target. * or may be a target.
* @param beanName bean name to check * @param beanName bean name to check
* @return <code>true</code> if it's an Advisor or Advice * @return {@code true} if it's an Advisor or Advice
*/ */
private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) { private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) {
Class namedBeanClass = this.beanFactory.getType(beanName); Class namedBeanClass = this.beanFactory.getType(beanName);
@@ -543,10 +549,10 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
Advisor advisor = namedBeanToAdvisor(next); Advisor advisor = namedBeanToAdvisor(next);
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("Adding advisor with name '" + name + "'"); logger.trace("Adding advisor with name '" + name + "'");
} }
addAdvisor(advisor); addAdvisor(advisor);
} }
/** /**
* Return a TargetSource to use when creating a proxy. If the target was not * Return a TargetSource to use when creating a proxy. If the target was not
* specified at the end of the interceptorNames list, the TargetSource will be * specified at the end of the interceptorNames list, the TargetSource will be
@@ -627,24 +633,26 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
private final String beanName; private final String beanName;
private final String message; private final String message;
public PrototypePlaceholderAdvisor(String beanName) { public PrototypePlaceholderAdvisor(String beanName) {
this.beanName = beanName; this.beanName = beanName;
this.message = "Placeholder for prototype Advisor/Advice with bean name '" + beanName + "'"; this.message = "Placeholder for prototype Advisor/Advice with bean name '" + beanName + "'";
} }
public String getBeanName() { public String getBeanName() {
return beanName; return beanName;
} }
@Override
public Advice getAdvice() { public Advice getAdvice() {
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message); throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
} }
@Override
public boolean isPerInstance() { public boolean isPerInstance() {
throw new UnsupportedOperationException("Cannot invoke methods: " + this.message); throw new UnsupportedOperationException("Cannot invoke methods: " + this.message);
} }
@Override @Override
public String toString() { public String toString() {
return this.message; return this.message;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 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.
@@ -114,14 +114,17 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
} }
@Override
public final Object getProxy() { public final Object getProxy() {
return this.proxy; return this.proxy;
} }
@Override
public final Object getThis() { public final Object getThis() {
return this.target; return this.target;
} }
@Override
public final AccessibleObject getStaticPart() { public final AccessibleObject getStaticPart() {
return this.method; return this.method;
} }
@@ -131,19 +134,23 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* May or may not correspond with a method invoked on an underlying * May or may not correspond with a method invoked on an underlying
* implementation of that interface. * implementation of that interface.
*/ */
@Override
public final Method getMethod() { public final Method getMethod() {
return this.method; return this.method;
} }
@Override
public final Object[] getArguments() { public final Object[] getArguments() {
return (this.arguments != null ? this.arguments : new Object[0]); return (this.arguments != null ? this.arguments : new Object[0]);
} }
@Override
public void setArguments(Object[] arguments) { public void setArguments(Object[] arguments) {
this.arguments = arguments; this.arguments = arguments;
} }
@Override
public Object proceed() throws Throwable { public Object proceed() throws Throwable {
// We start with an index of -1 and increment early. // We start with an index of -1 and increment early.
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) { if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
@@ -151,12 +158,12 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
} }
Object interceptorOrInterceptionAdvice = Object interceptorOrInterceptionAdvice =
this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex); this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex);
if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) { if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) {
// Evaluate dynamic method matcher here: static part will already have // Evaluate dynamic method matcher here: static part will already have
// been evaluated and found to match. // been evaluated and found to match.
InterceptorAndDynamicMethodMatcher dm = InterceptorAndDynamicMethodMatcher dm =
(InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice; (InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice;
if (dm.methodMatcher.matches(this.method, this.targetClass, this.arguments)) { if (dm.methodMatcher.matches(this.method, this.targetClass, this.arguments)) {
return dm.interceptor.invoke(this); return dm.interceptor.invoke(this);
} }
@@ -192,6 +199,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* current interceptor index. * current interceptor index.
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override
public MethodInvocation invocableClone() { public MethodInvocation invocableClone() {
Object[] cloneArguments = null; Object[] cloneArguments = null;
if (this.arguments != null) { if (this.arguments != null) {
@@ -210,6 +218,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* current interceptor index. * current interceptor index.
* @see java.lang.Object#clone() * @see java.lang.Object#clone()
*/ */
@Override
public MethodInvocation invocableClone(Object[] arguments) { public MethodInvocation invocableClone(Object[] arguments) {
// Force initialization of the user attributes Map, // Force initialization of the user attributes Map,
// for having a shared Map reference in the clone. // for having a shared Map reference in the clone.
@@ -230,6 +239,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
} }
@Override
public void setUserAttribute(String key, Object value) { public void setUserAttribute(String key, Object value) {
if (value != null) { if (value != null) {
if (this.userAttributes == null) { if (this.userAttributes == null) {
@@ -244,6 +254,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
} }
} }
@Override
public Object getUserAttribute(String key) { public Object getUserAttribute(String key) {
return (this.userAttributes != null ? this.userAttributes.get(key) : null); return (this.userAttributes != null ? this.userAttributes.get(key) : null);
} }
@@ -253,7 +264,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
* This method provides an invocation-bound alternative to a ThreadLocal. * This method provides an invocation-bound alternative to a ThreadLocal.
* <p>This map is initialized lazily and is not used in the AOP framework itself. * <p>This map is initialized lazily and is not used in the AOP framework itself.
* @return any user attributes associated with this invocation * @return any user attributes associated with this invocation
* (never <code>null</code>) * (never {@code null})
*/ */
public Map<String, Object> getUserAttributes() { public Map<String, Object> getUserAttributes() {
if (this.userAttributes == null) { if (this.userAttributes == null) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -38,7 +38,7 @@ public interface AdvisorAdapter {
/** /**
* Does this adapter understand this advice object? Is it valid to * Does this adapter understand this advice object? Is it valid to
* invoke the <code>getInterceptors</code> method with an Advisor that * invoke the {@code getInterceptors} method with an Advisor that
* contains this advice as an argument? * contains this advice as an argument?
* @param advice an Advice such as a BeforeAdvice * @param advice an Advice such as a BeforeAdvice
* @return whether this adapter understands the given advice object * @return whether this adapter understands the given advice object

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -48,10 +48,12 @@ public class AdvisorAdapterRegistrationManager implements BeanPostProcessor {
} }
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean; return bean;
} }
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AdvisorAdapter){ if (bean instanceof AdvisorAdapter){
this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean); this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -38,7 +38,7 @@ public interface AdvisorAdapterRegistry {
* {@link org.springframework.aop.AfterReturningAdvice}, * {@link org.springframework.aop.AfterReturningAdvice},
* {@link org.springframework.aop.ThrowsAdvice}. * {@link org.springframework.aop.ThrowsAdvice}.
* @param advice object that should be an advice * @param advice object that should be an advice
* @return an Advisor wrapping the given advice. Never returns <code>null</code>. * @return an Advisor wrapping the given advice. Never returns {@code null}.
* If the advice parameter is an Advisor, return it. * If the advice parameter is an Advisor, return it.
* @throws UnknownAdviceTypeException if no registered advisor adapter * @throws UnknownAdviceTypeException if no registered advisor adapter
* can wrap the supposed advice * can wrap the supposed advice

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -31,12 +31,15 @@ import org.springframework.aop.AfterReturningAdvice;
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
@SuppressWarnings("serial")
class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable { class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable {
@Override
public boolean supportsAdvice(Advice advice) { public boolean supportsAdvice(Advice advice) {
return (advice instanceof AfterReturningAdvice); return (advice instanceof AfterReturningAdvice);
} }
@Override
public MethodInterceptor getInterceptor(Advisor advisor) { public MethodInterceptor getInterceptor(Advisor advisor) {
AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice(); AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice();
return new AfterReturningAdviceInterceptor(advice); return new AfterReturningAdviceInterceptor(advice);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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,6 +32,7 @@ import org.springframework.util.Assert;
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@SuppressWarnings("serial")
public class AfterReturningAdviceInterceptor implements MethodInterceptor, AfterAdvice, Serializable { public class AfterReturningAdviceInterceptor implements MethodInterceptor, AfterAdvice, Serializable {
private final AfterReturningAdvice advice; private final AfterReturningAdvice advice;
@@ -46,6 +47,7 @@ public class AfterReturningAdviceInterceptor implements MethodInterceptor, After
this.advice = advice; this.advice = advice;
} }
@Override
public Object invoke(MethodInvocation mi) throws Throwable { public Object invoke(MethodInvocation mi) throws Throwable {
Object retVal = mi.proceed(); Object retVal = mi.proceed();
this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis()); this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2012 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.
@@ -37,6 +37,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
* @author Rob Harrop * @author Rob Harrop
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
@SuppressWarnings("serial")
public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable { public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable {
private final List<AdvisorAdapter> adapters = new ArrayList<AdvisorAdapter>(3); private final List<AdvisorAdapter> adapters = new ArrayList<AdvisorAdapter>(3);
@@ -52,6 +53,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
} }
@Override
public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException { public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException {
if (adviceObject instanceof Advisor) { if (adviceObject instanceof Advisor) {
return (Advisor) adviceObject; return (Advisor) adviceObject;
@@ -73,6 +75,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
throw new UnknownAdviceTypeException(advice); throw new UnknownAdviceTypeException(advice);
} }
@Override
public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException { public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3); List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3);
Advice advice = advisor.getAdvice(); Advice advice = advisor.getAdvice();
@@ -90,6 +93,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
return interceptors.toArray(new MethodInterceptor[interceptors.size()]); return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
} }
@Override
public void registerAdvisorAdapter(AdvisorAdapter adapter) { public void registerAdvisorAdapter(AdvisorAdapter adapter) {
this.adapters.add(adapter); this.adapters.add(adapter);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -31,12 +31,15 @@ import org.springframework.aop.MethodBeforeAdvice;
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
*/ */
@SuppressWarnings("serial")
class MethodBeforeAdviceAdapter implements AdvisorAdapter, Serializable { class MethodBeforeAdviceAdapter implements AdvisorAdapter, Serializable {
@Override
public boolean supportsAdvice(Advice advice) { public boolean supportsAdvice(Advice advice) {
return (advice instanceof MethodBeforeAdvice); return (advice instanceof MethodBeforeAdvice);
} }
@Override
public MethodInterceptor getInterceptor(Advisor advisor) { public MethodInterceptor getInterceptor(Advisor advisor) {
MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice(); MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
return new MethodBeforeAdviceInterceptor(advice); return new MethodBeforeAdviceInterceptor(advice);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2012 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.
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
* *
* @author Rod Johnson * @author Rod Johnson
*/ */
@SuppressWarnings("serial")
public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Serializable { public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Serializable {
private MethodBeforeAdvice advice; private MethodBeforeAdvice advice;
@@ -45,6 +46,7 @@ public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Seriali
this.advice = advice; this.advice = advice;
} }
@Override
public Object invoke(MethodInvocation mi) throws Throwable { public Object invoke(MethodInvocation mi) throws Throwable {
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() ); this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() );
return mi.proceed(); return mi.proceed();

Some files were not shown because too many files have changed in this diff Show More