diff --git a/.gitignore b/.gitignore index 5d40a5584c..c79bac7342 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ integration-repo ivy-cache jxl.log jmx.log -spring-jdbc/derby.log +derby.log spring-test/test-output/ .gradle build @@ -19,8 +19,10 @@ build argfile* pom.xml -# IDEA metadata and output dirs +# IDEA artifacts and output dirs *.iml *.ipr *.iws out +test-output +atlassian-ide-plugin.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f06867ea7d..71739dc400 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,17 +47,13 @@ future pull requests as well, simply so the Spring Framework team knows 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 -currently under development. For example, if 3.1.1 was the latest Spring -Framework release, `master` represents 3.2.0 development, and the `3.1.x` -branch represents 3.1.2 development. - -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. +If your pull request addresses a bug or improvement, please create your branch +Spring Framework's `3.2.x` branch. `master` is reserved for work on new features +for the next major version of the framework. Rest assured that if your pull +request is accepted and merged into `3.2.x`, these changes will also eventually +be merged into `master`. ## Use short branch names diff --git a/build.gradle b/build.gradle index fd4a12d057..7cc210cf45 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,14 @@ configure(allprojects) { ext.slf4jVersion = "1.6.1" 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: "java" apply plugin: "propdeps-eclipse" @@ -24,10 +32,35 @@ configure(allprojects) { group = "org.springframework" - sourceCompatibility=1.5 - targetCompatibility=1.5 + compileJava { + 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"] @@ -41,7 +74,7 @@ configure(allprojects) { dependencies { testCompile("junit:junit:${junitVersion}") testCompile("org.hamcrest:hamcrest-all:1.3") - testCompile("org.easymock:easymock:${easymockVersion}") + testCompile("org.mockito:mockito-core:1.9.5") } ext.javadocLinks = [ @@ -67,7 +100,17 @@ configure(allprojects) { ] 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 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") { description = "Spring Core" @@ -297,7 +368,6 @@ project("spring-tx") { optional("javax.resource:connector-api:1.5") optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1") optional("javax.ejb:ejb-api:3.0") - testCompile "org.easymock:easymockclassextension:${easymockVersion}" testCompile("javax.persistence:persistence-api:1.0") testCompile("org.aspectj:aspectjweaver:${aspectjVersion}") } @@ -306,6 +376,14 @@ project("spring-tx") { project("spring-oxm") { description = "Spring Object/XML Marshalling" 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 { compile(project(":spring-beans")) compile(project(":spring-core")) @@ -335,10 +413,11 @@ project("spring-jms") { compile(project(":spring-tx")) optional(project(":spring-oxm")) 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") optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1") 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") { 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 { compile("aopalliance:aopalliance:1.0") 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.mail:mail:1.4") 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-api:3.0.1") testCompile("org.apache.tiles:tiles-core:3.0.1") { diff --git a/gradle/jdiff/Null.java b/gradle/jdiff/Null.java index 019b71895d..2d8649e544 100644 --- a/gradle/jdiff/Null.java +++ b/gradle/jdiff/Null.java @@ -1,6 +1,6 @@ -/** +/** * This class is used only as a "null" argument for Javadoc when comparing - * two API files. Javadoc has to have a package, .java or .class file as an + * two API files. Javadoc has to have a package, .java or .class file as an * argument, even though JDiff doesn't use it. */ public class Null { diff --git a/import-into-idea.md b/import-into-idea.md index 15a4e9e62d..4bbac88504 100644 --- a/import-into-idea.md +++ b/import-into-idea.md @@ -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 _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 3. Set the Project JDK as appropriate 4. Add git support @@ -12,21 +12,21 @@ _Within your locally cloned spring-framework working directory:_ ## 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. -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. - -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.: - -* http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaProject.html -* http://gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html -* http://gradle.org/docs/current/groovydoc/org/gradle/plugins/ide/idea/model/IdeaModule.html +1. `spring-aspects` does not compile out of the box due to references to aspect types unknown to IDEA. +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. +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 +likely need to set the following VM options to avoid out of memory errors: + -XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m ## 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 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 diff --git a/settings.gradle b/settings.gradle index 11ce95641f..8d4e147bcc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,3 +22,4 @@ include "spring-web" include "spring-webmvc" include "spring-webmvc-portlet" include "spring-webmvc-tiles3" +include "spring-build-junit" diff --git a/spring-aop/src/main/java/org/springframework/aop/Advisor.java b/spring-aop/src/main/java/org/springframework/aop/Advisor.java index 21c9c8301b..8959552925 100644 --- a/spring-aop/src/main/java/org/springframework/aop/Advisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/Advisor.java @@ -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"); * 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; -/** +/** * Base interface holding AOP advice (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). This interface is not for use by Spring users, but to * allow for commonality in support for different types of advice. * *

Spring AOP is based around around advice delivered via method - * interception, compliant with the AOP Alliance interception API. + * interception, compliant with the AOP Alliance interception API. * The Advisor interface allows support for different types of advice, * such as before and after advice, which need not be * implemented using interception. @@ -50,7 +50,7 @@ public interface Advisor { * (for example, creating a mixin) or shared with all instances of * the advised class obtained from the same Spring bean factory. *

Note that this method is not currently used by the framework. - * Typical Advisor implementations always return true. + * Typical Advisor implementations always return {@code true}. * Use singleton/prototype bean definitions or appropriate programmatic * proxy creation to ensure that Advisors have the correct lifecycle model. * @return whether this advice is associated with a particular target instance diff --git a/spring-aop/src/main/java/org/springframework/aop/AfterReturningAdvice.java b/spring-aop/src/main/java/org/springframework/aop/AfterReturningAdvice.java index ac4b9ba227..46362c2b13 100644 --- a/spring-aop/src/main/java/org/springframework/aop/AfterReturningAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/AfterReturningAdvice.java @@ -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"); * 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 method method being invoked * @param args arguments to the method - * @param target target of the method invocation. May be null. + * @param target target of the method invocation. May be {@code null}. * @throws Throwable if this object wishes to abort the call. * Any exception thrown will be returned to the caller if it's * allowed by the method signature. Otherwise the exception diff --git a/spring-aop/src/main/java/org/springframework/aop/AopInvocationException.java b/spring-aop/src/main/java/org/springframework/aop/AopInvocationException.java index fa23500793..8c38ff4b81 100644 --- a/spring-aop/src/main/java/org/springframework/aop/AopInvocationException.java +++ b/spring-aop/src/main/java/org/springframework/aop/AopInvocationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.core.NestedRuntimeException; * @author Juergen Hoeller * @since 2.0 */ +@SuppressWarnings("serial") public class AopInvocationException extends NestedRuntimeException { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/DynamicIntroductionAdvice.java b/spring-aop/src/main/java/org/springframework/aop/DynamicIntroductionAdvice.java index 4fcd874cb0..17f7645e7c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/DynamicIntroductionAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/DynamicIntroductionAdvice.java @@ -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"); * 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; -/** +/** * Subinterface of AOP Alliance Advice that allows additional interfaces * to be implemented by an Advice, and available via a proxy using that * interceptor. This is a fundamental AOP concept called introduction. @@ -37,7 +37,7 @@ import org.aopalliance.aop.Advice; * @see IntroductionAdvisor */ public interface DynamicIntroductionAdvice extends Advice { - + /** * Does this introduction advice implement the given interface? * @param intf the interface to check diff --git a/spring-aop/src/main/java/org/springframework/aop/IntroductionAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/IntroductionAdvisor.java index 9e71253ef0..b576aa4b21 100644 --- a/spring-aop/src/main/java/org/springframework/aop/IntroductionAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/IntroductionAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ package org.springframework.aop; * @see IntroductionInterceptor */ public interface IntroductionAdvisor extends Advisor, IntroductionInfo { - + /** * Return the filter determining which target classes this introduction * should apply to. @@ -39,7 +39,7 @@ public interface IntroductionAdvisor extends Advisor, IntroductionInfo { * @return the class filter */ ClassFilter getClassFilter(); - + /** * Can the advised interfaces be implemented by the introduction advice? * Invoked before adding an IntroductionAdvisor. diff --git a/spring-aop/src/main/java/org/springframework/aop/IntroductionAwareMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/IntroductionAwareMethodMatcher.java index 1363960890..ffefed7eee 100644 --- a/spring-aop/src/main/java/org/springframework/aop/IntroductionAwareMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/IntroductionAwareMethodMatcher.java @@ -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"); * 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 * if the caller supports the extended IntroductionAwareMethodMatcher interface. * @param method the candidate method - * @param targetClass the target class (may be null, 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) - * @param hasIntroductions true if the object on whose behalf we are - * asking is the subject on one or more introductions; false otherwise + * @param hasIntroductions {@code true} if the object on whose behalf we are + * asking is the subject on one or more introductions; {@code false} otherwise * @return whether or not this method matches statically */ boolean matches(Method method, Class targetClass, boolean hasIntroductions); diff --git a/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java b/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java index c10e63c81d..6ba69a833d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java +++ b/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ package org.springframework.aop; * @since 1.1.1 */ public interface IntroductionInfo { - + /** * Return the additional interfaces introduced by this Advisor or Advice. * @return the introduced interfaces diff --git a/spring-aop/src/main/java/org/springframework/aop/MethodBeforeAdvice.java b/spring-aop/src/main/java/org/springframework/aop/MethodBeforeAdvice.java index 9383af683c..fb8b08e220 100644 --- a/spring-aop/src/main/java/org/springframework/aop/MethodBeforeAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/MethodBeforeAdvice.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,12 +28,12 @@ import java.lang.reflect.Method; * @author Rod Johnson */ public interface MethodBeforeAdvice extends BeforeAdvice { - + /** * Callback before a given method is invoked. * @param method method being invoked * @param args arguments to the method - * @param target target of the method invocation. May be null. + * @param target target of the method invocation. May be {@code null}. * @throws Throwable if this object wishes to abort the call. * Any exception thrown will be returned to the caller if it's * allowed by the method signature. Otherwise the exception diff --git a/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java index 40ebad2777..15526c1fc8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java @@ -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"); * 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 * previous advice applying to the joinpoint. * - *

If an implementation returns false from its {@link #isRuntime()} + *

If an implementation returns {@code false} from its {@link #isRuntime()} * 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 - * if the {@link #isRuntime()} method returns false, 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. * - *

If an implementation returns true from its 2-arg + *

If an implementation returns {@code true} from its 2-arg * {@link #matches(java.lang.reflect.Method, Class)} method and its {@link #isRuntime()} method - * returns true, 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 immediately before each potential execution of the related advice, * 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 @@ -49,11 +49,11 @@ public interface MethodMatcher { /** * Perform static checking whether the given method matches. If this - * returns false or if the {@link #isRuntime()} method - * returns false, no runtime check (i.e. no. + * returns {@code false} or if the {@link #isRuntime()} method + * returns {@code false}, no runtime check (i.e. no. * {@link #matches(java.lang.reflect.Method, Class, Object[])} call) will be made. * @param method the candidate method - * @param targetClass the target class (may be null, 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) * @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 * {@link #matches(java.lang.reflect.Method, Class, Object[])} method at - * runtime even if the 2-arg matches method returns true? + * runtime even if the 2-arg matches method returns {@code true}? *

Can be invoked when an AOP proxy is created, and need not be invoked * again before each method invocation, * @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, * which must have matched statically. *

This method is invoked only if the 2-arg matches method returns - * true for the given method and target class, and if the - * {@link #isRuntime()} method returns true. Invoked + * {@code true} for the given method and target class, and if the + * {@link #isRuntime()} method returns {@code true}. Invoked * immediately before potential running of the advice, after any * advice earlier in the advice chain has run. * @param method the candidate method - * @param targetClass the target class (may be null, 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) * @param args arguments to the method * @return whether there's a runtime match diff --git a/spring-aop/src/main/java/org/springframework/aop/Pointcut.java b/spring-aop/src/main/java/org/springframework/aop/Pointcut.java index cebbfa023c..489e7beb82 100644 --- a/spring-aop/src/main/java/org/springframework/aop/Pointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/Pointcut.java @@ -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"); * 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 (never null) + * @return the ClassFilter (never {@code null}) */ ClassFilter getClassFilter(); /** * Return the MethodMatcher for this pointcut. - * @return the MethodMatcher (never null) + * @return the MethodMatcher (never {@code null}) */ MethodMatcher getMethodMatcher(); diff --git a/spring-aop/src/main/java/org/springframework/aop/PointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/PointcutAdvisor.java index 02818d12e7..7b7c1e7864 100644 --- a/spring-aop/src/main/java/org/springframework/aop/PointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/PointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java index 00015a5d9e..935f745de4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/ProxyMethodInvocation.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,22 +40,22 @@ public interface ProxyMethodInvocation extends MethodInvocation { Object getProxy(); /** - * Create a clone of this object. If cloning is done before proceed() - * is invoked on this object, proceed() can be invoked once per clone + * Create a clone of this object. If cloning is done before {@code proceed()} + * 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. * @return an invocable clone of this invocation. - * proceed() can be called once per clone. + * {@code proceed()} can be called once per clone. */ MethodInvocation invocableClone(); /** - * Create a clone of this object. If cloning is done before proceed() - * is invoked on this object, proceed() can be invoked once per clone + * Create a clone of this object. If cloning is done before {@code proceed()} + * 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. * @param arguments the arguments that the cloned invocation is supposed to use, * overriding the original arguments * @return an invocable clone of this invocation. - * proceed() can be called once per clone. + * {@code proceed()} can be called once per clone. */ MethodInvocation invocableClone(Object[] arguments); @@ -71,14 +71,14 @@ public interface ProxyMethodInvocation extends MethodInvocation { *

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. * @param key the name of the attribute - * @param value the value of the attribute, or null to reset it + * @param value the value of the attribute, or {@code null} to reset it */ void setUserAttribute(String key, Object value); /** * Return the value of the specified user attribute. * @param key the name of the attribute - * @return the value of the attribute, or null if not set + * @return the value of the attribute, or {@code null} if not set * @see #setUserAttribute */ Object getUserAttribute(String key); diff --git a/spring-aop/src/main/java/org/springframework/aop/TargetClassAware.java b/spring-aop/src/main/java/org/springframework/aop/TargetClassAware.java index 5334ae26ff..e2eccfac57 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TargetClassAware.java +++ b/spring-aop/src/main/java/org/springframework/aop/TargetClassAware.java @@ -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"); * 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 * (typically a proxy configuration or an actual proxy). - * @return the target Class, or null if not known + * @return the target Class, or {@code null} if not known */ Class getTargetClass(); diff --git a/spring-aop/src/main/java/org/springframework/aop/TargetSource.java b/spring-aop/src/main/java/org/springframework/aop/TargetSource.java index f5be5fdb9b..8e5ccc1fa6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/TargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -17,16 +17,16 @@ package org.springframework.aop; /** - * A TargetSource 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 * advice chooses to end the interceptor chain itself. * - *

If a TargetSource is "static", it will always return + *

If a {@code TargetSource} is "static", it will always return * the same target, allowing optimizations in the AOP framework. Dynamic * target sources can support pooling, hot swapping, etc. * *

Application developers don't usually need to work with - * TargetSources directly: this is an AOP framework interface. + * {@code TargetSources} directly: this is an AOP framework interface. * * @author Rod Johnson */ @@ -34,11 +34,12 @@ public interface TargetSource extends TargetClassAware { /** * Return the type of targets returned by this {@link TargetSource}. - *

Can return null, although certain usages of a - * TargetSource might just work with a predetermined + *

Can return {@code null}, although certain usages of a + * {@code TargetSource} might just work with a predetermined * target class. * @return the type of targets returned by this {@link TargetSource} */ + @Override Class getTargetClass(); /** @@ -46,7 +47,7 @@ public interface TargetSource extends TargetClassAware { *

In that case, there will be no need to invoke * {@link #releaseTarget(Object)}, and the AOP framework can cache * the return value of {@link #getTarget()}. - * @return true if the target is immutable + * @return {@code true} if the target is immutable * @see #getTarget */ boolean isStatic(); diff --git a/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java index 0b8c228a4a..1d622196f7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,24 +23,26 @@ import java.io.Serializable; * * @author Rod Johnson */ +@SuppressWarnings("serial") class TrueClassFilter implements ClassFilter, Serializable { - + public static final TrueClassFilter INSTANCE = new TrueClassFilter(); - + /** * Enforce Singleton pattern. */ private TrueClassFilter() { } + @Override public boolean matches(Class clazz) { return true; } - + /** * Required to support serialization. Replaces with canonical * instance on deserialization, protecting Singleton pattern. - * Alternative to overriding equals(). + * Alternative to overriding {@code equals()}. */ private Object readResolve() { return INSTANCE; diff --git a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java index 7be4d470a2..b4722cdf00 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/TrueMethodMatcher.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,38 +24,42 @@ import java.lang.reflect.Method; * * @author Rod Johnson */ +@SuppressWarnings("serial") class TrueMethodMatcher implements MethodMatcher, Serializable { - + public static final TrueMethodMatcher INSTANCE = new TrueMethodMatcher(); - + /** * Enforce Singleton pattern. */ private TrueMethodMatcher() { } + @Override public boolean isRuntime() { return false; } + @Override public boolean matches(Method method, Class targetClass) { return true; } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { // Should never be invoked as isRuntime returns false. throw new UnsupportedOperationException(); } - + /** * Required to support serialization. Replaces with canonical * instance on deserialization, protecting Singleton pattern. - * Alternative to overriding equals(). + * Alternative to overriding {@code equals()}. */ private Object readResolve() { return INSTANCE; } - + @Override public String toString() { return "MethodMatcher.TRUE"; diff --git a/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java b/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java index 0c6efcb70e..1a44c2ac26 100644 --- a/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/TruePointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,28 +23,31 @@ import java.io.Serializable; * * @author Rod Johnson */ +@SuppressWarnings("serial") class TruePointcut implements Pointcut, Serializable { - + public static final TruePointcut INSTANCE = new TruePointcut(); - + /** * Enforce Singleton pattern. */ private TruePointcut() { } + @Override public ClassFilter getClassFilter() { return ClassFilter.TRUE; } + @Override public MethodMatcher getMethodMatcher() { return MethodMatcher.TRUE; } - + /** * Required to support serialization. Replaces with canonical * instance on deserialization, protecting Singleton pattern. - * Alternative to overriding equals(). + * Alternative to overriding {@code equals()}. */ private Object readResolve() { return INSTANCE; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java index 9cc93f3d28..3a6436c7f8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java @@ -203,6 +203,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence return this.aspectInstanceFactory.getAspectClassLoader(); } + @Override public int getOrder() { return this.aspectInstanceFactory.getOrder(); } @@ -211,7 +212,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence public void setAspectName(String name) { this.aspectName = name; } - + + @Override public String getAspectName() { return this.aspectName; } @@ -223,6 +225,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence this.declarationOrder = order; } + @Override public int getDeclarationOrder() { 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"); } - /** + /** * We need to hold the returning name at this level for argument binding calculations, * this method allows the afterReturning advice subclass to set the name. */ @@ -302,7 +305,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence throw new UnsupportedOperationException("Only afterThrowing advice can be used to bind a thrown exception"); } - /** + /** * We need to hold the throwing name at this level for argument binding calculations, * this method allows the afterThrowing advice subclass to set the name. */ @@ -347,8 +350,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence * on subsequent advice invocations can be as fast as possible. *

If the first argument is of type JoinPoint or ProceedingJoinPoint then we * pass a JoinPoint in that position (ProceedingJoinPoint for around advice). - *

If the first argument is of type JoinPoint.StaticPart - * then we pass a JoinPoint.StaticPart in that position. + *

If the first argument is of type {@code JoinPoint.StaticPart} + * then we pass a {@code JoinPoint.StaticPart} in that position. *

Remaining arguments have to be bound by pointcut evaluation at * 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 @@ -365,11 +368,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes(); if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) { numUnboundArgs--; - } + } else if (maybeBindJoinPointStaticPart(parameterTypes[0])) { numUnboundArgs--; } - + if (numUnboundArgs > 0) { // need to bind arguments by name as returned from the pointcut match bindArgumentsByName(numUnboundArgs); @@ -398,7 +401,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence } else { return false; - } + } } protected boolean supportsProceedingJoinPoint() { @@ -409,7 +412,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence if (candidateParameterType.equals(JoinPoint.StaticPart.class)) { this.joinPointStaticPartArgumentIndex = 0; return true; - } + } else { return false; } @@ -422,7 +425,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence if (this.argumentNames != null) { // We have been able to determine the arg names. bindExplicitArguments(numArgumentsExpectingToBind); - } + } else { throw new IllegalStateException("Advice method [" + this.aspectJAdviceMethod.getName() + "] " + "requires " + numArgumentsExpectingToBind + " arguments to be bound by name, but " + @@ -471,9 +474,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence // specified, and find the discovered argument types. if (this.returningName != null) { if (!this.argumentBindings.containsKey(this.returningName)) { - throw new IllegalStateException("Returning argument name '" + throw new IllegalStateException("Returning argument name '" + this.returningName + "' was not bound in advice arguments"); - } + } else { Integer index = this.argumentBindings.get(this.returningName); this.discoveredReturningType = this.aspectJAdviceMethod.getParameterTypes()[index]; @@ -482,9 +485,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence } if (this.throwingName != null) { if (!this.argumentBindings.containsKey(this.throwingName)) { - throw new IllegalStateException("Throwing argument name '" + throw new IllegalStateException("Throwing argument name '" + this.throwingName + "' was not bound in advice arguments"); - } + } else { Integer index = this.argumentBindings.get(this.throwingName); this.discoveredThrowingType = this.aspectJAdviceMethod.getParameterTypes()[index]; @@ -525,7 +528,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence pointcutParameterTypes[index] = methodParameterTypes[i]; index++; } - + this.pointcut.setParameterNames(pointcutParameterNames); this.pointcut.setParameterTypes(pointcutParameterTypes); } @@ -549,7 +552,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence if (this.joinPointArgumentIndex != -1) { adviceInvocationArgs[this.joinPointArgumentIndex] = jp; numBound++; - } + } else if (this.joinPointStaticPartArgumentIndex != -1) { adviceInvocationArgs[this.joinPointStaticPartArgumentIndex] = jp.getStaticPart(); numBound++; @@ -582,8 +585,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence if (numBound != this.adviceInvocationArgumentCount) { throw new IllegalStateException("Required to bind " + this.adviceInvocationArgumentCount - + " arguments, but only bound " + numBound + " (JoinPointMatch " + - (jpMatch == null ? "was NOT" : "WAS") + + + " arguments, but only bound " + numBound + " (JoinPointMatch " + + (jpMatch == null ? "was NOT" : "WAS") + " bound in invocation)"); } @@ -678,6 +681,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence this.adviceMethod = adviceMethod; } + @Override public boolean matches(Method method, Class targetClass) { return !this.adviceMethod.equals(method); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectInstanceFactory.java index 0794a3fe1b..2f1e7aaa6b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectInstanceFactory.java @@ -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"); * 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. - * @return the aspect instance (never null) + * @return the aspect instance (never {@code null}) */ Object getAspectInstance(); /** * Expose the aspect class loader that this factory uses. - * @return the aspect class loader (never null) + * @return the aspect class loader (never {@code null}) */ ClassLoader getAspectClassLoader(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java index 7a9dba9612..0fbeed07b8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java @@ -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"); * 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 * for an advice method from the pointcut expression, returning, and throwing clauses. - * If an unambiguous interpretation is not available, it returns null. + * If an unambiguous interpretation is not available, it returns {@code null}. * *

This class interprets arguments in the following way: *

    *
  1. If the first parameter of the method is of type {@link JoinPoint} * or {@link ProceedingJoinPoint}, it is assumed to be for passing - * thisJoinPoint to the advice, and the parameter name will - * be assigned the value "thisJoinPoint".
  2. + * {@code thisJoinPoint} to the advice, and the parameter name will + * be assigned the value {@code "thisJoinPoint"}. *
  3. If the first parameter of the method is of type - * JoinPoint.StaticPart, it is assumed to be for passing - * "thisJoinPointStaticPart" to the advice, and the parameter name - * will be assigned the value "thisJoinPointStaticPart".
  4. + * {@code JoinPoint.StaticPart}, it is assumed to be for passing + * {@code "thisJoinPointStaticPart"} to the advice, and the parameter name + * will be assigned the value {@code "thisJoinPointStaticPart"}. *
  5. If a {@link #setThrowingName(String) throwingName} has been set, and - * there are no unbound arguments of type Throwable+, then an + * there are no unbound arguments of type {@code Throwable+}, then an * {@link IllegalArgumentException} is raised. If there is more than one - * unbound argument of type Throwable+, then an + * unbound argument of type {@code Throwable+}, then an * {@link AmbiguousBindingException} is raised. If there is exactly one - * unbound argument of type Throwable+, then the corresponding + * unbound argument of type {@code Throwable+}, then the corresponding * parameter name is assigned the value <throwingName>.
  6. *
  7. If there remain unbound arguments, then the pointcut expression is - * examined. Let a be the number of annotation-based pointcut + * examined. Let {@code a} be the number of annotation-based pointcut * expressions (@annotation, @this, @target, @args, * @within, @withincode) that are used in binding form. Usage in * binding form has itself to be deduced: if the expression inside the * pointcut is a single string literal that meets Java variable name - * conventions it is assumed to be a variable name. If a is - * zero we proceed to the next stage. If a > 1 then an - * AmbiguousBindingException is raised. If a == 1, - * and there are no unbound arguments of type Annotation+, - * then an IllegalArgumentException is raised. if there is + * conventions it is assumed to be a variable name. If {@code a} is + * zero we proceed to the next stage. If {@code a} > 1 then an + * {@code AmbiguousBindingException} is raised. If {@code a} == 1, + * and there are no unbound arguments of type {@code Annotation+}, + * then an {@code IllegalArgumentException} is raised. if there is * exactly one such argument, then the corresponding parameter name is * assigned the value from the pointcut expression.
  8. *
  9. If a returningName has been set, and there are no unbound arguments - * then an IllegalArgumentException is raised. If there is + * then an {@code IllegalArgumentException} is raised. If there is * more than one unbound argument then an - * AmbiguousBindingException is raised. If there is exactly + * {@code AmbiguousBindingException} is raised. If there is exactly * one unbound argument then the corresponding parameter name is assigned * the value <returningName>.
  10. *
  11. If there remain unbound arguments, then the pointcut expression is - * examined once more for this, target, and - * args pointcut expressions used in the binding form (binding + * examined once more for {@code this}, {@code target}, and + * {@code args} pointcut expressions used in the binding form (binding * forms are deduced as described for the annotation based pointcuts). If * there remains more than one unbound argument of a primitive type (which - * can only be bound in args) then an - * AmbiguousBindingException is raised. If there is exactly - * one argument of a primitive type, then if exactly one args + * can only be bound in {@code args}) then an + * {@code AmbiguousBindingException} is raised. If there is exactly + * one argument of a primitive type, then if exactly one {@code args} * bound variable was found, we assign the corresponding parameter name - * the variable name. If there were no args bound variables - * found an IllegalStateException is raised. If there are - * multiple args bound variables, an - * AmbiguousBindingException is raised. At this point, if + * the variable name. If there were no {@code args} bound variables + * found an {@code IllegalStateException} is raised. If there are + * multiple {@code args} bound variables, an + * {@code AmbiguousBindingException} is raised. At this point, if * there remains more than one unbound argument we raise an - * AmbiguousBindingException. 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, and only one candidate variable name unbound from - * this, target, or args, it is + * {@code this}, {@code target}, or {@code args}, it is * assigned as the corresponding parameter name. If there are multiple - * possibilities, an AmbiguousBindingException is raised.
  12. + * possibilities, an {@code AmbiguousBindingException} is raised. *
* - *

The behavior on raising an IllegalArgumentException or - * AmbiguousBindingException is configurable to allow this discoverer + *

The behavior on raising an {@code IllegalArgumentException} or + * {@code AmbiguousBindingException} is configurable to allow this discoverer * to be used as part of a chain-of-responsibility. By default the condition will - * be logged and the getParameterNames(..) method will simply return - * null. If the {@link #setRaiseExceptions(boolean) raiseExceptions} - * property is set to true, the conditions will be thrown as - * IllegalArgumentException and AmbiguousBindingException, + * be logged and the {@code getParameterNames(..)} method will simply return + * {@code null}. If the {@link #setRaiseExceptions(boolean) raiseExceptions} + * property is set to {@code true}, the conditions will be thrown as + * {@code IllegalArgumentException} and {@code AmbiguousBindingException}, * respectively. * *

Was that perfectly clear? ;) * *

Short version: If an unambiguous binding can be deduced, then it is. - * If the advice requirements cannot possibly be satisfied, then null + * If the advice requirements cannot possibly be satisfied, then {@code null} * is returned. By setting the {@link #setRaiseExceptions(boolean) raiseExceptions} - * property to true, descriptive exceptions will be thrown instead of - * returning null in the case that the parameter names cannot be discovered. + * property to {@code true}, descriptive exceptions will be thrown instead of + * returning {@code null} in the case that the parameter names cannot be discovered. * * @author Adrian Colyer * @since 2.0 @@ -191,14 +191,14 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov /** * Indicate whether {@link IllegalArgumentException} and {@link AmbiguousBindingException} * must be thrown as appropriate in the case of failing to deduce advice parameter names. - * @param raiseExceptions true if exceptions are to be thrown + * @param raiseExceptions {@code true} if exceptions are to be thrown */ public void setRaiseExceptions(boolean raiseExceptions) { this.raiseExceptions = raiseExceptions; } /** - * If afterReturning advice binds the return value, the + * If {@code afterReturning} advice binds the return value, the * returning variable name must be specified. * @param returningName the name of the returning variable */ @@ -207,7 +207,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov } /** - * If afterThrowing advice binds the thrown value, the + * If {@code afterThrowing} advice binds the thrown value, the * throwing variable name must be specified. * @param throwingName the name of the throwing variable */ @@ -222,6 +222,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov * @param method the target {@link Method} * @return the parameter names */ + @Override public String[] getParameterNames(Method method) { this.argumentTypes = method.getParameterTypes(); this.numberOfRemainingUnboundArguments = this.argumentTypes.length; @@ -305,10 +306,11 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov /** * An advice method can never be a constructor in Spring. - * @return null + * @return {@code null} * @throws UnsupportedOperationException if - * {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to true + * {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true} */ + @Override public String[] getParameterNames(Constructor ctor) { if (this.raiseExceptions) { 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 args or at_args), + * Given an args pointcut body (could be {@code args} or {@code at_args}), * add any candidate variable names to the given list. */ private void maybeExtractVariableNamesFromArgs(String argsSpec, List varNames) { @@ -700,7 +702,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov // 1 primitive arg, and one candidate... for (int i = 0; i < this.argumentTypes.length; i++) { if (isUnbound(i) && this.argumentTypes[i].isPrimitive()) { - bindParameterName(i, (String) varNames.get(0)); + bindParameterName(i, varNames.get(0)); break; } } @@ -726,7 +728,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov } /* - * Return true if the given argument type is a subclass + * Return {@code true} if the given argument type is a subclass * of the given supertype. */ 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 - * varName in that position. + * {@code varName} in that position. */ private void findAndBind(Class argumentType, String varName) { 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 * trying to resolve a method's parameter names. */ + @SuppressWarnings("serial") public static class AmbiguousBindingException extends RuntimeException { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterAdvice.java index 148f71ce5d..c6669af251 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterAdvice.java @@ -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"); * 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); } - + + @Override public Object invoke(MethodInvocation mi) throws Throwable { try { return mi.proceed(); @@ -46,10 +47,12 @@ public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodI } } + @Override public boolean isBeforeAdvice() { return false; } + @Override public boolean isAfterAdvice() { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java index 2f9396c230..6ae24d5d7b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java @@ -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"); * 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); } + @Override public boolean isBeforeAdvice() { return false; } + @Override public boolean isAfterAdvice() { return true; } @@ -53,6 +55,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement setReturningNameNoCheck(name); } + @Override public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { if (shouldInvokeOnReturnValueOf(method, returnValue)) { invokeAdviceMethod(getJoinPointMatch(), returnValue, null); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterThrowingAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterThrowingAdvice.java index 6b9b611b96..a7bef4b213 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterThrowingAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterThrowingAdvice.java @@ -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"); * 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); } + @Override public boolean isBeforeAdvice() { return false; } + @Override public boolean isAfterAdvice() { return true; } @@ -50,6 +52,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements setThrowingNameNoCheck(name); } + @Override public Object invoke(MethodInvocation mi) throws Throwable { try { return mi.proceed(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAopUtils.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAopUtils.java index d8fe47d3e6..2155c81cd5 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAopUtils.java @@ -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"); * 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 { /** - * Return true 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) { AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); @@ -43,7 +43,7 @@ public abstract class AspectJAopUtils { } /** - * Return true 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) { AspectJPrecedenceInformation precedenceInfo = getAspectJPrecedenceInformationFor(anAdvisor); @@ -56,7 +56,7 @@ public abstract class AspectJAopUtils { /** * Return the AspectJPrecedenceInformation provided by this advisor or its advice. * If neither the advisor nor the advice have precedence information, this method - * will return null. + * will return {@code null}. */ public static AspectJPrecedenceInformation getAspectJPrecedenceInformationFor(Advisor anAdvisor) { if (anAdvisor instanceof AspectJPrecedenceInformation) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java index 3048103a10..b9c546342b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAroundAdvice.java @@ -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"); * 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); } + @Override public boolean isBeforeAdvice() { return false; } + @Override public boolean isAfterAdvice() { return false; } @@ -55,6 +57,7 @@ public class AspectJAroundAdvice extends AbstractAspectJAdvice implements Method } + @Override public Object invoke(MethodInvocation mi) throws Throwable { if (!(mi instanceof ProxyMethodInvocation)) { throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java index 348b8449c3..2f92de4f8f 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -76,6 +76,7 @@ import org.springframework.util.StringUtils; * @author Dave Syer * @since 2.0 */ +@SuppressWarnings("serial") public class AspectJExpressionPointcut extends AbstractExpressionPointcut implements ClassFilter, IntroductionAwareMethodMatcher, BeanFactoryAware { @@ -154,16 +155,19 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut this.pointcutParameterTypes = types; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } + @Override public ClassFilter getClassFilter() { checkReadyToMatch(); return this; } + @Override public MethodMatcher getMethodMatcher() { checkReadyToMatch(); return this; @@ -223,9 +227,9 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut /** * If a pointcut expression has been specified in XML, the user cannot - * write and as "&&" (though && will work). - * We also allow and between two pointcut sub-expressions. - *

This method converts back to && for the AspectJ pointcut parser. + * write {@code and} as "&&" (though && will work). + * We also allow {@code and} between two pointcut sub-expressions. + *

This method converts back to {@code &&} for the AspectJ pointcut parser. */ private String replaceBooleanOperators(String pcExpr) { String result = StringUtils.replace(pcExpr, " and ", " && "); @@ -243,6 +247,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut return this.pointcutExpression; } + @Override public boolean matches(Class targetClass) { checkReadyToMatch(); try { @@ -259,13 +264,14 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut ex); return false; } - } + } catch (BCException ex) { logger.debug("PointcutExpression matching rejected target class", ex); return false; } } + @Override public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) { checkReadyToMatch(); Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass); @@ -286,15 +292,18 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut } } + @Override public boolean matches(Method method, Class targetClass) { return matches(method, targetClass, false); } + @Override public boolean isRuntime() { checkReadyToMatch(); return this.pointcutExpression.mayNeedDynamicTest(); } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { checkReadyToMatch(); ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method); @@ -494,10 +503,10 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut /** - * Handler for the Spring-specific bean() pointcut designator + * Handler for the Spring-specific {@code bean()} pointcut designator * extension to AspectJ. *

This handler must be added to each pointcut object that needs to - * handle the bean() 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 * 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"; + @Override public String getDesignatorName() { return BEAN_DESIGNATOR_NAME; } + @Override public ContextBasedMatcher parse(String expression) { return new BeanNameContextMatcher(expression); } @@ -530,22 +541,27 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut this.expressionPattern = new NamePattern(expression); } + @Override public boolean couldMatchJoinPointsInType(Class someClass) { return (contextMatch(someClass) == FuzzyBoolean.YES); } + @Override public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) { return (contextMatch(someClass) == FuzzyBoolean.YES); } + @Override public boolean matchesDynamically(MatchingContext context) { return true; } + @Override public FuzzyBoolean matchesStatically(MatchingContext context) { return contextMatch(null); } + @Override public boolean mayNeedDynamicTest() { return false; } @@ -554,7 +570,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut String advisedBeanName = getCurrentProxiedBeanName(); if (advisedBeanName == null) { // no proxy creation in progress // abstain; can't return YES, since that will make pointcut with negation fail - return FuzzyBoolean.MAYBE; + return FuzzyBoolean.MAYBE; } if (BeanFactoryUtils.isGeneratedBeanName(advisedBeanName)) { return FuzzyBoolean.NO; @@ -610,18 +626,22 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut this.other = other; } + @Override public boolean alwaysMatches() { return primary.alwaysMatches(); } + @Override public boolean maybeMatches() { return primary.maybeMatches(); } + @Override public boolean neverMatches() { return primary.neverMatches(); } + @Override public JoinPointMatch matchesJoinPoint(Object thisObject, Object targetObject, Object[] args) { try { @@ -631,6 +651,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut } } + @Override public void setMatchingContext(MatchingContext aMatchContext) { primary.setMatchingContext(aMatchContext); other.setMatchingContext(aMatchContext); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisor.java index 001b161fe4..5354360cd4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisor.java @@ -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"); * 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. - * + * * @author Rob Harrop * @since 2.0 */ +@SuppressWarnings("serial") public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdvisor { private final AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); + @Override public Pointcut getPointcut() { return this.pointcut; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJMethodBeforeAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJMethodBeforeAdvice.java index 503119714f..6f7ce26b39 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJMethodBeforeAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJMethodBeforeAdvice.java @@ -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"); * 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); } + @Override public void before(Method method, Object[] args, Object target) throws Throwable { invokeAdviceMethod(getJoinPointMatch(), null, null); } + @Override public boolean isBeforeAdvice() { return true; } + @Override public boolean isAfterAdvice() { return false; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java index 2b8950a0e6..14ad6c67a9 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java @@ -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"); * 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() { return true; } + @Override public Advice getAdvice() { return this.advice; } + @Override public Pointcut getPointcut() { return this.pointcut; } + @Override public int getOrder() { if (this.order != null) { return this.order; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java index 5c92ae6b4d..3463e8cc61 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java @@ -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"); * 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 */ public abstract class AspectJProxyUtils { - + /** * Add special advisors if necessary to work with a proxy chain that contains AspectJ advisors. * This will expose the current Spring AOP invocation (necessary for some AspectJ pointcut matching) * and make available the current AspectJ JoinPoint. The call will have no effect if there are no * AspectJ advisors in the advisor chain. * @param advisors Advisors available - * @return true if any special {@link Advisor Advisors} were added, otherwise false. + * @return {@code true} if any special {@link Advisor Advisors} were added, otherwise {@code false}. */ public static boolean makeAdvisorChainAspectJCapableIfNecessary(List advisors) { // Don't add advisors to an empty list; may indicate that proxying is just not required diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJWeaverMessageHandler.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJWeaverMessageHandler.java index 8932259dc3..c6e568b7d8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJWeaverMessageHandler.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJWeaverMessageHandler.java @@ -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"); * 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 * routes AspectJ weaving messages through the same logging system as the * regular Spring messages. - * + * *

Pass the option... * *

-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler * *

to the weaver; for example, specifying the following in a - * "META-INF/aop.xml file: + * "{@code META-INF/aop.xml} file: * *

<weaver options="..."/> * @@ -44,10 +44,11 @@ import org.aspectj.bridge.IMessageHandler; public class AspectJWeaverMessageHandler implements IMessageHandler { private static final String AJ_ID = "[AspectJ] "; - - private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver"); - + private static final Log LOGGER = LogFactory.getLog("AspectJ Weaver"); + + + @Override public boolean handleMessage(IMessage message) throws AbortException { Kind messageKind = message.getKind(); @@ -56,52 +57,55 @@ public class AspectJWeaverMessageHandler implements IMessageHandler { LOGGER.debug(makeMessageFor(message)); return true; } - } - + } + if (LOGGER.isInfoEnabled()) { if ((messageKind == IMessage.INFO) || (messageKind == IMessage.WEAVEINFO)) { LOGGER.info(makeMessageFor(message)); return true; } - } - + } + if (LOGGER.isWarnEnabled()) { if (messageKind == IMessage.WARNING) { LOGGER.warn(makeMessageFor(message)); return true; } } - + if (LOGGER.isErrorEnabled()) { if (messageKind == IMessage.ERROR) { LOGGER.error(makeMessageFor(message)); return true; } } - + if (LOGGER.isFatalEnabled()) { if (messageKind == IMessage.ABORT) { LOGGER.fatal(makeMessageFor(message)); return true; } } - + return false; } - + private String makeMessageFor(IMessage aMessage) { return AJ_ID + aMessage.getMessage(); } + @Override public boolean isIgnoring(Kind messageKind) { // We want to see everything, and allow configuration of log levels dynamically. return false; } + @Override public void dontIgnore(Kind messageKind) { // We weren't ignoring anything anyway... } + @Override public void ignore(Kind kind) { // We weren't ignoring anything anyway... } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java index a60227a5df..0d1a84247b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java @@ -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"); * 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 */ public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) { - this(interfaceType, typePattern, defaultImpl, + this(interfaceType, typePattern, defaultImpl, new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); } @@ -59,7 +59,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param delegateRef the delegate implementation object */ public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) { - this(interfaceType, typePattern, delegateRef.getClass(), + this(interfaceType, typePattern, delegateRef.getClass(), new DelegatingIntroductionInterceptor(delegateRef)); } @@ -77,6 +77,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { // Excludes methods implemented. ClassFilter exclusion = new ClassFilter() { + @Override public boolean matches(Class clazz) { return !(introducedInterface.isAssignableFrom(clazz)); } @@ -87,22 +88,27 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { } + @Override public ClassFilter getClassFilter() { return this.typePatternClassFilter; } + @Override public void validateInterfaces() throws IllegalArgumentException { // Do nothing } + @Override public boolean isPerInstance() { return true; } + @Override public Advice getAdvice() { return this.advice; } + @Override public Class[] getInterfaces() { return new Class[] {this.introducedInterface}; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java index 6668a8b015..952706078e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java @@ -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"); * 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 * wrapping an AOP Alliance MethodInvocation. * - *

Note: the getThis() method returns the current Spring AOP proxy. - * The getTarget() method returns the current Spring AOP target (which may be - * null if there is no target), and is a plain POJO without any advice. + *

Note: the {@code getThis()} method returns the current Spring AOP proxy. + * The {@code getTarget()} method returns the current Spring AOP target (which may be + * {@code null} if there is no target), and is a plain POJO without any advice. * If you want to call the object and have the advice take effect, use - * getThis(). A common example is casting the object to an + * {@code getThis()}. A common example is casting the object to an * introduced interface in the implementation of an introduction. * *

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 */ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, JoinPoint.StaticPart { - + private final ProxyMethodInvocation methodInvocation; private Object[] defensiveCopyOfArgs; @@ -72,14 +72,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, this.methodInvocation = methodInvocation; } + @Override public void set$AroundClosure(AroundClosure aroundClosure) { throw new UnsupportedOperationException(); } + @Override public Object proceed() throws Throwable { return this.methodInvocation.invocableClone().proceed(); } + @Override public Object proceed(Object[] arguments) throws Throwable { Assert.notNull(arguments, "Argument array passed to proceed cannot be null"); if (arguments.length != this.methodInvocation.getArguments().length) { @@ -92,19 +95,22 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, } /** - * Returns the Spring AOP proxy. Cannot be null. + * Returns the Spring AOP proxy. Cannot be {@code null}. */ + @Override public Object getThis() { return this.methodInvocation.getProxy(); } /** - * Returns the Spring AOP target. May be null if there is no target. + * Returns the Spring AOP target. May be {@code null} if there is no target. */ + @Override public Object getTarget() { return this.methodInvocation.getThis(); } + @Override public Object[] getArgs() { if (this.defensiveCopyOfArgs == null) { Object[] argsSource = this.methodInvocation.getArguments(); @@ -114,6 +120,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, return this.defensiveCopyOfArgs; } + @Override public Signature getSignature() { if (this.signature == null) { this.signature = new MethodSignatureImpl(); @@ -121,6 +128,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, return signature; } + @Override public SourceLocation getSourceLocation() { if (this.sourceLocation == null) { this.sourceLocation = new SourceLocationImpl(); @@ -128,23 +136,28 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, return this.sourceLocation; } + @Override public String getKind() { return ProceedingJoinPoint.METHOD_EXECUTION; } + @Override public int getId() { // TODO: It's just an adapter but returning 0 might still have side effects... return 0; } + @Override public JoinPoint.StaticPart getStaticPart() { return this; } + @Override public String toShortString() { return "execution(" + getSignature().toShortString() + ")"; } + @Override public String toLongString() { return "execution(" + getSignature().toLongString() + ")"; } @@ -161,34 +174,42 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, private volatile String[] parameterNames; + @Override public String getName() { return methodInvocation.getMethod().getName(); } + @Override public int getModifiers() { return methodInvocation.getMethod().getModifiers(); } + @Override public Class getDeclaringType() { return methodInvocation.getMethod().getDeclaringClass(); } + @Override public String getDeclaringTypeName() { return methodInvocation.getMethod().getDeclaringClass().getName(); } + @Override public Class getReturnType() { return methodInvocation.getMethod().getReturnType(); } + @Override public Method getMethod() { return methodInvocation.getMethod(); } + @Override public Class[] getParameterTypes() { return methodInvocation.getMethod().getParameterTypes(); } + @Override public String[] getParameterNames() { if (this.parameterNames == null) { this.parameterNames = (new LocalVariableTableParameterNameDiscoverer()).getParameterNames(getMethod()); @@ -196,14 +217,17 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, return this.parameterNames; } + @Override public Class[] getExceptionTypes() { return methodInvocation.getMethod().getExceptionTypes(); } + @Override public String toShortString() { return toString(false, false, false, false); } + @Override public String toLongString() { return toString(true, true, true, true); } @@ -267,6 +291,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, */ private class SourceLocationImpl implements SourceLocation { + @Override public Class getWithinType() { if (methodInvocation.getThis() == 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(); } + @Override public String getFileName() { throw new UnsupportedOperationException(); } + @Override public int getLine() { throw new UnsupportedOperationException(); } + @Override public int getColumn() { throw new UnsupportedOperationException(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java index 1af86cc417..7d52c03615 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java @@ -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"); * 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 - * pushed back into the AspectJ project in a future release. + * pushed back into the AspectJ project in a future release. * *

It relies on implementation specific knowledge in AspectJ to break * encapsulation and do something AspectJ was not designed to do: query * the types of runtime tests that will be performed. The code here should - * migrate to ShadowMatch.getVariablesInvolvedInRuntimeTest() + * migrate to {@code ShadowMatch.getVariablesInvolvedInRuntimeTest()} * or some similar operation. * *

See . @@ -106,38 +106,47 @@ class RuntimeTestWalker { protected static final int AT_TARGET_VAR = 4; protected static final int AT_ANNOTATION_VAR = 8; + @Override public void visit(And e) { e.getLeft().accept(this); e.getRight().accept(this); } + @Override public void visit(Or e) { e.getLeft().accept(this); e.getRight().accept(this); } + @Override public void visit(Not e) { e.getBody().accept(this); } + @Override public void visit(Instanceof i) { } + @Override public void visit(Literal literal) { } + @Override public void visit(Call call) { } + @Override public void visit(FieldGetCall fieldGetCall) { } + @Override public void visit(HasAnnotation hasAnnotation) { } + @Override public void visit(MatchingContextBasedTest matchingContextTest) { } - + protected int getVarType(ReflectionVar v) { try { Field varTypeField = ReflectionVar.class.getDeclaredField("varType"); @@ -169,7 +178,7 @@ class RuntimeTestWalker { this.matches = defaultMatches; this.matchVarType = matchVarType; } - + public boolean instanceOfMatches(Test test) { test.accept(this); return matches; @@ -236,7 +245,7 @@ class RuntimeTestWalker { aTest.accept(this); return this.testsSubtypeSensitiveVars; } - + @Override public void visit(Instanceof i) { ReflectionVar v = (ReflectionVar) i.getVar(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java index 8c0f70fe98..dfb36d6a72 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/SimpleAspectInstanceFactory.java @@ -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"); * 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 null). + * Return the specified aspect class (never {@code null}). */ public final Class getAspectClass() { return this.aspectClass; } + @Override public final Object getAspectInstance() { try { return this.aspectClass.newInstance(); @@ -61,6 +62,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory { } } + @Override public ClassLoader getAspectClassLoader() { return this.aspectClass.getClassLoader(); } @@ -73,6 +75,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory { * @see org.springframework.core.Ordered * @see #getOrderForAspectClass */ + @Override public int getOrder() { return getOrderForAspectClass(this.aspectClass); } @@ -81,7 +84,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory { * Determine a fallback order for the case that the aspect instance * does not express an instance-specific order through implementing * the {@link org.springframework.core.Ordered} interface. - *

The default implementation simply returns Ordered.LOWEST_PRECEDENCE. + *

The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}. * @param aspectClass the aspect class */ protected int getOrderForAspectClass(Class aspectClass) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/SingletonAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/SingletonAspectInstanceFactory.java index 53e8600224..1e8f723efb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/SingletonAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/SingletonAspectInstanceFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.util.Assert; * @see SimpleAspectInstanceFactory */ public class SingletonAspectInstanceFactory implements AspectInstanceFactory { - + private final Object aspectInstance; @@ -44,10 +44,12 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory { } + @Override public final Object getAspectInstance() { return this.aspectInstance; } + @Override public ClassLoader getAspectClassLoader() { return this.aspectInstance.getClass().getClassLoader(); } @@ -60,6 +62,7 @@ public class SingletonAspectInstanceFactory implements AspectInstanceFactory { * @see org.springframework.core.Ordered * @see #getOrderForAspectClass */ + @Override public int getOrder() { if (this.aspectInstance instanceof Ordered) { 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 * does not express an instance-specific order through implementing * the {@link org.springframework.core.Ordered} interface. - *

The default implementation simply returns Ordered.LOWEST_PRECEDENCE. + *

The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}. * @param aspectClass the aspect class */ protected int getOrderForAspectClass(Class aspectClass) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java index 984c46f4f9..f2893fc583 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/TypePatternClassFilter.java @@ -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"); * 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. * @param typePattern the type pattern that AspectJ weaver should parse - * @throws IllegalArgumentException if the supplied typePattern is null - * or is recognized as invalid + * @throws IllegalArgumentException if the supplied {@code typePattern} is {@code null} + * or is recognized as invalid */ public TypePatternClassFilter(String typePattern) { setTypePattern(typePattern); @@ -68,12 +68,12 @@ public class TypePatternClassFilter implements ClassFilter { * * org.springframework.beans.ITestBean+ * - * This will match the ITestBean interface and any class + * This will match the {@code ITestBean} interface and any class * that implements it. *

These conventions are established by AspectJ, not Spring AOP. * @param typePattern the type pattern that AspectJ weaver should parse - * @throws IllegalArgumentException if the supplied typePattern is null - * or is recognized as invalid + * @throws IllegalArgumentException if the supplied {@code typePattern} is {@code null} + * or is recognized as invalid */ public void setTypePattern(String typePattern) { Assert.notNull(typePattern); @@ -93,6 +93,7 @@ public class TypePatternClassFilter implements ClassFilter { * @return whether the advice should apply to this candidate target class * @throws IllegalStateException if no {@link #setTypePattern(String)} has been set */ + @Override public boolean matches(Class clazz) { if (this.aspectJTypePatternMatcher == null) { 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 - * write and as "&&" (though && will work). - * We also allow and between two sub-expressions. - *

This method converts back to && for the AspectJ pointcut parser. + * write {@code and} as "&&" (though && will work). + * We also allow {@code and} between two sub-expressions. + *

This method converts back to {@code &&} for the AspectJ pointcut parser. */ private String replaceBooleanOperators(String pcExpr) { pcExpr = StringUtils.replace(pcExpr," and "," && "); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java index cb09937a39..add6c5fac2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ import org.springframework.util.StringUtils; * @since 2.0 */ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFactory { - + protected static final ParameterNameDiscoverer ASPECTJ_ANNOTATION_PARAMETER_NAME_DISCOVERER = new AspectJAnnotationParameterNameDiscoverer(); @@ -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 * when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP. */ + @Override public boolean isAspect(Class 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 - * interpreted by Spring AOP. + * interpreted by Spring AOP. */ private boolean compiledByAjc(Class clazz) { // The AJTypeSystem goes to great lengths to provide a uniform appearance between code-style and @@ -135,6 +136,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac return false; } + @Override public void validate(Class aspectClass) throws AopConfigException { // If the parent has the annotation and isn't abstract it's an error if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null && @@ -154,11 +156,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) { throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + "This is not supported in Spring AOP."); - } + } } /** - * The pointcut and advice annotations both have an "argNames" member which contains a + * The pointcut and advice annotations both have an "argNames" member which contains a * comma-separated list of the argument names. We use this (if non-empty) to build the * formal parameters for the pointcut. */ @@ -169,13 +171,13 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac if (pointcutParameterNames != null) { pointcutParameterTypes = extractPointcutParameterTypes(pointcutParameterNames,annotatedMethod); } - + AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(declarationScope,pointcutParameterNames,pointcutParameterTypes); ajexp.setLocation(annotatedMethod.toString()); return ajexp; } - + /** * Create the pointcut parameters needed by aspectj based on the given argument names * and the argument types that are available from the adviceMethod. Needs to take into @@ -309,6 +311,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac */ private static class AspectJAnnotationParameterNameDiscoverer implements ParameterNameDiscoverer { + @Override public String[] getParameterNames(Method method) { if (method.getParameterTypes().length == 0) { return new String[0]; @@ -326,10 +329,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac return names; } else { - return null; + return null; } } - + + @Override public String[] getParameterNames(Constructor ctor) { throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice"); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java index d19a5d7c67..9eff81682b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ import org.springframework.util.Assert; * @since 2.0 * @see org.springframework.aop.aspectj.annotation.AspectJAdvisorFactory */ +@SuppressWarnings("serial") public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorAutoProxyCreator { private List includePatterns; @@ -103,7 +104,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA /** * Check whether the given aspect bean is eligible for auto-proxying. *

If no <aop:include> elements were used then "includePatterns" will be - * null 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. */ protected boolean isEligibleAspectBean(String beanName) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java index d6141af1ab..36bf115105 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJAdvisorFactory.java @@ -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"); * 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 * by AspectJ's {@link org.aspectj.lang.reflect.AjTypeSystem}. - *

Will simply return false if the supposed aspect is + *

Will simply return {@code false} if the supposed aspect is * invalid (such as an extension of a concrete aspect class). * Will return true for some aspects that Spring AOP cannot process, * such as those with unsupported instantiation models. @@ -75,7 +75,7 @@ public interface AspectJAdvisorFactory { * @param aif the aspect instance factory * @param declarationOrderInAspect the declaration order within the aspect * @param aspectName the name of the aspect - * @return null 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 * create a Spring advice in its own right */ @@ -89,7 +89,7 @@ public interface AspectJAdvisorFactory { * @param aif the aspect instance factory * @param declarationOrderInAspect the declaration order within the aspect * @param aspectName the name of the aspect - * @return null 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 * create a Spring advice in its own right * @see org.springframework.aop.aspectj.AspectJAroundAdvice diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java index cbe06d3c27..b160ded0b8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java @@ -46,6 +46,7 @@ import org.springframework.util.ClassUtils; * @see #getProxy(ClassLoader) * @see org.springframework.aop.framework.ProxyFactory */ +@SuppressWarnings("serial") public class AspectJProxyFactory extends ProxyCreatorSupport { /** Cache for singleton aspect instances */ @@ -72,7 +73,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport { } /** - * Create a new AspectJProxyFactory. + * Create a new {@code AspectJProxyFactory}. * No target, only interfaces. Must add interceptors. */ public AspectJProxyFactory(Class[] interfaces) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java index cde9f43ef3..ccf2aa610b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java @@ -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"); * you may not use this file except in compliance with the License. @@ -55,8 +55,8 @@ public class AspectMetadata { private final Pointcut perClausePointcut; /** - * The name of this aspect as defined to Spring (the bean name) - - * allows us to determine if two pieces of advice come from the + * The name of this aspect as defined to Spring (the bean name) - + * allows us to determine if two pieces of advice come from the * same aspect and hence their relative precedence. */ private String aspectName; @@ -109,7 +109,7 @@ public class AspectMetadata { } /** - * Extract contents from String of form pertarget(contents). + * Extract contents from String of form {@code pertarget(contents)}. */ private String findPerClause(Class aspectClass) { // 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. - * (e.g. Pointcut.TRUE if it's a singleton). + * (e.g. {@code Pointcut.TRUE} if it's a singleton). */ public Pointcut getPerClausePointcut() { return this.perClausePointcut; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java index a640e36458..855af77216 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectInstanceFactory.java @@ -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"); * 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}. * *

Note that this may instantiate multiple times if using a prototype, - * which probably won't give the semantics you expect. + * which probably won't give the semantics you expect. * Use a {@link LazySingletonAspectInstanceFactoryDecorator} * to wrap this to ensure only one new aspect comes back. * @@ -56,7 +56,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name) { this(beanFactory, name, beanFactory.getType(name)); } - + /** * Create a BeanFactoryAspectInstanceFactory, providing a type that AspectJ should * introspect to create AJType metadata. Use if the BeanFactory may consider the type @@ -72,10 +72,12 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst } + @Override public Object getAspectInstance() { return this.beanFactory.getBean(this.name); } + @Override public ClassLoader getAspectClassLoader() { if (this.beanFactory instanceof ConfigurableBeanFactory) { return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); @@ -85,6 +87,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst } } + @Override public AspectMetadata getAspectMetadata() { return this.aspectMetadata; } @@ -99,6 +102,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst * @see org.springframework.core.Ordered * @see org.springframework.core.annotation.Order */ + @Override public int getOrder() { Class type = this.beanFactory.getType(this.name); if (type != null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java index 433a33bb6b..2d16ece7c5 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/InstantiationModelAwarePointcutAdvisorImpl.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,23 +41,23 @@ class InstantiationModelAwarePointcutAdvisorImpl implements InstantiationModelAwarePointcutAdvisor, AspectJPrecedenceInformation { private final AspectJExpressionPointcut declaredPointcut; - + private Pointcut pointcut; - + private final MetadataAwareAspectInstanceFactory aspectInstanceFactory; - + private final Method method; - + private final boolean lazy; - + private final AspectJAdvisorFactory atAspectJAdvisorFactory; - + private Advice instantiatedAdvice; private int declarationOrder; - + private String aspectName; - + private Boolean isBeforeAdvice; private Boolean isAfterAdvice; @@ -72,12 +72,12 @@ class InstantiationModelAwarePointcutAdvisorImpl this.aspectInstanceFactory = aif; this.declarationOrder = declarationOrderInAspect; this.aspectName = aspectName; - + if (aif.getAspectMetadata().isLazilyInstantiated()) { // Static part of the pointcut is a lazy type. Pointcut preInstantiationPointcut = Pointcuts.union(aif.getAspectMetadata().getPerClausePointcut(), this.declaredPointcut); - + // Make it dynamic: must mutate from pre-instantiation to post-instantiation state. // If it's not a dynamic pointcut, it may be optimized out // by the Spring AOP infrastructure after the first evaluation. @@ -97,19 +97,21 @@ class InstantiationModelAwarePointcutAdvisorImpl * The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change * depending on the state of the advice. */ + @Override public Pointcut getPointcut() { return this.pointcut; } /** * This is only of interest for Spring AOP: AspectJ instantiation semantics - * are much richer. In AspectJ terminology, all a return of true + * are much richer. In AspectJ terminology, all a return of {@code true} * means here is that the aspect is not a SINGLETON. */ + @Override public boolean isPerInstance() { return (getAspectMetadata().getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON); } - + /** * Return the AspectJ AspectMetadata for this advisor. */ @@ -120,17 +122,20 @@ class InstantiationModelAwarePointcutAdvisorImpl /** * Lazily instantiate advice if necessary. */ + @Override public synchronized Advice getAdvice() { if (this.instantiatedAdvice == null) { this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut); } return this.instantiatedAdvice; } - + + @Override public boolean isLazy() { return this.lazy; } + @Override public synchronized boolean isAdviceInstantiated() { return (this.instantiatedAdvice != null); } @@ -140,7 +145,7 @@ class InstantiationModelAwarePointcutAdvisorImpl return this.atAspectJAdvisorFactory.getAdvice( this.method, pcut, this.aspectInstanceFactory, this.declarationOrder, this.aspectName); } - + public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() { return this.aspectInstanceFactory; } @@ -149,18 +154,22 @@ class InstantiationModelAwarePointcutAdvisorImpl return this.declaredPointcut; } + @Override public int getOrder() { return this.aspectInstanceFactory.getOrder(); } + @Override public String getAspectName() { return this.aspectName; } + @Override public int getDeclarationOrder() { return this.declarationOrder; } + @Override public boolean isBeforeAdvice() { if (this.isBeforeAdvice == null) { determineAdviceType(); @@ -168,6 +177,7 @@ class InstantiationModelAwarePointcutAdvisorImpl return this.isBeforeAdvice; } + @Override public boolean isAfterAdvice() { if (this.isAfterAdvice == null) { determineAdviceType(); @@ -245,6 +255,7 @@ class InstantiationModelAwarePointcutAdvisorImpl this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass); } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { // This can match only on declared pointcut. return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/LazySingletonAspectInstanceFactoryDecorator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/LazySingletonAspectInstanceFactoryDecorator.java index 39d28fff7e..36bb4eeb42 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/LazySingletonAspectInstanceFactoryDecorator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/LazySingletonAspectInstanceFactoryDecorator.java @@ -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"); * 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() { if (this.materialized == null) { synchronized (this) { @@ -57,14 +58,17 @@ public class LazySingletonAspectInstanceFactoryDecorator implements MetadataAwar return (this.materialized != null); } + @Override public ClassLoader getAspectClassLoader() { return this.maaif.getAspectClassLoader(); } + @Override public AspectMetadata getAspectMetadata() { return this.maaif.getAspectMetadata(); } + @Override public int getOrder() { return this.maaif.getOrder(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java index 297286cbf4..1c45cbc2f6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/NotAnAtAspectException.java @@ -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"); * 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 * @since 2.0 */ +@SuppressWarnings("serial") public class NotAnAtAspectException extends AopConfigException { private Class nonAspectClass; diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java index c2e356678a..35ed1e2847 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java @@ -75,6 +75,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto new InstanceComparator( Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class), new Converter() { + @Override public Annotation convert(Method method) { AspectJAnnotation annotation = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); return annotation == null ? null : annotation.getAnnotation(); @@ -82,6 +83,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto })); comparator.addComparator(new ConvertingComparator( new Converter() { + @Override public String convert(Method method) { return method.getName(); } @@ -90,6 +92,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto } + @Override public List getAdvisors(MetadataAwareAspectInstanceFactory maaif) { final Class aspectClass = maaif.getAspectMetadata().getAspectClass(); final String aspectName = maaif.getAspectMetadata().getAspectName(); @@ -128,6 +131,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto private List getAdvisorMethods(Class aspectClass) { final List methods = new LinkedList(); ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException { // Exclude pointcuts if (AnnotationUtils.getAnnotation(method, Pointcut.class) == null) { @@ -144,7 +148,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto * for the given introduction field. *

Resulting Advisors will need to be evaluated for targets. * @param introductionField the field to introspect - * @return null if not an Advisor + * @return {@code null} if not an Advisor */ private Advisor getDeclareParentsAdvisor(Field introductionField) { DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class); @@ -164,6 +168,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto } + @Override public Advisor getAdvisor(Method candidateAdviceMethod, MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) { @@ -191,6 +196,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto } + @Override public Advice getAdvice(Method candidateAdviceMethod, AspectJExpressionPointcut ajexp, MetadataAwareAspectInstanceFactory aif, int declarationOrderInAspect, String aspectName) { @@ -203,7 +209,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto return null; } - // If we get here, we know we have an AspectJ method. + // If we get here, we know we have an AspectJ method. // Check that it's an AspectJ-annotated class if (!isAspect(candidateAspectClass)) { throw new AopConfigException("Advice must be declared inside an aspect type: " + @@ -272,6 +278,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) { super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() { + @Override public void before(Method method, Object[] args, Object target) { // Simply instantiate the aspect aif.getAspectInstance(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SimpleMetadataAwareAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SimpleMetadataAwareAspectInstanceFactory.java index 33d19a8811..70ff5e6532 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SimpleMetadataAwareAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SimpleMetadataAwareAspectInstanceFactory.java @@ -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"); * 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() { return this.metadata; } @@ -53,7 +54,7 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan * Determine a fallback order for the case that the aspect instance * does not express an instance-specific order through implementing * the {@link org.springframework.core.Ordered} interface. - *

The default implementation simply returns Ordered.LOWEST_PRECEDENCE. + *

The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}. * @param aspectClass the aspect class */ @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SingletonMetadataAwareAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SingletonMetadataAwareAspectInstanceFactory.java index aa279de07c..31f1e18f27 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SingletonMetadataAwareAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/SingletonMetadataAwareAspectInstanceFactory.java @@ -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"); * 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() { return this.metadata; } @@ -54,7 +55,7 @@ public class SingletonMetadataAwareAspectInstanceFactory extends SingletonAspect /** * Check whether the aspect class carries an * {@link org.springframework.core.annotation.Order} annotation, - * falling back to Ordered.LOWEST_PRECEDENCE. + * falling back to {@code Ordered.LOWEST_PRECEDENCE}. * @see org.springframework.core.annotation.Order */ @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/package-info.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/package-info.java index b0f747284b..36b3f59f3d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/package-info.java @@ -2,7 +2,7 @@ /** * * Classes enabling AspectJ 5 @Annotated classes to be used in Spring AOP. - * + * *

Normally to be used through an AspectJAutoProxyCreator rather than directly. * */ diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java index 0cb786cc25..847b1932af 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.util.ClassUtils; * @author Ramnivas Laddad * @since 2.0 */ +@SuppressWarnings("serial") public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator { private static final Comparator DEFAULT_PRECEDENCE_COMPARATOR = new AspectJPrecedenceComparator(); @@ -72,22 +73,22 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx for (Advisor element : advisors) { partiallyComparableAdvisors.add( new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR)); - } - + } + // sort it List sorted = - (List) PartialOrder.sort(partiallyComparableAdvisors); + PartialOrder.sort(partiallyComparableAdvisors); if (sorted == null) { // TODO: work harder to give a better error message here. throw new IllegalArgumentException("Advice precedence circularity error"); } - + // extract results again List result = new LinkedList(); for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) { result.add(pcAdvisor.getAdvisor()); } - + return result; } @@ -130,11 +131,13 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx this.comparator = comparator; } + @Override public int compareTo(Object obj) { Advisor otherAdvisor = ((PartiallyComparableAdvisorHolder) obj).advisor; return this.comparator.compare(this.advisor, otherAdvisor); } + @Override public int fallbackCompareTo(Object obj) { return 0; } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java index c293f0be72..2e2134675b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java @@ -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"); * 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 (not invocation order). * - *

Given two pieces of advice, a and b: + *

Given two pieces of advice, {@code a} and {@code b}: *

@@ -76,6 +76,7 @@ class AspectJPrecedenceComparator implements Comparator { } + @Override public int compare(Object o1, Object o2) { if (!(o1 instanceof Advisor && o2 instanceof Advisor)) { throw new IllegalArgumentException( @@ -106,14 +107,14 @@ class AspectJPrecedenceComparator implements Comparator { boolean oneOrOtherIsAfterAdvice = (AspectJAopUtils.isAfterAdvice(advisor1) || AspectJAopUtils.isAfterAdvice(advisor2)); int adviceDeclarationOrderDelta = getAspectDeclarationOrder(advisor1) - getAspectDeclarationOrder(advisor2); - + if (oneOrOtherIsAfterAdvice) { // the advice declared last has higher precedence if (adviceDeclarationOrderDelta < 0) { // advice1 was declared before advice2 // so advice1 has lower precedence return LOWER_PRECEDENCE; - } + } else if (adviceDeclarationOrderDelta == 0) { return SAME_PRECEDENCE; } @@ -153,7 +154,7 @@ class AspectJPrecedenceComparator implements Comparator { } private int getAspectDeclarationOrder(Advisor anAdvisor) { - AspectJPrecedenceInformation precedenceInfo = + AspectJPrecedenceInformation precedenceInfo = AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor); if (precedenceInfo != null) { return precedenceInfo.getDeclarationOrder(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/package-info.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/package-info.java index 8355bc3082..99d336b05a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/package-info.java @@ -1,12 +1,11 @@ - /** * * AspectJ integration package. Includes Spring AOP advice implementations for AspectJ 5 * annotation-style methods, and an AspectJExpressionPointcut: a Spring AOP Pointcut * implementation that allows use of the AspectJ pointcut expression language with the Spring AOP * runtime framework. - * - *

Note that use of this package does not require the use of the ajc compiler + * + *

Note that use of this package does not 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 * functionality, with consistent semantics, with the proxy-based Spring AOP framework. * diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java b/spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java index 43de1f6446..65169d1a8d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AbstractInterceptorDrivenBeanDefinitionDecorator.java @@ -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"); * 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. * *

This base class controls the creation of the {@link ProxyFactoryBean} bean definition - * and wraps the original as an inner-bean definition for the target property + * and wraps the original as an inner-bean definition for the {@code target} property * of {@link ProxyFactoryBean}. * *

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 * interceptor is simply added to the existing definition. * - *

Subclasses have only to create the BeanDefinition to the interceptor that + *

Subclasses have only to create the {@code BeanDefinition} to the interceptor that * they wish to add. * * @author Rob Harrop @@ -58,9 +58,10 @@ import org.springframework.util.StringUtils; */ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implements BeanDefinitionDecorator { + @Override public final BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definitionHolder, ParserContext parserContext) { BeanDefinitionRegistry registry = parserContext.getRegistry(); - + // get the root bean name - will be the name of the generated proxy factory bean String existingBeanName = definitionHolder.getBeanName(); BeanDefinition targetDefinition = definitionHolder.getBeanDefinition(); @@ -118,7 +119,7 @@ public abstract class AbstractInterceptorDrivenBeanDefinitionDecorator implement } /** - * Subclasses should implement this method to return the BeanDefinition + * Subclasses should implement this method to return the {@code BeanDefinition} * for the interceptor they wish to apply to the bean being decorated. */ protected abstract BeanDefinition createInterceptorDefinition(Node node); diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java index 4fa6a8a552..85e59523a7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java @@ -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"); * 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. - * + * * @author Mark Fisher * @since 2.0 */ diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorComponentDefinition.java b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorComponentDefinition.java index 36eda24329..bd86b2ea2e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorComponentDefinition.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorComponentDefinition.java @@ -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"); * 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} * that bridges the gap between the advisor bean definition configured - * by the <aop:advisor> tag and the component definition + * by the {@code <aop:advisor>} tag and the component definition * infrastructure. * * @author Rob Harrop @@ -91,6 +91,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition { } + @Override public String getName() { return this.advisorBeanName; } @@ -110,6 +111,7 @@ public class AdvisorComponentDefinition extends AbstractComponentDefinition { return this.beanReferences; } + @Override public Object getSource() { return this.advisorDefinition.getSource(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java index fa635ae7a9..13be36d8f3 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java @@ -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"); * 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. - * + * * @author Mark Fisher * @since 2.0 */ diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java b/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java index dd568a51bd..3da1f13f0a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java @@ -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"); * 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. * - *

Only a single auto-proxy creator can be registered yet multiple concrete - * implementations are available. Therefore this class wraps a simple escalation + *

Only a single auto-proxy creator can be registered yet multiple concrete + * implementations are available. Therefore this class wraps a simple escalation * protocol, allowing classes to request a particular auto-proxy creator and know - * that class, or a subclass thereof, will eventually be resident + * that class, {@code or a subclass thereof}, will eventually be resident * in the application context. * * @author Rob Harrop diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java index 9f0dc56d03..459c394219 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java @@ -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"); * 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; /** - * NamespaceHandler for the aop namespace. + * {@code NamespaceHandler} for the {@code aop} namespace. * *

Provides a {@link org.springframework.beans.factory.xml.BeanDefinitionParser} for the - * <aop:config> tag. A config tag can include nested - * pointcut, advisor and aspect tags. + * {@code <aop:config>} tag. A {@code config} tag can include nested + * {@code pointcut}, {@code advisor} and {@code aspect} tags. * - *

The pointcut tag allows for creation of named + *

The {@code pointcut} tag allows for creation of named * {@link AspectJExpressionPointcut} beans using a simple syntax: *

  * <aop:pointcut id="getNameCalls" expression="execution(* *..ITestBean.getName(..))"/>
  * 
* - *

Using the advisor tag you can configure an {@link org.springframework.aop.Advisor} + *

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} - * automatically. The advisor tag supports both in-line and referenced + * automatically. The {@code advisor} tag supports both in-line and referenced * {@link org.springframework.aop.Pointcut Pointcuts}: * *

@@ -56,9 +56,10 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport {
 
 	/**
 	 * Register the {@link BeanDefinitionParser BeanDefinitionParsers} for the
-	 * 'config', 'spring-configured', 'aspectj-autoproxy'
-	 * and 'scoped-proxy' tags.
+	 * '{@code config}', '{@code spring-configured}', '{@code aspectj-autoproxy}'
+	 * and '{@code scoped-proxy}' tags.
 	 */
+	@Override
 	public void init() {
 		// In 2.0 XSD as well as in 2.1 XSD.
 		registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser());
diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java
index ae9888dca4..73ff37197c 100644
--- a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java
+++ b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java
@@ -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");
  * 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
- * by the 'aop' namespace tags.
+ * by the '{@code aop}' namespace tags.
  *
  * 

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 @@ -42,12 +42,12 @@ import org.springframework.beans.factory.xml.ParserContext; public abstract class AopNamespaceUtils { /** - * The proxy-target-class 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"; /** - * The expose-proxy 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"; diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java index 0aca37520b..95371f59b7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java @@ -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"); * 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; /** - * {@link BeanDefinitionParser} for the aspectj-autoproxy tag, + * {@link BeanDefinitionParser} for the {@code aspectj-autoproxy} tag, * enabling the automatic application of @AspectJ-style aspects found in * the {@link org.springframework.beans.factory.BeanFactory}. * @@ -37,6 +37,7 @@ import org.springframework.beans.factory.xml.ParserContext; */ class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser { + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element); extendBeanDefinition(element, parserContext); diff --git a/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java index de8beff487..c7cb6735d6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java @@ -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"); * 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; /** - * {@link BeanDefinitionParser} for the <aop:config> tag. + * {@link BeanDefinitionParser} for the {@code <aop:config>} tag. * * @author Rob Harrop * @author Juergen Hoeller @@ -93,8 +93,9 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2; private ParseState parseState = new ParseState(); - + + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { CompositeComponentDefinition compositeDef = 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} - * created by the '<aop:config/>' tag. Will force class proxying if the - * 'proxy-target-class' attribute is set to 'true'. + * created by the '{@code <aop:config/>}' tag. Will force class proxying if the + * '{@code proxy-target-class}' attribute is set to '{@code true}'. * @see AopNamespaceUtils */ private void configureAutoProxyCreator(ParserContext parserContext, Element element) { @@ -131,7 +132,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Parses the supplied <advisor> element and registers the resulting + * Parses the supplied {@code <advisor>} element and registers the resulting * {@link org.springframework.aop.Advisor} and any resulting {@link org.springframework.aop.Pointcut} * 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 not - * parse any associated 'pointcut' or 'pointcut-ref' attributes. + * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. */ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); @@ -257,9 +258,9 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Return true if the supplied node describes an advice type. May be one of: - * 'before', 'after', 'after-returning', - * 'after-throwing' or 'around'. + * Return {@code true} if the supplied node describes an advice type. May be one of: + * '{@code before}', '{@code after}', '{@code after-returning}', + * '{@code after-throwing}' or '{@code around}'. */ private boolean isAdviceNode(Node aNode, ParserContext parserContext) { if (!(aNode instanceof Element)) { @@ -273,7 +274,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Parse a 'declare-parents' element and register the appropriate + * Parse a '{@code declare-parents}' element and register the appropriate * DeclareParentsAdvisor with the BeanDefinitionRegistry encapsulated in the * supplied ParserContext. */ @@ -281,10 +282,10 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class); builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE)); builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN)); - + String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL); String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF); - + if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) { builder.addConstructorArgValue(defaultImpl); } @@ -304,8 +305,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Parses one of 'before', 'after', 'after-returning', - * 'after-throwing' or 'around' and registers the resulting + * Parses one of '{@code before}', '{@code after}', '{@code after-returning}', + * '{@code after-throwing}' or '{@code around}' and registers the resulting * BeanDefinition with the supplied BeanDefinitionRegistry. * @return the generated advice RootBeanDefinition */ @@ -427,7 +428,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Parses the supplied <pointcut> and registers the resulting + * Parses the supplied {@code <pointcut>} and registers the resulting * Pointcut with the BeanDefinitionRegistry. */ private AbstractBeanDefinition parsePointcut(Element pointcutElement, ParserContext parserContext) { @@ -435,7 +436,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { String expression = pointcutElement.getAttribute(EXPRESSION); AbstractBeanDefinition pointcutDefinition = null; - + try { this.parseState.push(new PointcutEntry(id)); pointcutDefinition = createPointcutDefinition(expression); @@ -460,8 +461,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { } /** - * Parses the pointcut or pointcut-ref attributes of the supplied - * {@link Element} and add a pointcut property as appropriate. Generates a + * Parses the {@code pointcut} or {@code pointcut-ref} attributes of the supplied + * {@link Element} and add a {@code pointcut} property as appropriate. Generates a * {@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. */ diff --git a/spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java index 5891bc8455..abb26930cb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFacto this.methodName = methodName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { if (!StringUtils.hasText(this.targetBeanName)) { throw new IllegalArgumentException("Property 'targetBeanName' is required"); @@ -78,14 +79,17 @@ public class MethodLocatingFactoryBean implements FactoryBean, BeanFacto } + @Override public Method getObject() throws Exception { return this.method; } + @Override public Class getObjectType() { return Method.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/PointcutComponentDefinition.java b/spring-aop/src/main/java/org/springframework/aop/config/PointcutComponentDefinition.java index cd1c0f9f59..3cbf472e58 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/PointcutComponentDefinition.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/PointcutComponentDefinition.java @@ -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"); * 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() { return this.pointcutBeanName; } @@ -60,6 +61,7 @@ public class PointcutComponentDefinition extends AbstractComponentDefinition { return new BeanDefinition[] {this.pointcutDefinition}; } + @Override public Object getSource() { return this.pointcutDefinition.getSource(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java index c308d5b833..10f6327e5c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java @@ -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"); * 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. - * + * * @author Mark Fisher * @since 2.0 */ diff --git a/spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java b/spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java index ac118d7096..0acf968b51 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/ScopedProxyBeanDefinitionDecorator.java @@ -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"); * 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 - * <aop:scoped-proxy/> tag. + * {@code <aop:scoped-proxy/>} tag. * * @author Rob Harrop * @author Juergen Hoeller @@ -39,6 +39,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator { private static final String PROXY_TARGET_CLASS = "proxy-target-class"; + @Override public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { boolean proxyTargetClass = true; if (node instanceof Element) { @@ -47,7 +48,7 @@ class ScopedProxyBeanDefinitionDecorator implements BeanDefinitionDecorator { proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)); } } - + // Register the original bean definition as it will be referenced by the scoped proxy // and is relevant for tooling (validation, navigation). BeanDefinitionHolder holder = diff --git a/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java b/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java index 6ffc8c8868..64cc673bab 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/SimpleBeanFactoryAwareAspectInstanceFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan this.aspectBeanName = aspectBeanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; 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. * @see #setAspectBeanName */ + @Override public Object getAspectInstance() { return this.beanFactory.getBean(this.aspectBeanName); } + @Override public ClassLoader getAspectClassLoader() { if (this.beanFactory instanceof ConfigurableBeanFactory) { return ((ConfigurableBeanFactory) this.beanFactory).getBeanClassLoader(); @@ -72,6 +75,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan } } + @Override public int getOrder() { if (this.beanFactory.isSingleton(this.aspectBeanName) && this.beanFactory.isTypeMatch(this.aspectBeanName, Ordered.class)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java index 36c2a9c911..59aed08e0e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/SpringConfiguredBeanDefinitionParser.java @@ -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"); * 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"; + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) { RootBeanDefinition def = new RootBeanDefinition(); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java index cf22fddded..f65ae62508 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java @@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils; * @author Juergen Hoeller * @since 3.2 */ +@SuppressWarnings("serial") public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig implements BeanPostProcessor, BeanClassLoaderAware, Ordered { @@ -49,6 +50,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig private final Map eligibleBeans = new ConcurrentHashMap(64); + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } @@ -57,15 +59,18 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof AopInfrastructureBean) { // 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 * post-processor's {@link Advisor}. - *

Implements caching of canApply results per bean name. + *

Implements caching of {@code canApply} results per bean name. * @param bean the bean instance * @param beanName the name of the bean * @see AopUtils#canApply(Advisor, Class) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java index 18d8d25d15..261d1cab60 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java @@ -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"); * 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; } + @Override public void setBeanClassLoader(ClassLoader classLoader) { if (this.proxyClassLoader == null) { this.proxyClassLoader = classLoader; @@ -129,6 +130,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig } + @Override public void afterPropertiesSet() { if (this.target == null) { throw new IllegalArgumentException("Property 'target' is required"); @@ -190,6 +192,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig } + @Override public Object getObject() { if (this.proxy == null) { throw new FactoryBeanNotInitializedException(); @@ -197,6 +200,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig return this.proxy; } + @Override public Class getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); @@ -213,6 +217,7 @@ public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig return null; } + @Override public final boolean isSingleton() { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java b/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java index 397c97b769..3c822cf2da 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/Advised.java @@ -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"); * 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 * ThreadLocal for retrieval via the AopContext class. This is useful * if an advised object needs to call another advised method on itself. - * (If it uses this, the invocation will not be advised). + * (If it uses {@code this}, the invocation will not be advised). *

Default is "false", for optimal performance. */ void setExposeProxy(boolean exposeProxy); @@ -85,7 +85,7 @@ public interface Advised extends TargetClassAware { /** * 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 - * benefitting from advice. (If it invokes a method on this 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(). * @see AopContext */ @@ -110,7 +110,7 @@ public interface Advised extends TargetClassAware { /** * Return the advisors applying to this proxy. - * @return a list of Advisors applying to this proxy (never null) + * @return a list of Advisors applying to this proxy (never {@code null}) */ Advisor[] getAdvisors(); @@ -124,7 +124,7 @@ public interface Advised extends TargetClassAware { */ void addAdvisor(Advisor advisor) throws AopConfigException; - /** + /** * Add an Advisor at the specified position in the chain. * @param advisor the advisor to add at the specified position in the chain * @param pos position in chain (0 is head). Must be valid. @@ -135,7 +135,7 @@ public interface Advised extends TargetClassAware { /** * Remove the given advisor. * @param advisor the advisor to remove - * @return true if the advisor was removed; false + * @return {@code true} if the advisor was removed; {@code false} * if the advisor was not found and hence could not be removed */ boolean removeAdvisor(Advisor advisor); @@ -165,7 +165,7 @@ public interface Advised extends TargetClassAware { * @param a the advisor to replace * @param b the advisor to replace it with * @return whether it was replaced. If the advisor wasn't found in the - * list of advisors, this method returns false and does nothing. + * list of advisors, this method returns {@code false} and does nothing. * @throws AopConfigException in case of invalid advice */ 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. *

This will be wrapped in a DefaultPointcutAdvisor with a pointcut that always - * applies, and returned from the getAdvisors() method in this wrapped form. + * applies, and returned from the {@code getAdvisors()} method in this wrapped form. *

Note that the given advice will apply to all invocations on the proxy, - * even to the toString() 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. * @param advice advice to add to the tail of the chain * @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()} * method in this wrapped form. *

Note: The given advice will apply to all invocations on the proxy, - * even to the toString() 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. * @param pos index from 0 (head) * @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. * @param advice the advice to remove - * @return true of the advice was found and removed; - * false if there was no such advice + * @return {@code true} of the advice was found and removed; + * {@code false} if there was no such advice */ boolean removeAdvice(Advice advice); @@ -219,7 +219,7 @@ public interface Advised extends TargetClassAware { /** - * As toString() 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. * @return a string description of the proxy configuration */ diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index ebb59896ec..5cf6828d66 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -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"); * 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)); } + @Override public void setTargetSource(TargetSource targetSource) { this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE); } + @Override public TargetSource getTargetSource() { return this.targetSource; } @@ -162,14 +164,17 @@ public class AdvisedSupport extends ProxyConfig implements Advised { this.targetSource = EmptyTargetSource.forClass(targetClass); } + @Override public Class getTargetClass() { return this.targetSource.getTargetClass(); } + @Override public void setPreFiltered(boolean preFiltered) { this.preFiltered = preFiltered; } + @Override public boolean isPreFiltered() { return this.preFiltered; } @@ -184,7 +189,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } /** - * Return the advisor chain factory to use (never null). + * Return the advisor chain factory to use (never {@code null}). */ public AdvisorChainFactory getAdvisorChainFactory() { return this.advisorChainFactory; @@ -221,17 +226,19 @@ public class AdvisedSupport extends ProxyConfig implements Advised { * Remove a proxied interface. *

Does nothing if the given interface isn't proxied. * @param intf the interface to remove from the proxy - * @return true if the interface was removed; false + * @return {@code true} if the interface was removed; {@code false} * if the interface was not found and hence could not be removed */ public boolean removeInterface(Class intf) { return this.interfaces.remove(intf); } + @Override public Class[] getProxiedInterfaces() { return this.interfaces.toArray(new Class[this.interfaces.size()]); } + @Override public boolean isInterfaceProxied(Class intf) { for (Class proxyIntf : this.interfaces) { if (intf.isAssignableFrom(proxyIntf)) { @@ -242,15 +249,18 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } + @Override public final Advisor[] getAdvisors() { return this.advisorArray; } + @Override public void addAdvisor(Advisor advisor) { int pos = this.advisors.size(); addAdvisor(pos, advisor); } + @Override public void addAdvisor(int pos, Advisor advisor) throws AopConfigException { if (advisor instanceof IntroductionAdvisor) { validateIntroductionAdvisor((IntroductionAdvisor) advisor); @@ -258,6 +268,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { addAdvisorInternal(pos, advisor); } + @Override public boolean removeAdvisor(Advisor advisor) { int index = indexOf(advisor); if (index == -1) { @@ -269,6 +280,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } } + @Override public void removeAdvisor(int index) throws AopConfigException { if (isFrozen()) { throw new AopConfigException("Cannot remove Advisor: Configuration is frozen."); @@ -292,11 +304,13 @@ public class AdvisedSupport extends ProxyConfig implements Advised { adviceChanged(); } + @Override public int indexOf(Advisor advisor) { Assert.notNull(advisor, "Advisor must not be null"); return this.advisors.indexOf(advisor); } + @Override public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException { Assert.notNull(a, "Advisor a 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 { int pos = this.advisors.size(); addAdvice(pos, advice); @@ -396,6 +411,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { /** * Cannot add introductions this way unless the advice implements IntroductionInfo. */ + @Override public void addAdvice(int pos, Advice advice) throws AopConfigException { Assert.notNull(advice, "Advice must not be null"); if (advice instanceof IntroductionInfo) { @@ -412,6 +428,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } } + @Override public boolean removeAdvice(Advice advice) throws AopConfigException { int index = indexOf(advice); if (index == -1) { @@ -423,6 +440,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } } + @Override public int indexOf(Advice advice) { Assert.notNull(advice, "Advice must not be null"); for (int i = 0; i < this.advisors.size(); i++) { @@ -554,6 +572,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { } + @Override public String toProxyConfigString() { return toString(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopConfigException.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopConfigException.java index 46cd1075ac..26a45a4657 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopConfigException.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopConfigException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.core.NestedRuntimeException; * @author Rod Johnson * @since 13.03.2003 */ +@SuppressWarnings("serial") public class AopConfigException extends NestedRuntimeException { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java index 299ebfa31a..13a86ecb89 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -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"); * 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. * - *

The currentProxy() method is usable if the AOP framework is configured to + *

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 - * or advice can use this to make advised calls, in the same way as getEJBObject() + * 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. * *

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. - * Will contain null unless the "exposeProxy" property on + * Will contain {@code null} unless the "exposeProxy" property on * the controlling proxy configuration has been set to "true". * @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 * calling method has been invoked via AOP, and the AOP framework has been set * to expose proxies. Otherwise, this method will throw an IllegalStateException. - * @return Object the current AOP proxy (never returns null) + * @return Object the current AOP proxy (never returns {@code null}) * @throws IllegalStateException if the proxy cannot be found, because the * method was invoked outside an AOP invocation context, or because the * 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 currentProxy() method. + * Make the given proxy available via the {@code currentProxy()} method. *

Note that the caller should be careful to keep the old value as appropriate. - * @param proxy the proxy to expose (or null to reset it) - * @return the old proxy, which may be null if none was bound + * @param proxy the proxy to expose (or {@code null} to reset it) + * @return the old proxy, which may be {@code null} if none was bound * @see #currentProxy() */ static Object setCurrentProxy(Object proxy) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxy.java index 2fe5af6c35..80c6690564 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxy.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,20 +33,20 @@ public interface AopProxy { * Create a new proxy object. *

Uses the AopProxy's default class loader (if necessary for proxy creation): * usually, the thread context class loader. - * @return the new proxy object (never null) - * @see java.lang.Thread#getContextClassLoader() + * @return the new proxy object (never {@code null}) + * @see Thread#getContextClassLoader() */ Object getProxy(); /** * Create a new proxy object. *

Uses the given class loader (if necessary for proxy creation). - * null 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 * by the AopProxy implementation's {@link #getProxy()} method. * @param classLoader the class loader to create the proxy with - * (or null for the low-level proxy facility's default) - * @return the new proxy object (never null) + * (or {@code null} for the low-level proxy facility's default) + * @return the new proxy object (never {@code null}) */ Object getProxy(ClassLoader classLoader); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyFactory.java index d97934f16c..9a2e2298e4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ package org.springframework.aop.framework; * *

Proxies may or may not allow advice changes to be made. * If they do not permit advice changes (for example, because - * the configuration was frozen) a proxy should throw an + * the configuration was frozen) a proxy should throw an * {@link AopConfigException} on an attempted advice change. * * @author Rod Johnson diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java index 28e48adb4f..5ac4ed7f66 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java @@ -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"); * 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. * @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; - * never null) + * never {@code null}) * @see org.springframework.aop.TargetClassAware#getTargetClass() - * @see org.springframework.aop.framework.Advised#getTargetSource() + * @see Advised#getTargetSource() */ public static Class ultimateTargetClass(Object candidate) { 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. * @param proxy the proxy to analyze (usually a JDK dynamic proxy) * @return all user-specified interfaces that the proxy implements, - * in the original order (never null or empty) + * in the original order (never {@code null} or empty) * @see Advised */ public static Class[] proxiedUserInterfaces(Object proxy) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index bbf7015e0a..6ee9f6d450 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -146,10 +146,12 @@ final class CglibAopProxy implements AopProxy, Serializable { } + @Override public Object getProxy() { return getProxy(null); } + @Override public Object getProxy(ClassLoader classLoader) { if (logger.isDebugEnabled()) { 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 Class has already been validated and + * Checks to see whether the supplied {@code Class} has already been validated and * validates it if not. */ private void validateClassIfNecessary(Class proxySuperClass) { @@ -249,7 +251,7 @@ final class CglibAopProxy implements AopProxy, Serializable { } /** - * Checks for final methods on the Class and writes warnings to the log + * Checks for final methods on the {@code Class} and writes warnings to the log * for each one found. */ 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 * 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 - * this. + * {@code this}. */ private static class StaticUnadvisedInterceptor implements MethodInterceptor, Serializable { @@ -386,6 +388,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.target = target; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { Object retVal = methodProxy.invoke(this.target, args); return processReturnType(proxy, this.target, method, retVal); @@ -405,6 +408,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.target = target; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { Object oldProxy = null; try { @@ -432,6 +436,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.targetSource = targetSource; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { Object target = this.targetSource.getTarget(); try { @@ -456,6 +461,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.targetSource = targetSource; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { Object oldProxy = null; Object target = this.targetSource.getTarget(); @@ -485,6 +491,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.target = target; } + @Override public Object loadObject() { return this.target; } @@ -502,6 +509,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.advised = advised; } + @Override public Object loadObject() throws Exception { return this.advised; } @@ -509,7 +517,7 @@ final class CglibAopProxy implements AopProxy, Serializable { /** - * Dispatcher for the equals method. + * Dispatcher for the {@code equals} method. * Ensures that the method call is always handled by this class. */ private static class EqualsInterceptor implements MethodInterceptor, Serializable { @@ -520,6 +528,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.advised = advised; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) { Object other = args[0]; if (proxy == other) { @@ -541,7 +550,7 @@ final class CglibAopProxy implements AopProxy, Serializable { /** - * Dispatcher for the hashCode method. + * Dispatcher for the {@code hashCode} method. * Ensures that the method call is always handled by this class. */ private static class HashCodeInterceptor implements MethodInterceptor, Serializable { @@ -552,6 +561,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.advised = advised; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) { return CglibAopProxy.class.hashCode() * 13 + this.advised.getTargetSource().hashCode(); } @@ -575,6 +585,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.targetClass = targetClass; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args, this.targetClass, this.adviceChain, methodProxy); @@ -598,6 +609,7 @@ final class CglibAopProxy implements AopProxy, Serializable { this.advised = advised; } + @Override public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { Object oldProxy = null; boolean setProxyContext = false; @@ -609,7 +621,7 @@ final class CglibAopProxy implements AopProxy, Serializable { oldProxy = AopContext.setCurrentProxy(proxy); setProxyContext = true; } - // May be null. 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. target = getTarget(); if (target != null) { @@ -745,15 +757,16 @@ final class CglibAopProxy implements AopProxy, Serializable { * invoke the advice chain. Otherwise a DyanmicAdvisedInterceptor is * used. *

For non-advised methods:
- *
Where it can be determined that the method will not return this - * or when ProxyFactory.getExposeProxy() returns false, + *
Where it can be determined that the method will not return {@code this} + * or when {@code ProxyFactory.getExposeProxy()} returns {@code false}, * then a Dispatcher is used. For static targets, the StaticDispatcher is used; * and for dynamic targets, a DynamicUnadvisedInterceptor is used. - * If it possible for the method to return this then a + * If it possible for the method to return {@code this} then a * StaticUnadvisedInterceptor is used for static targets - the * DynamicUnadvisedInterceptor already considers this.
* */ + @Override public int accept(Method method) { if (AopUtils.isFinalizeMethod(method)) { logger.debug("Found finalize() method - using NO_OVERRIDE"); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java index 806e3602bc..3eef11bd9b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java @@ -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"); * 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 * @since 2.0.3 */ +@SuppressWarnings("serial") public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable { + @Override public List getInterceptorsAndDynamicInterceptionAdvice( Advised config, Method method, Class targetClass) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAopProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAopProxyFactory.java index 43293527e6..5d3640677a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAopProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAopProxyFactory.java @@ -45,9 +45,11 @@ import org.springframework.aop.SpringProxy; * @see AdvisedSupport#setProxyTargetClass * @see AdvisedSupport#setInterfaces */ +@SuppressWarnings("serial") public class DefaultAopProxyFactory implements AopProxyFactory, Serializable { + @Override public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException { if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) { Class targetClass = config.getTargetClass(); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java index 24c0610c08..ad36cd8934 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java @@ -106,10 +106,12 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa } + @Override public Object getProxy() { return getProxy(ClassUtils.getDefaultClassLoader()); } + @Override public Object getProxy(ClassLoader classLoader) { if (logger.isDebugEnabled()) { 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 InvocationHandler.invoke. + * Implementation of {@code InvocationHandler.invoke}. *

Callers will see exactly the exception thrown by the target, * unless a hook method throws an exception. */ + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { MethodInvocation invocation; Object oldProxy = null; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyConfig.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyConfig.java index e012777285..fc7ae7b878 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyConfig.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyConfig.java @@ -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"); * 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 * ThreadLocal for retrieval via the AopContext class. This is useful * if an advised object needs to call another advised method on itself. - * (If it uses this, the invocation will not be advised). + * (If it uses {@code this}, the invocation will not be advised). *

Default is "false", in order to avoid unnecessary extra interception. * This means that no guarantees are provided that AopContext access will * work consistently within any method of the advised object. diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java index c5eeb924ec..e1867efd7e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java @@ -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"); * 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 * @see #createAopProxy() */ +@SuppressWarnings("serial") public class ProxyCreatorSupport extends AdvisedSupport { private AopProxyFactory aopProxyFactory; @@ -95,7 +96,7 @@ public class ProxyCreatorSupport extends AdvisedSupport { /** * Subclasses should call this to get a new AOP proxy. They should not - * create an AOP proxy with this as an argument. + * create an AOP proxy with {@code this} as an argument. */ protected final synchronized AopProxy createAopProxy() { if (!this.active) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactory.java index 989160bf65..67e89eeefd 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactory.java @@ -32,6 +32,7 @@ import org.springframework.util.ClassUtils; * @author Rob Harrop * @since 14.03.2003 */ +@SuppressWarnings("serial") public class ProxyFactory extends ProxyCreatorSupport { /** @@ -74,7 +75,7 @@ public class ProxyFactory extends ProxyCreatorSupport { } /** - * Create a ProxyFactory for the specified TargetSource, + * Create a ProxyFactory for the specified {@code TargetSource}, * making the proxy implement the specified interface. * @param proxyInterface the interface that the proxy should implement * @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. *

Uses the given class loader (if necessary for proxy creation). * @param classLoader the class loader to create the proxy with - * (or null for the low-level proxy facility's default) + * (or {@code null} for the low-level proxy facility's default) * @return the proxy object */ public Object getProxy(ClassLoader classLoader) { @@ -127,7 +128,7 @@ public class ProxyFactory extends ProxyCreatorSupport { } /** - * Create a proxy for the specified TargetSource, + * Create a proxy for the specified {@code TargetSource}, * implementing the specified interface. * @param proxyInterface the interface that the proxy should implement * @param targetSource the TargetSource that the proxy should invoke @@ -140,8 +141,8 @@ public class ProxyFactory extends ProxyCreatorSupport { } /** - * Create a proxy for the specified TargetSource that extends - * the target class of the TargetSource. + * Create a proxy for the specified {@code TargetSource} that extends + * the target class of the {@code TargetSource}. * @param targetSource the TargetSource that the proxy should invoke * @return the proxy object */ diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java index 9b4461fcb4..7e62678340 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java @@ -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"); * 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 Advised */ +@SuppressWarnings("serial") public class ProxyFactoryBean extends ProxyCreatorSupport implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware { @@ -100,7 +101,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport protected final Log logger = LogFactory.getLog(getClass()); private String[] interceptorNames; - + private String targetName; private boolean autodetectInterfaces = true; @@ -217,12 +218,14 @@ public class ProxyFactoryBean extends ProxyCreatorSupport this.classLoaderConfigured = (classLoader != null); } + @Override public void setBeanClassLoader(ClassLoader classLoader) { if (!this.classLoaderConfigured) { this.proxyClassLoader = classLoader; } } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; checkInterceptorNames(); @@ -233,9 +236,10 @@ public class ProxyFactoryBean extends ProxyCreatorSupport * 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. * The instance will be cached for a singleton, and create on each call to - * getObject() for a proxy. + * {@code getObject()} for a proxy. * @return a fresh AOP proxy reflecting the current state of this factory */ + @Override public Object getObject() throws BeansException { initializeAdvisorChain(); if (isSingleton()) { @@ -256,6 +260,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport * a single one), the target bean type, or the TargetSource's target class. * @see org.springframework.aop.TargetSource#getTargetClass */ + @Override public Class getObjectType() { synchronized (this) { if (this.singletonInstance != null) { @@ -277,6 +282,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport } } + @Override public boolean isSingleton() { return this.singleton; } @@ -351,7 +357,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport /** * Return the proxy object to expose. - *

The default implementation uses a getProxy call with + *

The default implementation uses a {@code getProxy} call with * the factory's bean class loader. Can be overridden to specify a * custom class loader. * @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, * or may be a target. * @param beanName bean name to check - * @return true if it's an Advisor or Advice + * @return {@code true} if it's an Advisor or Advice */ private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) { Class namedBeanClass = this.beanFactory.getType(beanName); @@ -543,10 +549,10 @@ public class ProxyFactoryBean extends ProxyCreatorSupport Advisor advisor = namedBeanToAdvisor(next); if (logger.isTraceEnabled()) { logger.trace("Adding advisor with name '" + name + "'"); - } + } addAdvisor(advisor); } - + /** * Return a TargetSource to use when creating a proxy. If the target was not * specified at the end of the interceptorNames list, the TargetSource will be @@ -627,24 +633,26 @@ public class ProxyFactoryBean extends ProxyCreatorSupport private final String beanName; private final String message; - + public PrototypePlaceholderAdvisor(String beanName) { this.beanName = beanName; this.message = "Placeholder for prototype Advisor/Advice with bean name '" + beanName + "'"; } - + public String getBeanName() { return beanName; } - + + @Override public Advice getAdvice() { throw new UnsupportedOperationException("Cannot invoke methods: " + this.message); } - + + @Override public boolean isPerInstance() { throw new UnsupportedOperationException("Cannot invoke methods: " + this.message); } - + @Override public String toString() { return this.message; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java index 458cc46518..8556823d92 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java @@ -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"); * 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() { return this.proxy; } + @Override public final Object getThis() { return this.target; } + @Override public final AccessibleObject getStaticPart() { 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 * implementation of that interface. */ + @Override public final Method getMethod() { return this.method; } + @Override public final Object[] getArguments() { return (this.arguments != null ? this.arguments : new Object[0]); } + @Override public void setArguments(Object[] arguments) { this.arguments = arguments; } + @Override public Object proceed() throws Throwable { // We start with an index of -1 and increment early. if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) { @@ -151,12 +158,12 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea } Object interceptorOrInterceptionAdvice = - this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex); + this.interceptorsAndDynamicMethodMatchers.get(++this.currentInterceptorIndex); if (interceptorOrInterceptionAdvice instanceof InterceptorAndDynamicMethodMatcher) { // Evaluate dynamic method matcher here: static part will already have // been evaluated and found to match. InterceptorAndDynamicMethodMatcher dm = - (InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice; + (InterceptorAndDynamicMethodMatcher) interceptorOrInterceptionAdvice; if (dm.methodMatcher.matches(this.method, this.targetClass, this.arguments)) { return dm.interceptor.invoke(this); } @@ -192,6 +199,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea * current interceptor index. * @see java.lang.Object#clone() */ + @Override public MethodInvocation invocableClone() { Object[] cloneArguments = null; if (this.arguments != null) { @@ -210,6 +218,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea * current interceptor index. * @see java.lang.Object#clone() */ + @Override public MethodInvocation invocableClone(Object[] arguments) { // Force initialization of the user attributes Map, // 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) { if (value != null) { if (this.userAttributes == null) { @@ -244,6 +254,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea } } + @Override public Object getUserAttribute(String key) { 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 map is initialized lazily and is not used in the AOP framework itself. * @return any user attributes associated with this invocation - * (never null) + * (never {@code null}) */ public Map getUserAttributes() { if (this.userAttributes == null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapter.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapter.java index 5acc518359..425c3f87c4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapter.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapter.java @@ -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"); * 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 - * invoke the getInterceptors method with an Advisor that + * invoke the {@code getInterceptors} method with an Advisor that * contains this advice as an argument? * @param advice an Advice such as a BeforeAdvice * @return whether this adapter understands the given advice object diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationManager.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationManager.java index bd3ebe7d57..4ef00db86c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationManager.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationManager.java @@ -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"); * 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 { return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AdvisorAdapter){ this.advisorAdapterRegistry.registerAdvisorAdapter((AdvisorAdapter) bean); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java index f0b38d0d67..9eacf479ba 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistry.java @@ -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"); * 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.ThrowsAdvice}. * @param advice object that should be an advice - * @return an Advisor wrapping the given advice. Never returns null. + * @return an Advisor wrapping the given advice. Never returns {@code null}. * If the advice parameter is an Advisor, return it. * @throws UnknownAdviceTypeException if no registered advisor adapter * can wrap the supposed advice diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceAdapter.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceAdapter.java index 10f8613300..de562f4fbe 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceAdapter.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceAdapter.java @@ -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"); * 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 Juergen Hoeller */ +@SuppressWarnings("serial") class AfterReturningAdviceAdapter implements AdvisorAdapter, Serializable { + @Override public boolean supportsAdvice(Advice advice) { return (advice instanceof AfterReturningAdvice); } + @Override public MethodInterceptor getInterceptor(Advisor advisor) { AfterReturningAdvice advice = (AfterReturningAdvice) advisor.getAdvice(); return new AfterReturningAdviceInterceptor(advice); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceInterceptor.java index 1e0b0b6417..5e0bd1d23d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/AfterReturningAdviceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.util.Assert; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class AfterReturningAdviceInterceptor implements MethodInterceptor, AfterAdvice, Serializable { private final AfterReturningAdvice advice; @@ -46,6 +47,7 @@ public class AfterReturningAdviceInterceptor implements MethodInterceptor, After this.advice = advice; } + @Override public Object invoke(MethodInvocation mi) throws Throwable { Object retVal = mi.proceed(); this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis()); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java index 8ac6e5c3e8..0925b818af 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java @@ -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"); * 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 Juergen Hoeller */ +@SuppressWarnings("serial") public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable { private final List adapters = new ArrayList(3); @@ -52,6 +53,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se } + @Override public Advisor wrap(Object adviceObject) throws UnknownAdviceTypeException { if (adviceObject instanceof Advisor) { return (Advisor) adviceObject; @@ -73,6 +75,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se throw new UnknownAdviceTypeException(advice); } + @Override public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException { List interceptors = new ArrayList(3); Advice advice = advisor.getAdvice(); @@ -90,6 +93,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se return interceptors.toArray(new MethodInterceptor[interceptors.size()]); } + @Override public void registerAdvisorAdapter(AdvisorAdapter adapter) { this.adapters.add(adapter); } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceAdapter.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceAdapter.java index 6757ab65f5..57e0e16af7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceAdapter.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceAdapter.java @@ -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"); * 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 Juergen Hoeller */ +@SuppressWarnings("serial") class MethodBeforeAdviceAdapter implements AdvisorAdapter, Serializable { + @Override public boolean supportsAdvice(Advice advice) { return (advice instanceof MethodBeforeAdvice); } + @Override public MethodInterceptor getInterceptor(Advisor advisor) { MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice(); return new MethodBeforeAdviceInterceptor(advice); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.java index 82f339b3f6..8b3fd0ce20 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.util.Assert; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Serializable { private MethodBeforeAdvice advice; @@ -45,6 +46,7 @@ public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Seriali this.advice = advice; } + @Override public Object invoke(MethodInvocation mi) throws Throwable { this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() ); return mi.proceed(); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceAdapter.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceAdapter.java index 0803088e8b..822b789b54 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceAdapter.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceAdapter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,12 +31,15 @@ import org.springframework.aop.ThrowsAdvice; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") class ThrowsAdviceAdapter implements AdvisorAdapter, Serializable { + @Override public boolean supportsAdvice(Advice advice) { return (advice instanceof ThrowsAdvice); } + @Override public MethodInterceptor getInterceptor(Advisor advisor) { return new ThrowsAdviceInterceptor(advisor.getAdvice()); } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java index 8773e933c0..de2767be2c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ import org.springframework.util.Assert; /** * Interceptor to wrap an after-throwing advice. * - *

The signatures on handler methods on the ThrowsAdvice + *

The signatures on handler methods on the {@code ThrowsAdvice} * implementation method argument must be of the form:
* - * void afterThrowing([Method, args, target], ThrowableSubclass); + * {@code void afterThrowing([Method, args, target], ThrowableSubclass);} * *

Only the last argument is required. * @@ -87,13 +87,13 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice { } } } - + if (this.exceptionHandlerMap.isEmpty()) { throw new IllegalArgumentException( "At least one handler method must be found in class [" + throwsAdvice.getClass() + "]"); } } - + public int getHandlerMethodCount() { return this.exceptionHandlerMap.size(); } @@ -119,6 +119,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice { return handler; } + @Override public Object invoke(MethodInvocation mi) throws Throwable { try { return mi.proceed(); @@ -131,7 +132,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice { throw ex; } } - + private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable { Object[] handlerArgs; if (method.getParameterTypes().length == 1) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/UnknownAdviceTypeException.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/UnknownAdviceTypeException.java index 5d216e9b6b..e95e513caa 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/UnknownAdviceTypeException.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/UnknownAdviceTypeException.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,7 @@ package org.springframework.aop.framework.adapter; * @see org.aopalliance.aop.Advice * @see org.springframework.aop.Advisor */ +@SuppressWarnings("serial") public class UnknownAdviceTypeException extends IllegalArgumentException { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/package-info.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/package-info.java index 765d127397..0b3d0a28bf 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/package-info.java @@ -7,7 +7,7 @@ * its capabilities, don't need to concern themselves with this package. *
* You may wish to use these adapters to wrap Spring-specific advices, such as MethodBeforeAdvice, - * in MethodInterceptor, to allow their use in another AOP framework supporting the AOP Alliance interfaces. + * in MethodInterceptor, to allow their use in another AOP framework supporting the AOP Alliance interfaces. *
*
* These adapters do not depend on any other Spring framework classes to allow such usage. diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java index 8bca7ccd9d..035442282d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAdvisorAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import org.springframework.core.OrderComparator; * @author Juergen Hoeller * @see #findCandidateAdvisors */ +@SuppressWarnings("serial") public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyCreator { private BeanFactoryAdvisorRetrievalHelper advisorRetrievalHelper; @@ -76,7 +77,7 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC * Find all eligible Advisors for auto-proxying this class. * @param beanClass the clazz to find advisors for * @param beanName the name of the currently proxied bean - * @return the empty List, not null, + * @return the empty List, not {@code null}, * if there are no pointcuts or interceptors * @see #findCandidateAdvisors * @see #sortAdvisors diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 3216c3e101..db4f429198 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -87,6 +87,7 @@ import org.springframework.util.ClassUtils; * @see BeanNameAutoProxyCreator * @see DefaultAdvisorAutoProxyCreator */ +@SuppressWarnings("serial") public abstract class AbstractAutoProxyCreator extends ProxyConfig implements SmartInstantiationAwareBeanPostProcessor, BeanClassLoaderAware, BeanFactoryAware, Ordered, AopInfrastructureBean { @@ -147,13 +148,14 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig /** * Set the ordering which will apply to this class's implementation * of Ordered, used when applying multiple BeanPostProcessors. - *

Default value is Integer.MAX_VALUE, meaning that it's non-ordered. + *

Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered. * @param order ordering value */ public final void setOrder(int order) { this.order = order; } + @Override public final int getOrder() { return this.order; } @@ -231,44 +233,50 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig this.classLoaderConfigured = (classLoader != null); } + @Override public void setBeanClassLoader(ClassLoader classLoader) { if (!this.classLoaderConfigured) { this.proxyClassLoader = classLoader; } } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } /** * Return the owning BeanFactory. - * May be null, as this object doesn't need to belong to a bean factory. + * May be {@code null}, as this object doesn't need to belong to a bean factory. */ protected BeanFactory getBeanFactory() { return this.beanFactory; } + @Override public Class predictBeanType(Class beanClass, String beanName) { Object cacheKey = getCacheKey(beanClass, beanName); return this.proxyTypes.get(cacheKey); } + @Override public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException { return null; } + @Override public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { Object cacheKey = getCacheKey(bean.getClass(), beanName); this.earlyProxyReferences.put(cacheKey, Boolean.TRUE); return wrapIfNecessary(bean, beanName, cacheKey); } + @Override public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { Object cacheKey = getCacheKey(beanClass, beanName); - if (!this.targetSourcedBeans.containsKey(beanName)) { + if (beanName == null || !this.targetSourcedBeans.containsKey(beanName)) { if (this.advisedBeans.containsKey(cacheKey)) { return null; } @@ -281,28 +289,33 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig // Create proxy here if we have a custom TargetSource. // Suppresses unnecessary default instantiation of the target bean: // The TargetSource will handle target instances in a custom fashion. - TargetSource targetSource = getCustomTargetSource(beanClass, beanName); - if (targetSource != null) { - this.targetSourcedBeans.put(beanName, Boolean.TRUE); - Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource); - Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource); - this.proxyTypes.put(cacheKey, proxy.getClass()); - return proxy; + if (beanName != null) { + TargetSource targetSource = getCustomTargetSource(beanClass, beanName); + if (targetSource != null) { + this.targetSourcedBeans.put(beanName, Boolean.TRUE); + Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource); + Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource); + this.proxyTypes.put(cacheKey, proxy.getClass()); + return proxy; + } } return null; } + @Override public boolean postProcessAfterInstantiation(Object bean, String beanName) { return true; } + @Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) { return pvs; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return bean; } @@ -312,6 +325,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig * identified as one to proxy by the subclass. * @see #getAdvicesAndAdvisorsForBean */ + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean != null) { Object cacheKey = getCacheKey(bean.getClass(), beanName); @@ -341,7 +355,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig * @return a proxy wrapping the bean, or the raw bean instance as-is */ protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { - if (this.targetSourcedBeans.containsKey(beanName)) { + if (beanName != null && this.targetSourcedBeans.containsKey(beanName)) { return bean; } if (Boolean.FALSE.equals(this.advisedBeans.get(cacheKey))) { @@ -368,17 +382,18 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig /** * Return whether the given bean class represents an infrastructure class * that should never be proxied. - *

Default implementation considers Advisors, Advices and - * AbstractAutoProxyCreators as infrastructure classes. + *

The default implementation considers Advices, Advisors and + * AopInfrastructureBeans as infrastructure classes. * @param beanClass the class of the bean * @return whether the bean represents an infrastructure class + * @see org.aopalliance.aop.Advice * @see org.springframework.aop.Advisor - * @see org.aopalliance.intercept.MethodInterceptor + * @see org.springframework.aop.framework.AopInfrastructureBean * @see #shouldSkip */ protected boolean isInfrastructureClass(Class beanClass) { - boolean retVal = Advisor.class.isAssignableFrom(beanClass) || - Advice.class.isAssignableFrom(beanClass) || + boolean retVal = Advice.class.isAssignableFrom(beanClass) || + Advisor.class.isAssignableFrom(beanClass) || AopInfrastructureBean.class.isAssignableFrom(beanClass); if (retVal && logger.isTraceEnabled()) { logger.trace("Did not attempt to auto-proxy infrastructure class [" + beanClass.getName() + "]"); @@ -387,10 +402,10 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig } /** - * Subclasses should override this method to return true if the + * Subclasses should override this method to return {@code true} if the * given bean should not be considered for auto-proxying by this post-processor. *

Sometimes we need to be able to avoid this happening if it will lead to - * a circular reference. This implementation returns false. + * a circular reference. This implementation returns {@code false}. * @param beanClass the class of the bean * @param beanName the name of the bean * @return whether to skip the given bean @@ -401,7 +416,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig /** * Create a target source for bean instances. Uses any TargetSourceCreators if set. - * Returns null if no custom TargetSource should be used. + * Returns {@code null} if no custom TargetSource should be used. *

This implementation uses the "customTargetSourceCreators" property. * Subclasses can override this method to use a different mechanism. * @param beanClass the class of the bean to create a TargetSource for @@ -494,7 +509,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig * Return whether the Advisors returned by the subclass are pre-filtered * to match the bean's target class already, allowing the ClassFilter check * to be skipped when building advisors chains for AOP invocations. - *

Default is false. Subclasses may override this if they + *

Default is {@code false}. Subclasses may override this if they * will always return pre-filtered Advisors. * @return whether the Advisors are pre-filtered * @see #getAdvicesAndAdvisorsForBean @@ -578,10 +593,10 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig * @param beanName the name of the bean * @param customTargetSource the TargetSource returned by the * {@link #getCustomTargetSource} method: may be ignored. - * Will be null if no custom target source is in use. + * Will be {@code null} if no custom target source is in use. * @return an array of additional interceptors for the particular bean; * or an empty array if no additional interceptors but just the common ones; - * or null if no proxy at all, not even with the common interceptors. + * or {@code null} if no proxy at all, not even with the common interceptors. * See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS. * @throws BeansException in case of errors * @see #DO_NOT_PROXY diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java index dbc184c2a3..88a75e877a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public abstract class AutoProxyUtils { /** * Bean definition attribute that may indicate whether a given bean is supposed * to be proxied with its target class (in case of it getting proxied in the first - * place). The value is Boolean.TRUE or Boolean.FALSE. + * place). The value is {@code Boolean.TRUE} or {@code Boolean.FALSE}. *

Proxy factories can set this attribute if they built a target class proxy * for a specific bean, and want to enforce that that bean can always be cast * to its target class (even if AOP advices get applied through auto-proxying). diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java index 4000181369..e417f92df0 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java @@ -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"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ public class BeanFactoryAdvisorRetrievalHelper { /** * Determine whether the aspect bean with the given name is eligible. - *

The default implementation always returns true. + *

The default implementation always returns {@code true}. * @param beanName the name of the aspect bean * @return whether the bean is eligible */ diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java index a7b01b573c..e91f9db74a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import org.springframework.util.StringUtils; * @see #setInterceptorNames * @see AbstractAutoProxyCreator */ +@SuppressWarnings("serial") public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator { private List beanNames; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/DefaultAdvisorAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/DefaultAdvisorAutoProxyCreator.java index 334b9a5cfe..044c7bbc11 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/DefaultAdvisorAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/DefaultAdvisorAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,15 +24,16 @@ import org.springframework.beans.factory.BeanNameAware; * no special code to handle any particular aspects, such as pooling aspects. * *

It's possible to filter out advisors - for example, to use multiple post processors - * of this type in the same factory - by setting the usePrefix property + * of this type in the same factory - by setting the {@code usePrefix} property * to true, in which case only advisors beginning with the DefaultAdvisorAutoProxyCreator's * bean name followed by a dot (like "aapc.") will be used. This default prefix can be - * changed from the bean name by setting the advisorBeanNamePrefix property. + * changed from the bean name by setting the {@code advisorBeanNamePrefix} property. * The separator (.) will also be used in this case. * * @author Rod Johnson * @author Rob Harrop */ +@SuppressWarnings("serial") public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator implements BeanNameAware { /** Separator between prefix and remainder of bean name */ @@ -78,6 +79,7 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea return this.advisorBeanNamePrefix; } + @Override public void setBeanName(String name) { // If no infrastructure bean name prefix has been set, override it. if (this.advisorBeanNamePrefix == null) { @@ -94,6 +96,6 @@ public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCrea @Override protected boolean isEligibleAdvisorBean(String beanName) { return (!isUsePrefix() || beanName.startsWith(getAdvisorBeanNamePrefix())); - } + } } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/InfrastructureAdvisorAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/InfrastructureAdvisorAutoProxyCreator.java index 35ad24e1c7..90034eafbb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/InfrastructureAdvisorAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/InfrastructureAdvisorAutoProxyCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; * @author Juergen Hoeller * @since 2.0.7 */ +@SuppressWarnings("serial") public class InfrastructureAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator { private ConfigurableListableBeanFactory beanFactory; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java index 244b1eadd5..ce350d651b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class ProxyCreationContext { /** * Return the name of the currently proxied bean instance. - * @return the name of the bean, or null if none available + * @return the name of the bean, or {@code null} if none available */ public static String getCurrentProxiedBeanName() { return currentProxiedBeanName.get(); @@ -43,7 +43,7 @@ public class ProxyCreationContext { /** * Set the name of the currently proxied bean instance. - * @param beanName the name of the bean, or null to reset it + * @param beanName the name of the bean, or {@code null} to reset it */ static void setCurrentProxiedBeanName(String beanName) { if (beanName != null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java index 6219a5015c..67f9638ce4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/TargetSourceCreator.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,12 +30,12 @@ import org.springframework.aop.TargetSource; * @author Juergen Hoeller */ public interface TargetSourceCreator { - + /** * Create a special TargetSource for the given bean, if any. * @param beanClass the class of the bean to create a TargetSource for * @param beanName the name of the bean - * @return a special TargetSource or null if this TargetSourceCreator isn't + * @return a special TargetSource or {@code null} if this TargetSourceCreator isn't * interested in the particular bean */ TargetSource getTargetSource(Class beanClass, String beanName); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/package-info.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/package-info.java index 691464cd7d..8646ea4958 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/package-info.java @@ -3,10 +3,10 @@ * * Bean post-processors for use in ApplicationContexts to simplify AOP usage * by automatically creating AOP proxies without the need to use a ProxyFactoryBean. - * + * *

The various post-processors in this package need only be added to an ApplicationContext * (typically in an XML bean definition document) to automatically proxy selected beans. - * + * *

NB: Automatic auto-proxying is not supported for BeanFactory implementations, * as post-processors beans are only automatically detected in application contexts. * Post-processors can be explicitly registered on a ConfigurableBeanFactory instead. diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java index a7bf4b490c..3735ba06e7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -66,6 +66,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator new HashMap(); + @Override public final void setBeanFactory(BeanFactory beanFactory) { if (!(beanFactory instanceof ConfigurableBeanFactory)) { throw new IllegalStateException("Cannot do auto-TargetSource creation with a BeanFactory " + @@ -86,6 +87,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator // Implementation of the TargetSourceCreator interface //--------------------------------------------------------------------- + @Override public final TargetSource getTargetSource(Class beanClass, String beanName) { AbstractBeanFactoryBasedTargetSource targetSource = createBeanFactoryBasedTargetSource(beanClass, beanName); @@ -159,6 +161,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator * Destroys the internal BeanFactory on shutdown of the TargetSourceCreator. * @see #getInternalBeanFactoryForBean */ + @Override public void destroy() { synchronized (this.internalBeanFactories) { for (DefaultListableBeanFactory bf : this.internalBeanFactories.values()) { @@ -184,14 +187,14 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator /** * Subclasses must implement this method to return a new AbstractPrototypeBasedTargetSource - * if they wish to create a custom TargetSource for this bean, or null if they are + * if they wish to create a custom TargetSource for this bean, or {@code null} if they are * not interested it in, in which case no special target source will be created. - * Subclasses should not call setTargetBeanName or setBeanFactory + * Subclasses should not call {@code setTargetBeanName} or {@code setBeanFactory} * on the AbstractPrototypeBasedTargetSource: This class' implementation of - * getTargetSource() will do that. + * {@code getTargetSource()} will do that. * @param beanClass the class of the bean to create a TargetSource for * @param beanName the name of the bean - * @return the AbstractPrototypeBasedTargetSource, or null if we don't match this + * @return the AbstractPrototypeBasedTargetSource, or {@code null} if we don't match this */ protected abstract AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource( Class beanClass, String beanName); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/QuickTargetSourceCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/QuickTargetSourceCreator.java index 094188be1c..d972b95cf1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/QuickTargetSourceCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/QuickTargetSourceCreator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.springframework.aop.target.ThreadLocalTargetSource; /** * Convenient TargetSourceCreator using bean name prefixes to create one of three - * well-known TargetSource types: + * well-known TargetSource types: *

  • : CommonsPoolTargetSource *
  • % ThreadLocalTargetSource *
  • ! PrototypeTargetSource @@ -59,5 +59,5 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour return null; } } - + } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/package-info.java b/spring-aop/src/main/java/org/springframework/aop/framework/package-info.java index 4958a010cb..3581a82efe 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/package-info.java @@ -3,13 +3,13 @@ * * Package containing Spring's basic AOP infrastructure, compliant with the * AOP Alliance interfaces. - * + * *

    Spring AOP supports proxying interfaces or classes, introductions, and offers * static and dynamic pointcuts. - * + * *

    Any Spring AOP proxy can be cast to the ProxyConfig AOP configuration interface * in this package to add or remove interceptors. - * + * *

    The ProxyFactoryBean is a convenient way to create AOP proxies in a BeanFactory * or ApplicationContext. However, proxies can be created programmatically using the * ProxyFactory class. diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java index 0c257c1c50..0159d307a1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ import org.aopalliance.intercept.MethodInvocation; /** * Base class for monitoring interceptors, such as performance monitors. - * Provides prefix and suffix properties + * Provides {@code prefix} and {@code suffix} properties * that help to classify/group performance monitoring results. * - *

    Subclasses should call the createInvocationTraceName(MethodInvocation) + *

    Subclasses should call the {@code createInvocationTraceName(MethodInvocation)} * method to create a name for the given trace that includes information about the * method invocation under trace along with the prefix and suffix added as appropriate. - * + * * @author Rob Harrop * @author Juergen Hoeller * @since 1.2.7 @@ -36,6 +36,7 @@ import org.aopalliance.intercept.MethodInvocation; * @see #setSuffix * @see #createInvocationTraceName */ +@SuppressWarnings("serial") public abstract class AbstractMonitoringInterceptor extends AbstractTraceInterceptor { private String prefix = ""; @@ -87,7 +88,7 @@ public abstract class AbstractMonitoringInterceptor extends AbstractTraceInterce /** - * Create a String name for the given MethodInvocation + * Create a {@code String} name for the given {@code MethodInvocation} * that can be used for trace/logging purposes. This name is made up of the * configured prefix, followed by the fully-qualified name of the method being * invoked, followed by the configured suffix. diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractTraceInterceptor.java index 2c367c20c0..1ba6dca904 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractTraceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,16 +26,16 @@ import org.apache.commons.logging.LogFactory; import org.springframework.aop.support.AopUtils; /** - * Base MethodInterceptor implementation for tracing. + * Base {@code MethodInterceptor} implementation for tracing. * *

    By default, log messages are written to the log for the interceptor class, - * not the class which is being intercepted. Setting the useDynamicLogger - * bean property to true causes all log messages to be written to - * the Log for the target class being intercepted. + * not the class which is being intercepted. Setting the {@code useDynamicLogger} + * bean property to {@code true} causes all log messages to be written to + * the {@code Log} for the target class being intercepted. * - *

    Subclasses must implement the invokeUnderTrace method, which + *

    Subclasses must implement the {@code invokeUnderTrace} method, which * is invoked by this class ONLY when a particular invocation SHOULD be traced. - * Subclasses should write to the Log instance provided. + * Subclasses should write to the {@code Log} instance provided. * * @author Rob Harrop * @author Juergen Hoeller @@ -43,11 +43,12 @@ import org.springframework.aop.support.AopUtils; * @see #setUseDynamicLogger * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ +@SuppressWarnings("serial") public abstract class AbstractTraceInterceptor implements MethodInterceptor, Serializable { /** - * The default Log instance used to write trace messages. - * This instance is mapped to the implementing Class. + * The default {@code Log} instance used to write trace messages. + * This instance is mapped to the implementing {@code Class}. */ protected transient Log defaultLogger = LogFactory.getLog(getClass()); @@ -61,9 +62,9 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser /** * Set whether to use a dynamic logger or a static logger. * Default is a static logger for this trace interceptor. - *

    Used to determine which Log instance should be used to write + *

    Used to determine which {@code Log} instance should be used to write * log messages for a particular method invocation: a dynamic one for the - * Class getting called, or a static one for the Class + * {@code Class} getting called, or a static one for the {@code Class} * of the trace interceptor. *

    NOTE: Specify either this property or "loggerName", not both. * @see #getLoggerForInvocation(org.aopalliance.intercept.MethodInvocation) @@ -99,11 +100,12 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser /** - * Determines whether or not logging is enabled for the particular MethodInvocation. + * Determines whether or not logging is enabled for the particular {@code MethodInvocation}. * If not, the method invocation proceeds as normal, otherwise the method invocation is passed - * to the invokeUnderTrace method for handling. + * to the {@code invokeUnderTrace} method for handling. * @see #invokeUnderTrace(org.aopalliance.intercept.MethodInvocation, org.apache.commons.logging.Log) */ + @Override public Object invoke(MethodInvocation invocation) throws Throwable { Log logger = getLoggerForInvocation(invocation); if (isInterceptorEnabled(invocation, logger)) { @@ -115,13 +117,13 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser } /** - * Return the appropriate Log instance to use for the given - * MethodInvocation. If the useDynamicLogger flag - * is set, the Log instance will be for the target class of the - * MethodInvocation, otherwise the Log will be the + * Return the appropriate {@code Log} instance to use for the given + * {@code MethodInvocation}. If the {@code useDynamicLogger} flag + * is set, the {@code Log} instance will be for the target class of the + * {@code MethodInvocation}, otherwise the {@code Log} will be the * default static logger. - * @param invocation the MethodInvocation being traced - * @return the Log instance to use + * @param invocation the {@code MethodInvocation} being traced + * @return the {@code Log} instance to use * @see #setUseDynamicLogger */ protected Log getLoggerForInvocation(MethodInvocation invocation) { @@ -146,12 +148,12 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser /** * Determine whether the interceptor should kick in, that is, - * whether the invokeUnderTrace method should be called. - *

    Default behavior is to check whether the given Log + * whether the {@code invokeUnderTrace} method should be called. + *

    Default behavior is to check whether the given {@code Log} * instance is enabled. Subclasses can override this to apply the * interceptor in other cases as well. - * @param invocation the MethodInvocation being traced - * @param logger the Log instance to check + * @param invocation the {@code MethodInvocation} being traced + * @param logger the {@code Log} instance to check * @see #invokeUnderTrace * @see #isLogEnabled */ @@ -161,9 +163,9 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser /** * Determine whether the given {@link Log} instance is enabled. - *

    Default is true when the "trace" level is enabled. + *

    Default is {@code true} when the "trace" level is enabled. * Subclasses can override this to change the level under which 'tracing' occurs. - * @param logger the Log instance to check + * @param logger the {@code Log} instance to check */ protected boolean isLogEnabled(Log logger) { return logger.isTraceEnabled(); @@ -172,16 +174,16 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser /** * Subclasses must override this method to perform any tracing around the - * supplied MethodInvocation. Subclasses are responsible for - * ensuring that the MethodInvocation actually executes by - * calling MethodInvocation.proceed(). - *

    By default, the passed-in Log instance will have log level + * supplied {@code MethodInvocation}. Subclasses are responsible for + * ensuring that the {@code MethodInvocation} actually executes by + * calling {@code MethodInvocation.proceed()}. + *

    By default, the passed-in {@code Log} instance will have log level * "trace" enabled. Subclasses do not have to check for this again, unless - * they overwrite the isInterceptorEnabled method to modify + * they overwrite the {@code isInterceptorEnabled} method to modify * the default behavior. - * @param logger the Log to write trace messages to - * @return the result of the call to MethodInvocation.proceed() - * @throws Throwable if the call to MethodInvocation.proceed() + * @param logger the {@code Log} to write trace messages to + * @return the result of the call to {@code MethodInvocation.proceed()} + * @throws Throwable if the call to {@code MethodInvocation.proceed()} * encountered any errors * @see #isInterceptorEnabled * @see #isLogEnabled diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java index 96237b86d1..f94b575806 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java @@ -80,6 +80,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { /** * Set the {@link BeanFactory} to be used when looking up executors by qualifier. */ + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java index 8b2c788ef3..7730f54426 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java @@ -30,19 +30,19 @@ import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.util.ReflectionUtils; /** - * AOP Alliance MethodInterceptor that processes method invocations + * AOP Alliance {@code MethodInterceptor} that processes method invocations * asynchronously, using a given {@link org.springframework.core.task.AsyncTaskExecutor}. * Typically used with the {@link org.springframework.scheduling.annotation.Async} annotation. * *

    In terms of target method signatures, any parameter types are supported. - * However, the return type is constrained to either void or - * java.util.concurrent.Future. In the latter case, the Future handle + * However, the return type is constrained to either {@code void} or + * {@code java.util.concurrent.Future}. In the latter case, the Future handle * returned from the proxy will be an actual asynchronous Future that can be used * to track the result of the asynchronous method execution. However, since the * target method needs to implement the same signature, it will have to return * a temporary Future handle that just passes the return value through * (like Spring's {@link org.springframework.scheduling.annotation.AsyncResult} - * or EJB 3.1's javax.ejb.AsyncResult). + * or EJB 3.1's {@code javax.ejb.AsyncResult}). * *

    As of Spring 3.1.2 the {@code AnnotationAsyncExecutionInterceptor} subclass is * preferred for use due to its support for executor qualification in conjunction with @@ -75,9 +75,11 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport * @return {@link Future} if the original method returns {@code Future}; {@code null} * otherwise. */ + @Override public Object invoke(final MethodInvocation invocation) throws Throwable { Future result = this.determineAsyncExecutor(invocation.getMethod()).submit( new Callable() { + @Override public Object call() throws Exception { try { Object result = invocation.proceed(); @@ -113,6 +115,7 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport return null; } + @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java index bf14ab6430..ad57e4c635 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,6 +39,7 @@ import org.springframework.util.ConcurrencyThrottleSupport; * @since 11.02.2004 * @see #setConcurrencyLimit */ +@SuppressWarnings("serial") public class ConcurrencyThrottleInterceptor extends ConcurrencyThrottleSupport implements MethodInterceptor, Serializable { @@ -46,6 +47,7 @@ public class ConcurrencyThrottleInterceptor extends ConcurrencyThrottleSupport setConcurrencyLimit(1); } + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { beforeAccess(); try { diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java index db00bcbbf6..a5d1f50805 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/CustomizableTraceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; /** - * MethodInterceptor implementation that allows for highly customizable + * {@code MethodInterceptor} implementation that allows for highly customizable * method-level tracing, using placeholders. * *

    Trace messages are written on method entry, and if the method invocation succeeds @@ -40,19 +40,19 @@ import org.springframework.util.StringUtils; * messages. The placeholders available are: * *

      - *
    • $[methodName] - replaced with the name of the method being invoked
    • - *
    • $[targetClassName] - replaced with the name of the class that is + *
    • {@code $[methodName]} - replaced with the name of the method being invoked
    • + *
    • {@code $[targetClassName]} - replaced with the name of the class that is * the target of the invocation
    • - *
    • $[targetClassShortName] - replaced with the short name of the class + *
    • {@code $[targetClassShortName]} - replaced with the short name of the class * that is the target of the invocation
    • - *
    • $[returnValue] - replaced with the value returned by the invocation
    • - *
    • $[argumentTypes] - replaced with a comma-separated list of the + *
    • {@code $[returnValue]} - replaced with the value returned by the invocation
    • + *
    • {@code $[argumentTypes]} - replaced with a comma-separated list of the * short class names of the method arguments
    • - *
    • $[arguments] - replaced with a comma-separated list of the - * String representation of the method arguments
    • - *
    • $[exception] - replaced with the String representation - * of any Throwable raised during the invocation
    • - *
    • $[invocationTime] - replaced with the time, in milliseconds, + *
    • {@code $[arguments]} - replaced with a comma-separated list of the + * {@code String} representation of the method arguments
    • + *
    • {@code $[exception]} - replaced with the {@code String} representation + * of any {@code Throwable} raised during the invocation
    • + *
    • {@code $[invocationTime]} - replaced with the time, in milliseconds, * taken by the method invocation
    • *
    * @@ -67,59 +67,60 @@ import org.springframework.util.StringUtils; * @see #setExceptionMessage * @see SimpleTraceInterceptor */ +@SuppressWarnings("serial") public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { /** - * The $[methodName] placeholder. + * The {@code $[methodName]} placeholder. * Replaced with the name of the method being invoked. */ public static final String PLACEHOLDER_METHOD_NAME = "$[methodName]"; /** - * The $[targetClassName] placeholder. - * Replaced with the fully-qualifed name of the Class + * The {@code $[targetClassName]} placeholder. + * Replaced with the fully-qualifed name of the {@code Class} * of the method invocation target. */ public static final String PLACEHOLDER_TARGET_CLASS_NAME = "$[targetClassName]"; /** - * The $[targetClassShortName] placeholder. - * Replaced with the short name of the Class of the + * The {@code $[targetClassShortName]} placeholder. + * Replaced with the short name of the {@code Class} of the * method invocation target. */ public static final String PLACEHOLDER_TARGET_CLASS_SHORT_NAME = "$[targetClassShortName]"; /** - * The $[returnValue] placeholder. - * Replaced with the String representation of the value + * The {@code $[returnValue]} placeholder. + * Replaced with the {@code String} representation of the value * returned by the method invocation. */ public static final String PLACEHOLDER_RETURN_VALUE = "$[returnValue]"; /** - * The $[argumentTypes] placeholder. + * The {@code $[argumentTypes]} placeholder. * Replaced with a comma-separated list of the argument types for the * method invocation. Argument types are written as short class names. */ public static final String PLACEHOLDER_ARGUMENT_TYPES = "$[argumentTypes]"; /** - * The $[arguments] placeholder. + * The {@code $[arguments]} placeholder. * Replaced with a comma separated list of the argument values for the - * method invocation. Relies on the toString() method of + * method invocation. Relies on the {@code toString()} method of * each argument type. */ public static final String PLACEHOLDER_ARGUMENTS = "$[arguments]"; /** - * The $[exception] placeholder. - * Replaced with the String representation of any - * Throwable raised during method invocation. + * The {@code $[exception]} placeholder. + * Replaced with the {@code String} representation of any + * {@code Throwable} raised during method invocation. */ public static final String PLACEHOLDER_EXCEPTION = "$[exception]"; /** - * The $[invocationTime] placeholder. + * The {@code $[invocationTime]} placeholder. * Replaced with the time taken by the invocation (in milliseconds). */ public static final String PLACEHOLDER_INVOCATION_TIME = "$[invocationTime]"; @@ -143,12 +144,12 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { "Exception thrown in method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]"; /** - * The Pattern used to match placeholders. + * The {@code Pattern} used to match placeholders. */ private static final Pattern PATTERN = Pattern.compile("\\$\\[\\p{Alpha}+\\]"); /** - * The Set of allowed placeholders. + * The {@code Set} of allowed placeholders. */ private static final Set ALLOWED_PLACEHOLDERS = new Constants(CustomizableTraceInterceptor.class).getValues("PLACEHOLDER_"); @@ -174,10 +175,10 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { * Set the template used for method entry log messages. * This template can contain any of the following placeholders: *
      - *
    • $[targetClassName]
    • - *
    • $[targetClassShortName]
    • - *
    • $[argumentTypes]
    • - *
    • $[arguments]
    • + *
    • {@code $[targetClassName]}
    • + *
    • {@code $[targetClassShortName]}
    • + *
    • {@code $[argumentTypes]}
    • + *
    • {@code $[arguments]}
    • *
    */ public void setEnterMessage(String enterMessage) throws IllegalArgumentException { @@ -196,12 +197,12 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { * Set the template used for method exit log messages. * This template can contain any of the following placeholders: *
      - *
    • $[targetClassName]
    • - *
    • $[targetClassShortName]
    • - *
    • $[argumentTypes]
    • - *
    • $[arguments]
    • - *
    • $[returnValue]
    • - *
    • $[invocationTime]
    • + *
    • {@code $[targetClassName]}
    • + *
    • {@code $[targetClassShortName]}
    • + *
    • {@code $[argumentTypes]}
    • + *
    • {@code $[arguments]}
    • + *
    • {@code $[returnValue]}
    • + *
    • {@code $[invocationTime]}
    • *
    */ public void setExitMessage(String exitMessage) { @@ -216,11 +217,11 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { * Set the template used for method exception log messages. * This template can contain any of the following placeholders: *
      - *
    • $[targetClassName]
    • - *
    • $[targetClassShortName]
    • - *
    • $[argumentTypes]
    • - *
    • $[arguments]
    • - *
    • $[exception]
    • + *
    • {@code $[targetClassName]}
    • + *
    • {@code $[targetClassShortName]}
    • + *
    • {@code $[argumentTypes]}
    • + *
    • {@code $[arguments]}
    • + *
    • {@code $[exception]}
    • *
    */ public void setExceptionMessage(String exceptionMessage) { @@ -235,10 +236,10 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { /** - * Writes a log message before the invocation based on the value of enterMessage. + * Writes a log message before the invocation based on the value of {@code enterMessage}. * If the invocation succeeds, then a log message is written on exit based on the value - * exitMessage. If an exception occurs during invocation, then a message is - * written based on the value of exceptionMessage. + * {@code exitMessage}. If an exception occurs during invocation, then a message is + * written based on the value of {@code exceptionMessage}. * @see #setEnterMessage * @see #setExitMessage * @see #setExceptionMessage @@ -277,7 +278,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } /** - * Writes the supplied message to the supplied Log instance. + * Writes the supplied message to the supplied {@code Log} instance. * @see #writeToLog(org.apache.commons.logging.Log, String, Throwable) */ protected void writeToLog(Log logger, String message) { @@ -286,8 +287,8 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { /** * Writes the supplied message and {@link Throwable} to the - * supplied Log instance. By default messages are written - * at TRACE level. Sub-classes can override this method + * supplied {@code Log} instance. By default messages are written + * at {@code TRACE} level. Sub-classes can override this method * to control which level the message is written at. */ protected void writeToLog(Log logger, String message, Throwable ex) { @@ -303,16 +304,16 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { * Replace the placeholders in the given message with the supplied values, * or values derived from those supplied. * @param message the message template containing the placeholders to be replaced - * @param methodInvocation the MethodInvocation being logged. - * Used to derive values for all placeholders except $[exception] - * and $[returnValue]. + * @param methodInvocation the {@code MethodInvocation} being logged. + * Used to derive values for all placeholders except {@code $[exception]} + * and {@code $[returnValue]}. * @param returnValue any value returned by the invocation. - * Used to replace the $[returnValue] placeholder. May be null. - * @param throwable any Throwable raised during the invocation. - * The value of Throwable.toString() is replaced for the - * $[exception] placeholder. May be null. + * Used to replace the {@code $[returnValue]} placeholder. May be {@code null}. + * @param throwable any {@code Throwable} raised during the invocation. + * The value of {@code Throwable.toString()} is replaced for the + * {@code $[exception]} placeholder. May be {@code null}. * @param invocationTime the value to write in place of the - * $[invocationTime] placeholder + * {@code $[invocationTime]} placeholder * @return the formatted output to write to the log */ protected String replacePlaceholders(String message, MethodInvocation methodInvocation, @@ -360,12 +361,12 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } /** - * Adds the String representation of the method return value - * to the supplied StringBuffer. Correctly handles - * null and void results. - * @param methodInvocation the MethodInvocation that returned the value - * @param matcher the Matcher containing the matched placeholder - * @param output the StringBuffer to write output to + * Adds the {@code String} representation of the method return value + * to the supplied {@code StringBuffer}. Correctly handles + * {@code null} and {@code void} results. + * @param methodInvocation the {@code MethodInvocation} that returned the value + * @param matcher the {@code Matcher} containing the matched placeholder + * @param output the {@code StringBuffer} to write output to * @param returnValue the value returned by the method invocation. */ private void appendReturnValue( @@ -383,14 +384,14 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } /** - * Adds a comma-separated list of the short Class names of the + * Adds a comma-separated list of the short {@code Class} names of the * method argument types to the output. For example, if a method has signature - * put(java.lang.String, java.lang.Object) then the value returned - * will be String, Object. - * @param methodInvocation the MethodInvocation being logged. - * Arguments will be retrieved from the corresponding Method. - * @param matcher the Matcher containing the state of the output - * @param output the StringBuffer containing the output + * {@code put(java.lang.String, java.lang.Object)} then the value returned + * will be {@code String, Object}. + * @param methodInvocation the {@code MethodInvocation} being logged. + * Arguments will be retrieved from the corresponding {@code Method}. + * @param matcher the {@code Matcher} containing the state of the output + * @param output the {@code StringBuffer} containing the output */ private void appendArgumentTypes(MethodInvocation methodInvocation, Matcher matcher, StringBuffer output) { Class[] argumentTypes = methodInvocation.getMethod().getParameterTypes(); @@ -402,9 +403,9 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } /** - * Checks to see if the supplied String has any placeholders + * Checks to see if the supplied {@code String} has any placeholders * that are not specified as constants on this class and throws an - * IllegalArgumentException if so. + * {@code IllegalArgumentException} if so. */ private void checkForInvalidPlaceholders(String message) throws IllegalArgumentException { Matcher matcher = PATTERN.matcher(message); @@ -417,8 +418,8 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor { } /** - * Replaces $ in inner class names with \$. - *

    This code is equivalent to JDK 1.5's quoteReplacement + * Replaces {@code $} in inner class names with {@code \$}. + *

    This code is equivalent to JDK 1.5's {@code quoteReplacement} * method in the Matcher class itself. We're keeping our own version * here for JDK 1.4 compliance reasons only. */ diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/DebugInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/DebugInterceptor.java index 665238f35b..0a2c2ec8e9 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/DebugInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/DebugInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,19 +19,20 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; /** - * AOP Alliance MethodInterceptor that can be introduced in a chain + * AOP Alliance {@code MethodInterceptor} that can be introduced in a chain * to display verbose information about intercepted invocations to the logger. * *

    Logs full invocation details on method entry and method exit, * including invocation arguments and invocation count. This is only - * intended for debugging purposes; use SimpleTraceInterceptor - * or CustomizableTraceInterceptor for pure tracing purposes. + * intended for debugging purposes; use {@code SimpleTraceInterceptor} + * or {@code CustomizableTraceInterceptor} for pure tracing purposes. * * @author Rod Johnson * @author Juergen Hoeller * @see SimpleTraceInterceptor * @see CustomizableTraceInterceptor */ +@SuppressWarnings("serial") public class DebugInterceptor extends SimpleTraceInterceptor { private volatile long count; diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java index 81b3110742..78479765ca 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisors.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.beans.factory.NamedBean; /** * Convenient methods for creating advisors that may be used when autoproxying beans * created with the Spring IoC container, binding the bean name to the current - * invocation. May support a bean() pointcut designator with AspectJ. + * invocation. May support a {@code bean()} pointcut designator with AspectJ. * *

    Typically used in Spring auto-proxying, where the bean name is known * at proxy creation time. @@ -52,7 +52,7 @@ public abstract class ExposeBeanNameAdvisors { * Find the bean name for the current invocation. Assumes that an ExposeBeanNameAdvisor * has been included in the interceptor chain, and that the invocation is exposed * with ExposeInvocationInterceptor. - * @return the bean name (never null) + * @return the bean name (never {@code null}) * @throws IllegalStateException if the bean name has not been exposed */ public static String getBeanName() throws IllegalStateException { @@ -63,7 +63,7 @@ public abstract class ExposeBeanNameAdvisors { * Find the bean name for the given invocation. Assumes that an ExposeBeanNameAdvisor * has been included in the interceptor chain. * @param mi MethodInvocation that should contain the bean name as an attribute - * @return the bean name (never null) + * @return the bean name (never {@code null}) * @throws IllegalStateException if the bean name has not been exposed */ public static String getBeanName(MethodInvocation mi) throws IllegalStateException { @@ -109,6 +109,7 @@ public abstract class ExposeBeanNameAdvisors { this.beanName = beanName; } + @Override public Object invoke(MethodInvocation mi) throws Throwable { if (!(mi instanceof ProxyMethodInvocation)) { throw new IllegalStateException("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); @@ -123,9 +124,10 @@ public abstract class ExposeBeanNameAdvisors { /** * Introduction that exposes the specified bean name as invocation attribute. */ + @SuppressWarnings("serial") private static class ExposeBeanNameIntroduction extends DelegatingIntroductionInterceptor implements NamedBean { - private final String beanName; + private final String beanName; public ExposeBeanNameIntroduction(String beanName) { this.beanName = beanName; @@ -141,6 +143,7 @@ public abstract class ExposeBeanNameAdvisors { return super.invoke(mi); } + @Override public String getBeanName() { return this.beanName; } diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java index 86ac202756..9f9d887e7a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ import org.springframework.core.Ordered; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered, Serializable { /** Singleton instance of this class */ @@ -83,6 +84,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered, private ExposeInvocationInterceptor() { } + @Override public Object invoke(MethodInvocation mi) throws Throwable { MethodInvocation oldInvocation = invocation.get(); invocation.set(mi); @@ -94,6 +96,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered, } } + @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE + 1; } @@ -101,7 +104,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, Ordered, /** * Required to support serialization. Replaces with canonical instance * on deserialization, protecting Singleton pattern. - *

    Alternative to overriding the equals method. + *

    Alternative to overriding the {@code equals} method. */ private Object readResolve() { return INSTANCE; diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptor.java index 0ea4dd527f..5ff0f9cba8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.apache.commons.logging.Log; * and output the stats. * *

    This code is inspired by Thierry Templier's blog. - * + * * @author Dmitriy Kopylenko * @author Juergen Hoeller * @author Rob Harrop @@ -35,6 +35,7 @@ import org.apache.commons.logging.Log; * @see com.jamonapi.MonitorFactory * @see PerformanceMonitorInterceptor */ +@SuppressWarnings("serial") public class JamonPerformanceMonitorInterceptor extends AbstractMonitoringInterceptor { private boolean trackAllInvocations = false; diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptor.java index f22f54a77b..4362c5de10 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,10 +22,10 @@ import org.apache.commons.logging.Log; import org.springframework.util.StopWatch; /** - * Simple AOP Alliance MethodInterceptor for performance monitoring. + * Simple AOP Alliance {@code MethodInterceptor} for performance monitoring. * This interceptor has no effect on the intercepted method call. * - *

    Uses a StopWatch for the actual performance measuring. + *

    Uses a {@code StopWatch} for the actual performance measuring. * * @author Rod Johnson * @author Dmitriy Kopylenko @@ -33,6 +33,7 @@ import org.springframework.util.StopWatch; * @see org.springframework.util.StopWatch * @see JamonPerformanceMonitorInterceptor */ +@SuppressWarnings("serial") public class PerformanceMonitorInterceptor extends AbstractMonitoringInterceptor { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java index 34d0185561..e70f502fd1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,11 +20,11 @@ import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; /** - * Simple AOP Alliance MethodInterceptor that can be introduced + * Simple AOP Alliance {@code MethodInterceptor} that can be introduced * in a chain to display verbose trace information about intercepted method * invocations, with method entry and method exit info. * - *

    Consider using CustomizableTraceInterceptor for more + *

    Consider using {@code CustomizableTraceInterceptor} for more * advanced needs. * * @author Dmitriy Kopylenko @@ -32,6 +32,7 @@ import org.apache.commons.logging.Log; * @since 1.2 * @see CustomizableTraceInterceptor */ +@SuppressWarnings("serial") public class SimpleTraceInterceptor extends AbstractTraceInterceptor { /** diff --git a/spring-aop/src/main/java/org/springframework/aop/package-info.java b/spring-aop/src/main/java/org/springframework/aop/package-info.java index 5076bc0678..b5691ccfa6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/package-info.java +++ b/spring-aop/src/main/java/org/springframework/aop/package-info.java @@ -2,9 +2,9 @@ /** * * Core Spring AOP interfaces, built on AOP Alliance AOP interoperability interfaces. - * + * *
    Any AOP Alliance MethodInterceptor is usable in Spring. - * + * *
    Spring AOP also offers: *

      *
    • Introduction support @@ -15,7 +15,7 @@ *
    • Extensibility allowing arbitrary custom advice types to * be plugged in without modifying the core framework. *
    - * + * *
    * Spring AOP can be used programmatically or (preferably) * integrated with the Spring IoC container. diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/DefaultScopedObject.java b/spring-aop/src/main/java/org/springframework/aop/scope/DefaultScopedObject.java index 77c3a107ab..337c660022 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/DefaultScopedObject.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/DefaultScopedObject.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.springframework.util.Assert; /** * Default implementation of the {@link ScopedObject} interface. - * + * *

    Simply delegates the calls to the underlying * {@link ConfigurableBeanFactory bean factory} * ({@link ConfigurableBeanFactory#getBean(String)}/ @@ -34,6 +34,7 @@ import org.springframework.util.Assert; * @see org.springframework.beans.factory.BeanFactory#getBean * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#destroyScopedBean */ +@SuppressWarnings("serial") public class DefaultScopedObject implements ScopedObject, Serializable { private final ConfigurableBeanFactory beanFactory; @@ -54,10 +55,12 @@ public class DefaultScopedObject implements ScopedObject, Serializable { } + @Override public Object getTargetObject() { return this.beanFactory.getBean(this.targetBeanName); } + @Override public void removeFromScope() { this.beanFactory.destroyScopedBean(this.targetBeanName); } diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedObject.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedObject.java index 1a50082641..4b7046e359 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedObject.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedObject.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,5 +49,5 @@ public interface ScopedObject extends RawTargetAccess { * the exact same target object in the target scope). */ void removeFromScope(); - + } diff --git a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java index b13a9eb509..a0c6fee7b6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,14 +32,14 @@ import org.springframework.util.ClassUtils; /** * Convenient proxy factory bean for scoped objects. - * + * *

    Proxies created using this factory bean are thread-safe singletons * and may be injected into shared objects, with transparent scoping behavior. * *

    Proxies returned by this class implement the {@link ScopedObject} interface. * This presently allows for removing the corresponding object from the scope, * seamlessly creating a new instance in the scope on next access. - * + * *

    Please note that the proxies created by this factory are * class-based proxies by default. This can be customized * through switching the "proxyTargetClass" property to "false". @@ -49,6 +49,7 @@ import org.springframework.util.ClassUtils; * @since 2.0 * @see #setProxyTargetClass */ +@SuppressWarnings("serial") public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware { /** The TargetSource that manages scoping */ @@ -77,6 +78,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean getObjectType() { if (this.proxy != null) { return this.proxy.getClass(); @@ -127,6 +131,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBeannull if none is available + * or {@code null} if none is available */ public String getLocation() { return this.location; @@ -82,6 +83,7 @@ public abstract class AbstractExpressionPointcut implements ExpressionPointcut, /** * Return this pointcut's expression. */ + @Override public String getExpression() { return this.expression; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AbstractGenericPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/AbstractGenericPointcutAdvisor.java index 66ed6ff0ca..f3a9137b15 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AbstractGenericPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AbstractGenericPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.aopalliance.aop.Advice; * @see #setAdvice * @see DefaultPointcutAdvisor */ +@SuppressWarnings("serial") public abstract class AbstractGenericPointcutAdvisor extends AbstractPointcutAdvisor { private Advice advice; @@ -38,6 +39,7 @@ public abstract class AbstractGenericPointcutAdvisor extends AbstractPointcutAdv this.advice = advice; } + @Override public Advice getAdvice() { return this.advice; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java index a9031bcc3c..06f9b9dc64 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AbstractPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.util.ObjectUtils; * @since 1.1.2 * @see AbstractGenericPointcutAdvisor */ +@SuppressWarnings("serial") public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordered, Serializable { private Integer order; @@ -43,6 +44,7 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere this.order = order; } + @Override public int getOrder() { if (this.order != null) { return this.order; @@ -54,6 +56,7 @@ public abstract class AbstractPointcutAdvisor implements PointcutAdvisor, Ordere return Ordered.LOWEST_PRECEDENCE; } + @Override public boolean isPerInstance() { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java index ac64a99226..c5aa32ada5 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java @@ -34,8 +34,8 @@ import org.springframework.util.StringUtils; * * *

    Note: the regular expressions must be a match. For example, - * .*get.* will match com.mycom.Foo.getBar(). - * get.* will not. + * {@code .*get.*} will match com.mycom.Foo.getBar(). + * {@code get.*} will not. * *

    This base class is serializable. Subclasses should declare all fields transient * - the initPatternRepresentation method in this class will be invoked again on the @@ -47,6 +47,7 @@ import org.springframework.util.StringUtils; * @since 1.1 * @see JdkRegexpMethodPointcut */ +@SuppressWarnings("serial") public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { @@ -123,6 +124,7 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo * of the target class as well as against the method's declaring class, * plus the name of the method. */ + @Override public boolean matches(Method method, Class targetClass) { return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) || matchesPattern(method.getDeclaringClass().getName() + "." + method.getName())); @@ -172,17 +174,17 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo /** * Does the pattern at the given index match this string? - * @param pattern String pattern to match + * @param pattern {@code String} pattern to match * @param patternIndex index of pattern from 0 - * @return true if there is a match, else false. + * @return {@code true} if there is a match, else {@code false}. */ protected abstract boolean matches(String pattern, int patternIndex); /** * Does the exclusion pattern at the given index match this string? - * @param pattern String pattern to match. + * @param pattern {@code String} pattern to match. * @param patternIndex index of pattern starting from 0. - * @return true if there is a match, else false. + * @return {@code true} if there is a match, else {@code false}. */ protected abstract boolean matchesExclusion(String pattern, int patternIndex); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java index 86234323a2..fdd985191e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java @@ -109,7 +109,7 @@ public abstract class AopUtils { *

    Returns the target class for an AOP proxy and the plain class else. * @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; - * never null) + * never {@code null}) * @see org.springframework.aop.TargetClassAware#getTargetClass() * @see org.springframework.aop.framework.AopProxyUtils#ultimateTargetClass(Object) */ @@ -161,17 +161,17 @@ public abstract class AopUtils { /** * Given a method, which may come from an interface, and a target class used * in the current AOP invocation, find the corresponding target method if there - * is one. E.g. the method may be IFoo.bar() and the target class - * may be DefaultFoo. In this case, the method may be - * DefaultFoo.bar(). This enables attributes on that method to be found. + * is one. E.g. the method may be {@code IFoo.bar()} and the target class + * may be {@code DefaultFoo}. In this case, the method may be + * {@code DefaultFoo.bar()}. This enables attributes on that method to be found. *

    NOTE: In contrast to {@link org.springframework.util.ClassUtils#getMostSpecificMethod}, * this method resolves Java 5 bridge methods in order to retrieve attributes * from the original method definition. * @param method the method to be invoked, which may come from an interface * @param targetClass the target class for the current invocation. - * May be null or may not even implement the method. + * May be {@code null} or may not even implement the method. * @return the specific target method, or the original method if the - * targetClass doesn't implement it or is null + * {@code targetClass} doesn't implement it or is {@code null} * @see org.springframework.util.ClassUtils#getMostSpecificMethod */ public static Method getMostSpecificMethod(Method method, Class targetClass) { @@ -268,7 +268,7 @@ public abstract class AopUtils { } /** - * Determine the sublist of the candidateAdvisors list + * Determine the sublist of the {@code candidateAdvisors} list * that is applicable to the given class. * @param candidateAdvisors the Advisors to evaluate * @param clazz the target class diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java b/spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java index e8fd0213ea..bde74d3a27 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java @@ -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"); * you may not use this file except in compliance with the License. @@ -87,6 +87,7 @@ public abstract class ClassFilters { /** * ClassFilter implementation for a union of the given ClassFilters. */ + @SuppressWarnings("serial") private static class UnionClassFilter implements ClassFilter, Serializable { private ClassFilter[] filters; @@ -95,6 +96,7 @@ public abstract class ClassFilters { this.filters = filters; } + @Override public boolean matches(Class clazz) { for (int i = 0; i < this.filters.length; i++) { if (this.filters[i].matches(clazz)) { @@ -120,6 +122,7 @@ public abstract class ClassFilters { /** * ClassFilter implementation for an intersection of the given ClassFilters. */ + @SuppressWarnings("serial") private static class IntersectionClassFilter implements ClassFilter, Serializable { private ClassFilter[] filters; @@ -128,6 +131,7 @@ public abstract class ClassFilters { this.filters = filters; } + @Override public boolean matches(Class clazz) { for (int i = 0; i < this.filters.length; i++) { if (!this.filters[i].matches(clazz)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java index b92e535f63..4d2747c148 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ComposablePointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ import org.springframework.util.ObjectUtils; * Convenient class for building up pointcuts. All methods return * ComposablePointcut, so we can use a concise idiom like: * - * + * {@code * Pointcut pc = new ComposablePointcut().union(classFilter).intersection(methodMatcher).intersection(pointcut); - * + * } * * @author Rod Johnson * @author Juergen Hoeller @@ -49,8 +49,8 @@ public class ComposablePointcut implements Pointcut, Serializable { /** - * Create a default ComposablePointcut, with ClassFilter.TRUE - * and MethodMatcher.TRUE. + * Create a default ComposablePointcut, with {@code ClassFilter.TRUE} + * and {@code MethodMatcher.TRUE}. */ public ComposablePointcut() { this.classFilter = ClassFilter.TRUE; @@ -69,7 +69,7 @@ public class ComposablePointcut implements Pointcut, Serializable { /** * Create a ComposablePointcut for the given ClassFilter, - * with MethodMatcher.TRUE. + * with {@code MethodMatcher.TRUE}. * @param classFilter the ClassFilter to use */ public ComposablePointcut(ClassFilter classFilter) { @@ -80,7 +80,7 @@ public class ComposablePointcut implements Pointcut, Serializable { /** * Create a ComposablePointcut for the given MethodMatcher, - * with ClassFilter.TRUE. + * with {@code ClassFilter.TRUE}. * @param methodMatcher the MethodMatcher to use */ public ComposablePointcut(MethodMatcher methodMatcher) { @@ -170,10 +170,12 @@ public class ComposablePointcut implements Pointcut, Serializable { } + @Override public ClassFilter getClassFilter() { return this.classFilter; } + @Override public MethodMatcher getMethodMatcher() { return this.methodMatcher; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java index e0d0b6dc33..bc1e153bdf 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.util.ObjectUtils; * @author Rob Harrop * @see org.springframework.core.ControlFlow */ +@SuppressWarnings("serial") public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable { private Class clazz; @@ -70,6 +71,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher /** * Subclasses can override this for greater filtering (and performance). */ + @Override public boolean matches(Class clazz) { return true; } @@ -78,14 +80,17 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher * Subclasses can override this if it's possible to filter out * some candidate classes. */ + @Override public boolean matches(Method method, Class targetClass) { return true; } + @Override public boolean isRuntime() { return true; } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { ++this.evaluations; ControlFlow cflow = ControlFlowFactory.createControlFlow(); @@ -100,10 +105,12 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher } + @Override public ClassFilter getClassFilter() { return this; } + @Override public MethodMatcher getMethodMatcher() { return this; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultBeanFactoryPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultBeanFactoryPointcutAdvisor.java index 0de1c9fd08..bcfef02343 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultBeanFactoryPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultBeanFactoryPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.aop.Pointcut; * @see #setPointcut * @see #setAdviceBeanName */ +@SuppressWarnings("serial") public class DefaultBeanFactoryPointcutAdvisor extends AbstractBeanFactoryPointcutAdvisor { private Pointcut pointcut = Pointcut.TRUE; @@ -39,13 +40,14 @@ public class DefaultBeanFactoryPointcutAdvisor extends AbstractBeanFactoryPointc /** * Specify the pointcut targeting the advice. - *

    Default is Pointcut.TRUE. + *

    Default is {@code Pointcut.TRUE}. * @see #setAdviceBeanName */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); } + @Override public Pointcut getPointcut() { return this.pointcut; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java index 194ae88656..11bdcf5207 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,11 +38,11 @@ import org.springframework.util.ClassUtils; * @author Juergen Hoeller * @since 11.11.2003 */ -@SuppressWarnings({ "unchecked", "serial" }) +@SuppressWarnings({"serial" }) public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable { private final Advice advice; - + private final Set interfaces = new HashSet(); private int order = Integer.MAX_VALUE; @@ -62,7 +62,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param introductionInfo the IntroductionInfo that describes - * the interface to introduce (may be null) + * the interface to introduce (may be {@code null}) */ public DefaultIntroductionAdvisor(Advice advice, IntroductionInfo introductionInfo) { Assert.notNull(advice, "Advice must not be null"); @@ -102,10 +102,12 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil this.interfaces.add(intf); } + @Override public Class[] getInterfaces() { return this.interfaces.toArray(new Class[this.interfaces.size()]); } + @Override public void validateInterfaces() throws IllegalArgumentException { for (Class ifc : this.interfaces) { if (this.advice instanceof DynamicIntroductionAdvice && @@ -121,23 +123,28 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public Advice getAdvice() { return this.advice; } + @Override public boolean isPerInstance() { return true; } + @Override public ClassFilter getClassFilter() { return this; } + @Override public boolean matches(Class clazz) { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultPointcutAdvisor.java index cb4402683d..7dabc1a006 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.aop.Pointcut; * @see #setPointcut * @see #setAdvice */ +@SuppressWarnings("serial") public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor implements Serializable { private Pointcut pointcut = Pointcut.TRUE; @@ -42,20 +43,20 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple /** * Create an empty DefaultPointcutAdvisor. *

    Advice must be set before use using setter methods. - * Pointcut will normally be set also, but defaults to Pointcut.TRUE. + * Pointcut will normally be set also, but defaults to {@code Pointcut.TRUE}. */ public DefaultPointcutAdvisor() { } - + /** * Create a DefaultPointcutAdvisor that matches all methods. - *

    Pointcut.TRUE will be used as Pointcut. + *

    {@code Pointcut.TRUE} will be used as Pointcut. * @param advice the Advice to use */ public DefaultPointcutAdvisor(Advice advice) { this(Pointcut.TRUE, advice); } - + /** * Create a DefaultPointcutAdvisor, specifying Pointcut and Advice. * @param pointcut the Pointcut targeting the Advice @@ -69,13 +70,14 @@ public class DefaultPointcutAdvisor extends AbstractGenericPointcutAdvisor imple /** * Specify the pointcut targeting the advice. - *

    Default is Pointcut.TRUE. + *

    Default is {@code Pointcut.TRUE}. * @see #setAdvice */ public void setPointcut(Pointcut pointcut) { this.pointcut = (pointcut != null ? pointcut : Pointcut.TRUE); } + @Override public Pointcut getPointcut() { return this.pointcut; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java index 5278ee233f..a17e2734f5 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2087 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.aop.ProxyMethodInvocation; * object will have its own delegate (whereas DelegatingIntroductionInterceptor * shares the same delegate, and hence the same state across all targets). * - *

    The suppressInterface method can be used to suppress interfaces + *

    The {@code suppressInterface} method can be used to suppress interfaces * implemented by the delegate class but which should not be introduced to the * owning AOP proxy. * @@ -50,10 +50,11 @@ import org.springframework.aop.ProxyMethodInvocation; * @see #suppressInterface * @see DelegatingIntroductionInterceptor */ +@SuppressWarnings("serial") public class DelegatePerTargetObjectIntroductionInterceptor extends IntroductionInfoSupport implements IntroductionInterceptor { - /** + /** * Hold weak references to keys as we don't want to interfere with garbage collection.. */ private final Map delegateMap = new WeakHashMap(); @@ -82,15 +83,16 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ + @Override public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { Object delegate = getIntroductionDelegateFor(mi.getThis()); - + // Using the following method rather than direct reflection, // we get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(delegate, mi.getMethod(), mi.getArguments()); - + // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == delegate && mi instanceof ProxyMethodInvocation) { @@ -126,7 +128,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction } } } - + private Object createNewDelegate() { try { return this.defaultImplType.newInstance(); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java index fc9631bd61..45f90dbef7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DelegatingIntroductionInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,10 +36,10 @@ import org.springframework.util.Assert; * All interfaces except IntroductionInterceptor are picked up from * the subclass or delegate by default. * - *

    The suppressInterface method can be used to suppress interfaces + *

    The {@code suppressInterface} method can be used to suppress interfaces * implemented by the delegate but which should not be introduced to the owning * AOP proxy. - * + * *

    An instance of this class is serializable if the delegate is. * * @author Rod Johnson @@ -48,9 +48,10 @@ import org.springframework.util.Assert; * @see #suppressInterface * @see DelegatePerTargetObjectIntroductionInterceptor */ +@SuppressWarnings("serial") public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport implements IntroductionInterceptor { - + /** * Object that actually implements the interfaces. * May be "this" if a subclass implements the introduced interfaces. @@ -66,7 +67,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport public DelegatingIntroductionInterceptor(Object delegate) { init(delegate); } - + /** * Construct a new DelegatingIntroductionInterceptor. * The delegate will be the subclass, which must implement @@ -91,20 +92,21 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport suppressInterface(IntroductionInterceptor.class); suppressInterface(DynamicIntroductionAdvice.class); } - - + + /** * Subclasses may need to override this if they want to perform custom * behaviour in around advice. However, subclasses should invoke this * method, which handles introduced interfaces and forwarding to the target. */ + @Override public Object invoke(MethodInvocation mi) throws Throwable { if (isMethodOnIntroducedInterface(mi)) { // Using the following method rather than direct reflection, we // get correct handling of InvocationTargetException // if the introduced method throws an exception. Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); - + // Massage return value if possible: if the delegate returned itself, // we really want to return the proxy. if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcher.java index d011aa641b..78b230d8f0 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcher.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,6 +26,7 @@ import org.springframework.aop.MethodMatcher; */ public abstract class DynamicMethodMatcher implements MethodMatcher { + @Override public final boolean isRuntime() { return true; } @@ -34,6 +35,7 @@ public abstract class DynamicMethodMatcher implements MethodMatcher { * Can override to add preconditions for dynamic matching. This implementation * always returns true. */ + @Override public boolean matches(Method method, Class targetClass) { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcherPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcherPointcut.java index 5adc4fa539..df3963dc85 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcherPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DynamicMethodMatcherPointcut.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,10 +30,12 @@ import org.springframework.aop.Pointcut; */ public abstract class DynamicMethodMatcherPointcut extends DynamicMethodMatcher implements Pointcut { + @Override public ClassFilter getClassFilter() { return ClassFilter.TRUE; } + @Override public final MethodMatcher getMethodMatcher() { return this; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java index c04c049163..e10c0c9921 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ import org.springframework.util.ClassUtils; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class IntroductionInfoSupport implements IntroductionInfo, Serializable { protected final Set publishedInterfaces = new HashSet(); @@ -58,6 +59,7 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable { this.publishedInterfaces.remove(intf); } + @Override public Class[] getInterfaces() { return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]); } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java index d2a4fe1395..071da29247 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /** - * Regular expression pointcut based on the java.util.regex package. + * Regular expression pointcut based on the {@code java.util.regex} package. * Supports the following JavaBean properties: *

      *
    • pattern: regular expression for the fully-qualified method names to match @@ -30,28 +30,29 @@ import java.util.regex.PatternSyntaxException; *
    * *

    Note: the regular expressions must be a match. For example, - * .*get.* will match com.mycom.Foo.getBar(). - * get.* will not. + * {@code .*get.*} will match com.mycom.Foo.getBar(). + * {@code get.*} will not. * * @author Dmitriy Kopylenko * @author Rob Harrop * @since 1.1 */ +@SuppressWarnings("serial") public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { - - /** + + /** * Compiled form of the patterns. */ private Pattern[] compiledPatterns = new Pattern[0]; - /** + /** * Compiled form of the exclusion patterns. */ private Pattern[] compiledExclusionPatterns = new Pattern[0]; /** - * Initialize {@link Pattern Patterns} from the supplied String[]. + * Initialize {@link Pattern Patterns} from the supplied {@code String[]}. */ @Override protected void initPatternRepresentation(String[] patterns) throws PatternSyntaxException { @@ -59,7 +60,7 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { } /** - * Initialize exclusion {@link Pattern Patterns} from the supplied String[]. + * Initialize exclusion {@link Pattern Patterns} from the supplied {@code String[]}. */ @Override protected void initExcludedPatternRepresentation(String[] excludedPatterns) throws PatternSyntaxException { @@ -67,8 +68,8 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { } /** - * Returns true if the {@link Pattern} at index patternIndex - * matches the supplied candidate String. + * Returns {@code true} if the {@link Pattern} at index {@code patternIndex} + * matches the supplied candidate {@code String}. */ @Override protected boolean matches(String pattern, int patternIndex) { @@ -77,8 +78,8 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { } /** - * Returns true if the exclusion {@link Pattern} at index patternIndex - * matches the supplied candidate String. + * Returns {@code true} if the exclusion {@link Pattern} at index {@code patternIndex} + * matches the supplied candidate {@code String}. */ @Override protected boolean matchesExclusion(String candidate, int patternIndex) { @@ -88,7 +89,7 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { /** - * Compiles the supplied String[] into an array of + * Compiles the supplied {@code String[]} into an array of * {@link Pattern} objects and returns that array. */ private Pattern[] compilePatterns(String[] source) throws PatternSyntaxException { diff --git a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java index b4d4fd6f47..160496c074 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java @@ -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"); * you may not use this file except in compliance with the License. @@ -82,10 +82,10 @@ public abstract class MethodMatchers { * (if applicable). * @param mm the MethodMatcher to apply (may be an IntroductionAwareMethodMatcher) * @param method the candidate method - * @param targetClass the target class (may be null, 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) - * @param hasIntroductions true if the object on whose behalf we are - * asking is the subject on one or more introductions; false otherwise + * @param hasIntroductions {@code true} if the object on whose behalf we are + * asking is the subject on one or more introductions; {@code false} otherwise * @return whether or not this method matches statically */ public static boolean matches(MethodMatcher mm, Method method, Class targetClass, boolean hasIntroductions) { @@ -99,6 +99,7 @@ public abstract class MethodMatchers { /** * MethodMatcher implementation for a union of two given MethodMatchers. */ + @SuppressWarnings("serial") private static class UnionMethodMatcher implements IntroductionAwareMethodMatcher, Serializable { private MethodMatcher mm1; @@ -111,11 +112,13 @@ public abstract class MethodMatchers { this.mm2 = mm2; } + @Override public boolean matches(Method method, Class targetClass, boolean hasIntroductions) { return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) || (matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); } + @Override public boolean matches(Method method, Class targetClass) { return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) || (matchesClass2(targetClass) && this.mm2.matches(method, targetClass)); @@ -129,10 +132,12 @@ public abstract class MethodMatchers { return true; } + @Override public boolean isRuntime() { return this.mm1.isRuntime() || this.mm2.isRuntime(); } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args); } @@ -163,6 +168,7 @@ public abstract class MethodMatchers { * MethodMatcher implementation for a union of two given MethodMatchers, * supporting an associated ClassFilter per MethodMatcher. */ + @SuppressWarnings("serial") private static class ClassFilterAwareUnionMethodMatcher extends UnionMethodMatcher { private final ClassFilter cf1; @@ -201,6 +207,7 @@ public abstract class MethodMatchers { /** * MethodMatcher implementation for an intersection of two given MethodMatchers. */ + @SuppressWarnings("serial") private static class IntersectionMethodMatcher implements IntroductionAwareMethodMatcher, Serializable { private MethodMatcher mm1; @@ -213,19 +220,23 @@ public abstract class MethodMatchers { this.mm2 = mm2; } + @Override public boolean matches(Method method, Class targetClass, boolean hasIntroductions) { return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions); } + @Override public boolean matches(Method method, Class targetClass) { return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass); } + @Override public boolean isRuntime() { return this.mm1.isRuntime() || this.mm2.isRuntime(); } + @Override public boolean matches(Method method, Class targetClass, Object[] args) { // Because a dynamic intersection may be composed of a static and dynamic part, // we must avoid calling the 3-arg matches method on a dynamic matcher, as diff --git a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java index 44a03380ff..26ffedaf5a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.util.PatternMatchUtils; * @since 11.02.2004 * @see #isMatch */ +@SuppressWarnings("serial") public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { private List mappedNames = new LinkedList(); @@ -42,7 +43,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme /** * Convenience method when we have only a single method name to match. - * Use either this method or setMappedNames, not both. + * Use either this method or {@code setMappedNames}, not both. * @see #setMappedNames */ public void setMappedName(String mappedName) { @@ -76,6 +77,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme } + @Override public boolean matches(Method method, Class targetClass) { for (String mappedName : this.mappedNames) { if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcutAdvisor.java index 4cd21ec070..375ecdeac7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.aop.Pointcut; * @author Rob Harrop * @see NameMatchMethodPointcut */ +@SuppressWarnings("serial") public class NameMatchMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor { private final NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); @@ -53,7 +54,7 @@ public class NameMatchMethodPointcutAdvisor extends AbstractGenericPointcutAdvis /** * Convenience method when we have only a single method name to match. - * Use either this method or setMappedNames, not both. + * Use either this method or {@code setMappedNames}, not both. * @see #setMappedNames * @see NameMatchMethodPointcut#setMappedName */ @@ -84,6 +85,7 @@ public class NameMatchMethodPointcutAdvisor extends AbstractGenericPointcutAdvis } + @Override public Pointcut getPointcut() { return this.pointcut; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java index cdeb21e8b9..957f5d319e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java @@ -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"); * you may not use this file except in compliance with the License. @@ -91,10 +91,12 @@ public abstract class Pointcuts { /** * Pointcut implementation that matches bean property setters. */ + @SuppressWarnings("serial") private static class SetterPointcut extends StaticMethodMatcherPointcut implements Serializable { public static SetterPointcut INSTANCE = new SetterPointcut(); + @Override public boolean matches(Method method, Class targetClass) { return method.getName().startsWith("set") && method.getParameterTypes().length == 1 && @@ -110,10 +112,12 @@ public abstract class Pointcuts { /** * Pointcut implementation that matches bean property getters. */ + @SuppressWarnings("serial") private static class GetterPointcut extends StaticMethodMatcherPointcut implements Serializable { public static GetterPointcut INSTANCE = new GetterPointcut(); + @Override public boolean matches(Method method, Class targetClass) { return method.getName().startsWith("get") && method.getParameterTypes().length == 0; diff --git a/spring-aop/src/main/java/org/springframework/aop/support/RegexpMethodPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/RegexpMethodPointcutAdvisor.java index a610e37f71..177fe9b277 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/RegexpMethodPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/RegexpMethodPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.util.ObjectUtils; * @see #setPatterns * @see JdkRegexpMethodPointcut */ +@SuppressWarnings("serial") public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor { private String[] patterns; @@ -115,6 +116,7 @@ public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor /** * Initialize the singleton Pointcut held within this Advisor. */ + @Override public Pointcut getPointcut() { synchronized (this.pointcutMonitor) { if (this.pointcut == null) { @@ -128,7 +130,7 @@ public class RegexpMethodPointcutAdvisor extends AbstractGenericPointcutAdvisor /** * Create the actual pointcut: By default, a {@link JdkRegexpMethodPointcut} * will be used. - * @return the Pointcut instance (never null) + * @return the Pointcut instance (never {@code null}) */ protected AbstractRegexpMethodPointcut createPointcut() { return new JdkRegexpMethodPointcut(); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java index 193de1d969..c232b2826b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/RootClassFilter.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,16 +24,18 @@ import org.springframework.aop.ClassFilter; * Simple ClassFilter implementation that passes classes (and optionally subclasses) * @author Rod Johnson */ +@SuppressWarnings("serial") public class RootClassFilter implements ClassFilter, Serializable { - + private Class clazz; - + // TODO inheritance - + public RootClassFilter(Class clazz) { this.clazz = clazz; } + @Override public boolean matches(Class candidate) { return clazz.isAssignableFrom(candidate); } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java index 8023ff8837..8bb1d74d73 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcher.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,14 +22,16 @@ import org.springframework.aop.MethodMatcher; /** * Convenient abstract superclass for static method matchers, which don't care - * about arguments at runtime. + * about arguments at runtime. */ public abstract class StaticMethodMatcher implements MethodMatcher { + @Override public final boolean isRuntime() { return false; } + @Override public final boolean matches(Method method, Class targetClass, Object[] args) { // should never be invoked because isRuntime() returns false throw new UnsupportedOperationException("Illegal MethodMatcher usage"); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcut.java index 7e96730e37..1c2f1106cb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,11 +43,13 @@ public abstract class StaticMethodMatcherPointcut extends StaticMethodMatcher im this.classFilter = classFilter; } + @Override public ClassFilter getClassFilter() { return this.classFilter; } + @Override public final MethodMatcher getMethodMatcher() { return this; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java index 921129c89b..9dbe10dbf4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMat this.order = order; } + @Override public int getOrder() { return this.order; } @@ -71,14 +72,17 @@ public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMat this.advice = advice; } + @Override public Advice getAdvice() { return this.advice; } + @Override public boolean isPerInstance() { return true; } + @Override public Pointcut getPointcut() { return this; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java index 9136c8974e..aacf645c3f 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationClassFilter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ public class AnnotationClassFilter implements ClassFilter { } + @Override public boolean matches(Class clazz) { return (this.checkInherited ? (AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) : diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java index 01181525e8..46c6f69e3e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMatchingPointcut.java @@ -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"); * you may not use this file except in compliance with the License. @@ -64,9 +64,9 @@ public class AnnotationMatchingPointcut implements Pointcut { /** * Create a new AnnotationMatchingPointcut for the given annotation type. * @param classAnnotationType the annotation type to look for at the class level - * (can be null) + * (can be {@code null}) * @param methodAnnotationType the annotation type to look for at the method level - * (can be null) + * (can be {@code null}) */ public AnnotationMatchingPointcut( Class classAnnotationType, Class methodAnnotationType) { @@ -90,10 +90,12 @@ public class AnnotationMatchingPointcut implements Pointcut { } + @Override public ClassFilter getClassFilter() { return this.classFilter; } + @Override public MethodMatcher getMethodMatcher() { return this.methodMatcher; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java index 4f4dd6c391..9b557473ff 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/annotation/AnnotationMethodMatcher.java @@ -47,6 +47,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher { } + @Override public boolean matches(Method method, Class targetClass) { if (method.isAnnotationPresent(this.annotationType)) { return true; diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java index 2980b0bf42..0928b54b89 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractBeanFactoryBasedTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -94,8 +94,8 @@ public abstract class AbstractBeanFactoryBasedTargetSource /** * Specify the target class explicitly, to avoid any kind of access to the * target bean (for example, to avoid initialization of a FactoryBean instance). - *

    Default is to detect the type automatically, through a getType - * call on the BeanFactory (or even a full getBean call as fallback). + *

    Default is to detect the type automatically, through a {@code getType} + * call on the BeanFactory (or even a full {@code getBean} call as fallback). */ public void setTargetClass(Class targetClass) { this.targetClass = targetClass; @@ -103,8 +103,9 @@ public abstract class AbstractBeanFactoryBasedTargetSource /** * Set the owning BeanFactory. We need to save a reference so that we can - * use the getBean method on every invocation. + * use the {@code getBean} method on every invocation. */ + @Override public void setBeanFactory(BeanFactory beanFactory) { if (this.targetBeanName == null) { throw new IllegalStateException("Property'targetBeanName' is required"); @@ -120,6 +121,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource } + @Override public synchronized Class getTargetClass() { if (this.targetClass == null && this.beanFactory != null) { // Determine type of the target bean. @@ -137,10 +139,12 @@ public abstract class AbstractBeanFactoryBasedTargetSource return this.targetClass; } + @Override public boolean isStatic() { return false; } + @Override public void releaseTarget(Object target) throws Exception { // Nothing to do here. } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java index 3119e847f1..97f3ae8732 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractLazyCreationTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.aop.TargetSource; * lazily create a user-managed object. * *

    Creation of the lazy target object is controlled by the user by implementing - * the {@link #createObject()} method. This TargetSource will invoke + * the {@link #createObject()} method. This {@code TargetSource} will invoke * this method the first time the proxy is accessed. * *

    Useful when you need to pass a reference to some dependency to an object @@ -57,17 +57,19 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource { } /** - * This default implementation returns null if the - * target is null (it is hasn't yet been initialized), + * This default implementation returns {@code null} if the + * target is {@code null} (it is hasn't yet been initialized), * or the target class if the target has already been initialized. *

    Subclasses may wish to override this method in order to provide - * a meaningful value when the target is still null. + * a meaningful value when the target is still {@code null}. * @see #isInitialized() */ + @Override public synchronized Class getTargetClass() { return (this.lazyTarget != null ? this.lazyTarget.getClass() : null); } + @Override public boolean isStatic() { return false; } @@ -77,6 +79,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource { * creating it on-the-fly if it doesn't exist already. * @see #createObject() */ + @Override public synchronized Object getTarget() throws Exception { if (this.lazyTarget == null) { logger.debug("Initializing lazy target object"); @@ -85,6 +88,7 @@ public abstract class AbstractLazyCreationTargetSource implements TargetSource { return this.lazyTarget; } + @Override public void releaseTarget(Object target) throws Exception { // nothing to do } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPoolingTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPoolingTargetSource.java index 8111f2e4c4..c0bef77145 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPoolingTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPoolingTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -68,6 +68,7 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased /** * Return the maximum size of the pool. */ + @Override public int getMaxSize() { return this.maxSize; } @@ -90,19 +91,20 @@ public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBased * @throws Exception to avoid placing constraints on pooling APIs */ protected abstract void createPool() throws Exception; - + /** * Acquire an object from the pool. * @return an object from the pool * @throws Exception we may need to deal with checked exceptions from pool * APIs, so we're forgiving with our exception signature */ + @Override public abstract Object getTarget() throws Exception; - + /** * Return the given object to the pool. * @param target object that must have been acquired from the pool - * via a call to getTarget() + * via a call to {@code getTarget()} * @throws Exception to allow pooling APIs to throw exception * @see #getTarget */ diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java index f2677afbc2..4880d5119b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java @@ -33,7 +33,7 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; * new-instance-per-invocation strategy. * *

    Such TargetSources must run in a {@link BeanFactory}, as it needs to - * call the getBean method to create a new prototype instance. + * call the {@code getBean} method to create a new prototype instance. * Therefore, this base class extends {@link AbstractBeanFactoryBasedTargetSource}. * * @author Rod Johnson @@ -102,7 +102,7 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac /** * Replaces this object with a SingletonTargetSource on serialization. * Protected as otherwise it won't be invoked for subclasses. - * (The writeReplace() method must be visible to the class + * (The {@code writeReplace()} method must be visible to the class * being serialized.) *

    With this implementation of this method, there is no need to mark * non-serializable fields in this class or subclasses as transient. diff --git a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java index 887e253a08..08f16258a1 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPoolTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,21 +27,21 @@ import org.springframework.core.Constants; * TargetSource implementation that holds objects in a configurable * Jakarta Commons Pool. * - *

    By default, an instance of GenericObjectPool is created. - * Subclasses may change the type of ObjectPool used by - * overriding the createObjectPool() method. + *

    By default, an instance of {@code GenericObjectPool} is created. + * Subclasses may change the type of {@code ObjectPool} used by + * overriding the {@code createObjectPool()} method. * *

    Provides many configuration properties mirroring those of the Commons Pool - * GenericObjectPool class; these properties are passed to the - * GenericObjectPool during construction. If creating a subclass of this - * class to change the ObjectPool implementation type, pass in the values + * {@code GenericObjectPool} class; these properties are passed to the + * {@code GenericObjectPool} during construction. If creating a subclass of this + * class to change the {@code ObjectPool} implementation type, pass in the values * of configuration properties that are relevant to your chosen implementation. * - *

    The testOnBorrow, testOnReturn and testWhileIdle + *

    The {@code testOnBorrow}, {@code testOnReturn} and {@code testWhileIdle} * properties are explictly not mirrored because the implementation of - * PoolableObjectFactory used by this class does not implement + * {@code PoolableObjectFactory} used by this class does not implement * meaningful validation. All exposed Commons Pool properties use the corresponding - * Commons Pool defaults: for example, + * Commons Pool defaults: for example, * * @author Rod Johnson * @author Rob Harrop @@ -58,6 +58,8 @@ import org.springframework.core.Constants; public class CommonsPoolTargetSource extends AbstractPoolingTargetSource implements PoolableObjectFactory { + private static final long serialVersionUID = 1L; + private static final Constants constants = new Constants(GenericObjectPool.class); @@ -74,7 +76,7 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource private byte whenExhaustedAction = GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION; /** - * The Jakarta Commons ObjectPool used to pool target objects + * The Jakarta Commons {@code ObjectPool} used to pool target objects */ private ObjectPool pool; @@ -217,7 +219,7 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource * Subclasses can override this if they want to return a specific Commons pool. * They should apply any configuration properties to the pool here. *

    Default is a GenericObjectPool instance with the given pool size. - * @return an empty Commons ObjectPool. + * @return an empty Commons {@code ObjectPool}. * @see org.apache.commons.pool.impl.GenericObjectPool * @see #setMaxSize */ @@ -235,7 +237,7 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource /** - * Borrow an object from the ObjectPool. + * Borrow an object from the {@code ObjectPool}. */ @Override public Object getTarget() throws Exception { @@ -243,25 +245,28 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource } /** - * Returns the specified object to the underlying ObjectPool. + * Returns the specified object to the underlying {@code ObjectPool}. */ @Override public void releaseTarget(Object target) throws Exception { this.pool.returnObject(target); } + @Override public int getActiveCount() throws UnsupportedOperationException { return this.pool.getNumActive(); } + @Override public int getIdleCount() throws UnsupportedOperationException { return this.pool.getNumIdle(); } /** - * Closes the underlying ObjectPool when destroying this object. + * Closes the underlying {@code ObjectPool} when destroying this object. */ + @Override public void destroy() throws Exception { logger.debug("Closing Commons ObjectPool"); this.pool.close(); @@ -272,21 +277,26 @@ public class CommonsPoolTargetSource extends AbstractPoolingTargetSource // Implementation of org.apache.commons.pool.PoolableObjectFactory interface //---------------------------------------------------------------------------- + @Override public Object makeObject() throws BeansException { return newPrototypeInstance(); } + @Override public void destroyObject(Object obj) throws Exception { destroyPrototypeInstance(obj); } + @Override public boolean validateObject(Object obj) { return true; } + @Override public void activateObject(Object obj) { } + @Override public void passivateObject(Object obj) { } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java index d67b03f0f3..826917a561 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/EmptyTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.aop.TargetSource; import org.springframework.util.ObjectUtils; /** - * Canonical TargetSource when there is no target + * Canonical {@code TargetSource} when there is no target * (or just the target class known), and behavior is supplied * by interfaces and advisors only. * @@ -47,7 +47,7 @@ public class EmptyTargetSource implements TargetSource, Serializable { /** * Return an EmptyTargetSource for the given target Class. - * @param targetClass the target Class (may be null) + * @param targetClass the target Class (may be {@code null}) * @see #getTargetClass() */ public static EmptyTargetSource forClass(Class targetClass) { @@ -56,7 +56,7 @@ public class EmptyTargetSource implements TargetSource, Serializable { /** * Return an EmptyTargetSource for the given target Class. - * @param targetClass the target Class (may be null) + * @param targetClass the target Class (may be {@code null}) * @param isStatic whether the TargetSource should be marked as static * @see #getTargetClass() */ @@ -76,9 +76,9 @@ public class EmptyTargetSource implements TargetSource, Serializable { /** * Create a new instance of the {@link EmptyTargetSource} class. - *

    This constructor is private to enforce the + *

    This constructor is {@code private} to enforce the * Singleton pattern / factory method pattern. - * @param targetClass the target class to expose (may be null) + * @param targetClass the target class to expose (may be {@code null}) * @param isStatic whether the TargetSource is marked as static */ private EmptyTargetSource(Class targetClass, boolean isStatic) { @@ -87,22 +87,25 @@ public class EmptyTargetSource implements TargetSource, Serializable { } /** - * Always returns the specified target Class, or null if none. + * Always returns the specified target Class, or {@code null} if none. */ + @Override public Class getTargetClass() { return this.targetClass; } /** - * Always returns true. + * Always returns {@code true}. */ + @Override public boolean isStatic() { return this.isStatic; } /** - * Always returns null. + * Always returns {@code null}. */ + @Override public Object getTarget() { return null; } @@ -110,6 +113,7 @@ public class EmptyTargetSource implements TargetSource, Serializable { /** * Nothing to release. */ + @Override public void releaseTarget(Object target) { } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java index 14c32af6e2..9f7e5fc263 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/HotSwappableTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,18 +59,22 @@ public class HotSwappableTargetSource implements TargetSource, Serializable { * Return the type of the current target object. *

    The returned type should usually be constant across all target objects. */ + @Override public synchronized Class getTargetClass() { return this.target.getClass(); } + @Override public final boolean isStatic() { return false; } + @Override public synchronized Object getTarget() { return this.target; } + @Override public void releaseTarget(Object target) { // nothing to do } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java index 2786e16fba..bad59acf1b 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/LazyInitTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ import org.springframework.beans.BeansException; * the actual target object should not be initialized until first use. * When the target bean is defined in an * {@link org.springframework.context.ApplicationContext} (or a - * BeanFactory that is eagerly pre-instantiating singleton beans) + * {@code BeanFactory} that is eagerly pre-instantiating singleton beans) * it must be marked as "lazy-init" too, else it will be instantiated by said - * ApplicationContext (or BeanFactory) on startup. + * {@code ApplicationContext} (or {@code BeanFactory}) on startup. *

    For example: * *

    @@ -56,11 +56,13 @@ import org.springframework.beans.BeansException;
      * @see org.springframework.beans.factory.BeanFactory#getBean
      * @see #postProcessTargetObject
      */
    +@SuppressWarnings("serial")
     public class LazyInitTargetSource extends AbstractBeanFactoryBasedTargetSource {
     
     	private Object target;
     
     
    +	@Override
     	public synchronized Object getTarget() throws BeansException {
     		if (this.target == null) {
     			this.target = getBeanFactory().getBean(getTargetBeanName());
    diff --git a/spring-aop/src/main/java/org/springframework/aop/target/PoolingConfig.java b/spring-aop/src/main/java/org/springframework/aop/target/PoolingConfig.java
    index 4327a2747a..c671f024f5 100644
    --- a/spring-aop/src/main/java/org/springframework/aop/target/PoolingConfig.java
    +++ b/spring-aop/src/main/java/org/springframework/aop/target/PoolingConfig.java
    @@ -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");
      * you may not use this file except in compliance with the License.
      * You may obtain a copy of the License at
    - * 
    + *
      *      http://www.apache.org/licenses/LICENSE-2.0
    - * 
    + *
      * Unless required by applicable law or agreed to in writing, software
      * distributed under the License is distributed on an "AS IS" BASIS,
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    diff --git a/spring-aop/src/main/java/org/springframework/aop/target/PrototypeTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/PrototypeTargetSource.java
    index 14f2f28501..a404a93234 100644
    --- a/spring-aop/src/main/java/org/springframework/aop/target/PrototypeTargetSource.java
    +++ b/spring-aop/src/main/java/org/springframework/aop/target/PrototypeTargetSource.java
    @@ -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");
      * you may not use this file except in compliance with the License.
    @@ -31,10 +31,13 @@ import org.springframework.beans.BeansException;
      */
     public class PrototypeTargetSource extends AbstractPrototypeBasedTargetSource {
     
    +	private static final long serialVersionUID = 1L;
    +
     	/**
     	 * Obtain a new prototype instance for every call.
     	 * @see #newPrototypeInstance()
     	 */
    +	@Override
     	public Object getTarget() throws BeansException {
     		return newPrototypeInstance();
     	}
    diff --git a/spring-aop/src/main/java/org/springframework/aop/target/SimpleBeanTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/SimpleBeanTargetSource.java
    index 656a88088d..805f1a0562 100644
    --- a/spring-aop/src/main/java/org/springframework/aop/target/SimpleBeanTargetSource.java
    +++ b/spring-aop/src/main/java/org/springframework/aop/target/SimpleBeanTargetSource.java
    @@ -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");
      * you may not use this file except in compliance with the License.
    @@ -27,8 +27,10 @@ package org.springframework.aop.target;
      * @author Juergen Hoeller
      * @since 2.0.3
      */
    +@SuppressWarnings("serial")
     public class SimpleBeanTargetSource extends AbstractBeanFactoryBasedTargetSource {
     
    +	@Override
     	public Object getTarget() throws Exception {
     		return getBeanFactory().getBean(getTargetBeanName());
     	}
    diff --git a/spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java
    index 08ae6534a6..439e59509a 100644
    --- a/spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java
    +++ b/spring-aop/src/main/java/org/springframework/aop/target/SingletonTargetSource.java
    @@ -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");
      * you may not use this file except in compliance with the License.
    @@ -55,18 +55,22 @@ public class SingletonTargetSource implements TargetSource, Serializable {
     	}
     
     
    +	@Override
     	public Class getTargetClass() {
     		return this.target.getClass();
     	}
    -	
    +
    +	@Override
     	public Object getTarget() {
     		return this.target;
     	}
    -	
    +
    +	@Override
     	public void releaseTarget(Object target) {
     		// nothing to do
     	}
     
    +	@Override
     	public boolean isStatic() {
     		return true;
     	}
    diff --git a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java
    index 6048f7b484..af22df411d 100644
    --- a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java
    +++ b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java
    @@ -37,7 +37,7 @@ import org.springframework.core.NamedThreadLocal;
      * for example, if one caller makes repeated calls on the AOP proxy.
      *
      * 

    Cleanup of thread-bound objects is performed on BeanFactory destruction, - * calling their DisposableBean.destroy() method if available. + * calling their {@code DisposableBean.destroy()} method if available. * Be aware that many thread-bound objects can be around until the application * actually shuts down. * @@ -49,7 +49,9 @@ import org.springframework.core.NamedThreadLocal; */ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource implements ThreadLocalTargetSourceStats, DisposableBean { - + + private static final long serialVersionUID = 1L; + /** * ThreadLocal holding the target associated with the current * thread. Unlike most ThreadLocals, which are static, this variable @@ -62,9 +64,9 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource * Set of managed targets, enabling us to keep track of the targets we've created. */ private final Set targetSet = new HashSet(); - + private int invocationCount; - + private int hitCount; @@ -73,13 +75,16 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource * We look for a target held in a ThreadLocal. If we don't find one, * we create one and bind it to the thread. No synchronization is required. */ + @Override public Object getTarget() throws BeansException { ++this.invocationCount; Object target = this.targetInThread.get(); if (target == null) { if (logger.isDebugEnabled()) { - logger.debug("No target for prototype '" + getTargetBeanName() + "' bound to thread: " + - "creating one and binding it to thread '" + Thread.currentThread().getName() + "'"); + logger.debug("No target for prototype '" + getTargetBeanName() + + "' bound to thread: " + + "creating one and binding it to thread '" + + Thread.currentThread().getName() + "'"); } // Associate target with ThreadLocal. target = newPrototypeInstance(); @@ -93,11 +98,12 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource } return target; } - + /** * Dispose of targets if necessary; clear ThreadLocal. * @see #destroyPrototypeInstance */ + @Override public void destroy() { logger.debug("Destroying ThreadLocalTargetSource bindings"); synchronized (this.targetSet) { @@ -111,14 +117,17 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource } + @Override public int getInvocationCount() { return this.invocationCount; } + @Override public int getHitCount() { return this.hitCount; } + @Override public int getObjectCount() { synchronized (this.targetSet) { return this.targetSet.size(); diff --git a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSourceStats.java b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSourceStats.java index 7e3a2fa5cf..f3801a79db 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSourceStats.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSourceStats.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ package org.springframework.aop.target; * @author Juergen Hoeller */ public interface ThreadLocalTargetSourceStats { - + /** * Return the number of client invocations. */ diff --git a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java index befbcf3939..c96c21e193 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/AbstractRefreshableTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -56,13 +56,14 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R * Set the delay between refresh checks, in milliseconds. * Default is -1, indicating no refresh checks at all. *

    Note that an actual refresh will only happen when - * {@link #requiresRefresh()} returns true. + * {@link #requiresRefresh()} returns {@code true}. */ public void setRefreshCheckDelay(long refreshCheckDelay) { this.refreshCheckDelay = refreshCheckDelay; } + @Override public synchronized Class getTargetClass() { if (this.targetObject == null) { refresh(); @@ -73,10 +74,12 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R /** * Not static. */ + @Override public boolean isStatic() { return false; } + @Override public final synchronized Object getTarget() { if ((refreshCheckDelayElapsed() && requiresRefresh()) || this.targetObject == null) { refresh(); @@ -87,10 +90,12 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R /** * No need to release target. */ + @Override public void releaseTarget(Object object) { } + @Override public final synchronized void refresh() { logger.debug("Attempting to refresh target"); @@ -101,10 +106,12 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R logger.debug("Target refreshed successfully"); } + @Override public synchronized long getRefreshCount() { return this.refreshCount; } + @Override public synchronized long getLastRefreshTime() { return this.lastRefreshTime; } @@ -131,7 +138,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R /** * Determine whether a refresh is required. * Invoked for each refresh check, after the refresh check delay has elapsed. - *

    The default implementation always returns true, triggering + *

    The default implementation always returns {@code true}, triggering * a refresh every time the delay has elapsed. To be overridden by subclasses * with an appropriate check of the underlying target resource. * @return whether a refresh is required @@ -143,7 +150,7 @@ public abstract class AbstractRefreshableTargetSource implements TargetSource, R /** * Obtain a fresh target object. *

    Only invoked if a refresh check has found that a refresh is required - * (that is, {@link #requiresRefresh()} has returned true). + * (that is, {@link #requiresRefresh()} has returned {@code true}). * @return the fresh target object */ protected abstract Object freshTarget(); diff --git a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/BeanFactoryRefreshableTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/BeanFactoryRefreshableTargetSource.java index ac39d756c7..f2f894dbec 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/BeanFactoryRefreshableTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/BeanFactoryRefreshableTargetSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.util.Assert; /** * Refreshable TargetSource that fetches fresh target beans from a BeanFactory. * - *

    Can be subclassed to override requiresRefresh() to suppress + *

    Can be subclassed to override {@code requiresRefresh()} to suppress * unnecessary refreshes. By default, a refresh will be performed every time * the "refreshCheckDelay" has elapsed. * diff --git a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/Refreshable.java b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/Refreshable.java index 7d55a0d59a..187544e6d8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/dynamic/Refreshable.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/dynamic/Refreshable.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java index 3bc43af657..5efbb2f893 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public final class AspectJAdviceParameterNameDiscoverAnnotationTests @Retention(RetentionPolicy.RUNTIME) @interface MyAnnotation {} - + public void pjpAndAnAnnotation(ProceedingJoinPoint pjp, MyAnnotation ann) {} @Test diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java index f135239fe0..7662195c0f 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -247,7 +247,7 @@ public class AspectJAdviceParameterNameDiscovererTests { public void testReferenceBindingWithAlternateTokenizations() { assertParameterNames(getMethod("onePrimitive"),"call(bar *) && somepc(foo)",new String[] {"foo"}); assertParameterNames(getMethod("onePrimitive"),"somepc ( foo )",new String[] {"foo"}); - assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"}); + assertParameterNames(getMethod("onePrimitive"),"somepc( foo)",new String[] {"foo"}); } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java index b1678c9d7c..cf96bf3f06 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ import test.beans.subpkg.DeepBean; * @author Chris Beams */ public final class AspectJExpressionPointcutTests { - + public static final String MATCH_ALL_METHODS = "execution(* *(..))"; private Method getAge; @@ -54,8 +54,8 @@ public final class AspectJExpressionPointcutTests { private Method setSomeNumber; private Method isPostProcessed; - - + + @Before public void setUp() throws NoSuchMethodException { getAge = TestBean.class.getMethod("getAge", (Class[])null); @@ -63,7 +63,7 @@ public final class AspectJExpressionPointcutTests { setSomeNumber = TestBean.class.getMethod("setSomeNumber", new Class[]{Number.class}); isPostProcessed = TestBean.class.getMethod("isPostProcessed", (Class[]) null); } - + @Test public void testMatchExplicit() { String expression = "execution(int test.beans.TestBean.getAge())"; @@ -100,60 +100,61 @@ public final class AspectJExpressionPointcutTests { assertTrue("Expression should match setAge(int) method", methodMatcher.matches(setAge, TestBean.class)); } - + @Test public void testThis() throws SecurityException, NoSuchMethodException{ testThisOrTarget("this"); } - + @Test public void testTarget() throws SecurityException, NoSuchMethodException { testThisOrTarget("target"); } - + public static class OtherIOther implements IOther { + @Override public void absquatulate() { // Empty } - + } - + /** * This and target are equivalent. Really instanceof pointcuts. - * @throws Exception * @param which this or target - * @throws NoSuchMethodException - * @throws SecurityException + * @throws Exception + * @throws NoSuchMethodException + * @throws SecurityException */ private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException { String matchesTestBean = which + "(test.beans.TestBean)"; String matchesIOther = which + "(test.beans.IOther)"; AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut(); testBeanPc.setExpression(matchesTestBean); - + AspectJExpressionPointcut iOtherPc = new AspectJExpressionPointcut(); iOtherPc.setExpression(matchesIOther); - + assertTrue(testBeanPc.matches(TestBean.class)); assertTrue(testBeanPc.matches(getAge, TestBean.class)); assertTrue(iOtherPc.matches(OtherIOther.class.getMethod("absquatulate", (Class[])null), OtherIOther.class)); - + assertFalse(testBeanPc.matches(OtherIOther.class.getMethod("absquatulate", (Class[])null), OtherIOther.class)); } - + @Test public void testWithinRootPackage() throws SecurityException, NoSuchMethodException { testWithinPackage(false); } - + @Test public void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException { testWithinPackage(true); } - + private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException { String withinBeansPackage = "within(test.beans."; // Subpackages are matched by ** @@ -163,7 +164,7 @@ public final class AspectJExpressionPointcutTests { withinBeansPackage = withinBeansPackage + "*)"; AspectJExpressionPointcut withinBeansPc = new AspectJExpressionPointcut(); withinBeansPc.setExpression(withinBeansPackage); - + assertTrue(withinBeansPc.matches(TestBean.class)); assertTrue(withinBeansPc.matches(getAge, TestBean.class)); assertEquals(matchSubpackages, withinBeansPc.matches(DeepBean.class)); @@ -173,7 +174,7 @@ public final class AspectJExpressionPointcutTests { assertFalse(withinBeansPc.matches(OtherIOther.class.getMethod("absquatulate", (Class[])null), OtherIOther.class)); } - + @Test public void testFriendlyErrorOnNoLocationClassMatching() { AspectJExpressionPointcut pc = new AspectJExpressionPointcut(); @@ -185,7 +186,7 @@ public final class AspectJExpressionPointcutTests { assertTrue(ex.getMessage().indexOf("expression") != -1); } } - + @Test public void testFriendlyErrorOnNoLocation2ArgMatching() { AspectJExpressionPointcut pc = new AspectJExpressionPointcut(); @@ -197,7 +198,7 @@ public final class AspectJExpressionPointcutTests { assertTrue(ex.getMessage().indexOf("expression") != -1); } } - + @Test public void testFriendlyErrorOnNoLocation3ArgMatching() { AspectJExpressionPointcut pc = new AspectJExpressionPointcut(); @@ -210,7 +211,7 @@ public final class AspectJExpressionPointcutTests { } } - + @Test public void testMatchWithArgs() throws Exception { String expression = "execution(void test.beans.TestBean.setSomeNumber(Number)) && args(Double)"; @@ -329,19 +330,19 @@ public final class AspectJExpressionPointcutTests { @Test public void testAndSubstitution() { Pointcut pc = getPointcut("execution(* *(..)) and args(String)"); - PointcutExpression expr = + PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression(); assertEquals("execution(* *(..)) && args(String)",expr.getPointcutExpression()); } - + @Test public void testMultipleAndSubstitutions() { Pointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)"); - PointcutExpression expr = + PointcutExpression expr = ((AspectJExpressionPointcut) pc).getPointcutExpression(); - assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression()); + assertEquals("execution(* *(..)) && args(String) && this(Object)",expr.getPointcutExpression()); } - + private Pointcut getPointcut(String expression) { AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); pointcut.setExpression(expression); @@ -354,6 +355,7 @@ class CallCountingInterceptor implements MethodInterceptor { private int count; + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { count++; return methodInvocation.proceed(); @@ -367,4 +369,4 @@ class CallCountingInterceptor implements MethodInterceptor { this.count = 0; } -} \ No newline at end of file +} diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java index ce148b7faa..ac6dc31a2a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,8 +34,8 @@ public final class BeanNamePointcutMatchingTests { public void testMatchingPointcuts() { assertMatch("someName", "bean(someName)"); - // Spring bean names are less restrictive compared to AspectJ names (methods, types etc.) - // MVC Controller-kind + // Spring bean names are less restrictive compared to AspectJ names (methods, types etc.) + // MVC Controller-kind assertMatch("someName/someOtherName", "bean(someName/someOtherName)"); assertMatch("someName/foo/someOtherName", "bean(someName/*/someOtherName)"); assertMatch("someName/foo/bar/someOtherName", "bean(someName/*/someOtherName)"); @@ -58,9 +58,9 @@ public final class BeanNamePointcutMatchingTests { // Or, and, not expressions assertMatch("someName", "bean(someName) || bean(someOtherName)"); assertMatch("someOtherName", "bean(someName) || bean(someOtherName)"); - + assertMatch("someName", "!bean(someOtherName)"); - + assertMatch("someName", "bean(someName) || !bean(someOtherName)"); assertMatch("someName", "bean(someName) && !bean(someOtherName)"); } @@ -90,6 +90,7 @@ public final class BeanNamePointcutMatchingTests { private static boolean matches(final String beanName, String pcExpression) { @SuppressWarnings("serial") AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut() { + @Override protected String getCurrentProxiedBeanName() { return beanName; } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index 6de4f5c640..8c84e801b8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -72,31 +72,32 @@ public final class MethodInvocationProceedingJoinPointTests { final Object raw = new TestBean(); // Will be set by advice during a method call final int newAge = 23; - + ProxyFactory pf = new ProxyFactory(raw); pf.setExposeProxy(true); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvice(new MethodBeforeAdvice() { private int depth; - + + @Override public void before(Method method, Object[] args, Object target) throws Throwable { JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); assertTrue("Method named in toString", jp.toString().contains(method.getName())); // Ensure that these don't cause problems jp.toShortString(); jp.toLongString(); - + assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget()); assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget())); - + ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis(); assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis())); - + assertNotSame(target, thisProxy); - + // Check getting again doesn't cause a problem assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis()); - + // Try reentrant call--will go through this advice. // Be sure to increment depth to avoid infinite recursion if (depth++ == 0) { @@ -109,10 +110,10 @@ public final class MethodInvocationProceedingJoinPointTests { assertSame(AopContext.currentProxy(), thisProxy); assertSame(target, raw); - + assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName()); assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers()); - + MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature(); assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature()); assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint()); @@ -135,6 +136,7 @@ public final class MethodInvocationProceedingJoinPointTests { ProxyFactory pf = new ProxyFactory(raw); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvice(new MethodBeforeAdvice() { + @Override public void before(Method method, Object[] args, Object target) throws Throwable { SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(); assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation()); @@ -146,7 +148,7 @@ public final class MethodInvocationProceedingJoinPointTests { catch (UnsupportedOperationException ex) { // Expected } - + try { sloc.getFileName(); fail("Can't get file name"); @@ -167,6 +169,7 @@ public final class MethodInvocationProceedingJoinPointTests { ProxyFactory pf = new ProxyFactory(raw); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvice(new MethodBeforeAdvice() { + @Override public void before(Method method, Object[] args, Object target) throws Throwable { StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart(); assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart()); @@ -186,12 +189,13 @@ public final class MethodInvocationProceedingJoinPointTests { ProxyFactory pf = new ProxyFactory(raw); pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvice(new MethodBeforeAdvice() { + @Override public void before(Method method, Object[] args, Object target) throws Throwable { // makeEncSJP, although meant for computing the enclosing join point, // it serves our purpose here JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method); JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); - + assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString()); assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString()); assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString()); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java index 824f51433b..2b92a5c661 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,37 +38,37 @@ public final class TigerAspectJAdviceParameterNameDiscovererTests public void testAtTarget() { assertParameterNames(getMethod("oneAnnotation"),"@target(a)",new String[]{"a"}); } - + @Test public void testAtArgs() { assertParameterNames(getMethod("oneAnnotation"),"@args(a)",new String[]{"a"}); } - + @Test public void testAtWithin() { assertParameterNames(getMethod("oneAnnotation"),"@within(a)",new String[]{"a"}); } - + @Test public void testAtWithincode() { assertParameterNames(getMethod("oneAnnotation"),"@withincode(a)",new String[]{"a"}); } - + @Test public void testAtAnnotation() { assertParameterNames(getMethod("oneAnnotation"),"@annotation(a)",new String[]{"a"}); } - + @Test public void testAmbiguousAnnotationTwoVars() { assertException(getMethod("twoAnnotations"),"@annotation(a) && @this(x)",AmbiguousBindingException.class, "Found 2 potential annotation variable(s), and 2 potential argument slots"); } - + @Test public void testAmbiguousAnnotationOneVar() { assertException(getMethod("oneAnnotation"),"@annotation(a) && @this(x)",IllegalArgumentException.class, - "Found 2 candidate annotation binding variables but only one potential argument binding slot"); + "Found 2 candidate annotation binding variables but only one potential argument binding slot"); } @Test diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index 9877171a60..b8c336b0fb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import test.annotation.transaction.Tx; import test.beans.TestBean; -/** +/** * Java5-specific {@link AspectJExpressionPointcutTests}. * * @author Rod Johnson @@ -54,10 +54,10 @@ public final class TigerAspectJExpressionPointcutTests { methodsOnHasGeneric.put(m.getName(), m); } } - + public static class HasGeneric { - + public void setFriends(List friends) { } public void setEnemies(List enemies) { @@ -73,41 +73,41 @@ public final class TigerAspectJExpressionPointcutTests { String expression = "execution(* set*(java.util.List) )"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(expression); - + // TODO this will currently map, would be nice for optimization //assertTrue(ajexp.matches(HasGeneric.class)); //assertFalse(ajexp.matches(TestBean.class)); - + Method takesGenericList = methodsOnHasGeneric.get("setFriends"); assertTrue(ajexp.matches(takesGenericList, HasGeneric.class)); assertTrue(ajexp.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class)); assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPartners"), HasGeneric.class)); assertFalse(ajexp.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class)); - + assertFalse(ajexp.matches(getAge, TestBean.class)); } - + @Test public void testMatchVarargs() throws SecurityException, NoSuchMethodException { class MyTemplate { - public int queryForInt(String sql, Object... params) { - return 0; - } + public int queryForInt(String sql, Object... params) { + return 0; + } } - + String expression = "execution(int *.*(String, Object...))"; AspectJExpressionPointcut jdbcVarArgs = new AspectJExpressionPointcut(); jdbcVarArgs.setExpression(expression); - + // TODO: the expression above no longer matches Object[] // assertFalse(jdbcVarArgs.matches( - // JdbcTemplate.class.getMethod("queryForInt", String.class, Object[].class), - // JdbcTemplate.class)); - + // JdbcTemplate.class.getMethod("queryForInt", String.class, Object[].class), + // JdbcTemplate.class)); + assertTrue(jdbcVarArgs.matches( MyTemplate.class.getMethod("queryForInt", String.class, Object[].class), MyTemplate.class)); - + Method takesGenericList = methodsOnHasGeneric.get("setFriends"); assertFalse(jdbcVarArgs.matches(takesGenericList, HasGeneric.class)); assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setEnemies"), HasGeneric.class)); @@ -115,44 +115,44 @@ public final class TigerAspectJExpressionPointcutTests { assertFalse(jdbcVarArgs.matches(methodsOnHasGeneric.get("setPhoneNumbers"), HasGeneric.class)); assertFalse(jdbcVarArgs.matches(getAge, TestBean.class)); } - + @Test public void testMatchAnnotationOnClassWithAtWithin() throws SecurityException, NoSuchMethodException { String expression = "@within(test.annotation.transaction.Tx)"; testMatchAnnotationOnClass(expression); } - + @Test public void testMatchAnnotationOnClassWithoutBinding() throws SecurityException, NoSuchMethodException { String expression = "within(@test.annotation.transaction.Tx *)"; testMatchAnnotationOnClass(expression); } - + @Test public void testMatchAnnotationOnClassWithSubpackageWildcard() throws SecurityException, NoSuchMethodException { String expression = "within(@(test.annotation..*) *)"; AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression); - assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), + assertFalse(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class)); - assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), + assertTrue(springAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), SpringAnnotated.class)); - + expression = "within(@(test.annotation.transaction..*) *)"; AspectJExpressionPointcut springTxAnnotatedPc = testMatchAnnotationOnClass(expression); - assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), + assertFalse(springTxAnnotatedPc.matches(SpringAnnotated.class.getMethod("foo", (Class[]) null), SpringAnnotated.class)); } - + @Test public void testMatchAnnotationOnClassWithExactPackageWildcard() throws SecurityException, NoSuchMethodException { String expression = "within(@(test.annotation.transaction.*) *)"; testMatchAnnotationOnClass(expression); } - + private AspectJExpressionPointcut testMatchAnnotationOnClass(String expression) throws SecurityException, NoSuchMethodException { AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(expression); - + assertFalse(ajexp.matches(getAge, TestBean.class)); assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class)); assertTrue(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class)); @@ -160,13 +160,13 @@ public final class TigerAspectJExpressionPointcutTests { assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); return ajexp; } - + @Test public void testAnnotationOnMethodWithFQN() throws SecurityException, NoSuchMethodException { String expression = "@annotation(test.annotation.transaction.Tx)"; AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(expression); - + assertFalse(ajexp.matches(getAge, TestBean.class)); assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class)); assertFalse(ajexp.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class)); @@ -174,13 +174,13 @@ public final class TigerAspectJExpressionPointcutTests { assertTrue(ajexp.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class)); assertFalse(ajexp.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); } - + @Test public void testAnnotationOnMethodWithWildcard() throws SecurityException, NoSuchMethodException { String expression = "execution(@(test.annotation..*) * *(..))"; AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut(); anySpringMethodAnnotation.setExpression(expression); - + assertFalse(anySpringMethodAnnotation.matches(getAge, TestBean.class)); assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class)); assertFalse(anySpringMethodAnnotation.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class)); @@ -194,43 +194,43 @@ public final class TigerAspectJExpressionPointcutTests { String expression = "@args(*, test.annotation.EmptySpringAnnotation))"; AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut(); takesSpringAnnotatedArgument2.setExpression(expression); - + assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class)); assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class)); assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); - + assertTrue(takesSpringAnnotatedArgument2.matches( ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class), ProcessesSpringAnnotatedParameters.class)); - + // True because it maybeMatches with potential argument subtypes assertTrue(takesSpringAnnotatedArgument2.matches( ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class), ProcessesSpringAnnotatedParameters.class)); - + assertFalse(takesSpringAnnotatedArgument2.matches( ProcessesSpringAnnotatedParameters.class.getMethod("takesNoAnnotatedParameters", TestBean.class, BeanA.class), ProcessesSpringAnnotatedParameters.class, new Object[] { new TestBean(), new BeanA()}) ); } - + @Test public void testAnnotationOnMethodArgumentsWithWildcards() throws SecurityException, NoSuchMethodException { String expression = "execution(* *(*, @(test..*) *))"; AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut(); takesSpringAnnotatedArgument2.setExpression(expression); - + assertFalse(takesSpringAnnotatedArgument2.matches(getAge, TestBean.class)); assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("foo", (Class[]) null), HasTransactionalAnnotation.class)); assertFalse(takesSpringAnnotatedArgument2.matches(HasTransactionalAnnotation.class.getMethod("bar", String.class), HasTransactionalAnnotation.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("getAge", (Class[]) null), BeanA.class)); assertFalse(takesSpringAnnotatedArgument2.matches(BeanA.class.getMethod("setName", String.class), BeanA.class)); - + assertTrue(takesSpringAnnotatedArgument2.matches( ProcessesSpringAnnotatedParameters.class.getMethod("takesAnnotatedParameters", TestBean.class, SpringAnnotated.class), ProcessesSpringAnnotatedParameters.class)); @@ -267,7 +267,7 @@ public final class TigerAspectJExpressionPointcutTests { } } - + static class BeanA { private String name; @@ -283,7 +283,7 @@ public final class TigerAspectJExpressionPointcutTests { } } - + @Tx static class BeanB { private String name; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java index 227c1553c3..088ba138c3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java @@ -67,7 +67,7 @@ public class TrickyAspectJPointcutExpressionTests { // Test with default class loader first... testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl"); - + // Then try again with a different class loader on the target... SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader()); // Make sure the interface is loaded from the parent class loader @@ -102,7 +102,7 @@ public class TrickyAspectJPointcutExpressionTests { } assertEquals(1, logAdvice.getCountThrows()); } - + public static class SimpleThrowawayClassLoader extends OverridingClassLoader { /** @@ -114,7 +114,8 @@ public class TrickyAspectJPointcutExpressionTests { } } - + + @SuppressWarnings("serial") public static class TestException extends RuntimeException { public TestException(String string) { @@ -129,32 +130,34 @@ public class TrickyAspectJPointcutExpressionTests { @Inherited public static @interface Log { } - + public static interface TestService { - public String sayHello(); + public String sayHello(); } - + @Log - public static class TestServiceImpl implements TestService{ - public String sayHello() { - throw new TestException("TestServiceImpl"); - } + public static class TestServiceImpl implements TestService { + @Override + public String sayHello() { + throw new TestException("TestServiceImpl"); + } } public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice { - + private int countBefore = 0; - + private int countThrows = 0; - + + @Override public void before(Method method, Object[] objects, Object o) throws Throwable { countBefore++; - } + } public void afterThrowing(Exception e) throws Throwable { countThrows++; - throw e; - } + throw e; + } public int getCountBefore() { return countBefore; @@ -163,12 +166,12 @@ public class TrickyAspectJPointcutExpressionTests { public int getCountThrows() { return countThrows; } - + public void reset() { countThrows = 0; countBefore = 0; } } - + } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java index c3708d6b86..fea874179e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public final class TypePatternClassFilterTests { assertFalse("Must be excluded: not subclass", tpcf.matches(IOther.class)); assertFalse("Must be excluded: not subclass", tpcf.matches(DefaultListableBeanFactory.class)); } - + @Test public void testAndOrNotReplacement() { TypePatternClassFilter tpcf = new TypePatternClassFilter("java.lang.Object or java.lang.String"); @@ -75,12 +75,12 @@ public final class TypePatternClassFilterTests { assertFalse("matches Double",tpcf.matches(Double.class)); tpcf = new TypePatternClassFilter("java.lang.Number+ and not java.lang.Float"); assertFalse("matches Float",tpcf.matches(Float.class)); - assertTrue("matches Double",tpcf.matches(Double.class)); + assertTrue("matches Double",tpcf.matches(Double.class)); } @Test(expected=IllegalArgumentException.class) public void testSetTypePatternWithNullArgument() throws Exception { - new TypePatternClassFilter(null); + new TypePatternClassFilter(null); } @Test(expected=IllegalStateException.class) diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index 1c366a7042..ae3ac04918 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -76,7 +76,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { * @return the fixture */ protected abstract AspectJAdvisorFactory getFixture(); - + @Test public void testRejectsPerCflowAspect() { @@ -88,7 +88,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { assertTrue(ex.getMessage().indexOf("PERCFLOW") != -1); } } - + @Test public void testRejectsPerCflowBelowAspect() { try { @@ -105,11 +105,11 @@ public abstract class AbstractAspectJAdvisorFactoryTests { TestBean target = new TestBean(); int realAge = 65; target.setAge(realAge); - TestBean itb = (TestBean) createProxy(target, + TestBean itb = (TestBean) createProxy(target, getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(), "someBean")), TestBean.class); assertEquals("Around advice must NOT apply", realAge, itb.getAge()); - + Advised advised = (Advised) itb; SyntheticInstantiationAdvisor sia = (SyntheticInstantiationAdvisor) advised.getAdvisors()[1]; assertTrue(sia.getPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null)); @@ -121,10 +121,10 @@ public abstract class AbstractAspectJAdvisorFactoryTests { // Check that the perclause pointcut is valid assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null)); assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut()); - + // Hit the method in the per clause to instantiate the aspect itb.getSpouse(); - + assertTrue(maaif.isMaterialized()); assertEquals("Around advice must apply", 0, itb.getAge()); @@ -190,11 +190,11 @@ public abstract class AbstractAspectJAdvisorFactoryTests { TestBean target = new TestBean(); int realAge = 65; target.setAge(realAge); - TestBean itb = (TestBean) createProxy(target, + TestBean itb = (TestBean) createProxy(target, getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new PerThisAspect(), "someBean")), TestBean.class); assertEquals("Around advice must NOT apply", realAge, itb.getAge()); - + Advised advised = (Advised) itb; // Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors assertEquals(4, advised.getAdvisors().length); @@ -208,30 +208,30 @@ public abstract class AbstractAspectJAdvisorFactoryTests { // Check that the perclause pointcut is valid assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null)); assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut()); - + // Hit the method in the per clause to instantiate the aspect itb.getSpouse(); - + assertTrue(maaif.isMaterialized()); assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null)); - + assertEquals("Around advice must apply", 0, itb.getAge()); assertEquals("Around advice must apply", 1, itb.getAge()); } - + @Test public void testPerTypeWithinAspect() throws SecurityException, NoSuchMethodException { TestBean target = new TestBean(); int realAge = 65; target.setAge(realAge); PerTypeWithinAspectInstanceFactory aif = new PerTypeWithinAspectInstanceFactory(); - TestBean itb = (TestBean) createProxy(target, - getFixture().getAdvisors(aif), + TestBean itb = (TestBean) createProxy(target, + getFixture().getAdvisors(aif), TestBean.class); assertEquals("No method calls", 0, aif.getInstantiationCount()); assertEquals("Around advice must now apply", 0, itb.getAge()); - + Advised advised = (Advised) itb; // Will be ExposeInvocationInterceptor, synthetic instantiation advisor, 2 method advisors assertEquals(4, advised.getAdvisors().length); @@ -245,19 +245,19 @@ public abstract class AbstractAspectJAdvisorFactoryTests { // Check that the perclause pointcut is valid assertTrue(maaif.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null)); assertNotSame(imapa.getDeclaredPointcut(), imapa.getPointcut()); - + // Hit the method in the per clause to instantiate the aspect itb.getSpouse(); - + assertTrue(maaif.isMaterialized()); assertTrue(imapa.getDeclaredPointcut().getMethodMatcher().matches(TestBean.class.getMethod("getAge"), null)); - + assertEquals("Around advice must still apply", 1, itb.getAge()); assertEquals("Around advice must still apply", 2, itb.getAge()); - - TestBean itb2 = (TestBean) createProxy(target, - getFixture().getAdvisors(aif), + + TestBean itb2 = (TestBean) createProxy(target, + getFixture().getAdvisors(aif), TestBean.class); assertEquals(1, aif.getInstantiationCount()); assertEquals("Around advice be independent for second instance", 0, itb2.getAge()); @@ -282,20 +282,20 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @Test public void testNamedPointcutFromAspectLibraryWithBinding() { TestBean target = new TestBean(); - ITestBean itb = (ITestBean) createProxy(target, - getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new NamedPointcutAspectFromLibraryWithBinding(),"someBean")), + ITestBean itb = (ITestBean) createProxy(target, + getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new NamedPointcutAspectFromLibraryWithBinding(),"someBean")), ITestBean.class); itb.setAge(10); assertEquals("Around advice must apply", 20, itb.getAge()); assertEquals(20,target.getAge()); } - + private void testNamedPointcuts(Object aspectInstance) { TestBean target = new TestBean(); int realAge = 65; target.setAge(realAge); - ITestBean itb = (ITestBean) createProxy(target, - getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspectInstance,"someBean")), + ITestBean itb = (ITestBean) createProxy(target, + getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspectInstance,"someBean")), ITestBean.class); assertEquals("Around advice must apply", -1, itb.getAge()); assertEquals(realAge, target.getAge()); @@ -304,8 +304,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @Test public void testBindingWithSingleArg() { TestBean target = new TestBean(); - ITestBean itb = (ITestBean) createProxy(target, - getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new BindingAspectWithSingleArg(),"someBean")), + ITestBean itb = (ITestBean) createProxy(target, + getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new BindingAspectWithSingleArg(),"someBean")), ITestBean.class); itb.setAge(10); assertEquals("Around advice must apply", 20, itb.getAge()); @@ -315,10 +315,10 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @Test public void testBindingWithMultipleArgsDifferentlyOrdered() { ManyValuedArgs target = new ManyValuedArgs(); - ManyValuedArgs mva = (ManyValuedArgs) createProxy(target, - getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ManyValuedArgs(),"someBean")), + ManyValuedArgs mva = (ManyValuedArgs) createProxy(target, + getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ManyValuedArgs(),"someBean")), ManyValuedArgs.class); - + String a = "a"; int b = 12; int c = 25; @@ -327,7 +327,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { String expectedResult = a + b+ c + d + e; assertEquals(expectedResult, mva.mungeArgs(a, b, c, d, e)); } - + /** * In this case the introduction will be made. */ @@ -344,7 +344,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { assertFalse(lockable.locked()); lockable.lock(); assertTrue(lockable.locked()); - + NotLockable notLockable2Target = new NotLockable(); NotLockable notLockable2 = (NotLockable) createProxy(notLockable2Target, getFixture().getAdvisors( @@ -363,17 +363,17 @@ public abstract class AbstractAspectJAdvisorFactoryTests { } assertTrue(lockable2.locked()); } - + @Test public void testIntroductionAdvisorExcludedFromTargetImplementingInterface() { assertTrue(AopUtils.findAdvisorsThatCanApply( getFixture().getAdvisors( new SingletonMetadataAwareAspectInstanceFactory( - new MakeLockable(),"someBean")), + new MakeLockable(),"someBean")), CannotBeUnlocked.class).isEmpty()); assertEquals(2, AopUtils.findAdvisorsThatCanApply(getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")), NotLockable.class).size()); } - + @Test public void testIntroductionOnTargetImplementingInterface() { CannotBeUnlocked target = new CannotBeUnlocked(); @@ -386,7 +386,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { ), CannotBeUnlocked.class); assertTrue(proxy instanceof Lockable); - Lockable lockable = (Lockable) proxy; + Lockable lockable = proxy; assertTrue("Already locked", lockable.locked()); lockable.lock(); assertTrue("Real target ignores locking", lockable.locked()); @@ -398,7 +398,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { // Ok } } - + @SuppressWarnings("unchecked") @Test public void testIntroductionOnTargetExcludedByTypePattern() { @@ -411,11 +411,12 @@ public abstract class AbstractAspectJAdvisorFactoryTests { CannotBeUnlocked.class); assertFalse("Type pattern must have excluded mixin", proxy instanceof Lockable); } + /* prereq AspectJ 1.6.7 @Test public void testIntroductionBasedOnAnnotationMatch_Spr5307() { AnnotatedTarget target = new AnnotatedTargetImpl(); - + List advisors = getFixture().getAdvisors( new SingletonMetadataAwareAspectInstanceFactory(new MakeAnnotatedTypeModifiable(),"someBean")); Object proxy = createProxy(target, @@ -426,23 +427,25 @@ public abstract class AbstractAspectJAdvisorFactoryTests { Lockable lockable = (Lockable)proxy; lockable.locked(); } - */ + */ + // TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed... + public void XtestIntroductionWithArgumentBinding() { TestBean target = new TestBean(); - + List advisors = getFixture().getAdvisors( new SingletonMetadataAwareAspectInstanceFactory(new MakeITestBeanModifiable(),"someBean")); advisors.addAll(getFixture().getAdvisors( new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean"))); - + Modifiable modifiable = (Modifiable) createProxy(target, advisors, ITestBean.class); assertTrue(modifiable instanceof Modifiable); Lockable lockable = (Lockable) modifiable; assertFalse(lockable.locked()); - + ITestBean itb = (ITestBean) modifiable; assertFalse(modifiable.isModified()); int oldAge = itb.getAge(); @@ -454,7 +457,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { assertFalse("Setting same value does not modify", modifiable.isModified()); itb.setName("And now for something completely different"); assertTrue(modifiable.isModified()); - + lockable.lock(); assertTrue(lockable.locked()); try { @@ -474,8 +477,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { UnsupportedOperationException expectedException = new UnsupportedOperationException(); List advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean")); assertEquals("One advice method was found", 1, advisors.size()); - ITestBean itb = (ITestBean) createProxy(target, - advisors, + ITestBean itb = (ITestBean) createProxy(target, + advisors, ITestBean.class); try { itb.getAge(); @@ -485,7 +488,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { assertSame(expectedException, ex); } } - + // TODO document this behaviour. // Is it different AspectJ behaviour, at least for checked exceptions? @Test @@ -494,8 +497,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { RemoteException expectedException = new RemoteException(); List advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new ExceptionAspect(expectedException),"someBean")); assertEquals("One advice method was found", 1, advisors.size()); - ITestBean itb = (ITestBean) createProxy(target, - advisors, + ITestBean itb = (ITestBean) createProxy(target, + advisors, ITestBean.class); try { itb.getAge(); @@ -505,7 +508,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { assertSame(expectedException, ex.getCause()); } } - + protected Object createProxy(Object target, List advisors, Class... interfaces) { ProxyFactory pf = new ProxyFactory(target); if (interfaces.length > 1 || interfaces[0].isInterface()) { @@ -533,8 +536,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { TwoAdviceAspect twoAdviceAspect = new TwoAdviceAspect(); List advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(twoAdviceAspect,"someBean")); assertEquals("Two advice methods found", 2, advisors.size()); - ITestBean itb = (ITestBean) createProxy(target, - advisors, + ITestBean itb = (ITestBean) createProxy(target, + advisors, ITestBean.class); itb.setName(""); assertEquals(0, itb.getAge()); @@ -549,8 +552,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { ExceptionHandling afterReturningAspect = new ExceptionHandling(); List advisors = getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(afterReturningAspect,"someBean")); - Echo echo = (Echo) createProxy(target, - advisors, + Echo echo = (Echo) createProxy(target, + advisors, Echo.class); assertEquals(0, afterReturningAspect.successCount); assertEquals("", echo.echo("")); @@ -672,19 +675,23 @@ public abstract class AbstractAspectJAdvisorFactoryTests { return this.count; } + @Override public Object getAspectInstance() { ++this.count; return new PerTypeWithinAspect(); } + @Override public ClassLoader getAspectClassLoader() { return PerTypeWithinAspect.class.getClassLoader(); } + @Override public AspectMetadata getAspectMetadata() { return new AspectMetadata(PerTypeWithinAspect.class, "perTypeWithin"); } + @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; } @@ -764,8 +771,8 @@ public abstract class AbstractAspectJAdvisorFactoryTests { public void setAge(int a) {} @Around(value="setAge(age)",argNames="age") - // @ArgNames({"age"}) // AMC needs more work here? ignoring pjp arg... ok?? - // // argNames should be suported in Around as it is in Pointcut + // @ArgNames({"age"}) // AMC needs more work here? ignoring pjp arg... ok?? + // argNames should be suported in Around as it is in Pointcut public void changeReturnType(ProceedingJoinPoint pjp, int age) throws Throwable { pjp.proceed(new Object[] {age*2}); } @@ -886,45 +893,48 @@ public abstract class AbstractAspectJAdvisorFactoryTests { */ @Aspect abstract class AbstractMakeModifiable { - + public interface MutableModifable extends Modifiable { void markDirty(); } - + public static class ModifiableImpl implements MutableModifable { private boolean modified; - + + @Override public void acceptChanges() { modified = false; } - + + @Override public boolean isModified() { return modified; } - + + @Override public void markDirty() { this.modified = true; } } - - @Before(value="execution(void set*(*)) && this(modifiable) && args(newValue)", + + @Before(value="execution(void set*(*)) && this(modifiable) && args(newValue)", argNames="modifiable,newValue") - public void recordModificationIfSetterArgumentDiffersFromOldValue(JoinPoint jp, + public void recordModificationIfSetterArgumentDiffersFromOldValue(JoinPoint jp, MutableModifable mixin, Object newValue) { - + /* * We use the mixin to check and, if necessary, change, - * modification status. We need the JoinPoint to get the - * setter method. We use newValue for comparison. + * modification status. We need the JoinPoint to get the + * setter method. We use newValue for comparison. * We try to invoke the getter if possible. */ - + if (mixin.isModified()) { // Already changed, don't need to change again //System.out.println("changed"); return; } - + // Find the current raw value, by invoking the corresponding setter Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod()); boolean modified = true; @@ -946,12 +956,12 @@ abstract class AbstractMakeModifiable { mixin.markDirty(); } } - + private Method getGetterFromSetter(Method setter) { String getterName = setter.getName().replaceFirst("set", "get"); try { return setter.getDeclaringClass().getMethod(getterName, (Class[]) null); - } + } catch (NoSuchMethodException ex) { // must be write only return null; @@ -968,7 +978,7 @@ abstract class AbstractMakeModifiable { */ @Aspect class MakeITestBeanModifiable extends AbstractMakeModifiable { - + @DeclareParents(value = "test.beans.ITestBean+", defaultImpl=ModifiableImpl.class) public static MutableModifable mixin; @@ -982,7 +992,7 @@ class MakeITestBeanModifiable extends AbstractMakeModifiable { */ @Aspect class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable { - + @DeclareParents(value = "(@org.springframework.aop.aspectj.annotation.Measured *)", // @DeclareParents(value = "(@Measured *)", // this would be a nice alternative... defaultImpl=DefaultLockable.class) @@ -996,11 +1006,11 @@ class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable { */ @Aspect class MakeLockable { - + @DeclareParents(value = "org.springframework..*", defaultImpl=DefaultLockable.class) public static Lockable mixin; - + @Before(value="execution(void set*(*)) && this(mixin)", argNames="mixin") public void checkNotLocked( Lockable mixin) // Bind to arg @@ -1017,17 +1027,21 @@ class MakeLockable { class CannotBeUnlocked implements Lockable, Comparable { + @Override public void lock() { } + @Override public void unlock() { throw new UnsupportedOperationException(); } + @Override public boolean locked() { return true; } + @Override public int compareTo(Object arg0) { throw new UnsupportedOperationException(); } @@ -1043,9 +1057,9 @@ class CannotBeUnlocked implements Lockable, Comparable { interface Modifiable { boolean isModified(); - + void acceptChanges(); - + } /** @@ -1057,14 +1071,14 @@ interface AnnotatedTarget { @Measured class AnnotatedTargetImpl implements AnnotatedTarget { - + } @Retention(RetentionPolicy.RUNTIME) @interface Measured {} class NotLockable { - + private int intValue; public int getIntValue() { @@ -1097,5 +1111,5 @@ class PerThisAspect { public void countSetter() { ++count; } - + } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java index 5f108cb56d..d15b0a11ca 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public final class ArgumentBindingTests { TestBean tb = new TestBean(); AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb); proxyFactory.addAspect(NamedPointcutWithArgs.class); - + ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy(); proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw } @@ -54,7 +54,7 @@ public final class ArgumentBindingTests { TransactionalBean tb = new TransactionalBean(); AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb); proxyFactory.addAspect(PointcutWithAnnotationArgument.class); - + ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy(); proxiedTestBean.doInTransaction(); // should throw } @@ -84,6 +84,7 @@ public final class ArgumentBindingTests { public static class TransactionalBean implements ITransactionalBean { + @Override @Transactional public void doInTransaction() { } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java index ead9f1f62c..88beb1455a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,56 +29,56 @@ import test.beans.TestBean; /** - * @author Rod Johnson + * @author Rod Johnson * @author Chris Beams */ public final class AspectJPointcutAdvisorTests { - + private AspectJAdvisorFactory af = new ReflectiveAspectJAdvisorFactory(); @Test public void testSingleton() throws SecurityException, NoSuchMethodException { AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS); - - InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp, - new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"), + + InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp, + new SingletonMetadataAwareAspectInstanceFactory(new AbstractAspectJAdvisorFactoryTests.ExceptionAspect(null),"someBean"), TestBean.class.getMethod("getAge", (Class[]) null),1,"someBean"); assertSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut()); assertFalse(ajpa.isPerInstance()); } - + @Test public void testPerTarget() throws SecurityException, NoSuchMethodException { AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut(); ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS); - - InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp, + + InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(af, ajexp, new SingletonMetadataAwareAspectInstanceFactory(new PerTargetAspect(),"someBean"), null, 1, "someBean"); assertNotSame(Pointcut.TRUE, ajpa.getAspectMetadata().getPerClausePointcut()); assertTrue(ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut); assertTrue(ajpa.isPerInstance()); - + assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class)); assertFalse(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches( TestBean.class.getMethod("getAge", (Class[]) null), TestBean.class)); - + assertTrue(ajpa.getAspectMetadata().getPerClausePointcut().getMethodMatcher().matches( TestBean.class.getMethod("getSpouse", (Class[]) null), TestBean.class)); } - + @Test(expected=AopConfigException.class) public void testPerCflowTarget() { testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class); } - + @Test(expected=AopConfigException.class) public void testPerCflowBelowTarget() { testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class); } - + private void testIllegalInstantiationModel(Class c) throws AopConfigException { new AspectMetadata(c,"someBean"); } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java index f1c32fe992..af55e122a6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,7 +37,7 @@ public final class AspectMetadataTests { public void testNotAnAspect() { new AspectMetadata(String.class,"someBean"); } - + @Test public void testSingletonAspect() { AspectMetadata am = new AspectMetadata(ExceptionAspect.class,"someBean"); @@ -45,7 +45,7 @@ public final class AspectMetadataTests { assertSame(Pointcut.TRUE, am.getPerClausePointcut()); assertEquals(PerClauseKind.SINGLETON, am.getAjType().getPerClause().getKind()); } - + @Test public void testPerTargetAspect() { AspectMetadata am = new AspectMetadata(PerTargetAspect.class,"someBean"); @@ -53,7 +53,7 @@ public final class AspectMetadataTests { assertNotSame(Pointcut.TRUE, am.getPerClausePointcut()); assertEquals(PerClauseKind.PERTARGET, am.getAjType().getPerClause().getKind()); } - + @Test public void testPerThisAspect() { AspectMetadata am = new AspectMetadata(PerThisAspect.class,"someBean"); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index d6c24cd0a1..93aebbfa67 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -111,6 +111,7 @@ public final class AspectProxyFactoryTests { private int age; + @Override public int getAge() { return age; } diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactoryTests.java index 9cb01199f0..f01d1bb9c6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.springframework.aop.aspectj.annotation; /** - * Tests for ReflectiveAtAspectJAdvisorFactory. + * Tests for ReflectiveAtAspectJAdvisorFactory. * Tests are inherited: we only set the test fixture here. * * @author Rod Johnson diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java index 0869a1fa02..08d95808ed 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,29 +41,6 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; */ public final class AspectJPrecedenceComparatorTests { - /* - * Specification for the comparator (as defined in the - * AspectJPrecedenceComparator class) - * - *

    - * Orders AspectJ advice/advisors by invocation order. - *

    - *

    - * Given two pieces of advice, a and b: - *

    - *
      - *
    • if a and b are defined in different - * aspects, then the advice in the aspect with the lowest order - * value has the highest precedence
    • - *
    • if a and b are defined in the same - * aspect, then if one of a or b is a form of - * after advice, then the advice declared last in the aspect has the - * highest precedence. If neither a nor b is a - * form of after advice, then the advice declared first in the aspect has - * the highest precedence.
    • - *
    - */ - private static final int HIGH_PRECEDENCE_ADVISOR_ORDER = 100; private static final int LOW_PRECEDENCE_ADVISOR_ORDER = 200; private static final int EARLY_ADVICE_DECLARATION_ORDER = 5; @@ -217,6 +194,7 @@ public final class AspectJPrecedenceComparatorTests { private Advisor createSpringAOPAfterAdvice(int order) { AfterReturningAdvice advice = new AfterReturningAdvice() { + @Override public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { } }; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index de36eb98b6..0d86588b8c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,18 +43,18 @@ import test.parsing.CollectingReaderEventListener; public final class AopNamespaceHandlerEventTests { private static final Class CLASS = AopNamespaceHandlerEventTests.class; - + private static final Resource CONTEXT = qualifiedResource(CLASS, "context.xml"); private static final Resource POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "pointcutEvents.xml"); private static final Resource POINTCUT_REF_CONTEXT = qualifiedResource(CLASS, "pointcutRefEvents.xml"); private static final Resource DIRECT_POINTCUT_EVENTS_CONTEXT = qualifiedResource(CLASS, "directPointcutEvents.xml"); - + private CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); private XmlBeanDefinitionReader reader; private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - + @Before diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index 860e3dd0ba..ba0b767921 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.beans.factory.xml.XmlBeanFactory; * @author Chris Beams */ public final class AopNamespaceHandlerPointcutErrorTests { - + @Test public void testDuplicatePointcutConfig() { try { diff --git a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index 353df218fa..3dbd38f98c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,12 +26,12 @@ import org.springframework.core.io.Resource; /** * Tests that the <aop:config/> element can be used as a top level element. - * + * * @author Rob Harrop * @author Chris Beams */ public final class TopLevelAopTagTests { - + private static final Resource CONTEXT = qualifiedResource(TopLevelAopTagTests.class, "context.xml"); @Test diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java index dda6cf20b1..dca823663d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import test.beans.TestBean; * @author Chris Beams */ public final class AopProxyUtilsTests { - + @Test public void testCompleteProxiedInterfacesWorksWithNull() { AdvisedSupport as = new AdvisedSupport(); @@ -45,7 +45,7 @@ public final class AopProxyUtilsTests { assertTrue(ifaces.contains(Advised.class)); assertTrue(ifaces.contains(SpringProxy.class)); } - + @Test public void testCompleteProxiedInterfacesWorksWithNullOpaque() { AdvisedSupport as = new AdvisedSupport(); @@ -53,7 +53,7 @@ public final class AopProxyUtilsTests { Class[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as); assertEquals(1, completedInterfaces.length); } - + @Test public void testCompleteProxiedInterfacesAdvisedNotIncluded() { AdvisedSupport as = new AdvisedSupport(); @@ -61,14 +61,14 @@ public final class AopProxyUtilsTests { as.addInterface(Comparable.class); Class[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as); assertEquals(4, completedInterfaces.length); - + // Can't assume ordering for others, so use a list List l = Arrays.asList(completedInterfaces); assertTrue(l.contains(Advised.class)); assertTrue(l.contains(ITestBean.class)); assertTrue(l.contains(Comparable.class)); } - + @Test public void testCompleteProxiedInterfacesAdvisedIncluded() { AdvisedSupport as = new AdvisedSupport(); @@ -77,14 +77,14 @@ public final class AopProxyUtilsTests { as.addInterface(Advised.class); Class[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as); assertEquals(4, completedInterfaces.length); - + // Can't assume ordering for others, so use a list List l = Arrays.asList(completedInterfaces); assertTrue(l.contains(Advised.class)); assertTrue(l.contains(ITestBean.class)); assertTrue(l.contains(Comparable.class)); } - + @Test public void testCompleteProxiedInterfacesAdvisedNotIncludedOpaque() { AdvisedSupport as = new AdvisedSupport(); @@ -93,7 +93,7 @@ public final class AopProxyUtilsTests { as.addInterface(Comparable.class); Class[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as); assertEquals(3, completedInterfaces.length); - + // Can't assume ordering for others, so use a list List l = Arrays.asList(completedInterfaces); assertFalse(l.contains(Advised.class)); @@ -129,6 +129,7 @@ public final class AopProxyUtilsTests { public void testProxiedUserInterfacesWithNoInterface() { Object proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[0], new InvocationHandler() { + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return null; } diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java index a8623ba81c..03b971fed0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,9 +25,9 @@ import test.beans.TestBean; /** * Benchmarks for introductions. - * + * * NOTE: No assertions! - * + * * @author Rod Johnson * @author Chris Beams * @since 2.0 @@ -42,6 +42,7 @@ public final class IntroductionBenchmarkTests { @SuppressWarnings("serial") public static class SimpleCounterIntroduction extends DelegatingIntroductionInterceptor implements Counter { + @Override public int getCount() { return EXPECTED_COMPARE; } diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java index 4fdbbc0126..4e81553444 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import test.beans.TestBean; * @since 14.03.2003 */ public final class MethodInvocationTests { - + @Test public void testValidInvocation() throws Throwable { Method m = Object.class.getMethod("hashCode", (Class[]) null); @@ -42,6 +42,7 @@ public final class MethodInvocationTests { final Object returnValue = new Object(); List is = new LinkedList(); is.add(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return returnValue; } @@ -52,7 +53,7 @@ public final class MethodInvocationTests { Object rv = invocation.proceed(); assertTrue("correct response", rv == returnValue); } - + /** * toString on target can cause failure. */ @@ -68,7 +69,7 @@ public final class MethodInvocationTests { Method m = Object.class.getMethod("hashCode", (Class[]) null); Object proxy = new Object(); ReflectiveMethodInvocation invocation = - new ReflectiveMethodInvocation(proxy, target, m, null, null, is); + new ReflectiveMethodInvocation(proxy, target, m, null, null, is); // If it hits target, the test will fail with the UnsupportedOpException // in the inner class above. diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java index 1879f8a4cd..11b127d0bc 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java @@ -44,6 +44,7 @@ public class NullPrimitiveTests { public void testNullPrimitiveWithJdkProxy() { class SimpleFoo implements Foo { + @Override public int getValue() { return 100; } @@ -52,6 +53,7 @@ public class NullPrimitiveTests { SimpleFoo target = new SimpleFoo(); ProxyFactory factory = new ProxyFactory(target); factory.addAdvice(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return null; } @@ -76,6 +78,7 @@ public class NullPrimitiveTests { Bar target = new Bar(); ProxyFactory factory = new ProxyFactory(target); factory.addAdvice(new MethodInterceptor() { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return null; } diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java index fd4eae3a7f..05a0fc327a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.core.io.Resource; * @since 03.09.2004 */ public final class PrototypeTargetTests { - + private static final Resource CONTEXT = qualifiedResource(PrototypeTargetTests.class, "context.xml"); @Test @@ -73,6 +73,7 @@ public final class PrototypeTargetTests { constructionCount++; } + @Override public void doSomething() { } } @@ -81,6 +82,7 @@ public final class PrototypeTargetTests { public static class TestInterceptor implements MethodInterceptor { private int invocationCount = 0; + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { invocationCount++; return methodInvocation.proceed(); diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index f7d325e4c5..ddf48d28d8 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public final class ProxyFactoryTests { assertEquals(1, pf.indexOf(advisor)); assertEquals(-1, advised.indexOf(new DefaultPointcutAdvisor(null))); } - + @Test public void testRemoveAdvisorByReference() { TestBean target = new TestBean(); @@ -84,7 +84,7 @@ public final class ProxyFactoryTests { assertEquals(2, nop.getCount()); assertFalse(pf.removeAdvisor(new DefaultPointcutAdvisor(null))); } - + @Test public void testRemoveAdvisorByIndex() { TestBean target = new TestBean(); @@ -113,7 +113,7 @@ public final class ProxyFactoryTests { assertEquals(1, cba.getCalls()); assertEquals(2, nop.getCount()); assertEquals(3, nop2.getCount()); - + // Check out of bounds try { pf.removeAdvisor(-1); @@ -121,14 +121,14 @@ public final class ProxyFactoryTests { catch (AopConfigException ex) { // Ok } - + try { pf.removeAdvisor(2); } catch (AopConfigException ex) { // Ok } - + assertEquals(5, proxied.getAge()); assertEquals(4, nop2.getCount()); } @@ -165,6 +165,7 @@ public final class ProxyFactoryTests { @Test public void testAddRepeatedInterface() { TimeStamped tst = new TimeStamped() { + @Override public long getTimeStamp() { throw new UnsupportedOperationException("getTimeStamp"); } @@ -181,6 +182,7 @@ public final class ProxyFactoryTests { public void testGetsAllInterfaces() throws Exception { // Extend to get new interface class TestBeanSubclass extends TestBean implements Comparable { + @Override public int compareTo(Object arg0) { throw new UnsupportedOperationException("compareTo"); } @@ -191,17 +193,17 @@ public final class ProxyFactoryTests { assertEquals("Found correct number of interfaces", 3, factory.getProxiedInterfaces().length); ITestBean tb = (ITestBean) factory.getProxy(); assertThat("Picked up secondary interface", tb, instanceOf(IOther.class)); - + raw.setAge(25); assertTrue(tb.getAge() == raw.getAge()); long t = 555555L; TimestampIntroductionInterceptor ti = new TimestampIntroductionInterceptor(t); - + Class[] oldProxiedInterfaces = factory.getProxiedInterfaces(); - + factory.addAdvisor(0, new DefaultIntroductionAdvisor(ti, TimeStamped.class)); - + Class[] newProxiedInterfaces = factory.getProxiedInterfaces(); assertEquals("Advisor proxies one more interface after introduction", oldProxiedInterfaces.length + 1, newProxiedInterfaces.length); @@ -210,15 +212,16 @@ public final class ProxyFactoryTests { // Shouldn't fail; ((IOther) ts).absquatulate(); } - + @Test public void testInterceptorInclusionMethods() { class MyInterceptor implements MethodInterceptor { + @Override public Object invoke(MethodInvocation invocation) throws Throwable { throw new UnsupportedOperationException(); } } - + NopInterceptor di = new NopInterceptor(); NopInterceptor diUnused = new NopInterceptor(); ProxyFactory factory = new ProxyFactory(new TestBean()); @@ -228,7 +231,7 @@ public final class ProxyFactoryTests { assertTrue(!factory.adviceIncluded(diUnused)); assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 1); assertTrue(factory.countAdvicesOfType(MyInterceptor.class) == 0); - + factory.addAdvice(0, diUnused); assertTrue(factory.adviceIncluded(diUnused)); assertTrue(factory.countAdvicesOfType(NopInterceptor.class) == 2); @@ -350,6 +353,7 @@ public final class ProxyFactoryTests { this.ts = ts; } + @Override public long getTimeStamp() { return ts; } diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java index ceae4f577e..fe72f96325 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,8 +23,10 @@ import java.rmi.RemoteException; import javax.transaction.TransactionRolledbackException; import org.aopalliance.intercept.MethodInvocation; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + import org.junit.Test; import test.aop.MethodCounter; @@ -47,12 +49,10 @@ public final class ThrowsAdviceInterceptorTests { MyThrowsHandler th = new MyThrowsHandler(); ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); Object ret = new Object(); - MethodInvocation mi = createMock(MethodInvocation.class); - expect(mi.proceed()).andReturn(ret); - replay(mi); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.proceed()).willReturn(ret); assertEquals(ret, ti.invoke(mi)); assertEquals(0, th.getCalls()); - verify(mi); } @Test @@ -61,9 +61,8 @@ public final class ThrowsAdviceInterceptorTests { ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); assertEquals(2, ti.getHandlerMethodCount()); Exception ex = new Exception(); - MethodInvocation mi = createMock(MethodInvocation.class); - expect(mi.proceed()).andThrow(ex); - replay(mi); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); @@ -72,7 +71,6 @@ public final class ThrowsAdviceInterceptorTests { assertEquals(ex, caught); } assertEquals(0, th.getCalls()); - verify(mi); } @Test @@ -80,12 +78,10 @@ public final class ThrowsAdviceInterceptorTests { MyThrowsHandler th = new MyThrowsHandler(); ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); FileNotFoundException ex = new FileNotFoundException(); - MethodInvocation mi = createMock(MethodInvocation.class); - expect(mi.getMethod()).andReturn(Object.class.getMethod("hashCode", (Class[]) null)); - expect(mi.getArguments()).andReturn(null); - expect(mi.getThis()).andReturn(new Object()); - expect(mi.proceed()).andThrow(ex); - replay(mi); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.getMethod()).willReturn(Object.class.getMethod("hashCode", (Class[]) null)); + given(mi.getThis()).willReturn(new Object()); + given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); @@ -95,7 +91,6 @@ public final class ThrowsAdviceInterceptorTests { } assertEquals(1, th.getCalls()); assertEquals(1, th.getCalls("ioException")); - verify(mi); } @Test @@ -104,9 +99,8 @@ public final class ThrowsAdviceInterceptorTests { ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); // Extends RemoteException TransactionRolledbackException ex = new TransactionRolledbackException(); - MethodInvocation mi = createMock(MethodInvocation.class); - expect(mi.proceed()).andThrow(ex); - replay(mi); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); @@ -116,7 +110,6 @@ public final class ThrowsAdviceInterceptorTests { } assertEquals(1, th.getCalls()); assertEquals(1, th.getCalls("remoteException")); - verify(mi); } @Test @@ -125,6 +118,7 @@ public final class ThrowsAdviceInterceptorTests { @SuppressWarnings("serial") MyThrowsHandler th = new MyThrowsHandler() { + @Override public void afterThrowing(RemoteException ex) throws Throwable { super.afterThrowing(ex); throw t; @@ -134,9 +128,8 @@ public final class ThrowsAdviceInterceptorTests { ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); // Extends RemoteException TransactionRolledbackException ex = new TransactionRolledbackException(); - MethodInvocation mi = createMock(MethodInvocation.class); - expect(mi.proceed()).andThrow(ex); - replay(mi); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); @@ -146,7 +139,6 @@ public final class ThrowsAdviceInterceptorTests { } assertEquals(1, th.getCalls()); assertEquals(1, th.getCalls("remoteException")); - verify(mi); } @SuppressWarnings("serial") diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index 9b3aaf6d9a..964fac9efa 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -120,6 +120,7 @@ public final class ConcurrencyThrottleInterceptorTests { this.ex = ex; } + @Override public void run() { if (this.ex != null) { try { diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java index 1fe27b3dfc..77aad8e9ff 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,13 @@ package org.springframework.aop.interceptor; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import java.lang.reflect.Method; @@ -83,47 +88,32 @@ public final class CustomizableTraceInterceptorTests { @Test public void testSunnyDayPathLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation methodInvocation = createMock(MethodInvocation.class); + MethodInvocation methodInvocation = mock(MethodInvocation.class); + given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{})); + given(methodInvocation.getThis()).willReturn(this); - Method toString = String.class.getMethod("toString", new Class[]{}); - - expect(log.isTraceEnabled()).andReturn(true); - expect(methodInvocation.getMethod()).andReturn(toString).times(4); - expect(methodInvocation.getThis()).andReturn(this).times(2); - log.trace(isA(String.class)); - expect(methodInvocation.proceed()).andReturn(null); - log.trace(isA(String.class)); - - replay(methodInvocation); - replay(log); + Log log = mock(Log.class); + given(log.isTraceEnabled()).willReturn(true); CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log); interceptor.invoke(methodInvocation); - verify(log); - verify(methodInvocation); + verify(log, times(2)).trace(anyString()); } @Test public void testExceptionPathLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation methodInvocation = createMock(MethodInvocation.class); + MethodInvocation methodInvocation = mock(MethodInvocation.class); - Method toString = String.class.getMethod("toString", new Class[]{}); - - expect(log.isTraceEnabled()).andReturn(true); - expect(methodInvocation.getMethod()).andReturn(toString).times(4); - expect(methodInvocation.getThis()).andReturn(this).times(2); - log.trace(isA(String.class)); IllegalArgumentException exception = new IllegalArgumentException(); - expect(methodInvocation.proceed()).andThrow(exception); - log.trace(isA(String.class), eq(exception)); + given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{})); + given(methodInvocation.getThis()).willReturn(this); + given(methodInvocation.proceed()).willThrow(exception); - replay(log); - replay(methodInvocation); + Log log = mock(Log.class); + given(log.isTraceEnabled()).willReturn(true); CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log); try { @@ -133,29 +123,22 @@ public final class CustomizableTraceInterceptorTests { catch (IllegalArgumentException expected) { } - verify(log); - verify(methodInvocation); + verify(log).trace(anyString()); + verify(log).trace(anyString(), eq(exception)); } @Test public void testSunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation methodInvocation = createMock(MethodInvocation.class); + MethodInvocation methodInvocation = mock(MethodInvocation.class); - Method toString = String.class.getMethod("toString", new Class[0]); - Object[] arguments = new Object[]{"$ One \\$", new Long(2)}; + given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0])); + given(methodInvocation.getThis()).willReturn(this); + given(methodInvocation.getArguments()).willReturn(new Object[]{"$ One \\$", new Long(2)}); + given(methodInvocation.proceed()).willReturn("Hello!"); - expect(log.isTraceEnabled()).andReturn(true); - expect(methodInvocation.getMethod()).andReturn(toString).times(7); - expect(methodInvocation.getThis()).andReturn(this).times(2); - expect(methodInvocation.getArguments()).andReturn(arguments).times(2); - log.trace(isA(String.class)); - expect(methodInvocation.proceed()).andReturn("Hello!"); - log.trace(isA(String.class)); - - replay(methodInvocation); - replay(log); + Log log = mock(Log.class); + given(log.isTraceEnabled()).willReturn(true); CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log); interceptor.setEnterMessage(new StringBuffer() @@ -174,8 +157,7 @@ public final class CustomizableTraceInterceptorTests { .append("' this long.").toString()); interceptor.invoke(methodInvocation); - verify(log); - verify(methodInvocation); + verify(log, times(2)).trace(anyString()); } @@ -189,6 +171,7 @@ public final class CustomizableTraceInterceptorTests { this.log = log; } + @Override protected Log getLoggerForInvocation(MethodInvocation invocation) { return this.log; } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java index 6ac026fcbf..d0cee0780e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,13 @@ package org.springframework.aop.interceptor; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; @@ -33,40 +38,29 @@ public final class DebugInterceptorTests { @Test public void testSunnyDayPathLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - - MethodInvocation methodInvocation = createMock(MethodInvocation.class); - expect(log.isTraceEnabled()).andReturn(true); - log.trace(isA(String.class)); - expect(methodInvocation.proceed()).andReturn(null); - log.trace(isA(String.class)); + MethodInvocation methodInvocation = mock(MethodInvocation.class); - replay(methodInvocation); - replay(log); + Log log = mock(Log.class); + given(log.isTraceEnabled()).willReturn(true); DebugInterceptor interceptor = new StubDebugInterceptor(log); interceptor.invoke(methodInvocation); checkCallCountTotal(interceptor); - verify(methodInvocation); - verify(log); + verify(log, times(2)).trace(anyString()); } @Test public void testExceptionPathStillLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - - MethodInvocation methodInvocation = createMock(MethodInvocation.class); - expect(log.isTraceEnabled()).andReturn(true); - log.trace(isA(String.class)); + MethodInvocation methodInvocation = mock(MethodInvocation.class); + IllegalArgumentException exception = new IllegalArgumentException(); - expect(methodInvocation.proceed()).andThrow(exception); - log.trace(isA(String.class), eq(exception)); + given(methodInvocation.proceed()).willThrow(exception); - replay(methodInvocation); - replay(log); + Log log = mock(Log.class); + given(log.isTraceEnabled()).willReturn(true); DebugInterceptor interceptor = new StubDebugInterceptor(log); try { @@ -76,8 +70,8 @@ public final class DebugInterceptorTests { } checkCallCountTotal(interceptor); - verify(methodInvocation); - verify(log); + verify(log).trace(anyString()); + verify(log).trace(anyString(), eq(exception)); } private void checkCallCountTotal(DebugInterceptor interceptor) { @@ -96,6 +90,7 @@ public final class DebugInterceptorTests { this.log = log; } + @Override protected Log getLoggerForInvocation(MethodInvocation invocation) { return log; } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java index cc105bebcd..170f5b34bc 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,20 +30,21 @@ import test.beans.TestBean; * @author Chris Beams */ public final class ExposeBeanNameAdvisorsTests { - + private class RequiresBeanNameBoundTestBean extends TestBean { private final String beanName; - + public RequiresBeanNameBoundTestBean(String beanName) { this.beanName = beanName; } - + + @Override public int getAge() { assertEquals(beanName, ExposeBeanNameAdvisors.getBeanName()); return super.getAge(); } } - + @Test public void testNoIntroduction() { String beanName = "foo"; @@ -52,12 +53,12 @@ public final class ExposeBeanNameAdvisorsTests { pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName)); ITestBean proxy = (ITestBean) pf.getProxy(); - + assertFalse("No introduction", proxy instanceof NamedBean); // Requires binding proxy.getAge(); } - + @Test public void testWithIntroduction() { String beanName = "foo"; @@ -66,11 +67,11 @@ public final class ExposeBeanNameAdvisorsTests { pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR); pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName)); ITestBean proxy = (ITestBean) pf.getProxy(); - + assertTrue("Introduction was made", proxy instanceof NamedBean); // Requires binding proxy.getAge(); - + NamedBean nb = (NamedBean) proxy; assertEquals("Name returned correctly", beanName, nb.getBeanName()); } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index bfa9ea4d05..ae224b6385 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,12 +29,12 @@ import test.beans.TestBean; /** * Non-XML tests are in AbstractAopProxyTests - * + * * @author Rod Johnson * @author Chris Beams */ public final class ExposeInvocationInterceptorTests { - + private static final Resource CONTEXT = qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"); @@ -53,26 +53,29 @@ public final class ExposeInvocationInterceptorTests { abstract class ExposedInvocationTestBean extends TestBean { + @Override public String getName() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); return super.getName(); } + @Override public void absquatulate() { MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation(); assertions(invocation); super.absquatulate(); } - + protected abstract void assertions(MethodInvocation invocation); } class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean { + @Override protected void assertions(MethodInvocation invocation) { assertTrue(invocation.getThis() == this); - assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), + assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(), ITestBean.class.isAssignableFrom(invocation.getMethod().getDeclaringClass())); } } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java index 5cc35f10ec..bf2c45fc2c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,10 +16,11 @@ package org.springframework.aop.interceptor; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; - -import java.lang.reflect.Method; +import static org.mockito.BDDMockito.given; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; @@ -48,35 +49,24 @@ public final class PerformanceMonitorInterceptorTests { @Test public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation mi = createMock(MethodInvocation.class); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0])); - Method toString = String.class.getMethod("toString", new Class[0]); - - expect(mi.getMethod()).andReturn(toString); - expect(mi.proceed()).andReturn(null); - log.trace(isA(String.class)); - - replay(mi, log); + Log log = mock(Log.class); PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true); interceptor.invokeUnderTrace(mi, log); - verify(mi, log); + verify(log).trace(anyString()); } @Test public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation mi = createMock(MethodInvocation.class); + MethodInvocation mi = mock(MethodInvocation.class); - Method toString = String.class.getMethod("toString", new Class[0]); - - expect(mi.getMethod()).andReturn(toString); - expect(mi.proceed()).andThrow(new IllegalArgumentException()); - log.trace(isA(String.class)); - - replay(mi, log); + given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0])); + given(mi.proceed()).willThrow(new IllegalArgumentException()); + Log log = mock(Log.class); PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true); try { @@ -86,7 +76,7 @@ public final class PerformanceMonitorInterceptorTests { catch (IllegalArgumentException expected) { } - verify(mi, log); + verify(log).trace(anyString()); } } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java index 7845f1268b..6efc651d27 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,13 @@ package org.springframework.aop.interceptor; -import static org.easymock.EasyMock.*; import static org.junit.Assert.fail; +import static org.mockito.BDDMockito.given; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import java.lang.reflect.Method; @@ -35,39 +40,27 @@ public final class SimpleTraceInterceptorTests { @Test public void testSunnyDayPathLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation mi = createMock(MethodInvocation.class); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{})); + given(mi.getThis()).willReturn(this); - Method toString = String.class.getMethod("toString", new Class[]{}); - - expect(mi.getMethod()).andReturn(toString); - expect(mi.getThis()).andReturn(this); - log.trace(isA(String.class)); - expect(mi.proceed()).andReturn(null); - log.trace(isA(String.class)); - - replay(mi, log); + Log log = mock(Log.class); SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true); interceptor.invokeUnderTrace(mi, log); - verify(mi, log); + verify(log, times(2)).trace(anyString()); } + @Test public void testExceptionPathStillLogsCorrectly() throws Throwable { - Log log = createMock(Log.class); - MethodInvocation mi = createMock(MethodInvocation.class); - - Method toString = String.class.getMethod("toString", new Class[]{}); - - expect(mi.getMethod()).andReturn(toString); - expect(mi.getThis()).andReturn(this); - log.trace(isA(String.class)); + MethodInvocation mi = mock(MethodInvocation.class); + given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{})); + given(mi.getThis()).willReturn(this); IllegalArgumentException exception = new IllegalArgumentException(); - expect(mi.proceed()).andThrow(exception); - log.trace(isA(String.class)); + given(mi.proceed()).willThrow(exception); - replay(mi, log); + Log log = mock(Log.class); final SimpleTraceInterceptor interceptor = new SimpleTraceInterceptor(true); @@ -77,7 +70,8 @@ public final class SimpleTraceInterceptorTests { } catch (IllegalArgumentException expected) { } - verify(mi, log); + verify(log).trace(anyString()); + verify(log).trace(anyString(), eq(exception)); } } diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java index 80f62da86b..9ec42626db 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.springframework.aop.scope; -import static org.easymock.EasyMock.*; +import static org.mockito.Mockito.mock; import org.junit.Test; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -52,14 +52,9 @@ public final class DefaultScopedObjectTests { testBadTargetBeanName(" "); } - private static void testBadTargetBeanName(final String badTargetBeanName) { - ConfigurableBeanFactory factory = createMock(ConfigurableBeanFactory.class); - replay(factory); - + ConfigurableBeanFactory factory = mock(ConfigurableBeanFactory.class); new DefaultScopedObject(factory, badTargetBeanName); - - verify(factory); } } diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index 3706293c2c..f44b215755 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,9 +28,9 @@ import org.springframework.core.io.Resource; * @author Chris Beams */ public final class ScopedProxyAutowireTests { - + private static final Class CLASS = ScopedProxyAutowireTests.class; - + private static final Resource SCOPED_AUTOWIRE_TRUE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireTrue.xml"); private static final Resource SCOPED_AUTOWIRE_FALSE_CONTEXT = qualifiedResource(CLASS, "scopedAutowireFalse.xml"); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index c423579aa0..505697408c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,11 +40,12 @@ public final class AopUtilsTests { @Test public void testPointcutCanNeverApply() { class TestPointcut extends StaticMethodMatcherPointcut { + @Override public boolean matches(Method method, Class clazzy) { return false; } } - + Pointcut no = new TestPointcut(); assertFalse(AopUtils.canApply(no, Object.class)); } @@ -58,13 +59,14 @@ public final class AopUtilsTests { @Test public void testPointcutAppliesToOneMethodOnObject() { class TestPointcut extends StaticMethodMatcherPointcut { + @Override public boolean matches(Method method, Class clazz) { return method.getName().equals("hashCode"); } } Pointcut pc = new TestPointcut(); - + // will return true if we're not proxying interfaces assertTrue(AopUtils.canApply(pc, Object.class)); } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java index 3c9f37ef13..42992fb57c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,11 +30,11 @@ import test.beans.TestBean; * @author Chris Beams */ public final class ClassFiltersTests { - + private ClassFilter exceptionFilter = new RootClassFilter(Exception.class); - + private ClassFilter itbFilter = new RootClassFilter(ITestBean.class); - + private ClassFilter hasRootCauseFilter = new RootClassFilter(NestedRuntimeException.class); @Test @@ -47,7 +47,7 @@ public final class ClassFiltersTests { assertTrue(union.matches(RuntimeException.class)); assertTrue(union.matches(TestBean.class)); } - + @Test public void testIntersection() { assertTrue(exceptionFilter.matches(RuntimeException.class)); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java index 85b40b9112..2ca2acd665 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,31 +33,35 @@ import test.beans.TestBean; * @author Chris Beams */ public final class ComposablePointcutTests { - + public static MethodMatcher GETTER_METHOD_MATCHER = new StaticMethodMatcher() { + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; - + public static MethodMatcher GET_AGE_METHOD_MATCHER = new StaticMethodMatcher() { + @Override public boolean matches(Method m, Class targetClass) { return m.getName().equals("getAge"); } }; - + public static MethodMatcher ABSQUATULATE_METHOD_MATCHER = new StaticMethodMatcher() { + @Override public boolean matches(Method m, Class targetClass) { return m.getName().equals("absquatulate"); } }; - + public static MethodMatcher SETTER_METHOD_MATCHER = new StaticMethodMatcher() { + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("set"); } }; - + @Test public void testMatchAll() throws NoSuchMethodException { Pointcut pc = new ComposablePointcut(); @@ -68,9 +72,9 @@ public final class ComposablePointcutTests { @Test public void testFilterByClass() throws NoSuchMethodException { ComposablePointcut pc = new ComposablePointcut(); - + assertTrue(pc.getClassFilter().matches(Object.class)); - + ClassFilter cf = new RootClassFilter(Exception.class); pc.intersection(cf); assertFalse(pc.getClassFilter().matches(Object.class)); @@ -92,15 +96,15 @@ public final class ComposablePointcutTests { assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null)); assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null)); assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null)); - + pc.union(GETTER_METHOD_MATCHER); // Should now match all getter methods assertFalse(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null)); assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null)); assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null)); - + pc.union(ABSQUATULATE_METHOD_MATCHER); - // Should now match absquatulate() as well + // Should now match absquatulate() as well assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class, null)); assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class, null)); assertTrue(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_GET_NAME, TestBean.class, null)); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index ed17db6618..6288f7674a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ import test.beans.TestBean; * @author Chris Beams */ public final class ControlFlowPointcutTests { - + @Test public void testMatches() { TestBean target = new TestBean(); @@ -41,21 +41,21 @@ public final class ControlFlowPointcutTests { ProxyFactory pf = new ProxyFactory(target); ITestBean proxied = (ITestBean) pf.getProxy(); pf.addAdvisor(new DefaultPointcutAdvisor(cflow, nop)); - + // Not advised, not under One assertEquals(target.getAge(), proxied.getAge()); assertEquals(0, nop.getCount()); - + // Will be advised assertEquals(target.getAge(), new One().getAge(proxied)); assertEquals(1, nop.getCount()); - + // Won't be advised assertEquals(target.getAge(), new One().nomatch(proxied)); assertEquals(1, nop.getCount()); assertEquals(3, cflow.getEvaluations()); } - + /** * Check that we can use a cflow pointcut only in conjunction with * a static pointcut: e.g. all setter methods that are invoked under @@ -73,19 +73,19 @@ public final class ControlFlowPointcutTests { ProxyFactory pf = new ProxyFactory(target); ITestBean proxied = (ITestBean) pf.getProxy(); pf.addAdvisor(new DefaultPointcutAdvisor(settersUnderOne, nop)); - + // Not advised, not under One target.setAge(16); assertEquals(0, nop.getCount()); - + // Not advised; under One but not a setter assertEquals(16, new One().getAge(proxied)); assertEquals(0, nop.getCount()); - + // Won't be advised new One().set(proxied); assertEquals(1, nop.getCount()); - + // We saved most evaluations assertEquals(1, cflow.getEvaluations()); } @@ -99,7 +99,7 @@ public final class ControlFlowPointcutTests { assertEquals(new ControlFlowPointcut(One.class, "getAge").hashCode(), new ControlFlowPointcut(One.class, "getAge").hashCode()); assertFalse(new ControlFlowPointcut(One.class, "getAge").hashCode() == new ControlFlowPointcut(One.class).hashCode()); } - + public class One { int getAge(ITestBean proxied) { return proxied.getAge(); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index cd51a4895c..1b7c8d60b3 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,8 +16,9 @@ package org.springframework.aop.support; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; import java.io.Serializable; @@ -56,17 +57,14 @@ public final class DelegatingIntroductionInterceptorTests { assertTrue(! (raw instanceof TimeStamped)); ProxyFactory factory = new ProxyFactory(raw); - TimeStamped ts = createMock(TimeStamped.class); + TimeStamped ts = mock(TimeStamped.class); long timestamp = 111L; - expect(ts.getTimeStamp()).andReturn(timestamp); - replay(ts); + given(ts.getTimeStamp()).willReturn(timestamp); factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts))); TimeStamped tsp = (TimeStamped) factory.getProxy(); assertTrue(tsp.getTimeStamp() == timestamp); - - verify(ts); } @Test @@ -75,17 +73,14 @@ public final class DelegatingIntroductionInterceptorTests { assertTrue(! (raw instanceof SubTimeStamped)); ProxyFactory factory = new ProxyFactory(raw); - TimeStamped ts = createMock(SubTimeStamped.class); + TimeStamped ts = mock(SubTimeStamped.class); long timestamp = 111L; - expect(ts.getTimeStamp()).andReturn(timestamp); - replay(ts); - + given(ts.getTimeStamp()).willReturn(timestamp); + factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), SubTimeStamped.class)); SubTimeStamped tsp = (SubTimeStamped) factory.getProxy(); assertTrue(tsp.getTimeStamp() == timestamp); - - verify(ts); } @Test @@ -94,26 +89,25 @@ public final class DelegatingIntroductionInterceptorTests { assertTrue(! (raw instanceof TimeStamped)); ProxyFactory factory = new ProxyFactory(raw); - TimeStamped ts = createMock(SubTimeStamped.class); + TimeStamped ts = mock(SubTimeStamped.class); long timestamp = 111L; - expect(ts.getTimeStamp()).andReturn(timestamp); - replay(ts); + given(ts.getTimeStamp()).willReturn(timestamp); factory.addAdvisor(0, new DefaultIntroductionAdvisor(new DelegatingIntroductionInterceptor(ts), TimeStamped.class)); TimeStamped tsp = (TimeStamped) factory.getProxy(); assertTrue(!(tsp instanceof SubTimeStamped)); assertTrue(tsp.getTimeStamp() == timestamp); - - verify(ts); } @Test public void testAutomaticInterfaceRecognitionInDelegate() throws Exception { final long t = 1001L; class Tester implements TimeStamped, ITester { + @Override public void foo() throws Exception { } + @Override public long getTimeStamp() { return t; } @@ -141,8 +135,10 @@ public final class DelegatingIntroductionInterceptorTests { final long t = 1001L; @SuppressWarnings("serial") class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester { + @Override public void foo() throws Exception { } + @Override public long getTimeStamp() { return t; } @@ -206,6 +202,7 @@ public final class DelegatingIntroductionInterceptorTests { String company = "Interface21"; target.setCompany(company); TestBean delegate = new TestBean() { + @Override public ITestBean getSpouse() { return this; } @@ -250,6 +247,7 @@ public final class DelegatingIntroductionInterceptorTests { final long t = 1001L; @SuppressWarnings("serial") class TestII extends DelegatingIntroductionInterceptor implements TimeStamped { + @Override public long getTimeStamp() { return t; } @@ -278,6 +276,7 @@ public final class DelegatingIntroductionInterceptorTests { this.ts = ts; } + @Override public long getTimeStamp() { return ts; } @@ -292,6 +291,7 @@ public final class DelegatingIntroductionInterceptorTests { this.t = t; } + @Override public long getTimeStamp() { return t; } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java index ca4f8839c8..0848ab58a9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ package org.springframework.aop.support; */ public final class JdkRegexpMethodPointcutTests extends AbstractRegexpMethodPointcutTests { + @Override protected AbstractRegexpMethodPointcut getRegexpMethodPointcut() { return new JdkRegexpMethodPointcut(); } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index 4df8bcde48..5b3ceb039b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,9 +37,9 @@ public final class MethodMatchersTests { private final Method EXCEPTION_GETMESSAGE; private final Method ITESTBEAN_SETAGE; - + private final Method ITESTBEAN_GETAGE; - + private final Method IOTHER_ABSQUATULATE; public MethodMatchersTests() throws Exception { @@ -55,7 +55,7 @@ public final class MethodMatchersTests { assertTrue(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)); assertTrue(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)); } - + @Test public void testMethodMatcherTrueSerializable() throws Exception { assertSame(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE), MethodMatcher.TRUE); @@ -72,7 +72,7 @@ public final class MethodMatchersTests { assertFalse(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)); } - + @Test public void testDynamicAndStaticMethodMatcherIntersection() throws Exception { MethodMatcher mm1 = MethodMatcher.TRUE; @@ -87,13 +87,13 @@ public final class MethodMatchersTests { assertTrue("2Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class)); assertFalse("3 - not Matched setAge method", intersection.matches(ITESTBEAN_SETAGE, TestBean.class, new Object[] { new Integer(5) })); } - + @Test public void testStaticMethodMatcherUnion() throws Exception { MethodMatcher getterMatcher = new StartsWithMatcher("get"); MethodMatcher setterMatcher = new StartsWithMatcher("set"); MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher); - + assertFalse("Union is a static matcher", union.isRuntime()); assertTrue("Matched setAge method", union.matches(ITESTBEAN_SETAGE, TestBean.class)); assertTrue("Matched getAge method", union.matches(ITESTBEAN_GETAGE, TestBean.class)); @@ -107,6 +107,7 @@ public final class MethodMatchersTests { public StartsWithMatcher(String s) { this.prefix = s; } + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith(prefix); } @@ -114,12 +115,14 @@ public final class MethodMatchersTests { private static class TestDynamicMethodMatcherWhichMatches extends DynamicMethodMatcher { + @Override public boolean matches(Method m, Class targetClass, Object[] args) { return true; } } private static class TestDynamicMethodMatcherWhichDoesNotMatch extends DynamicMethodMatcher { + @Override public boolean matches(Method m, Class targetClass, Object[] args) { return false; } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 996d72f02f..8b89281e76 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,11 +34,11 @@ import test.util.SerializationTestUtils; * @author Chris Beams */ public final class NameMatchMethodPointcutTests { - + protected NameMatchMethodPointcut pc; - + protected Person proxied; - + protected SerializableNopInterceptor nop; /** @@ -52,7 +52,7 @@ public final class NameMatchMethodPointcutTests { pf.addAdvisor(new DefaultPointcutAdvisor(pc, nop)); proxied = (Person) pf.getProxy(); } - + @Test public void testMatchingOnly() { // Can't do exact matching through isMatch @@ -63,7 +63,7 @@ public final class NameMatchMethodPointcutTests { assertFalse(pc.isMatch("setName", "set")); assertTrue(pc.isMatch("testing", "*ing")); } - + @Test public void testEmpty() throws Throwable { assertEquals(0, nop.getCount()); @@ -72,8 +72,8 @@ public final class NameMatchMethodPointcutTests { proxied.echo(null); assertEquals(0, nop.getCount()); } - - + + @Test public void testMatchOneMethod() throws Throwable { pc.addMethodName("echo"); @@ -84,7 +84,7 @@ public final class NameMatchMethodPointcutTests { assertEquals(0, nop.getCount()); proxied.echo(null); assertEquals(1, nop.getCount()); - + proxied.setName(""); assertEquals(2, nop.getCount()); proxied.setAge(25); @@ -102,7 +102,7 @@ public final class NameMatchMethodPointcutTests { proxied.echo(null); assertEquals(2, nop.getCount()); } - + @Test public void testSerializable() throws Throwable { testSets(); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java index eb008c7f30..1ed7cd8430 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,12 +31,12 @@ import test.beans.TestBean; * @author Chris Beams */ public final class PointcutsTests { - + public static Method TEST_BEAN_SET_AGE; public static Method TEST_BEAN_GET_AGE; public static Method TEST_BEAN_GET_NAME; public static Method TEST_BEAN_ABSQUATULATE; - + static { try { TEST_BEAN_SET_AGE = TestBean.class.getMethod("setAge", new Class[] { int.class }); @@ -48,72 +48,81 @@ public final class PointcutsTests { throw new RuntimeException("Shouldn't happen: error in test suite"); } } - + /** * Matches only TestBean class, not subclasses */ public static Pointcut allTestBeanMethodsPointcut = new StaticMethodMatcherPointcut() { + @Override public ClassFilter getClassFilter() { return new ClassFilter() { + @Override public boolean matches(Class clazz) { return clazz.equals(TestBean.class); } }; } + @Override public boolean matches(Method m, Class targetClass) { return true; } }; - + public static Pointcut allClassSetterPointcut = Pointcuts.SETTERS; - + // Subclass used for matching public static class MyTestBean extends TestBean { } - + public static Pointcut myTestBeanSetterPointcut = new StaticMethodMatcherPointcut() { + @Override public ClassFilter getClassFilter() { return new RootClassFilter(MyTestBean.class); } + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("set"); } }; - + // Will match MyTestBeanSubclass public static Pointcut myTestBeanGetterPointcut = new StaticMethodMatcherPointcut() { + @Override public ClassFilter getClassFilter() { return new RootClassFilter(MyTestBean.class); } + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; - + // Still more specific class public static class MyTestBeanSubclass extends MyTestBean { } - + public static Pointcut myTestBeanSubclassGetterPointcut = new StaticMethodMatcherPointcut() { + @Override public ClassFilter getClassFilter() { return new RootClassFilter(MyTestBeanSubclass.class); } + @Override public boolean matches(Method m, Class targetClass) { return m.getName().startsWith("get"); } }; - + public static Pointcut allClassGetterPointcut = Pointcuts.GETTERS; - + public static Pointcut allClassGetAgePointcut = new NameMatchMethodPointcut().addMethodName("getAge"); - + public static Pointcut allClassGetNamePointcut = new NameMatchMethodPointcut().addMethodName("getName"); - - + + @Test public void testTrue() { assertTrue(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); @@ -133,7 +142,7 @@ public final class PointcutsTests { assertTrue(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null)); assertFalse(Pointcuts.matches(allClassGetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); } - + /** * Should match all setters and getters on any class */ @@ -144,7 +153,7 @@ public final class PointcutsTests { assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null)); assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); } - + @Test public void testUnionOfSpecificGetters() { Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut); @@ -153,7 +162,7 @@ public final class PointcutsTests { assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class, null)); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null)); assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); - + // Union with all setters union = Pointcuts.union(union, allClassSetterPointcut); assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); @@ -161,10 +170,10 @@ public final class PointcutsTests { assertFalse(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_NAME, TestBean.class, null)); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null)); assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); - + assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); } - + /** * Tests vertical composition. First pointcut matches all setters. * Second one matches all getters in the MyTestBean class. TestBean getters shouldn't pass. @@ -174,7 +183,7 @@ public final class PointcutsTests { assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); assertTrue(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)})); assertFalse(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null)); - + Pointcut union = Pointcuts.union(myTestBeanSetterPointcut, allClassGetterPointcut); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class, null)); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBean.class, null)); @@ -182,7 +191,7 @@ public final class PointcutsTests { assertTrue(Pointcuts.matches(union, TEST_BEAN_SET_AGE, MyTestBean.class, new Object[] { new Integer(6)})); assertFalse(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, new Object[] { new Integer(6)})); } - + /** * Intersection should be MyTestBean getAge() only: * it's the union of allClassGetAge and subclass getters @@ -195,7 +204,7 @@ public final class PointcutsTests { assertFalse(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, TestBean.class, null)); assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, MyTestBean.class, null)); assertTrue(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_AGE, MyTestBean.class, null)); - + Pointcut intersection = Pointcuts.intersection(allClassGetAgePointcut, myTestBeanGetterPointcut); assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null)); assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class, null)); @@ -204,7 +213,7 @@ public final class PointcutsTests { // Matches subclass of MyTestBean assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null)); assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null)); - + // Now intersection with MyTestBeanSubclass getters should eliminate MyTestBean target intersection = Pointcuts.intersection(intersection, myTestBeanSubclassGetterPointcut); assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, TestBean.class, null)); @@ -214,7 +223,7 @@ public final class PointcutsTests { // Still matches subclass of MyTestBean assertFalse(Pointcuts.matches(intersection, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null)); assertTrue(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null)); - + // Now union with all TestBean methods Pointcut union = Pointcuts.union(intersection, allTestBeanMethodsPointcut); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_NAME, TestBean.class, null)); @@ -224,12 +233,12 @@ public final class PointcutsTests { // Still matches subclass of MyTestBean assertFalse(Pointcuts.matches(union, TEST_BEAN_GET_NAME, MyTestBeanSubclass.class, null)); assertTrue(Pointcuts.matches(union, TEST_BEAN_GET_AGE, MyTestBeanSubclass.class, null)); - + assertTrue(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, TestBean.class, null)); assertFalse(Pointcuts.matches(union, TEST_BEAN_ABSQUATULATE, MyTestBean.class, null)); } - - + + /** * The intersection of these two pointcuts leaves nothing. */ diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index 8218e4d5db..e52d9b14e0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,18 +37,18 @@ import test.util.SerializationTestUtils; * @author Chris Beams */ public final class RegexpMethodPointcutAdvisorIntegrationTests { - + private static final Resource CONTEXT = qualifiedResource(RegexpMethodPointcutAdvisorIntegrationTests.class, "context.xml"); @Test public void testSinglePattern() throws Throwable { - BeanFactory bf = new XmlBeanFactory(CONTEXT); + BeanFactory bf = new XmlBeanFactory(CONTEXT); ITestBean advised = (ITestBean) bf.getBean("settersAdvised"); // Interceptor behind regexp advisor NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor"); assertEquals(0, nop.getCount()); - + int newAge = 12; // Not advised advised.exceptional(null); @@ -58,21 +58,21 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests { // Only setter fired assertEquals(1, nop.getCount()); } - + @Test public void testMultiplePatterns() throws Throwable { - BeanFactory bf = new XmlBeanFactory(CONTEXT); + BeanFactory bf = new XmlBeanFactory(CONTEXT); // This is a CGLIB proxy, so we can proxy it to the target class TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised"); // Interceptor behind regexp advisor NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor"); assertEquals(0, nop.getCount()); - + int newAge = 12; // Not advised advised.exceptional(null); assertEquals(0, nop.getCount()); - + // This is proxied advised.absquatulate(); assertEquals(1, nop.getCount()); @@ -81,21 +81,21 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests { // Only setter fired assertEquals(2, nop.getCount()); } - + @Test public void testSerialization() throws Throwable { - BeanFactory bf = new XmlBeanFactory(CONTEXT); + BeanFactory bf = new XmlBeanFactory(CONTEXT); // This is a CGLIB proxy, so we can proxy it to the target class Person p = (Person) bf.getBean("serializableSettersAdvised"); // Interceptor behind regexp advisor NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor"); assertEquals(0, nop.getCount()); - + int newAge = 12; // Not advised assertEquals(0, p.getAge()); assertEquals(0, nop.getCount()); - + // This is proxied p.setAge(newAge); assertEquals(1, nop.getCount()); @@ -103,7 +103,7 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests { assertEquals(newAge, p.getAge()); // Only setter fired assertEquals(2, nop.getCount()); - + // Serialize and continue... p = (Person) SerializationTestUtils.serializeAndDeserialize(p); assertEquals(newAge, p.getAge()); diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java index 69907b0f2f..e70d2c7baa 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPoolTargetSourceProxyTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import test.beans.ITestBean; * @since 2.0 */ public final class CommonsPoolTargetSourceProxyTests { - + private static final Resource CONTEXT = qualifiedResource(CommonsPoolTargetSourceProxyTests.class, "context.xml"); diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index 284c3ae561..b3d6ceef18 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,19 +40,19 @@ import test.util.SerializationTestUtils; * @author Chris Beams */ public final class HotSwappableTargetSourceTests { - + private static final Resource CONTEXT = qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"); /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; private XmlBeanFactory beanFactory; - + @Before public void setUp() throws Exception { this.beanFactory = new XmlBeanFactory(CONTEXT); } - + /** * We must simulate container shutdown, which should clear threads. */ @@ -72,42 +72,42 @@ public final class HotSwappableTargetSourceTests { assertEquals(INITIAL_COUNT, proxied.getCount() ); proxied.doWork(); assertEquals(INITIAL_COUNT + 1, proxied.getCount() ); - + proxied = (SideEffectBean) beanFactory.getBean("swappable"); proxied.doWork(); assertEquals(INITIAL_COUNT + 2, proxied.getCount() ); } - + @Test public void testValidSwaps() { SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1"); SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2"); - + SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable"); assertEquals(target1.getCount(), proxied.getCount() ); proxied.doWork(); assertEquals(INITIAL_COUNT + 1, proxied.getCount() ); - + HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper"); Object old = swapper.swap(target2); assertEquals("Correct old target was returned", target1, old); - + // TODO should be able to make this assertion: need to fix target handling // in AdvisedSupport //assertEquals(target2, ((Advised) proxied).getTarget()); - + assertEquals(20, proxied.getCount()); proxied.doWork(); assertEquals(21, target2.getCount()); - + // Swap it back swapper.swap(target1); assertEquals(target1.getCount(), proxied.getCount()); } - - + + /** - * + * * @param invalid * @return the message */ @@ -122,46 +122,46 @@ public final class HotSwappableTargetSourceTests { // Ok aopex = ex; } - + // It shouldn't be corrupted, it should still work testBasicFunctionality(); return aopex; } - + @Test public void testRejectsSwapToNull() { IllegalArgumentException ex = testRejectsSwapToInvalidValue(null); assertTrue(ex.getMessage().indexOf("null") != -1); } - + // TODO test reject swap to wrong interface or class? // how to decide what's valid? - - + + @Test public void testSerialization() throws Exception { SerializablePerson sp1 = new SerializablePerson(); sp1.setName("Tony"); SerializablePerson sp2 = new SerializablePerson(); sp1.setName("Gordon"); - + HotSwappableTargetSource hts = new HotSwappableTargetSource(sp1); ProxyFactory pf = new ProxyFactory(); pf.addInterface(Person.class); pf.setTargetSource(hts); pf.addAdvisor(new DefaultPointcutAdvisor(new SerializableNopInterceptor())); Person p = (Person) pf.getProxy(); - + assertEquals(sp1.getName(), p.getName()); hts.swap(sp2); assertEquals(sp2.getName(), p.getName()); - + p = (Person) SerializationTestUtils.serializeAndDeserialize(p); // We need to get a reference to the client-side targetsource hts = (HotSwappableTargetSource) ((Advised) p).getTargetSource(); assertEquals(sp2.getName(), p.getName()); hts.swap(sp1); assertEquals(sp1.getName(), p.getName()); - + } } diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java index d6dc8f426c..2a584f9a5c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,9 +32,11 @@ public final class LazyCreationTargetSourceTests { @Test public void testCreateLazy() { TargetSource targetSource = new AbstractLazyCreationTargetSource() { + @Override protected Object createObject() { return new InitCountingBean(); } + @Override public Class getTargetClass() { return InitCountingBean.class; } diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index b26fbb1e91..984261bcc9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,9 +34,9 @@ import test.beans.ITestBean; * @since 07.01.2005 */ public final class LazyInitTargetSourceTests { - + private static final Class CLASS = LazyInitTargetSourceTests.class; - + private static final Resource SINGLETON_CONTEXT = qualifiedResource(CLASS, "singleton.xml"); private static final Resource CUSTOM_TARGET_CONTEXT = qualifiedResource(CLASS, "customTarget.xml"); private static final Resource FACTORY_BEAN_CONTEXT = qualifiedResource(CLASS, "factoryBean.xml"); @@ -80,8 +80,10 @@ public final class LazyInitTargetSourceTests { } + @SuppressWarnings("serial") public static class CustomLazyInitTargetSource extends LazyInitTargetSource { + @Override protected void postProcessTargetObject(Object targetObject) { ((ITestBean) targetObject).setName("Rob Harrop"); } diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index 43ba8a211a..93205fb1b9 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,22 +59,26 @@ public final class PrototypeBasedTargetSourceTests { assertNotNull(sts.getTarget()); } - + private static class TestTargetSource extends AbstractPrototypeBasedTargetSource { - + + private static final long serialVersionUID = 1L; + /** * Nonserializable test field to check that subclass * state can't prevent serialization from working */ private TestBean thisFieldIsNotSerializable = new TestBean(); + @Override public Object getTarget() throws Exception { return newPrototypeInstance(); } + @Override public void releaseTarget(Object target) throws Exception { // Do nothing } } -} \ No newline at end of file +} diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index c5f0fa9d38..204f3d8abd 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,14 +33,14 @@ import test.beans.SideEffectBean; * @author Chris Beams */ public final class PrototypeTargetSourceTests { - + private static final Resource CONTEXT = qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"); - + /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; - + private BeanFactory beanFactory; - + @Before public void setUp() throws Exception { this.beanFactory = new XmlBeanFactory(CONTEXT); @@ -57,7 +57,7 @@ public final class PrototypeTargetSourceTests { assertEquals(INITIAL_COUNT, singleton.getCount() ); singleton.doWork(); assertEquals(INITIAL_COUNT + 1, singleton.getCount() ); - + SideEffectBean prototype = (SideEffectBean) beanFactory.getBean("prototype"); assertEquals(INITIAL_COUNT, prototype.getCount() ); prototype.doWork(); diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index bd79620b70..c896b9e638 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,26 +33,26 @@ import test.beans.SideEffectBean; * @author Chris Beams */ public class ThreadLocalTargetSourceTests { - + private static final Resource CONTEXT = qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"); /** Initial count value set in bean factory XML */ private static final int INITIAL_COUNT = 10; private XmlBeanFactory beanFactory; - + @Before public void setUp() throws Exception { this.beanFactory = new XmlBeanFactory(CONTEXT); } - + /** * We must simulate container shutdown, which should clear threads. */ protected void tearDown() { this.beanFactory.destroySingletons(); } - + /** * Check we can use two different ThreadLocalTargetSources * managing objects of different types without them interfering @@ -64,7 +64,7 @@ public class ThreadLocalTargetSourceTests { assertEquals(INITIAL_COUNT, apartment.getCount() ); apartment.doWork(); assertEquals(INITIAL_COUNT + 1, apartment.getCount() ); - + ITestBean test = (ITestBean) beanFactory.getBean("threadLocal2"); assertEquals("Rod", test.getName()); assertEquals("Kerry", test.getSpouse().getName()); @@ -76,11 +76,11 @@ public class ThreadLocalTargetSourceTests { assertEquals(INITIAL_COUNT, apartment.getCount() ); apartment.doWork(); assertEquals(INITIAL_COUNT + 1, apartment.getCount() ); - + apartment = (SideEffectBean) beanFactory.getBean("apartment"); assertEquals(INITIAL_COUNT + 1, apartment.getCount() ); } - + /** * Relies on introduction. */ @@ -101,7 +101,7 @@ public class ThreadLocalTargetSourceTests { // Only one thread so only one object can have been bound assertEquals(1, stats.getObjectCount()); } - + @Test public void testNewThreadHasOwnInstance() throws InterruptedException { SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment"); @@ -110,9 +110,10 @@ public class ThreadLocalTargetSourceTests { apartment.doWork(); apartment.doWork(); assertEquals(INITIAL_COUNT + 3, apartment.getCount() ); - + class Runner implements Runnable { public SideEffectBean mine; + @Override public void run() { this.mine = (SideEffectBean) beanFactory.getBean("apartment"); assertEquals(INITIAL_COUNT, mine.getCount() ); @@ -124,16 +125,16 @@ public class ThreadLocalTargetSourceTests { Thread t = new Thread(r); t.start(); t.join(); - + assertNotNull(r); - + // Check it didn't affect the other thread's copy assertEquals(INITIAL_COUNT + 3, apartment.getCount() ); - - // When we use other thread's copy in this thread + + // When we use other thread's copy in this thread // it should behave like ours assertEquals(INITIAL_COUNT + 3, r.mine.getCount() ); - + // Bound to two threads assertEquals(2, ((ThreadLocalTargetSourceStats) apartment).getObjectCount()); } diff --git a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java index ee0913a114..3010a4674d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -116,6 +116,7 @@ public final class RefreshableTargetSourceTests { this.requiresRefresh = requiresRefresh; } + @Override protected Object freshTarget() { this.callCount++; return new Object(); @@ -125,6 +126,7 @@ public final class RefreshableTargetSourceTests { return this.callCount; } + @Override protected boolean requiresRefresh() { return this.requiresRefresh; } diff --git a/spring-aop/src/test/java/test/aop/CountingBeforeAdvice.java b/spring-aop/src/test/java/test/aop/CountingBeforeAdvice.java index 7a7baa3ef2..91a49faa0f 100644 --- a/spring-aop/src/test/java/test/aop/CountingBeforeAdvice.java +++ b/spring-aop/src/test/java/test/aop/CountingBeforeAdvice.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.aop.MethodBeforeAdvice; @SuppressWarnings("serial") public class CountingBeforeAdvice extends MethodCounter implements MethodBeforeAdvice { + @Override public void before(Method m, Object[] args, Object target) throws Throwable { count(m); } diff --git a/spring-aop/src/test/java/test/aop/DefaultLockable.java b/spring-aop/src/test/java/test/aop/DefaultLockable.java index 42d6c73cb0..1fddaca9f1 100644 --- a/spring-aop/src/test/java/test/aop/DefaultLockable.java +++ b/spring-aop/src/test/java/test/aop/DefaultLockable.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,21 +18,24 @@ package test.aop; /** * Simple implementation of Lockable interface for use in mixins. - * + * * @author Rod Johnson */ public class DefaultLockable implements Lockable { private boolean locked; + @Override public void lock() { this.locked = true; } + @Override public void unlock() { this.locked = false; } + @Override public boolean locked() { return this.locked; } diff --git a/spring-aop/src/test/java/test/aop/Lockable.java b/spring-aop/src/test/java/test/aop/Lockable.java index 9427274567..039b06e8a7 100644 --- a/spring-aop/src/test/java/test/aop/Lockable.java +++ b/spring-aop/src/test/java/test/aop/Lockable.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,15 +19,15 @@ package test.aop; /** * Simple interface to use for mixins - * + * * @author Rod Johnson * */ public interface Lockable { - + void lock(); - + void unlock(); - + boolean locked(); } \ No newline at end of file diff --git a/spring-aop/src/test/java/test/aop/MethodCounter.java b/spring-aop/src/test/java/test/aop/MethodCounter.java index 9c5ed06e9a..ae673bd168 100644 --- a/spring-aop/src/test/java/test/aop/MethodCounter.java +++ b/spring-aop/src/test/java/test/aop/MethodCounter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.HashMap; /** * Abstract superclass for counting advices etc. - * + * * @author Rod Johnson * @author Chris Beams */ diff --git a/spring-aop/src/test/java/test/aop/NopInterceptor.java b/spring-aop/src/test/java/test/aop/NopInterceptor.java index 81bdd9e703..20b9ece08f 100644 --- a/spring-aop/src/test/java/test/aop/NopInterceptor.java +++ b/spring-aop/src/test/java/test/aop/NopInterceptor.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,21 +25,22 @@ import org.aopalliance.intercept.MethodInvocation; * @author Rod Johnson */ public class NopInterceptor implements MethodInterceptor { - + private int count; /** * @see org.aopalliance.intercept.MethodInterceptor#invoke(MethodInvocation) */ + @Override public Object invoke(MethodInvocation invocation) throws Throwable { increment(); return invocation.proceed(); } - + public int getCount() { return this.count; } - + protected void increment() { ++count; } diff --git a/spring-aop/src/test/java/test/aop/PerTargetAspect.java b/spring-aop/src/test/java/test/aop/PerTargetAspect.java index 2d373f17e7..3896f2dc7a 100644 --- a/spring-aop/src/test/java/test/aop/PerTargetAspect.java +++ b/spring-aop/src/test/java/test/aop/PerTargetAspect.java @@ -1,5 +1,5 @@ /** - * + * */ package test.aop; @@ -25,6 +25,7 @@ public class PerTargetAspect implements Ordered { ++count; } + @Override public int getOrder() { return this.order; } diff --git a/spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java b/spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java index ca425b81f6..064df39ab5 100644 --- a/spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java +++ b/spring-aop/src/test/java/test/aop/SerializableNopInterceptor.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,26 +23,28 @@ import java.io.Serializable; /** * Subclass of NopInterceptor that is serializable and * can be used to test proxy serialization. - * + * * @author Rod Johnson * @author Chris Beams */ @SuppressWarnings("serial") public class SerializableNopInterceptor extends NopInterceptor implements Serializable { - + /** * We must override this field and the related methods as * otherwise count won't be serialized from the non-serializable * NopInterceptor superclass. */ private int count; - + + @Override public int getCount() { return this.count; } - + + @Override protected void increment() { ++count; } - + } \ No newline at end of file diff --git a/spring-aop/src/test/java/test/beans/DerivedTestBean.java b/spring-aop/src/test/java/test/beans/DerivedTestBean.java index 8cb213cefe..225ae1a300 100644 --- a/spring-aop/src/test/java/test/beans/DerivedTestBean.java +++ b/spring-aop/src/test/java/test/beans/DerivedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,12 +51,14 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA } + @Override public void setBeanName(String beanName) { if (this.beanName == null || beanName == null) { this.beanName = beanName; } } + @Override public String getBeanName() { return beanName; } @@ -75,10 +77,12 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA } + @Override public void destroy() { this.destroyed = true; } + @Override public boolean wasDestroyed() { return destroyed; } diff --git a/spring-aop/src/test/java/test/beans/INestedTestBean.java b/spring-aop/src/test/java/test/beans/INestedTestBean.java index 228109c284..56c9d829ee 100644 --- a/spring-aop/src/test/java/test/beans/INestedTestBean.java +++ b/spring-aop/src/test/java/test/beans/INestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aop/src/test/java/test/beans/IOther.java b/spring-aop/src/test/java/test/beans/IOther.java index 734235aa06..f3c6263261 100644 --- a/spring-aop/src/test/java/test/beans/IOther.java +++ b/spring-aop/src/test/java/test/beans/IOther.java @@ -1,13 +1,13 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aop/src/test/java/test/beans/NestedTestBean.java b/spring-aop/src/test/java/test/beans/NestedTestBean.java index d3fde438b6..edc145ad7d 100644 --- a/spring-aop/src/test/java/test/beans/NestedTestBean.java +++ b/spring-aop/src/test/java/test/beans/NestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean { this.company = (company != null ? company : ""); } + @Override public String getCompany() { return company; } diff --git a/spring-aop/src/test/java/test/beans/Person.java b/spring-aop/src/test/java/test/beans/Person.java index d163756b4e..974d7d9b77 100644 --- a/spring-aop/src/test/java/test/beans/Person.java +++ b/spring-aop/src/test/java/test/beans/Person.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,19 @@ package test.beans; /** - * + * * @author Rod Johnson */ public interface Person { - + String getName(); void setName(String name); int getAge(); void setAge(int i); - - /** + + /** * Test for non-property method matching. - * If the parameter is a Throwable, it will be thrown rather than + * If the parameter is a Throwable, it will be thrown rather than * returned. */ Object echo(Object o) throws Throwable; diff --git a/spring-aop/src/test/java/test/beans/SerializablePerson.java b/spring-aop/src/test/java/test/beans/SerializablePerson.java index e0a1839c0c..3aa60f1fdc 100644 --- a/spring-aop/src/test/java/test/beans/SerializablePerson.java +++ b/spring-aop/src/test/java/test/beans/SerializablePerson.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,29 +31,34 @@ public class SerializablePerson implements Person, Serializable { private String name; private int age; + @Override public int getAge() { return age; } - + + @Override public void setAge(int age) { this.age = age; } - + + @Override public String getName() { return name; } - + + @Override public void setName(String name) { this.name = name; } - + + @Override public Object echo(Object o) throws Throwable { if (o instanceof Throwable) { throw (Throwable) o; } return o; } - + public boolean equals(Object other) { if (!(other instanceof SerializablePerson)) { return false; diff --git a/spring-aop/src/test/java/test/beans/SideEffectBean.java b/spring-aop/src/test/java/test/beans/SideEffectBean.java index ea8279e2c2..621ecbc3a2 100644 --- a/spring-aop/src/test/java/test/beans/SideEffectBean.java +++ b/spring-aop/src/test/java/test/beans/SideEffectBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,17 +22,17 @@ package test.beans; * @author Rod Johnson */ public class SideEffectBean { - + private int count; - + public void setCount(int count) { this.count = count; } - + public int getCount() { return this.count; } - + public void doWork() { ++count; } diff --git a/spring-aop/src/test/java/test/beans/TestBean.java b/spring-aop/src/test/java/test/beans/TestBean.java index 8f14fd61a2..3f50f93836 100644 --- a/spring-aop/src/test/java/test/beans/TestBean.java +++ b/spring-aop/src/test/java/test/beans/TestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -146,10 +146,12 @@ public class TestBean implements ITestBean, IOther, Comparable { return postProcessed; } + @Override public String getName() { return name; } + @Override public void setName(String name) { this.name = name; } @@ -165,10 +167,12 @@ public class TestBean implements ITestBean, IOther, Comparable { } } + @Override public int getAge() { return age; } + @Override public void setAge(int age) { this.age = age; } @@ -181,14 +185,17 @@ public class TestBean implements ITestBean, IOther, Comparable { this.jedi = jedi; } + @Override public ITestBean getSpouse() { return (spouses != null ? spouses[0] : null); } + @Override public void setSpouse(ITestBean spouse) { this.spouses = new ITestBean[] {spouse}; } + @Override public ITestBean[] getSpouses() { return spouses; } @@ -215,10 +222,12 @@ public class TestBean implements ITestBean, IOther, Comparable { this.country = country; } + @Override public String[] getStringArray() { return stringArray; } + @Override public void setStringArray(String[] stringArray) { this.stringArray = stringArray; } @@ -287,6 +296,7 @@ public class TestBean implements ITestBean, IOther, Comparable { this.someProperties = someProperties; } + @Override public INestedTestBean getDoctor() { return doctor; } @@ -295,6 +305,7 @@ public class TestBean implements ITestBean, IOther, Comparable { this.doctor = doctor; } + @Override public INestedTestBean getLawyer() { return lawyer; } @@ -347,18 +358,21 @@ public class TestBean implements ITestBean, IOther, Comparable { /** * @see ITestBean#exceptional(Throwable) */ + @Override public void exceptional(Throwable t) throws Throwable { if (t != null) { throw t; } } + @Override public void unreliableFileOperation() throws IOException { throw new IOException(); } /** * @see ITestBean#returnsThis() */ + @Override public Object returnsThis() { return this; } @@ -366,9 +380,11 @@ public class TestBean implements ITestBean, IOther, Comparable { /** * @see IOther#absquatulate() */ + @Override public void absquatulate() { } + @Override public int haveBirthday() { return age++; } @@ -398,6 +414,7 @@ public class TestBean implements ITestBean, IOther, Comparable { return this.age; } + @Override public int compareTo(Object other) { if (this.name != null && other instanceof TestBean) { return this.name.compareTo(((TestBean) other).getName()); diff --git a/spring-aop/src/test/java/test/beans/subpkg/DeepBean.java b/spring-aop/src/test/java/test/beans/subpkg/DeepBean.java index 7920111e2e..b18646f4d0 100644 --- a/spring-aop/src/test/java/test/beans/subpkg/DeepBean.java +++ b/spring-aop/src/test/java/test/beans/subpkg/DeepBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,9 +20,9 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; /** * Used for testing pointcut matching. - * + * * @see AspectJExpressionPointcutTests#testWithinRootAndSubpackages() - * + * * @author Chris Beams */ public class DeepBean { diff --git a/spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java b/spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java index 4d9355f616..5aa69c1fa8 100644 --- a/spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java +++ b/spring-aop/src/test/java/test/parsing/CollectingReaderEventListener.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { private final List imports = new LinkedList(); + @Override public void defaultsRegistered(DefaultsDefinition defaultsDefinition) { this.defaults.add(defaultsDefinition); } @@ -54,6 +55,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return Collections.unmodifiableList(this.defaults); } + @Override public void componentRegistered(ComponentDefinition componentDefinition) { this.componentDefinitions.put(componentDefinition.getName(), componentDefinition); } @@ -67,6 +69,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return collection.toArray(new ComponentDefinition[collection.size()]); } + @Override @SuppressWarnings("unchecked") public void aliasRegistered(AliasDefinition aliasDefinition) { List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName()); @@ -82,6 +85,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return aliases == null ? null : Collections.unmodifiableList(aliases); } + @Override public void importProcessed(ImportDefinition importDefinition) { this.imports.add(importDefinition); } diff --git a/spring-aop/src/test/java/test/util/SerializationTestUtils.java b/spring-aop/src/test/java/test/util/SerializationTestUtils.java index 74130ff343..e9bc9fee04 100644 --- a/spring-aop/src/test/java/test/util/SerializationTestUtils.java +++ b/spring-aop/src/test/java/test/util/SerializationTestUtils.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -63,7 +63,7 @@ public final class SerializationTestUtils { oos.flush(); baos.flush(); byte[] bytes = baos.toByteArray(); - + ByteArrayInputStream is = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(is); Object o2 = ois.readObject(); diff --git a/spring-aop/src/test/java/test/util/TestResourceUtils.java b/spring-aop/src/test/java/test/util/TestResourceUtils.java index bae2b829ac..b294c1b606 100644 --- a/spring-aop/src/test/java/test/util/TestResourceUtils.java +++ b/spring-aop/src/test/java/test/util/TestResourceUtils.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,12 +30,12 @@ public class TestResourceUtils { /** * Loads a {@link ClassPathResource} qualified by the simple name of clazz, * and relative to the package for clazz. - * + * *

    Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', * this method will return a ClassPathResource representing com/foo/BarTests-context.xml - * + * *

    Intended for use loading context configuration XML files within JUnit tests. - * + * * @param clazz * @param resourceSuffix */ diff --git a/spring-aop/src/test/java/test/util/TimeStamped.java b/spring-aop/src/test/java/test/util/TimeStamped.java index 052b56ff73..4fedb8998b 100644 --- a/spring-aop/src/test/java/test/util/TimeStamped.java +++ b/spring-aop/src/test/java/test/util/TimeStamped.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ package test.util; * @author Rod Johnson */ public interface TimeStamped { - + /** * Return the timestamp for this object. * @return long the timestamp for this object, diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerAspect.aj index 97fe1cb3ea..760cea9dc1 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + package org.springframework.beans.factory.aspectj; import org.aspectj.lang.annotation.SuppressAjWarnings; @@ -23,12 +23,12 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport; * Abstract superaspect for AspectJ aspects that can perform Dependency * Injection on objects, however they may be created. Define the beanCreation() * pointcut in subaspects. - * + * *

    Subaspects may also need a metadata resolution strategy, in the - * BeanWiringInfoResolver interface. The default implementation + * {@code BeanWiringInfoResolver} interface. The default implementation * looks for a bean with the same name as the FQN. This is the default name * of a bean in a Spring container if the id value is not supplied explicitly. - * + * * @author Rob Harrop * @author Rod Johnson * @author Adrian Colyer @@ -62,7 +62,7 @@ public abstract aspect AbstractBeanConfigurerAspect extends BeanConfigurerSuppor /** * The initialization of a new object. - * + * *

    WARNING: Although this pointcut is non-abstract for backwards * compatibility reasons, it is meant to be overridden to select * initialization of any configurable bean. diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj index 9008182f02..390e1dc989 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractDependencyInjectionAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.SuppressAjWarnings; /** * Abstract base aspect that can perform Dependency * Injection on objects, however they may be created. - * + * * @author Ramnivas Laddad * @since 2.5.2 */ @@ -29,26 +29,26 @@ public abstract aspect AbstractDependencyInjectionAspect { /** * Select construction join points for objects to inject dependencies */ - public abstract pointcut beanConstruction(Object bean); + public abstract pointcut beanConstruction(Object bean); /** * Select deserialization join points for objects to inject dependencies */ public abstract pointcut beanDeserialization(Object bean); - + /** * Select join points in a configurable bean */ public abstract pointcut inConfigurableBean(); - + /** * Select join points in beans to be configured prior to construction? * By default, use post-construction injection matching the default in the Configurable annotation. */ public pointcut preConstructionConfiguration() : if(false); - + /** - * Select the most-specific initialization join point + * Select the most-specific initialization join point * (most concrete class) for the initialization of an instance. */ public pointcut mostSpecificSubTypeConstruction() : @@ -58,25 +58,25 @@ public abstract aspect AbstractDependencyInjectionAspect { * Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection */ public abstract pointcut leastSpecificSuperTypeConstruction(); - + /** * Configure the bean */ public abstract void configureBean(Object bean); - - private pointcut preConstructionCondition() : + + private pointcut preConstructionCondition() : leastSpecificSuperTypeConstruction() && preConstructionConfiguration(); - + private pointcut postConstructionCondition() : mostSpecificSubTypeConstruction() && !preConstructionConfiguration(); - + /** * Pre-construction configuration. */ @SuppressAjWarnings("adviceDidNotMatch") - before(Object bean) : - beanConstruction(bean) && preConstructionCondition() && inConfigurableBean() { + before(Object bean) : + beanConstruction(bean) && preConstructionCondition() && inConfigurableBean() { configureBean(bean); } @@ -84,18 +84,18 @@ public abstract aspect AbstractDependencyInjectionAspect { * Post-construction configuration. */ @SuppressAjWarnings("adviceDidNotMatch") - after(Object bean) returning : + after(Object bean) returning : beanConstruction(bean) && postConstructionCondition() && inConfigurableBean() { configureBean(bean); } - + /** * Post-deserialization configuration. */ @SuppressAjWarnings("adviceDidNotMatch") - after(Object bean) returning : + after(Object bean) returning : beanDeserialization(bean) && inConfigurableBean() { configureBean(bean); } - + } diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj index 4ecd2923de..5cd0140d46 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -26,36 +26,36 @@ import java.io.Serializable; * upon deserialization. Subaspects need to simply provide definition for the configureBean() method. This * method may be implemented without relying on Spring container if so desired. *

    - *

    + *

    * There are two cases that needs to be handled: *

      - *
    1. Normal object creation via the 'new' operator: this is - * taken care of by advising initialization() join points.
    2. + *
    3. Normal object creation via the '{@code new}' operator: this is + * taken care of by advising {@code initialization()} join points.
    4. *
    5. Object creation through deserialization: since no constructor is * invoked during deserialization, the aspect needs to advise a method that a * deserialization mechanism is going to invoke. Ideally, we should not * require user classes to implement any specific method. This implies that * we need to introduce the chosen method. We should also handle the cases * where the chosen method is already implemented in classes (in which case, - * the user's implementation for that method should take precedence over the + * the user's implementation for that method should take precedence over the * introduced implementation). There are a few choices for the chosen method: *
        *
      • readObject(ObjectOutputStream): Java requires that the method must be - * private

        . Since aspects cannot introduce a private member, + * {@code private}. Since aspects cannot introduce a private member, * while preserving its name, this option is ruled out.
      • - *
      • readResolve(): Java doesn't pose any restriction on an access specifier. - * Problem solved! There is one (minor) limitation of this approach in - * that if a user class already has this method, that method must be - * public. However, this shouldn't be a big burden, since - * use cases that need classes to implement readResolve() (custom enums, + *
      • readResolve(): Java doesn't pose any restriction on an access specifier. + * Problem solved! There is one (minor) limitation of this approach in + * that if a user class already has this method, that method must be + * {@code public}. However, this shouldn't be a big burden, since + * use cases that need classes to implement readResolve() (custom enums, * for example) are unlikely to be marked as @Configurable, and - * in any case asking to make that method public should not + * in any case asking to make that method {@code public} should not * pose any undue burden.
      • *
      - * The minor collaboration needed by user classes (i.e., that the - * implementation of readResolve(), if any, must be - * public) can be lifted as well if we were to use an - * experimental feature in AspectJ - the hasmethod() PCD.
    6. + * The minor collaboration needed by user classes (i.e., that the + * implementation of {@code readResolve()}, if any, must be + * {@code public}) can be lifted as well if we were to use an + * experimental feature in AspectJ - the {@code hasmethod()} PCD. *
    *

    @@ -63,7 +63,7 @@ import java.io.Serializable; * is to use a 'declare parents' statement another aspect (a subaspect of this aspect would be a logical choice) * that declares the classes that need to be configured by supplying the {@link ConfigurableObject} interface. *

    - * + * * @author Ramnivas Laddad * @since 2.5.2 */ @@ -71,8 +71,8 @@ public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends /** * Select initialization join point as object construction */ - public pointcut beanConstruction(Object bean) : - initialization(ConfigurableObject+.new(..)) && this(bean); + public pointcut beanConstruction(Object bean) : + initialization(ConfigurableObject+.new(..)) && this(bean); /** * Select deserialization join point made available through ITDs for ConfigurableDeserializationSupport @@ -80,40 +80,40 @@ public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends public pointcut beanDeserialization(Object bean) : execution(Object ConfigurableDeserializationSupport+.readResolve()) && this(bean); - + public pointcut leastSpecificSuperTypeConstruction() : initialization(ConfigurableObject.new(..)); - - - + + + // Implementation to support re-injecting dependencies once an object is deserialized /** - * Declare any class implementing Serializable and ConfigurableObject as also implementing - * ConfigurableDeserializationSupport. This allows us to introduce the readResolve() + * Declare any class implementing Serializable and ConfigurableObject as also implementing + * ConfigurableDeserializationSupport. This allows us to introduce the readResolve() * method and select it with the beanDeserialization() pointcut. - * + * *

    Here is an improved version that uses the hasmethod() pointcut and lifts * even the minor requirement on user classes: * *

    declare parents: ConfigurableObject+ Serializable+
    -	 *		            && !hasmethod(Object readResolve() throws ObjectStreamException) 
    +	 *		            && !hasmethod(Object readResolve() throws ObjectStreamException)
     	 *		            implements ConfigurableDeserializationSupport;
     	 * 
    */ - declare parents: + declare parents: ConfigurableObject+ && Serializable+ implements ConfigurableDeserializationSupport; - + /** - * A marker interface to which the readResolve() is introduced. + * A marker interface to which the {@code readResolve()} is introduced. */ static interface ConfigurableDeserializationSupport extends Serializable { } - + /** - * Introduce the readResolve() method so that we can advise its + * Introduce the {@code readResolve()} method so that we can advise its * execution to configure the object. - * + * *

    Note if a method with the same signature already exists in a - * Serializable class of ConfigurableObject type, + * {@code Serializable} class of ConfigurableObject type, * that implementation will take precedence (a good thing, since we are * merely interested in an opportunity to detect deserialization.) */ diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj index f960287720..5313df9ed1 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport; * annotation to identify which classes need autowiring. * *

    The bean name to look up will be taken from the - * @Configurable annotation if specified, otherwise the + * {@code @Configurable} annotation if specified, otherwise the * default bean name to look up will be the FQN of the class being configured. * * @author Rod Johnson @@ -43,7 +43,7 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport; * @see org.springframework.beans.factory.annotation.Configurable * @see org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver */ -public aspect AnnotationBeanConfigurerAspect +public aspect AnnotationBeanConfigurerAspect extends AbstractInterfaceDrivenDependencyInjectionAspect implements BeanFactoryAware, InitializingBean, DisposableBean { @@ -51,7 +51,7 @@ public aspect AnnotationBeanConfigurerAspect public pointcut inConfigurableBean() : @this(Configurable); - public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*); + public pointcut preConstructionConfiguration() : preConstructionConfigurationSupport(*); declare parents: @Configurable * implements ConfigurableObject; @@ -80,10 +80,10 @@ public aspect AnnotationBeanConfigurerAspect private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction()); /* - * This declaration shouldn't be needed, + * This declaration shouldn't be needed, * except for an AspectJ bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=214559) */ - declare parents: @Configurable Serializable+ + declare parents: @Configurable Serializable+ implements ConfigurableDeserializationSupport; } diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/ConfigurableObject.java b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/ConfigurableObject.java index 13597f9a97..869b7a72d8 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/ConfigurableObject.java +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/ConfigurableObject.java @@ -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"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.springframework.beans.factory.aspectj; /** * Marker interface for domain object that need DI through aspects. - * + * * @author Ramnivas Laddad * @since 2.5 */ diff --git a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj index 82795313e7..351c11d7d9 100644 --- a/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/GenericInterfaceDrivenDependencyInjectionAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -17,38 +17,38 @@ package org.springframework.beans.factory.aspectj; /** * Generic-based dependency injection aspect. - *

    - * This aspect allows users to implement efficient, type-safe dependency injection without + *

    + * This aspect allows users to implement efficient, type-safe dependency injection without * the use of the @Configurable annotation. - * - * The subaspect of this aspect doesn't need to include any AOP constructs. - * For example, here is a subaspect that configures the PricingStrategyClient objects. + * + * The subaspect of this aspect doesn't need to include any AOP constructs. + * For example, here is a subaspect that configures the {@code PricingStrategyClient} objects. *

    - * aspect PricingStrategyDependencyInjectionAspect 
    + * aspect PricingStrategyDependencyInjectionAspect
      *        extends GenericInterfaceDrivenDependencyInjectionAspect {
      *     private PricingStrategy pricingStrategy;
    - *     
    - *     public void configure(PricingStrategyClient bean) { 
    - *         bean.setPricingStrategy(pricingStrategy); 
    + *
    + *     public void configure(PricingStrategyClient bean) {
    + *         bean.setPricingStrategy(pricingStrategy);
    + *     }
    + *
    + *     public void setPricingStrategy(PricingStrategy pricingStrategy) {
    + *         this.pricingStrategy = pricingStrategy;
      *     }
    - *     
    - *     public void setPricingStrategy(PricingStrategy pricingStrategy) { 
    - *         this.pricingStrategy = pricingStrategy; 
    - *     } 
      * }
      * 
    * @author Ramnivas Laddad * @since 3.0.0 */ public abstract aspect GenericInterfaceDrivenDependencyInjectionAspect extends AbstractInterfaceDrivenDependencyInjectionAspect { - declare parents: I implements ConfigurableObject; - + declare parents: I implements ConfigurableObject; + public pointcut inConfigurableBean() : within(I+); - + public final void configureBean(Object bean) { configure((I)bean); } - - // Unfortunately, erasure used with generics won't allow to use the same named method + + // Unfortunately, erasure used with generics won't allow to use the same named method protected abstract void configure(I bean); } diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AbstractCacheAspect.aj b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AbstractCacheAspect.aj index ccd9472516..a9a6da82e9 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AbstractCacheAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AbstractCacheAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public abstract aspect AbstractCacheAspect extends CacheAspectSupport { } }; - return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs()); + return execute(aspectJInvoker, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs()); } /** diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnnotationCacheAspect.aj b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnnotationCacheAspect.aj index 0687b3c54c..be3957a3a0 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnnotationCacheAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnnotationCacheAspect.aj @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AspectJCachingConfiguration.java b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AspectJCachingConfiguration.java index ec6bda35eb..740ddaddca 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AspectJCachingConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AspectJCachingConfiguration.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/main/java/org/springframework/mock/staticmock/AbstractMethodMockingControl.aj b/spring-aspects/src/main/java/org/springframework/mock/staticmock/AbstractMethodMockingControl.aj index 6ca2bd728c..e373607d55 100644 --- a/spring-aspects/src/main/java/org/springframework/mock/staticmock/AbstractMethodMockingControl.aj +++ b/spring-aspects/src/main/java/org/springframework/mock/staticmock/AbstractMethodMockingControl.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ import java.util.List; /** * Abstract aspect to enable mocking of methods picked out by a pointcut. * Sub-aspects must define the mockStaticsTestMethod() pointcut to - * indicate call stacks when mocking should be triggered, and the + * indicate call stacks when mocking should be triggered, and the * methodToMock() pointcut to pick out a method invocations to mock. - * + * * @author Rod Johnson * @author Ramnivas Laddad */ @@ -42,7 +42,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth // Represents a list of expected calls to static entity methods // Public to allow inserted code to access: is this normal?? public class Expectations { - + // Represents an expected call to a static entity method private class Call { private final String signature; @@ -50,21 +50,21 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth private Object responseObject; // return value or throwable private CallResponse responseType = CallResponse.nothing; - + public Call(String name, Object[] args) { this.signature = name; this.args = args; } - + public boolean hasResponseSpecified() { return responseType != CallResponse.nothing; } - + public void setReturnVal(Object retVal) { this.responseObject = retVal; responseType = CallResponse.return_; } - + public void setThrow(Throwable throwable) { this.responseObject = throwable; responseType = CallResponse.throw_; @@ -89,7 +89,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth } } } - + private List calls = new LinkedList(); // Calls already verified @@ -101,12 +101,12 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth + " calls, received " + verified); } } - + /** * Validate the call and provide the expected return value * @param lastSig * @param args - * @return + * @return the return value */ public Object respond(String lastSig, Object[] args) { Call call = nextCall(); @@ -114,7 +114,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth if (responseType == CallResponse.return_) { return call.returnValue(lastSig, args); } else if(responseType == CallResponse.throw_) { - return (RuntimeException)call.throwException(lastSig, args); + return call.throwException(lastSig, args); } else if(responseType == CallResponse.nothing) { // do nothing } @@ -175,7 +175,7 @@ public abstract aspect AbstractMethodMockingControl percflow(mockStaticsTestMeth return expectations.respond(thisJoinPointStaticPart.toLongString(), thisJoinPoint.getArgs()); } } - + public void expectReturnInternal(Object retVal) { if (!recording) { throw new IllegalStateException("Not recording: Cannot set return value"); diff --git a/spring-aspects/src/main/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj b/spring-aspects/src/main/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj index 1c35a47e97..1c50c64bbe 100644 --- a/spring-aspects/src/main/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj +++ b/spring-aspects/src/main/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControl.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -18,16 +18,16 @@ package org.springframework.mock.staticmock; /** * Annotation-based aspect to use in test build to enable mocking static methods - * on JPA-annotated @Entity classes, as used by Roo for finders. + * on JPA-annotated {@code @Entity} classes, as used by Roo for finders. * - *

    Mocking will occur in the call stack of any method in a class (typically a test class) - * that is annotated with the @MockStaticEntityMethods annotation. + *

    Mocking will occur in the call stack of any method in a class (typically a test class) + * that is annotated with the @MockStaticEntityMethods annotation. * *

    Also provides static methods to simplify the programming model for * entering playback mode and setting expected return values. * *

    Usage: - *

      + *
        *
      1. Annotate a test class with @MockStaticEntityMethods. *
      2. In each test method, AnnotationDrivenStaticEntityMockingControl will begin in recording mode. * Invoke static methods on Entity classes, with each recording-mode invocation @@ -37,20 +37,20 @@ package org.springframework.mock.staticmock; *
      3. Call the code you wish to test that uses the static methods. Verification will * occur automatically. *
      - * + * * @author Rod Johnson * @author Ramnivas Laddad * @see MockStaticEntityMethods */ public aspect AnnotationDrivenStaticEntityMockingControl extends AbstractMethodMockingControl { - + /** * Stop recording mock calls and enter playback state */ public static void playback() { AnnotationDrivenStaticEntityMockingControl.aspectOf().playbackInternal(); } - + public static void expectReturn(Object retVal) { AnnotationDrivenStaticEntityMockingControl.aspectOf().expectReturnInternal(retVal); } diff --git a/spring-aspects/src/main/java/org/springframework/mock/staticmock/MockStaticEntityMethods.java b/spring-aspects/src/main/java/org/springframework/mock/staticmock/MockStaticEntityMethods.java index 07aee0364a..913d147b3e 100644 --- a/spring-aspects/src/main/java/org/springframework/mock/staticmock/MockStaticEntityMethods.java +++ b/spring-aspects/src/main/java/org/springframework/mock/staticmock/MockStaticEntityMethods.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.mock.staticmock; import java.lang.annotation.ElementType; diff --git a/spring-aspects/src/main/java/org/springframework/orm/jpa/aspectj/JpaExceptionTranslatorAspect.aj b/spring-aspects/src/main/java/org/springframework/orm/jpa/aspectj/JpaExceptionTranslatorAspect.aj index 6ff44249d0..3594725aae 100644 --- a/spring-aspects/src/main/java/org/springframework/orm/jpa/aspectj/JpaExceptionTranslatorAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/orm/jpa/aspectj/JpaExceptionTranslatorAspect.aj @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.orm.jpa.aspectj; import javax.persistence.EntityManager; @@ -9,14 +25,14 @@ import org.springframework.dao.DataAccessException; import org.springframework.orm.jpa.EntityManagerFactoryUtils; public aspect JpaExceptionTranslatorAspect { - pointcut entityManagerCall(): call(* EntityManager.*(..)) || call(* EntityManagerFactory.*(..)) || call(* EntityTransaction.*(..)) || call(* Query.*(..)); - - after() throwing(RuntimeException re): entityManagerCall() { - DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(re); - if (dex != null) { - throw dex; - } else { - throw re; - } - } -} \ No newline at end of file + pointcut entityManagerCall(): call(* EntityManager.*(..)) || call(* EntityManagerFactory.*(..)) || call(* EntityTransaction.*(..)) || call(* Query.*(..)); + + after() throwing(RuntimeException re): entityManagerCall() { + DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(re); + if (dex != null) { + throw dex; + } else { + throw re; + } + } +} diff --git a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj index c8abf4a729..a64def7ed1 100644 --- a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AbstractAsyncExecutionAspect.aj @@ -28,7 +28,7 @@ import org.springframework.core.task.AsyncTaskExecutor; /** * Abstract aspect that routes selected methods asynchronously. * - *

      This aspect needs to be injected with an implementation of + *

      This aspect needs to be injected with an implementation of * {@link Executor} to activate it for a specific thread pool. * Otherwise it will simply delegate all calls synchronously. * diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AbstractTransactionAspect.aj b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AbstractTransactionAspect.aj index c1b23c1bcb..ed0956ef9f 100644 --- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AbstractTransactionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AbstractTransactionAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.transaction.interceptor.TransactionAttributeSource; /** * Abstract superaspect for AspectJ transaction aspects. Concrete - * subaspects will implement the transactionalMethodExecution() + * subaspects will implement the {@code transactionalMethodExecution()} * pointcut using a strategy such as Java 5 annotations. * *

      Suitable for use inside or outside the Spring IoC container. @@ -66,7 +66,7 @@ public abstract aspect AbstractTransactionAspect extends TransactionAspectSuppor @SuppressAjWarnings("adviceDidNotMatch") after(Object txObject) throwing(Throwable t) : transactionalMethodExecution(txObject) { try { - completeTransactionAfterThrowing(TransactionAspectSupport.currentTransactionInfo(), t); + completeTransactionAfterThrowing(TransactionAspectSupport.currentTransactionInfo(), t); } catch (Throwable t2) { logger.error("Failed to close transaction after throwing in a transactional method", t2); diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj index f4b3109034..1fe8de9030 100644 --- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -21,17 +21,17 @@ import org.springframework.transaction.annotation.Transactional; /** * Concrete AspectJ transaction aspect using Spring's @Transactional annotation. - * + * *

      When using this aspect, you must annotate the implementation class * (and/or methods within that class), not the interface (if any) that - * the class implements. AspectJ follows Java's rule that annotations on + * the class implements. AspectJ follows Java's rule that annotations on * interfaces are not inherited. * *

      An @Transactional annotation on a class specifies the default transaction * semantics for the execution of any public operation in the class. * *

      An @Transactional annotation on a method within the class overrides the - * default transaction semantics given by the class annotation (if present). + * default transaction semantics given by the class annotation (if present). * Any method may be annotated (regardless of visibility). * Annotating non-public methods directly is the only way * to get transaction demarcation for the execution of such operations. @@ -57,7 +57,7 @@ public aspect AnnotationTransactionAspect extends AbstractTransactionAspect { execution(public * ((@Transactional *)+).*(..)) && within(@Transactional *); /** - * Matches the execution of any method with the + * Matches the execution of any method with the * Transactional annotation. */ private pointcut executionOfTransactionalMethod() : @@ -66,7 +66,7 @@ public aspect AnnotationTransactionAspect extends AbstractTransactionAspect { /** * Definition of pointcut from super aspect - matched join points * will have Spring transaction management applied. - */ + */ protected pointcut transactionalMethodExecution(Object txObject) : (executionOfAnyPublicMethodInAtTransactionalType() || executionOfTransactionalMethod() ) diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java index 54c30a1af0..582de64462 100644 --- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AspectJTransactionManagementConfiguration.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java index 2dd6faa417..e6f8cb8459 100644 --- a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import junit.framework.TestCase; public class AutoProxyWithCodeStyleAspectsTests extends TestCase { public void testNoAutoproxyingOfAjcCompiledAspects() { - new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/autoproxy/ajcAutoproxyTests.xml"); + new ClassPathXmlApplicationContext("org/springframework/aop/aspectj/autoproxy/ajcAutoproxyTests.xml"); } - + } diff --git a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj index 374bc00909..0758d3a403 100644 --- a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj +++ b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/CodeStyleAspect.aj @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/beans/Colour.java b/spring-aspects/src/test/java/org/springframework/beans/Colour.java index 60dc333e0b..a992a2ebfc 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/Colour.java +++ b/spring-aspects/src/test/java/org/springframework/beans/Colour.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum; /** * @author Rob Harrop */ +@SuppressWarnings("serial") public class Colour extends ShortCodedLabeledEnum { public static final Colour RED = new Colour(0, "RED"); @@ -32,4 +33,4 @@ public class Colour extends ShortCodedLabeledEnum { super(code, label); } -} \ No newline at end of file +} diff --git a/spring-aspects/src/test/java/org/springframework/beans/DerivedTestBean.java b/spring-aspects/src/test/java/org/springframework/beans/DerivedTestBean.java index 2bb41a9d5b..a10846ba95 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/DerivedTestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/DerivedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.beans.factory.DisposableBean; * @author Juergen Hoeller * @since 21.08.2003 */ +@SuppressWarnings("serial") public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean { private String beanName; @@ -82,4 +83,4 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA return destroyed; } -} \ No newline at end of file +} diff --git a/spring-aspects/src/test/java/org/springframework/beans/INestedTestBean.java b/spring-aspects/src/test/java/org/springframework/beans/INestedTestBean.java index 7d87547b5f..e0ae5f20a3 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/INestedTestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/INestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aspects/src/test/java/org/springframework/beans/IOther.java b/spring-aspects/src/test/java/org/springframework/beans/IOther.java index 797486ec44..d7fb346185 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/IOther.java +++ b/spring-aspects/src/test/java/org/springframework/beans/IOther.java @@ -1,13 +1,13 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aspects/src/test/java/org/springframework/beans/ITestBean.java b/spring-aspects/src/test/java/org/springframework/beans/ITestBean.java index cdf5ef510d..478999c05d 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/ITestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/ITestBean.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/beans/IndexedTestBean.java b/spring-aspects/src/test/java/org/springframework/beans/IndexedTestBean.java index ddb091770e..d7af36ed64 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/IndexedTestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/IndexedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/beans/NestedTestBean.java b/spring-aspects/src/test/java/org/springframework/beans/NestedTestBean.java index a06e15d150..88b450b917 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/NestedTestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/NestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-aspects/src/test/java/org/springframework/beans/TestBean.java b/spring-aspects/src/test/java/org/springframework/beans/TestBean.java index 7842bbfeac..ac8e5ea485 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/TestBean.java +++ b/spring-aspects/src/test/java/org/springframework/beans/TestBean.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerTests.java index c3f6386fe6..73f37a8f9e 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/AbstractBeanConfigurerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -248,6 +248,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { @Configurable("beanOne") + @SuppressWarnings("serial") protected static class ShouldBeConfiguredBySpring implements Serializable { private String name; @@ -263,6 +264,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { @Configurable("beanOne") + @SuppressWarnings("serial") private static class ShouldBeConfiguredBySpringContainsPublicReadResolve implements Serializable { private String name; @@ -317,6 +319,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { } + @SuppressWarnings("serial") private static class SerializableThatShouldNotBeConfiguredBySpring implements Serializable { private String name; @@ -444,6 +447,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { } @Configurable + @SuppressWarnings("serial") private static class BaseSerializableBean implements Serializable { public int setterCount; @@ -457,6 +461,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { } + @SuppressWarnings("serial") private static class SubSerializableBean extends BaseSerializableBean { } @@ -551,6 +556,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { } } + @SuppressWarnings("serial") public static class Order implements MailSenderClient, Serializable { private transient MailSender mailSender; @@ -577,6 +583,7 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { } @Configurable + @SuppressWarnings("serial") private static class PreOrPostConstructionConfiguredBean implements Serializable { private transient String name; protected transient boolean preConstructionConfigured; @@ -597,11 +604,13 @@ public abstract class AbstractBeanConfigurerTests extends TestCase { @Configurable(preConstruction=true) + @SuppressWarnings("serial") public static class PreConstructionConfiguredBean extends PreOrPostConstructionConfiguredBean { } @Configurable(preConstruction=false) + @SuppressWarnings("serial") private static class PostConstructionConfiguredBean extends PreOrPostConstructionConfiguredBean { } diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java index 16e2522d93..1c678ba6b1 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java index 47d3fef664..c5cc835a3d 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractAnnotationTest.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractAnnotationTest.java index b3f9d4937b..3771a21b9f 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractAnnotationTest.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AbstractAnnotationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTest.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTest.java index 81a7793fc8..df23767475 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTest.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java index a6d1b4f7bd..52a1b4265e 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedClassCacheableService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java index cdcb73b2cb..81dd758d19 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/CacheableService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.springframework.cache.config; /** * Basic service interface. - * + * * @author Costin Leau */ public interface CacheableService { diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java b/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java index e8938a804e..95edbcd9d6 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/DefaultCacheableService.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.cache.annotation.Caching; /** * Simple cacheable service - * + * * @author Costin Leau */ public class DefaultCacheableService implements CacheableService { diff --git a/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java b/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java index 13364bdbd1..b4cc29458b 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java +++ b/spring-aspects/src/test/java/org/springframework/cache/config/SomeKeyGenerator.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java b/spring-aspects/src/test/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java index e33e3aa3f3..8c1584fc99 100644 --- a/spring-aspects/src/test/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java +++ b/spring-aspects/src/test/java/org/springframework/mock/staticmock/AnnotationDrivenStaticEntityMockingControlTest.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest { playback(); Assert.assertEquals(expectedCount, Person.countPeople()); } - + @Test(expected=PersistenceException.class) public void testNoArgThrows() { Person.countPeople(); @@ -64,7 +64,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest { Assert.assertEquals(found, Person.findPerson(id)); } - + @Test public void testLongSeriesOfCalls() { long id1 = 13; @@ -80,7 +80,7 @@ public class AnnotationDrivenStaticEntityMockingControlTest { Person.countPeople(); expectReturn(0); playback(); - + Assert.assertEquals(found1, Person.findPerson(id1)); Assert.assertEquals(found2, Person.findPerson(id2)); Assert.assertEquals(found1, Person.findPerson(id1)); @@ -122,22 +122,22 @@ public class AnnotationDrivenStaticEntityMockingControlTest { public void testRejectUnexpectedCall() { new Delegate().rejectUnexpectedCall(); } - + @Test(expected=IllegalStateException.class) public void testFailTooFewCalls() { new Delegate().failTooFewCalls(); } - + @Test public void testEmpty() { // Test that verification check doesn't blow up if no replay() call happened } - + @Test(expected=IllegalStateException.class) public void testDoesntEverReplay() { new Delegate().doesntEverReplay(); } - + @Test(expected=IllegalStateException.class) public void testDoesntEverSetReturn() { new Delegate().doesntEverSetReturn(); diff --git a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java index c99dfe0c2e..ad9bac5443 100644 --- a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java +++ b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Delegate.java @@ -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"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class Delegate { AnnotationDrivenStaticEntityMockingControl.playback(); Assert.assertEquals(found, Person.findPerson(id + 1)); } - + @Test public void failTooFewCalls() { long id = 13; @@ -69,7 +69,7 @@ public class Delegate { public void doesntEverReplay() { Person.countPeople(); } - + @Test public void doesntEverSetReturn() { Person.countPeople(); @@ -81,7 +81,7 @@ public class Delegate { AnnotationDrivenStaticEntityMockingControl.playback(); Person.countPeople(); } - + @Test(expected=RemoteException.class) public void testVerificationFailsEvenWhenTestFailsInExpectedManner() throws RemoteException { Person.countPeople(); diff --git a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person.java b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person.java index a3b15c59c6..ca98b77f92 100644 --- a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person.java +++ b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person_Roo_Entity.aj b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person_Roo_Entity.aj index 4d30f14376..a6a62cdbb6 100644 --- a/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person_Roo_Entity.aj +++ b/spring-aspects/src/test/java/org/springframework/mock/staticmock/Person_Roo_Entity.aj @@ -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"); * you may not use this file except in compliance with the License. @@ -17,84 +17,84 @@ package org.springframework.mock.staticmock; privileged aspect Person_Roo_Entity { - - @javax.persistence.PersistenceContext - transient javax.persistence.EntityManager Person.entityManager; - - @javax.persistence.Id - @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) - @javax.persistence.Column(name = "id") - private java.lang.Long Person.id; - - @javax.persistence.Version - @javax.persistence.Column(name = "version") - private java.lang.Integer Person.version; - - public java.lang.Long Person.getId() { - return this.id; - } - - public void Person.setId(java.lang.Long id) { - this.id = id; - } - - public java.lang.Integer Person.getVersion() { - return this.version; - } - - public void Person.setVersion(java.lang.Integer version) { - this.version = version; - } - - @org.springframework.transaction.annotation.Transactional - public void Person.persist() { - if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - this.entityManager.persist(this); - } - - @org.springframework.transaction.annotation.Transactional - public void Person.remove() { - if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - this.entityManager.remove(this); - } - - @org.springframework.transaction.annotation.Transactional - public void Person.flush() { - if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - this.entityManager.flush(); - } - - @org.springframework.transaction.annotation.Transactional - public void Person.merge() { - if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - Person merged = this.entityManager.merge(this); - this.entityManager.flush(); - this.id = merged.getId(); - } - - public static long Person.countPeople() { - javax.persistence.EntityManager em = new Person().entityManager; - if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - return (Long) em.createQuery("select count(o) from Person o").getSingleResult(); - } - - public static java.util.List Person.findAllPeople() { - javax.persistence.EntityManager em = new Person().entityManager; - if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - return em.createQuery("select o from Person o").getResultList(); - } - - public static Person Person.findPerson(java.lang.Long id) { - if (id == null) throw new IllegalArgumentException("An identifier is required to retrieve an instance of Person"); - javax.persistence.EntityManager em = new Person().entityManager; - if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - return em.find(Person.class, id); - } - - public static java.util.List Person.findPersonEntries(int firstResult, int maxResults) { - javax.persistence.EntityManager em = new Person().entityManager; - if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); - return em.createQuery("select o from Person o").setFirstResult(firstResult).setMaxResults(maxResults).getResultList(); - } - + + @javax.persistence.PersistenceContext + transient javax.persistence.EntityManager Person.entityManager; + + @javax.persistence.Id + @javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) + @javax.persistence.Column(name = "id") + private java.lang.Long Person.id; + + @javax.persistence.Version + @javax.persistence.Column(name = "version") + private java.lang.Integer Person.version; + + public java.lang.Long Person.getId() { + return this.id; + } + + public void Person.setId(java.lang.Long id) { + this.id = id; + } + + public java.lang.Integer Person.getVersion() { + return this.version; + } + + public void Person.setVersion(java.lang.Integer version) { + this.version = version; + } + + @org.springframework.transaction.annotation.Transactional + public void Person.persist() { + if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + this.entityManager.persist(this); + } + + @org.springframework.transaction.annotation.Transactional + public void Person.remove() { + if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + this.entityManager.remove(this); + } + + @org.springframework.transaction.annotation.Transactional + public void Person.flush() { + if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + this.entityManager.flush(); + } + + @org.springframework.transaction.annotation.Transactional + public void Person.merge() { + if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + Person merged = this.entityManager.merge(this); + this.entityManager.flush(); + this.id = merged.getId(); + } + + public static long Person.countPeople() { + javax.persistence.EntityManager em = new Person().entityManager; + if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + return (Long) em.createQuery("select count(o) from Person o").getSingleResult(); + } + + public static java.util.List Person.findAllPeople() { + javax.persistence.EntityManager em = new Person().entityManager; + if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + return em.createQuery("select o from Person o").getResultList(); + } + + public static Person Person.findPerson(java.lang.Long id) { + if (id == null) throw new IllegalArgumentException("An identifier is required to retrieve an instance of Person"); + javax.persistence.EntityManager em = new Person().entityManager; + if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + return em.find(Person.class, id); + } + + public static java.util.List Person.findPersonEntries(int firstResult, int maxResults) { + javax.persistence.EntityManager em = new Person().entityManager; + if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); + return em.createQuery("select o from Person o").setFirstResult(firstResult).setMaxResults(maxResults).getResultList(); + } + } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java b/spring-aspects/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java index d5c2531fbd..969cf90a8f 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/CallCountingTransactionManager.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.transaction.support.DefaultTransactionStatus; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class CallCountingTransactionManager extends AbstractPlatformTransactionManager { public TransactionDefinition lastDefinition; @@ -50,7 +51,7 @@ public class CallCountingTransactionManager extends AbstractPlatformTransactionM ++rollbacks; --inflight; } - + public void clear() { begun = commits = rollbacks = inflight = 0; } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithPrivateAnnotatedMember.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithPrivateAnnotatedMember.java index 6351d55d0d..938265b97c 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithPrivateAnnotatedMember.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithPrivateAnnotatedMember.java @@ -1,19 +1,17 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * Created on 11 Sep 2006 by Adrian Colyer */ package org.springframework.transaction.aspectj; @@ -28,7 +26,7 @@ public class ClassWithPrivateAnnotatedMember { public void doSomething() { doInTransaction(); } - + @Transactional private void doInTransaction() {} } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithProtectedAnnotatedMember.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithProtectedAnnotatedMember.java index f681c81e84..07abf06c64 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithProtectedAnnotatedMember.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ClassWithProtectedAnnotatedMember.java @@ -1,19 +1,17 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * Created on 11 Sep 2006 by Adrian Colyer */ package org.springframework.transaction.aspectj; @@ -28,7 +26,7 @@ public class ClassWithProtectedAnnotatedMember { public void doSomething() { doInTransaction(); } - + @Transactional protected void doInTransaction() {} } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ITransactional.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ITransactional.java index 19a115ea21..44c3ea36b3 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ITransactional.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/ITransactional.java @@ -1,10 +1,26 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.transaction.aspectj; import org.springframework.transaction.annotation.Transactional; @Transactional public interface ITransactional { - + Object echo(Throwable t) throws Throwable; } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/MethodAnnotationOnClassWithNoInterface.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/MethodAnnotationOnClassWithNoInterface.java index 22cc31ebc6..3631b05550 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/MethodAnnotationOnClassWithNoInterface.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/MethodAnnotationOnClassWithNoInterface.java @@ -1,9 +1,25 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.transaction.aspectj; import org.springframework.transaction.annotation.Transactional; public class MethodAnnotationOnClassWithNoInterface { - + @Transactional(rollbackFor=InterruptedException.class) public Object echo(Throwable t) throws Throwable { if (t != null) { @@ -11,9 +27,9 @@ public class MethodAnnotationOnClassWithNoInterface { } return t; } - + public void noTransactionAttribute() { - + } } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java index 9449b2bcf7..be562b2585 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,17 +31,17 @@ import org.springframework.transaction.interceptor.TransactionAttribute; * @author Ramnivas Laddad */ public class TransactionAspectTests extends AbstractDependencyInjectionSpringContextTests { - + private TransactionAspectSupport transactionAspect; - + private CallCountingTransactionManager txManager; - + private TransactionalAnnotationOnlyOnClassWithNoInterface annotationOnlyOnClassWithNoInterface; - + private ClassWithProtectedAnnotatedMember beanWithAnnotatedProtectedMethod; private ClassWithPrivateAnnotatedMember beanWithAnnotatedPrivateMethod; - + private MethodAnnotationOnClassWithNoInterface methodAnnotationOnly = new MethodAnnotationOnClassWithNoInterface(); @@ -49,7 +49,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon TransactionalAnnotationOnlyOnClassWithNoInterface annotationOnlyOnClassWithNoInterface) { this.annotationOnlyOnClassWithNoInterface = annotationOnlyOnClassWithNoInterface; } - + public void setClassWithAnnotatedProtectedMethod(ClassWithProtectedAnnotatedMember aBean) { this.beanWithAnnotatedProtectedMethod = aBean; } @@ -84,14 +84,14 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon txManager.clear(); assertEquals(0, txManager.begun); beanWithAnnotatedProtectedMethod.doInTransaction(); - assertEquals(1, txManager.commits); + assertEquals(1, txManager.commits); } public void testCommitOnAnnotatedPrivateMethod() throws Throwable { txManager.clear(); assertEquals(0, txManager.begun); beanWithAnnotatedPrivateMethod.doSomething(); - assertEquals(1, txManager.commits); + assertEquals(1, txManager.commits); } public void testNoCommitOnNonAnnotatedNonPublicMethodInTransactionalType() throws Throwable { @@ -100,28 +100,28 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon annotationOnlyOnClassWithNoInterface.nonTransactionalMethod(); assertEquals(0,txManager.begun); } - + public void testCommitOnAnnotatedMethod() throws Throwable { txManager.clear(); assertEquals(0, txManager.begun); methodAnnotationOnly.echo(null); assertEquals(1, txManager.commits); } - - + + public static class NotTransactional { public void noop() { } } - + public void testNotTransactional() throws Throwable { txManager.clear(); assertEquals(0, txManager.begun); new NotTransactional().noop(); assertEquals(0, txManager.begun); } - - + + public void testDefaultCommitOnAnnotatedClass() throws Throwable { testRollback(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -129,7 +129,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon } }, false); } - + public void testDefaultRollbackOnAnnotatedClass() throws Throwable { testRollback(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -137,11 +137,11 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon } }, true); } - - + + public static class SubclassOfClassWithTransactionalAnnotation extends TransactionalAnnotationOnlyOnClassWithNoInterface { } - + public void testDefaultCommitOnSubclassOfAnnotatedClass() throws Throwable { testRollback(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -149,10 +149,10 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon } }, false); } - + public static class SubclassOfClassWithTransactionalMethodAnnotation extends MethodAnnotationOnClassWithNoInterface { } - + public void testDefaultCommitOnSubclassOfClassWithTransactionalMethodAnnotated() throws Throwable { testRollback(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -160,7 +160,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon } }, false); } - + public static class ImplementsAnnotatedInterface implements ITransactional { public Object echo(Throwable t) throws Throwable { if (t != null) { @@ -169,14 +169,14 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon return t; } } - + public void testDefaultCommitOnImplementationOfAnnotatedInterface() throws Throwable { // testRollback(new TransactionOperationCallback() { // public Object performTransactionalOperation() throws Throwable { // return new ImplementsAnnotatedInterface().echo(new Exception()); // } // }, false); - + final Exception ex = new Exception(); testNotTransactional(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -184,7 +184,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon } }, ex); } - + /** * Note: resolution does not occur. Thus we can't make a class transactional if * it implements a transactionally annotated interface. This behaviour could only @@ -198,15 +198,15 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class); assertNull(ta); } - - + + public void testDefaultRollbackOnImplementationOfAnnotatedInterface() throws Throwable { // testRollback(new TransactionOperationCallback() { // public Object performTransactionalOperation() throws Throwable { // return new ImplementsAnnotatedInterface().echo(new RuntimeException()); // } // }, true); - + final Exception rollbackProvokingException = new RuntimeException(); testNotTransactional(new TransactionOperationCallback() { public Object performTransactionalOperation() throws Throwable { @@ -215,7 +215,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon }, rollbackProvokingException); } - + protected void testRollback(TransactionOperationCallback toc, boolean rollback) throws Throwable { txManager.clear(); assertEquals(0, txManager.begun); @@ -228,13 +228,13 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon return; } } - + if (rollback) { assertEquals(1, txManager.rollbacks); } assertEquals(1, txManager.begun); } - + protected void testNotTransactional(TransactionOperationCallback toc, Throwable expected) throws Throwable { txManager.clear(); assertEquals(0, txManager.begun); @@ -251,7 +251,7 @@ public class TransactionAspectTests extends AbstractDependencyInjectionSpringCon assertEquals(0, txManager.begun); } } - + private interface TransactionOperationCallback { diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionalAnnotationOnlyOnClassWithNoInterface.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionalAnnotationOnlyOnClassWithNoInterface.java index 691506baa0..bca935ce3f 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionalAnnotationOnlyOnClassWithNoInterface.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionalAnnotationOnlyOnClassWithNoInterface.java @@ -1,17 +1,33 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.transaction.aspectj; import org.springframework.transaction.annotation.Transactional; @Transactional public class TransactionalAnnotationOnlyOnClassWithNoInterface { - + public Object echo(Throwable t) throws Throwable { if (t != null) { throw t; } return t; } - + void nonTransactionalMethod() { // no-op } diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java index c72277d2cf..8be616c7dd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java @@ -36,31 +36,38 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl private boolean extractOldValueForEditor = false; + @Override public void setExtractOldValueForEditor(boolean extractOldValueForEditor) { this.extractOldValueForEditor = extractOldValueForEditor; } + @Override public boolean isExtractOldValueForEditor() { return this.extractOldValueForEditor; } + @Override public void setPropertyValue(PropertyValue pv) throws BeansException { setPropertyValue(pv.getName(), pv.getValue()); } + @Override public void setPropertyValues(Map map) throws BeansException { setPropertyValues(new MutablePropertyValues(map)); } + @Override public void setPropertyValues(PropertyValues pvs) throws BeansException { setPropertyValues(pvs, false, false); } + @Override public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException { setPropertyValues(pvs, ignoreUnknown, false); } + @Override public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws BeansException { @@ -103,7 +110,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl } - // Redefined with public visibility. + // Redefined with public visibility. @Override public Class getPropertyType(String propertyPath) { return null; @@ -118,6 +125,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl * @throws PropertyAccessException if the property was valid but the * accessor method failed */ + @Override public abstract Object getPropertyValue(String propertyName) throws BeansException; /** @@ -129,6 +137,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl * @throws PropertyAccessException if the property was valid but the * accessor method failed or a type mismatch occured */ + @Override public abstract void setPropertyValue(String propertyName, Object value) throws BeansException; } diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java index 46e45ba1ef..ef170a1baa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanInstantiationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.springframework.beans; * @author Juergen Hoeller * @since 1.2.8 */ +@SuppressWarnings("serial") public class BeanInstantiationException extends FatalBeanException { private Class beanClass; diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.java b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.java index 8af75c662a..366256452c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttribute.java @@ -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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class BeanMetadataAttribute implements BeanMetadataElement { /** * Create a new AttributeValue instance. - * @param name the name of the attribute (never null) + * @param name the name of the attribute (never {@code null}) * @param value the value of the attribute (possibly before type conversion) */ public BeanMetadataAttribute(String name, Object value) { @@ -62,13 +62,14 @@ public class BeanMetadataAttribute implements BeanMetadataElement { } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttributeAccessor.java b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttributeAccessor.java index 39c28b5747..d08a8fa341 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttributeAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataAttributeAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,19 +26,21 @@ import org.springframework.core.AttributeAccessorSupport; * @author Juergen Hoeller * @since 2.5 */ +@SuppressWarnings("serial") public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport implements BeanMetadataElement { private Object source; /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } @@ -56,7 +58,7 @@ public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport impl * Look up the given BeanMetadataAttribute in this accessor's set of attributes. * @param name the name of the attribute * @return the corresponding BeanMetadataAttribute object, - * or null if no such attribute defined + * or {@code null} if no such attribute defined */ public BeanMetadataAttribute getMetadataAttribute(String name) { return (BeanMetadataAttribute) super.getAttribute(name); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataElement.java b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataElement.java index 5d39c7f4fd..6b6229d416 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanMetadataElement.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanMetadataElement.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ package org.springframework.beans; public interface BeanMetadataElement { /** - * Return the configuration source Object for this metadata element - * (may be null). + * Return the configuration source {@code Object} for this metadata element + * (may be {@code null}). */ Object getSource(); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index 8c82e9ed51..0a605478c1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -169,14 +169,14 @@ public abstract class BeanUtils { * Find a method with the given method name and the given parameter types, * declared on the given class or one of its superclasses. Prefers public methods, * but will return a protected, package access, or private method too. - *

      Checks Class.getMethod first, falling back to - * findDeclaredMethod. This allows to find public methods + *

      Checks {@code Class.getMethod} first, falling back to + * {@code findDeclaredMethod}. This allows to find public methods * without issues even in environments with restricted Java security settings. * @param clazz the class to check * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find - * @return the Method object, or null if not found - * @see java.lang.Class#getMethod + * @return the Method object, or {@code null} if not found + * @see Class#getMethod * @see #findDeclaredMethod */ public static Method findMethod(Class clazz, String methodName, Class... paramTypes) { @@ -192,12 +192,12 @@ public abstract class BeanUtils { * Find a method with the given method name and the given parameter types, * declared on the given class or one of its superclasses. Will return a public, * protected, package access, or private method. - *

      Checks Class.getDeclaredMethod, cascading upwards to all superclasses. + *

      Checks {@code Class.getDeclaredMethod}, cascading upwards to all superclasses. * @param clazz the class to check * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find - * @return the Method object, or null if not found - * @see java.lang.Class#getDeclaredMethod + * @return the Method object, or {@code null} if not found + * @see Class#getDeclaredMethod */ public static Method findDeclaredMethod(Class clazz, String methodName, Class[] paramTypes) { try { @@ -215,15 +215,15 @@ public abstract class BeanUtils { * Find a method with the given method name and minimal parameters (best case: none), * declared on the given class or one of its superclasses. Prefers public methods, * but will return a protected, package access, or private method too. - *

      Checks Class.getMethods first, falling back to - * findDeclaredMethodWithMinimalParameters. This allows for finding public + *

      Checks {@code Class.getMethods} first, falling back to + * {@code findDeclaredMethodWithMinimalParameters}. This allows for finding public * methods without issues even in environments with restricted Java security settings. * @param clazz the class to check * @param methodName the name of the method to find - * @return the Method object, or null if not found + * @return the Method object, or {@code null} if not found * @throws IllegalArgumentException if methods of the given name were found but * could not be resolved to a unique method with minimal parameters - * @see java.lang.Class#getMethods + * @see Class#getMethods * @see #findDeclaredMethodWithMinimalParameters */ public static Method findMethodWithMinimalParameters(Class clazz, String methodName) @@ -240,13 +240,13 @@ public abstract class BeanUtils { * Find a method with the given method name and minimal parameters (best case: none), * declared on the given class or one of its superclasses. Will return a public, * protected, package access, or private method. - *

      Checks Class.getDeclaredMethods, cascading upwards to all superclasses. + *

      Checks {@code Class.getDeclaredMethods}, cascading upwards to all superclasses. * @param clazz the class to check * @param methodName the name of the method to find - * @return the Method object, or null if not found + * @return the Method object, or {@code null} if not found * @throws IllegalArgumentException if methods of the given name were found but * could not be resolved to a unique method with minimal parameters - * @see java.lang.Class#getDeclaredMethods + * @see Class#getDeclaredMethods */ public static Method findDeclaredMethodWithMinimalParameters(Class clazz, String methodName) throws IllegalArgumentException { @@ -263,7 +263,7 @@ public abstract class BeanUtils { * in the given list of methods. * @param methods the methods to check * @param methodName the name of the method to find - * @return the Method object, or null if not found + * @return the Method object, or {@code null} if not found * @throws IllegalArgumentException if methods of the given name were found but * could not be resolved to a unique method with minimal parameters */ @@ -297,17 +297,17 @@ public abstract class BeanUtils { } /** - * Parse a method signature in the form methodName[([arg_list])], - * where arg_list is an optional, comma-separated list of fully-qualified - * type names, and attempts to resolve that signature against the supplied Class. - *

      When not supplying an argument list (methodName) the method whose name + * Parse a method signature in the form {@code methodName[([arg_list])]}, + * where {@code arg_list} is an optional, comma-separated list of fully-qualified + * type names, and attempts to resolve that signature against the supplied {@code Class}. + *

      When not supplying an argument list ({@code methodName}) the method whose name * matches and has the least number of parameters will be returned. When supplying an * argument type list, only the method whose name and argument types match will be returned. - *

      Note then that methodName and methodName() are not - * resolved in the same way. The signature methodName means the method called - * methodName with the least number of arguments, whereas methodName() - * means the method called methodName with exactly 0 arguments. - *

      If no method can be found, then null is returned. + *

      Note then that {@code methodName} and {@code methodName()} are not + * resolved in the same way. The signature {@code methodName} means the method called + * {@code methodName} with the least number of arguments, whereas {@code methodName()} + * means the method called {@code methodName} with exactly 0 arguments. + *

      If no method can be found, then {@code null} is returned. * @param signature the method signature as String representation * @param clazz the class to resolve the method signature against * @return the resolved Method @@ -353,9 +353,9 @@ public abstract class BeanUtils { /** - * Retrieve the JavaBeans PropertyDescriptors of a given class. + * Retrieve the JavaBeans {@code PropertyDescriptor}s of a given class. * @param clazz the Class to retrieve the PropertyDescriptors for - * @return an array of PropertyDescriptors for the given class + * @return an array of {@code PropertyDescriptors} for the given class * @throws BeansException if PropertyDescriptor look fails */ public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws BeansException { @@ -364,10 +364,10 @@ public abstract class BeanUtils { } /** - * Retrieve the JavaBeans PropertyDescriptors for the given property. + * Retrieve the JavaBeans {@code PropertyDescriptors} for the given property. * @param clazz the Class to retrieve the PropertyDescriptor for * @param propertyName the name of the property - * @return the corresponding PropertyDescriptor, or null if none + * @return the corresponding PropertyDescriptor, or {@code null} if none * @throws BeansException if PropertyDescriptor lookup fails */ public static PropertyDescriptor getPropertyDescriptor(Class clazz, String propertyName) @@ -378,11 +378,11 @@ public abstract class BeanUtils { } /** - * Find a JavaBeans PropertyDescriptor for the given method, + * Find a JavaBeans {@code PropertyDescriptor} for the given method, * with the method either being the read method or the write method for * that bean property. * @param method the method to find a corresponding PropertyDescriptor for - * @return the corresponding PropertyDescriptor, or null if none + * @return the corresponding PropertyDescriptor, or {@code null} if none * @throws BeansException if PropertyDescriptor lookup fails */ public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException { @@ -403,7 +403,7 @@ public abstract class BeanUtils { * {@link java.beans.PropertyEditorManager} but isolated from the latter's * registered default editors for primitive types. * @param targetType the type to find an editor for - * @return the corresponding editor, or null if none found + * @return the corresponding editor, or {@code null} if none found */ public static PropertyEditor findEditorByConvention(Class targetType) { if (targetType == null || targetType.isArray() || unknownEditorTypes.containsKey(targetType)) { @@ -453,7 +453,7 @@ public abstract class BeanUtils { * given classes/interfaces, if possible. * @param propertyName the name of the bean property * @param beanClasses the classes to check against - * @return the property type, or Object.class as fallback + * @return the property type, or {@code Object.class} as fallback */ public static Class findPropertyType(String propertyName, Class[] beanClasses) { if (beanClasses != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java index aea348d6fd..628ee8e78a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapper.java @@ -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"); * you may not use this file except in compliance with the License. @@ -50,14 +50,14 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor { /** * Return the bean instance wrapped by this object, if any. - * @return the bean instance, or null if none set + * @return the bean instance, or {@code null} if none set */ Object getWrappedInstance(); /** * Return the type of the wrapped JavaBean object. * @return the type of the wrapped bean instance, - * or null if no wrapped object has been set + * or {@code null} if no wrapped object has been set */ Class getWrappedClass(); diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index efe6fccbcc..705d4a7ac7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -19,7 +19,6 @@ package org.springframework.beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyDescriptor; import java.lang.reflect.Array; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -41,7 +40,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.core.CollectionFactory; import org.springframework.core.GenericCollectionTypeResolver; -import org.springframework.core.MethodParameter; import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.Property; @@ -55,18 +53,18 @@ import org.springframework.util.StringUtils; * for all typical use cases. Caches introspection results for efficiency. * *

      Note: Auto-registers default property editors from the - * org.springframework.beans.propertyeditors package, which apply + * {@code org.springframework.beans.propertyeditors} package, which apply * in addition to the JDK's standard PropertyEditors. Applications can call * the {@link #registerCustomEditor(Class, java.beans.PropertyEditor)} method * to register an editor for a particular instance (i.e. they are not shared * across the application). See the base class * {@link PropertyEditorRegistrySupport} for details. * - *

      BeanWrapperImpl will convert collection and array values + *

      {@code BeanWrapperImpl} will convert collection and array values * to the corresponding target collections or arrays, if necessary. Custom * property editors that deal with collections or arrays can either be - * written via PropertyEditor's setValue, or against a - * comma-delimited String via setAsText, as String arrays are + * written via PropertyEditor's {@code setValue}, or against a + * comma-delimited String via {@code setAsText}, as String arrays are * converted in such a format if the array itself is not assignable. * *

      NOTE: As of Spring 2.5, this is - for almost all purposes - an @@ -179,7 +177,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra * registering a nested path that the object is in. * @param object object wrapped by this BeanWrapper * @param nestedPath the nested path of the object - * @param superBw the containing BeanWrapper (must not be null) + * @param superBw the containing BeanWrapper (must not be {@code null}) */ private BeanWrapperImpl(Object object, String nestedPath, BeanWrapperImpl superBw) { setWrappedInstance(object, nestedPath, superBw.getWrappedInstance()); @@ -221,10 +219,12 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra setIntrospectionClass(object.getClass()); } + @Override public final Object getWrappedInstance() { return this.object; } + @Override public final Class getWrappedClass() { return (this.object != null ? this.object.getClass() : null); } @@ -259,6 +259,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra * enables auto-growth of collection elements when accessing an out-of-bounds index. *

      Default is "false" on a plain BeanWrapper. */ + @Override public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) { this.autoGrowNestedPaths = autoGrowNestedPaths; } @@ -266,6 +267,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra /** * Return whether "auto-growing" of nested paths has been activated. */ + @Override public boolean isAutoGrowNestedPaths() { return this.autoGrowNestedPaths; } @@ -274,6 +276,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra * Specify a limit for array and collection auto-growing. *

      Default is unlimited on a plain BeanWrapper. */ + @Override public void setAutoGrowCollectionLimit(int autoGrowCollectionLimit) { this.autoGrowCollectionLimit = autoGrowCollectionLimit; } @@ -281,6 +284,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra /** * Return the limit for array and collection auto-growing. */ + @Override public int getAutoGrowCollectionLimit() { return this.autoGrowCollectionLimit; } @@ -326,10 +330,12 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra } + @Override public PropertyDescriptor[] getPropertyDescriptors() { return getCachedIntrospectionResults().getPropertyDescriptors(); } + @Override public PropertyDescriptor getPropertyDescriptor(String propertyName) throws BeansException { PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName); if (pd == null) { @@ -341,10 +347,10 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra /** * Internal version of {@link #getPropertyDescriptor}: - * Returns null if not found rather than throwing an exception. + * Returns {@code null} if not found rather than throwing an exception. * @param propertyName the property to obtain the descriptor for * @return the property descriptor for the specified property, - * or null if not found + * or {@code null} if not found * @throws BeansException in case of introspection failure */ protected PropertyDescriptor getPropertyDescriptorInternal(String propertyName) throws BeansException { @@ -380,6 +386,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra return null; } + @Override public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException { try { BeanWrapperImpl nestedBw = getBeanWrapperForPropertyPath(propertyName); @@ -404,6 +411,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra return null; } + @Override public boolean isReadableProperty(String propertyName) { try { PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName); @@ -424,6 +432,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra return false; } + @Override public boolean isWritableProperty(String propertyName) { try { PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName); @@ -474,7 +483,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra /** * Convert the given value for the specified property to the latter's type. *

      This method is only intended for optimizations in a BeanFactory. - * Use the convertIfNecessary methods for programmatic conversion. + * Use the {@code convertIfNecessary} methods for programmatic conversion. * @param value the value to convert * @param propertyName the target property * (note that nested or indexed properties are not supported here) @@ -559,7 +568,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra propertyValue = setDefaultValue(tokens); } else { - throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); + throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + canonicalName); } } @@ -713,6 +722,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers()) && !readMethod.isAccessible()) { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { readMethod.setAccessible(true); return null; @@ -723,11 +733,12 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra readMethod.setAccessible(true); } } - + Object value; if (System.getSecurityManager() != null) { try { value = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { return readMethod.invoke(object, (Object[]) null); } @@ -738,10 +749,10 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra } } else { - value = readMethod.invoke(object, (Object[]) null); + value = readMethod.invoke(object, (Object[]) null); } - - if (tokens.keys != null) { + + if (tokens.keys != null) { if (value == null) { if (this.autoGrowNestedPaths) { value = setDefaultValue(tokens.actualName); @@ -749,9 +760,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra else { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName, "Cannot access indexed value of property referenced in indexed " + - "property path '" + propertyName + "': returned null"); + "property path '" + propertyName + "': returned null"); } - } + } String indexedPropertyName = tokens.actualName; // apply indexes and map keys for (int i = 0; i < tokens.keys.length; i++) { @@ -759,7 +770,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra if (value == null) { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName, "Cannot access indexed value of property referenced in indexed " + - "property path '" + propertyName + "': returned null"); + "property path '" + propertyName + "': returned null"); } else if (value.getClass().isArray()) { int index = Integer.parseInt(key); @@ -767,9 +778,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra value = Array.get(value, index); } else if (value instanceof List) { - int index = Integer.parseInt(key); + int index = Integer.parseInt(key); List list = (List) value; - growCollectionIfNecessary(list, index, indexedPropertyName, pd, i + 1); + growCollectionIfNecessary(list, index, indexedPropertyName, pd, i + 1); value = list.get(index); } else if (value instanceof Set) { @@ -804,7 +815,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra "Property referenced in indexed property path '" + propertyName + "' is neither an array nor a List nor a Set nor a Map; returned value was [" + value + "]"); } - indexedPropertyName += PROPERTY_KEY_PREFIX + key + PROPERTY_KEY_SUFFIX; + indexedPropertyName += PROPERTY_KEY_PREFIX + key + PROPERTY_KEY_SUFFIX; } } return value; @@ -1064,6 +1075,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra !readMethod.isAccessible()) { if (System.getSecurityManager()!= null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { readMethod.setAccessible(true); return null; @@ -1077,6 +1089,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra try { if (System.getSecurityManager() != null) { oldValue = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { return readMethod.invoke(object); } @@ -1106,6 +1119,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers()) && !writeMethod.isAccessible()) { if (System.getSecurityManager()!= null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { writeMethod.setAccessible(true); return null; @@ -1120,6 +1134,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra if (System.getSecurityManager() != null) { try { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { writeMethod.invoke(object, value); return null; diff --git a/spring-beans/src/main/java/org/springframework/beans/BeansException.java b/spring-beans/src/main/java/org/springframework/beans/BeansException.java index a2c0834d36..efbed41edf 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeansException.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeansException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.util.ObjectUtils; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public abstract class BeansException extends NestedRuntimeException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index 2e9dde90b8..47ff208dd4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -87,7 +87,7 @@ public class CachedIntrospectionResults { * whose lifecycle is not coupled to the application. In such a scenario, * CachedIntrospectionResults would by default not cache any of the application's * classes, since they would create a leak in the common ClassLoader. - *

      Any acceptClassLoader call at application startup should + *

      Any {@code acceptClassLoader} call at application startup should * be paired with a {@link #clearClassLoader} call at application shutdown. * @param classLoader the ClassLoader to accept */ diff --git a/spring-beans/src/main/java/org/springframework/beans/ConversionNotSupportedException.java b/spring-beans/src/main/java/org/springframework/beans/ConversionNotSupportedException.java index afd6a0fc09..5151193e8f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ConversionNotSupportedException.java +++ b/spring-beans/src/main/java/org/springframework/beans/ConversionNotSupportedException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,13 +25,14 @@ import java.beans.PropertyChangeEvent; * @author Juergen Hoeller * @since 3.0 */ +@SuppressWarnings("serial") public class ConversionNotSupportedException extends TypeMismatchException { /** * Create a new ConversionNotSupportedException. * @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem - * @param requiredType the required target type (or null if not known) - * @param cause the root cause (may be null) + * @param requiredType the required target type (or {@code null} if not known) + * @param cause the root cause (may be {@code null}) */ public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) { super(propertyChangeEvent, requiredType, cause); @@ -39,9 +40,9 @@ public class ConversionNotSupportedException extends TypeMismatchException { /** * Create a new ConversionNotSupportedException. - * @param value the offending value that couldn't be converted (may be null) - * @param requiredType the required target type (or null if not known) - * @param cause the root cause (may be null) + * @param value the offending value that couldn't be converted (may be {@code null}) + * @param requiredType the required target type (or {@code null} if not known) + * @param cause the root cause (may be {@code null}) */ public ConversionNotSupportedException(Object value, Class requiredType, Throwable cause) { super(value, requiredType, cause); diff --git a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java index caaa069b06..9e6c67703c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java @@ -16,7 +16,6 @@ package org.springframework.beans; -import org.springframework.core.MethodParameter; import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.core.convert.TypeDescriptor; @@ -60,11 +59,12 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { Assert.notNull(target, "Target object must not be null"); this.target = target; ReflectionUtils.doWithFields(this.target.getClass(), new ReflectionUtils.FieldCallback() { + @Override public void doWith(Field field) { if (fieldMap.containsKey(field.getName())) { // ignore superclass declarations of fields already found in a subclass } - else { + else { fieldMap.put(field.getName(), field); } } @@ -75,10 +75,12 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { } + @Override public boolean isReadableProperty(String propertyName) throws BeansException { return this.fieldMap.containsKey(propertyName); } + @Override public boolean isWritableProperty(String propertyName) throws BeansException { return this.fieldMap.containsKey(propertyName); } @@ -92,6 +94,7 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor { return null; } + @Override public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException { Field field = this.fieldMap.get(propertyName); if (field != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 856e62c031..caf47703a4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -217,35 +217,43 @@ class ExtendedBeanInfo implements BeanInfo { * method found during construction. * @see #ExtendedBeanInfo(BeanInfo) */ + @Override public PropertyDescriptor[] getPropertyDescriptors() { return this.propertyDescriptors.toArray( new PropertyDescriptor[this.propertyDescriptors.size()]); } + @Override public BeanInfo[] getAdditionalBeanInfo() { return delegate.getAdditionalBeanInfo(); } + @Override public BeanDescriptor getBeanDescriptor() { return delegate.getBeanDescriptor(); } + @Override public int getDefaultEventIndex() { return delegate.getDefaultEventIndex(); } + @Override public int getDefaultPropertyIndex() { return delegate.getDefaultPropertyIndex(); } + @Override public EventSetDescriptor[] getEventSetDescriptors() { return delegate.getEventSetDescriptors(); } + @Override public Image getIcon(int iconKind) { return delegate.getIcon(iconKind); } + @Override public MethodDescriptor[] getMethodDescriptors() { return delegate.getMethodDescriptors(); } @@ -655,6 +663,7 @@ class PropertyDescriptorUtils { */ class PropertyDescriptorComparator implements Comparator { + @Override public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) { String left = desc1.getName(); String right = desc2.getName(); diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java index 7e46211922..6908cc06b6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java @@ -40,6 +40,7 @@ public class ExtendedBeanInfoFactory implements Ordered, BeanInfoFactory { /** * Return a new {@link ExtendedBeanInfo} for the given bean class. */ + @Override public BeanInfo getBeanInfo(Class beanClass) throws IntrospectionException { return supports(beanClass) ? new ExtendedBeanInfo(Introspector.getBeanInfo(beanClass)) : null; @@ -58,6 +59,7 @@ public class ExtendedBeanInfoFactory implements Ordered, BeanInfoFactory { return false; } + @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; } diff --git a/spring-beans/src/main/java/org/springframework/beans/FatalBeanException.java b/spring-beans/src/main/java/org/springframework/beans/FatalBeanException.java index 43feaa766c..84fe47bb23 100644 --- a/spring-beans/src/main/java/org/springframework/beans/FatalBeanException.java +++ b/spring-beans/src/main/java/org/springframework/beans/FatalBeanException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ package org.springframework.beans; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class FatalBeanException extends BeansException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java index a2d5ee7af3..0f0c593162 100644 --- a/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import org.springframework.util.StringUtils; /** * Extension of the standard JavaBeans PropertyDescriptor class, - * overriding getPropertyType() such that a generically + * overriding {@code getPropertyType()} such that a generically * declared type will be resolved against the containing bean class. * * @author Juergen Hoeller @@ -95,7 +95,7 @@ class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor { public Class getBeanClass() { return this.beanClass; } - + @Override public Method getReadMethod() { return this.readMethod; diff --git a/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java b/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java index d1c976a5a2..96db41d162 100644 --- a/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/InvalidPropertyException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.springframework.beans; * @author Juergen Hoeller * @since 1.0.2 */ +@SuppressWarnings("serial") public class InvalidPropertyException extends FatalBeanException { private Class beanClass; diff --git a/spring-beans/src/main/java/org/springframework/beans/Mergeable.java b/spring-beans/src/main/java/org/springframework/beans/Mergeable.java index 97f742c442..cba64d94f8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/Mergeable.java +++ b/spring-beans/src/main/java/org/springframework/beans/Mergeable.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,9 +40,9 @@ public interface Mergeable { * the callee's value set must override those of the supplied object. * @param parent the object to merge with * @return the result of the merge operation - * @throws IllegalArgumentException if the supplied parent is null + * @throws IllegalArgumentException if the supplied parent is {@code null} * @exception IllegalStateException if merging is not enabled for this instance - * (i.e. mergeEnabled equals false). + * (i.e. {@code mergeEnabled} equals {@code false}). */ Object merge(Object parent); diff --git a/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java b/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java index 6a9c0eac84..e82daabbcb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/MethodInvocationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,13 +24,14 @@ import java.beans.PropertyChangeEvent; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class MethodInvocationException extends PropertyAccessException { /** * Error code that a method invocation error will be registered with. */ public static final String ERROR_CODE = "methodInvocation"; - + /** * Create a new MethodInvocationException. @@ -41,6 +42,7 @@ public class MethodInvocationException extends PropertyAccessException { super(propertyChangeEvent, "Property '" + propertyChangeEvent.getPropertyName() + "' threw exception", cause); } + @Override public String getErrorCode() { return ERROR_CODE; } diff --git a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java index 470a705dd5..56bf9bb374 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.util.StringUtils; * @author Rob Harrop * @since 13 May 2001 */ +@SuppressWarnings("serial") public class MutablePropertyValues implements PropertyValues, Serializable { private final List propertyValueList; @@ -46,7 +47,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { /** * Creates a new empty MutablePropertyValues object. - *

      Property values can be added with the add method. + *

      Property values can be added with the {@code add} method. * @see #add(String, Object) */ public MutablePropertyValues() { @@ -176,7 +177,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { } /** - * Overloaded version of addPropertyValue that takes + * Overloaded version of {@code addPropertyValue} that takes * a property name and a property value. *

      Note: As of Spring 3.0, we recommend using the more concise * and chaining-capable variant {@link #add}. @@ -234,7 +235,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { } /** - * Overloaded version of removePropertyValue that takes a property name. + * Overloaded version of {@code removePropertyValue} that takes a property name. * @param propertyName name of the property * @see #removePropertyValue(PropertyValue) */ @@ -243,10 +244,12 @@ public class MutablePropertyValues implements PropertyValues, Serializable { } + @Override public PropertyValue[] getPropertyValues() { return this.propertyValueList.toArray(new PropertyValue[this.propertyValueList.size()]); } + @Override public PropertyValue getPropertyValue(String propertyName) { for (PropertyValue pv : this.propertyValueList) { if (pv.getName().equals(propertyName)) { @@ -256,6 +259,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { return null; } + @Override public PropertyValues changesSince(PropertyValues old) { MutablePropertyValues changes = new MutablePropertyValues(); if (old == this) { @@ -277,11 +281,13 @@ public class MutablePropertyValues implements PropertyValues, Serializable { return changes; } + @Override public boolean contains(String propertyName) { return (getPropertyValue(propertyName) != null || (this.processedProperties != null && this.processedProperties.contains(propertyName))); } + @Override public boolean isEmpty() { return this.propertyValueList.isEmpty(); } @@ -291,7 +297,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { * Register the specified property as "processed" in the sense * of some processor calling the corresponding setter method * outside of the PropertyValue(s) mechanism. - *

      This will lead to true being returned from + *

      This will lead to {@code true} being returned from * a {@link #contains} call for the specified property. * @param propertyName the name of the property. */ @@ -311,8 +317,8 @@ public class MutablePropertyValues implements PropertyValues, Serializable { } /** - * Return whether this holder contains converted values only (true), - * or whether the values still need to be converted (false). + * Return whether this holder contains converted values only ({@code true}), + * or whether the values still need to be converted ({@code false}). */ public boolean isConverted() { return this.converted; diff --git a/spring-beans/src/main/java/org/springframework/beans/NotReadablePropertyException.java b/spring-beans/src/main/java/org/springframework/beans/NotReadablePropertyException.java index 49ba7d795a..2001d09eed 100644 --- a/spring-beans/src/main/java/org/springframework/beans/NotReadablePropertyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/NotReadablePropertyException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.springframework.beans; * @author Juergen Hoeller * @since 1.0.2 */ +@SuppressWarnings("serial") public class NotReadablePropertyException extends InvalidPropertyException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java b/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java index 73b607edb1..de734c28c3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/NotWritablePropertyException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ package org.springframework.beans; * @author Alef Arendsen * @author Arjen Poutsma */ +@SuppressWarnings("serial") public class NotWritablePropertyException extends InvalidPropertyException { private String[] possibleMatches = null; diff --git a/spring-beans/src/main/java/org/springframework/beans/NullValueInNestedPathException.java b/spring-beans/src/main/java/org/springframework/beans/NullValueInNestedPathException.java index 40c593c444..f1ad856b3f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/NullValueInNestedPathException.java +++ b/spring-beans/src/main/java/org/springframework/beans/NullValueInNestedPathException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ package org.springframework.beans; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class NullValueInNestedPathException extends InvalidPropertyException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java index 830ea5f40d..68bdde7412 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,10 +27,11 @@ import org.springframework.core.ErrorCoded; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public abstract class PropertyAccessException extends BeansException implements ErrorCoded { private transient PropertyChangeEvent propertyChangeEvent; - + /** * Create a new PropertyAccessException. @@ -55,7 +56,7 @@ public abstract class PropertyAccessException extends BeansException implements /** * Return the PropertyChangeEvent that resulted in the problem. - *

      May be null; only available if an actual bean property + *

      May be {@code null}; only available if an actual bean property * was affected. */ public PropertyChangeEvent getPropertyChangeEvent() { diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessor.java index c8b8edb63f..621bae5325 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public interface PropertyAccessor { /** * Determine whether the specified property is readable. - *

      Returns false if the property doesn't exist. + *

      Returns {@code false} if the property doesn't exist. * @param propertyName the property to check * (may be a nested path and/or an indexed/mapped property) * @return whether the property is readable @@ -66,7 +66,7 @@ public interface PropertyAccessor { /** * Determine whether the specified property is writable. - *

      Returns false if the property doesn't exist. + *

      Returns {@code false} if the property doesn't exist. * @param propertyName the property to check * (may be a nested path and/or an indexed/mapped property) * @return whether the property is writable @@ -80,7 +80,7 @@ public interface PropertyAccessor { * @param propertyName the property to check * (may be a nested path and/or an indexed/mapped property) * @return the property type for the particular property, - * or null if not determinable + * or {@code null} if not determinable * @throws InvalidPropertyException if there is no such property or * if the property isn't readable * @throws PropertyAccessException if the property was valid but the @@ -94,7 +94,7 @@ public interface PropertyAccessor { * @param propertyName the property to check * (may be a nested path and/or an indexed/mapped property) * @return the property type for the particular property, - * or null if not determinable + * or {@code null} if not determinable * @throws InvalidPropertyException if there is no such property or * if the property isn't readable */ @@ -191,7 +191,7 @@ public interface PropertyAccessor { * @see #setPropertyValues(PropertyValues, boolean, boolean) */ void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) - throws BeansException; + throws BeansException; /** * Perform a batch update with full control over behavior. @@ -213,6 +213,6 @@ public interface PropertyAccessor { * successfully updated. */ void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) - throws BeansException; + throws BeansException; } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java index 53d1377282..9da1ed0658 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorUtils.java @@ -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"); * you may not use this file except in compliance with the License. @@ -132,8 +132,8 @@ public abstract class PropertyAccessorUtils { /** * Determine the canonical name for the given property path. * Removes surrounding quotes from map keys:
      - * map['key'] -> map[key]
      - * map["key"] -> map[key] + * {@code map['key']} -> {@code map[key]}
      + * {@code map["key"]} -> {@code map[key]} * @param propertyName the bean property path * @return the canonical representation of the property path */ diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java b/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java index d7a574cc43..1919a47122 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyBatchUpdateException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.util.ObjectUtils; * @author Juergen Hoeller * @since 18 April 2001 */ +@SuppressWarnings("serial") public class PropertyBatchUpdateException extends BeansException { /** List of PropertyAccessException objects */ @@ -61,14 +62,14 @@ public class PropertyBatchUpdateException extends BeansException { /** * Return an array of the propertyAccessExceptions stored in this object. - *

      Will return the empty array (not null) if there were no errors. + *

      Will return the empty array (not {@code null}) if there were no errors. */ public final PropertyAccessException[] getPropertyAccessExceptions() { return this.propertyAccessExceptions; } /** - * Return the exception for this field, or null if there isn't any. + * Return the exception for this field, or {@code null} if there isn't any. */ public PropertyAccessException getPropertyAccessException(String propertyName) { for (PropertyAccessException pae : this.propertyAccessExceptions) { diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrar.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrar.java index 9e141fde3a..549334393f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrar.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrar.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,17 +31,17 @@ package org.springframework.beans; * @see java.beans.PropertyEditor */ public interface PropertyEditorRegistrar { - + /** * Register custom {@link java.beans.PropertyEditor PropertyEditors} with - * the given PropertyEditorRegistry. + * the given {@code PropertyEditorRegistry}. *

      The passed-in registry will usually be a {@link BeanWrapper} or a * {@link org.springframework.validation.DataBinder DataBinder}. *

      It is expected that implementations will create brand new - * PropertyEditors instances for each invocation of this - * method (since PropertyEditors are not threadsafe). - * @param registry the PropertyEditorRegistry to register the - * custom PropertyEditors with + * {@code PropertyEditors} instances for each invocation of this + * method (since {@code PropertyEditors} are not threadsafe). + * @param registry the {@code PropertyEditorRegistry} to register the + * custom {@code PropertyEditors} with */ void registerCustomEditors(PropertyEditorRegistry registry); diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistry.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistry.java index a14d3c0e92..f76df2a2d8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public interface PropertyEditorRegistry { *

      If the property path denotes an array or Collection property, * the editor will get applied either to the array/Collection itself * (the {@link PropertyEditor} has to create an array or Collection value) or - * to each element (the PropertyEditor has to create the element type), + * to each element (the {@code PropertyEditor} has to create the element type), * depending on the specified required type. *

      Note: Only one single registered custom editor per property path * is supported. In the case of a Collection/array, do not register an editor @@ -55,24 +55,24 @@ public interface PropertyEditorRegistry { *

      For example, if you wanted to register an editor for "items[n].quantity" * (for all values n), you would use "items.quantity" as the value of the * 'propertyPath' argument to this method. - * @param requiredType the type of the property. This may be null + * @param requiredType the type of the property. This may be {@code null} * if a property is given but should be specified in any case, in particular in * case of a Collection - making clear whether the editor is supposed to apply * to the entire Collection itself or to each of its entries. So as a general rule: - * Do not specify null here in case of a Collection/array! + * Do not specify {@code null} here in case of a Collection/array! * @param propertyPath the path of the property (name or nested path), or - * null if registering an editor for all properties of the given type + * {@code null} if registering an editor for all properties of the given type * @param propertyEditor editor to register */ void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor); /** * Find a custom property editor for the given type and property. - * @param requiredType the type of the property (can be null if a property + * @param requiredType the type of the property (can be {@code null} if a property * is given but should be specified in any case for consistency checking) * @param propertyPath the path of the property (name or nested path), or - * null if looking for an editor for all properties of the given type - * @return the registered editor, or null if none + * {@code null} if looking for an editor for all properties of the given type + * @return the registered editor, or {@code null} if none */ PropertyEditor findCustomEditor(Class requiredType, String propertyPath); diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index 2b547c0edf..b598879b3e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -163,7 +163,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Retrieve the default editor for the given property type, if any. *

      Lazily registers the default editors, if they are active. * @param requiredType type of the property - * @return the default editor, or null if none found + * @return the default editor, or {@code null} if none found * @see #registerDefaultEditors */ public PropertyEditor getDefaultEditor(Class requiredType) { @@ -269,10 +269,12 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { // Management of custom editors //--------------------------------------------------------------------- + @Override public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) { registerCustomEditor(requiredType, null, propertyEditor); } + @Override public void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor) { if (requiredType == null && propertyPath == null) { throw new IllegalArgumentException("Either requiredType or propertyPath is required"); @@ -319,6 +321,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { return (this.sharedEditors != null && this.sharedEditors.contains(propertyEditor)); } + @Override public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) { Class requiredTypeToUse = requiredType; if (propertyPath != null) { @@ -349,9 +352,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Determine whether this registry contains a custom editor * for the specified array/collection element. * @param elementType the target type of the element - * (can be null if not known) + * (can be {@code null} if not known) * @param propertyPath the property path (typically of the array/collection; - * can be null if not known) + * can be {@code null} if not known) * @return whether a matching custom editor has been found */ public boolean hasCustomEditorForElement(Class elementType, String propertyPath) { @@ -372,11 +375,11 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Determine the property type for the given property path. *

      Called by {@link #findCustomEditor} if no required type has been specified, * to be able to find a type-specific editor even if just given a property path. - *

      The default implementation always returns null. - * BeanWrapperImpl overrides this with the standard getPropertyType + *

      The default implementation always returns {@code null}. + * BeanWrapperImpl overrides this with the standard {@code getPropertyType} * method as defined by the BeanWrapper interface. * @param propertyPath the property path to determine the type for - * @return the type of the property, or null if not determinable + * @return the type of the property, or {@code null} if not determinable * @see BeanWrapper#getPropertyType(String) */ protected Class getPropertyType(String propertyPath) { @@ -387,7 +390,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Get custom editor that has been registered for the given property. * @param propertyName the property path to look for * @param requiredType the type to look for - * @return the custom editor, or null if none specific for this property + * @return the custom editor, or {@code null} if none specific for this property */ private PropertyEditor getCustomEditor(String propertyName, Class requiredType) { CustomEditorHolder holder = this.customEditorsForPath.get(propertyName); @@ -397,9 +400,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { /** * Get custom editor for the given type. If no direct match found, * try custom editor for superclass (which will in any case be able - * to render a value as String via getAsText). + * to render a value as String via {@code getAsText}). * @param requiredType the type to look for - * @return the custom editor, or null if none found for this type + * @return the custom editor, or {@code null} if none found for this type * @see java.beans.PropertyEditor#getAsText() */ private PropertyEditor getCustomEditor(Class requiredType) { @@ -436,7 +439,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Guess the property type of the specified property from the registered * custom editors (provided that they were registered for a specific type). * @param propertyName the name of the property - * @return the property type, or null if not determinable + * @return the property type, or {@code null} if not determinable */ protected Class guessPropertyTypeFromEditors(String propertyName) { if (this.customEditorsForPath != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java index 0c68290650..82830a198c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java @@ -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"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ final class PropertyMatches { /** * Generate possible property alternatives for the given property and - * class. Internally uses the getStringDistance method, which + * class. Internally uses the {@code getStringDistance} method, which * in turn uses the Levenshtein algorithm to determine the distance between * two Strings. * @param propertyDescriptors the JavaBeans property descriptors to search diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java b/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java index abc9c66662..feecaf0e59 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import org.springframework.util.ObjectUtils; * @see PropertyValues * @see BeanWrapper */ +@SuppressWarnings("serial") public class PropertyValue extends BeanMetadataAttributeAccessor implements Serializable { private final String name; @@ -65,7 +66,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri /** * Create a new PropertyValue instance. - * @param name the name of the property (never null) + * @param name the name of the property (never {@code null}) * @param value the value of the property (possibly before type conversion) */ public PropertyValue(String name, Object value) { @@ -75,7 +76,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri /** * Copy constructor. - * @param original the PropertyValue to copy (never null) + * @param original the PropertyValue to copy (never {@code null}) */ public PropertyValue(PropertyValue original) { Assert.notNull(original, "Original must not be null"); @@ -94,7 +95,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri /** * Constructor that exposes a new value for an original value holder. * The original holder will be exposed as source of the new holder. - * @param original the PropertyValue to link to (never null) + * @param original the PropertyValue to link to (never {@code null}) * @param newValue the new value to apply */ public PropertyValue(PropertyValue original, Object newValue) { @@ -149,8 +150,8 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri } /** - * Return whether this holder contains a converted value already (true), - * or whether the value still needs to be converted (false). + * Return whether this holder contains a converted value already ({@code true}), + * or whether the value still needs to be converted ({@code false}). */ public synchronized boolean isConverted() { return this.converted; diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/PropertyValues.java index e2180a077e..8af2c77ff7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyValues.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,26 +26,26 @@ package org.springframework.beans; * @see PropertyValue */ public interface PropertyValues { - - /** + + /** * Return an array of the PropertyValue objects held in this object. */ - PropertyValue[] getPropertyValues(); - + PropertyValue[] getPropertyValues(); + /** * Return the property value with the given name, if any. * @param propertyName the name to search for - * @return the property value, or null + * @return the property value, or {@code null} */ PropertyValue getPropertyValue(String propertyName); /** * Return the changes since the previous PropertyValues. - * Subclasses should also override equals. + * Subclasses should also override {@code equals}. * @param old old property values * @return PropertyValues updated or new properties. * Return empty PropertyValues if there are no changes. - * @see java.lang.Object#equals + * @see Object#equals */ PropertyValues changesSince(PropertyValues old); diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverter.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverter.java index 383f8e0d1e..2efc1edf73 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverter.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverter.java @@ -33,11 +33,11 @@ public interface TypeConverter { /** * Convert the value to the required type (if necessary from a String). - *

      Conversions from String to any type will typically use the setAsText + *

      Conversions from String to any type will typically use the {@code setAsText} * method of the PropertyEditor class, or a Spring Converter in a ConversionService. * @param value the value to convert * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @return the new value, possibly the result of type conversion * @throws TypeMismatchException if type conversion failed * @see java.beans.PropertyEditor#setAsText(String) @@ -49,13 +49,13 @@ public interface TypeConverter { /** * Convert the value to the required type (if necessary from a String). - *

      Conversions from String to any type will typically use the setAsText + *

      Conversions from String to any type will typically use the {@code setAsText} * method of the PropertyEditor class, or a Spring Converter in a ConversionService. * @param value the value to convert * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param methodParam the method parameter that is the target of the conversion - * (for analysis of generic types; may be null) + * (for analysis of generic types; may be {@code null}) * @return the new value, possibly the result of type conversion * @throws TypeMismatchException if type conversion failed * @see java.beans.PropertyEditor#setAsText(String) @@ -68,13 +68,13 @@ public interface TypeConverter { /** * Convert the value to the required type (if necessary from a String). - *

      Conversions from String to any type will typically use the setAsText + *

      Conversions from String to any type will typically use the {@code setAsText} * method of the PropertyEditor class, or a Spring Converter in a ConversionService. * @param value the value to convert * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param field the reflective field that is the target of the conversion - * (for analysis of generic types; may be null) + * (for analysis of generic types; may be {@code null}) * @return the new value, possibly the result of type conversion * @throws TypeMismatchException if type conversion failed * @see java.beans.PropertyEditor#setAsText(String) diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java index 9b47e79443..24bc57e9e3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -81,9 +81,9 @@ class TypeConverterDelegate { * Convert the value to the specified required type. * @param newValue the proposed new value * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param methodParam the method parameter that is the target of the conversion - * (may be null) + * (may be {@code null}) * @return the new value, possibly the result of type conversion * @throws IllegalArgumentException if type conversion failed */ @@ -98,9 +98,9 @@ class TypeConverterDelegate { * Convert the value to the specified required type. * @param newValue the proposed new value * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param field the reflective field that is the target of the conversion - * (may be null) + * (may be {@code null}) * @return the new value, possibly the result of type conversion * @throws IllegalArgumentException if type conversion failed */ @@ -114,10 +114,10 @@ class TypeConverterDelegate { /** * Convert the value to the required type for the specified property. * @param propertyName name of the property - * @param oldValue the previous value, if available (may be null) + * @param oldValue the previous value, if available (may be {@code null}) * @param newValue the proposed new value * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @return the new value, possibly the result of type conversion * @throws IllegalArgumentException if type conversion failed */ @@ -132,10 +132,10 @@ class TypeConverterDelegate { * Convert the value to the required type (if necessary from a String), * for the specified property. * @param propertyName name of the property - * @param oldValue the previous value, if available (may be null) + * @param oldValue the previous value, if available (may be {@code null}) * @param newValue the proposed new value * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param typeDescriptor the descriptor for the target property or field * @return the new value, possibly the result of type conversion * @throws IllegalArgumentException if type conversion failed @@ -326,7 +326,7 @@ class TypeConverterDelegate { /** * Find a default editor for the given type. * @param requiredType the type to find an editor for - * @return the corresponding editor, or null if none + * @return the corresponding editor, or {@code null} if none */ private PropertyEditor findDefaultEditor(Class requiredType) { PropertyEditor editor = null; @@ -344,10 +344,10 @@ class TypeConverterDelegate { /** * Convert the value to the required type (if necessary from a String), * using the given property editor. - * @param oldValue the previous value, if available (may be null) + * @param oldValue the previous value, if available (may be {@code null}) * @param newValue the proposed new value * @param requiredType the type we must convert to - * (or null if not known, for example in case of a collection element) + * (or {@code null} if not known, for example in case of a collection element) * @param editor the PropertyEditor to use * @return the new value, possibly the result of type conversion * @throws IllegalArgumentException if type conversion failed @@ -434,7 +434,7 @@ class TypeConverterDelegate { /** * Convert the given text value using the given property editor. - * @param oldValue the previous value, if available (may be null) + * @param oldValue the previous value, if available (may be {@code null}) * @param newTextValue the proposed text value * @param editor the PropertyEditor to use * @return the converted value diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java index 61fb062afe..ec1f5a2b4c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java @@ -35,16 +35,19 @@ public abstract class TypeConverterSupport extends PropertyEditorRegistrySupport TypeConverterDelegate typeConverterDelegate; + @Override public T convertIfNecessary(Object value, Class requiredType) throws TypeMismatchException { return doConvert(value, requiredType, null, null); } + @Override public T convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam) throws TypeMismatchException { return doConvert(value, requiredType, methodParam, null); } + @Override public T convertIfNecessary(Object value, Class requiredType, Field field) throws TypeMismatchException { diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeMismatchException.java b/spring-beans/src/main/java/org/springframework/beans/TypeMismatchException.java index f2d05a31f0..83883a31a1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeMismatchException.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeMismatchException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.util.ClassUtils; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class TypeMismatchException extends PropertyAccessException { /** @@ -51,8 +52,8 @@ public class TypeMismatchException extends PropertyAccessException { /** * Create a new TypeMismatchException. * @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem - * @param requiredType the required target type (or null if not known) - * @param cause the root cause (may be null) + * @param requiredType the required target type (or {@code null} if not known) + * @param cause the root cause (may be {@code null}) */ public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) { super(propertyChangeEvent, @@ -69,8 +70,8 @@ public class TypeMismatchException extends PropertyAccessException { /** * Create a new TypeMismatchException without PropertyChangeEvent. - * @param value the offending value that couldn't be converted (may be null) - * @param requiredType the required target type (or null if not known) + * @param value the offending value that couldn't be converted (may be {@code null}) + * @param requiredType the required target type (or {@code null} if not known) */ public TypeMismatchException(Object value, Class requiredType) { this(value, requiredType, null); @@ -78,9 +79,9 @@ public class TypeMismatchException extends PropertyAccessException { /** * Create a new TypeMismatchException without PropertyChangeEvent. - * @param value the offending value that couldn't be converted (may be null) - * @param requiredType the required target type (or null if not known) - * @param cause the root cause (may be null) + * @param value the offending value that couldn't be converted (may be {@code null}) + * @param requiredType the required target type (or {@code null} if not known) + * @param cause the root cause (may be {@code null}) */ public TypeMismatchException(Object value, Class requiredType, Throwable cause) { super("Failed to convert value of type '" + ClassUtils.getDescriptiveType(value) + "'" + @@ -92,7 +93,7 @@ public class TypeMismatchException extends PropertyAccessException { /** - * Return the offending value (may be null) + * Return the offending value (may be {@code null}) */ @Override public Object getValue() { @@ -106,6 +107,7 @@ public class TypeMismatchException extends PropertyAccessException { return this.requiredType; } + @Override public String getErrorCode() { return ERROR_CODE; } diff --git a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java index db3c74965b..f6e1b737ff 100644 --- a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java @@ -38,7 +38,7 @@ public abstract class AnnotationBeanUtils { /** * Copy the properties of the supplied {@link Annotation} to the supplied target bean. - * Any properties defined in excludedProperties will not be copied. + * Any properties defined in {@code excludedProperties} will not be copied. * @param ann the annotation to copy from * @param bean the bean instance to copy to * @param excludedProperties the names of excluded properties, if any @@ -50,11 +50,11 @@ public abstract class AnnotationBeanUtils { /** * Copy the properties of the supplied {@link Annotation} to the supplied target bean. - * Any properties defined in excludedProperties will not be copied. + * Any properties defined in {@code excludedProperties} will not be copied. *

      A specified value resolver may resolve placeholders in property values, for example. * @param ann the annotation to copy from * @param bean the bean instance to copy to - * @param valueResolver a resolve to post-process String property values (may be null) + * @param valueResolver a resolve to post-process String property values (may be {@code null}) * @param excludedProperties the names of excluded properties, if any * @see org.springframework.beans.BeanWrapper */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanClassLoaderAware.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanClassLoaderAware.java index 5ec4832163..ab584354b8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanClassLoaderAware.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanClassLoaderAware.java @@ -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"); * you may not use this file except in compliance with the License. @@ -42,12 +42,12 @@ public interface BeanClassLoaderAware extends Aware { * a bean instance. *

      Invoked after the population of normal bean properties but * before an initialization callback such as - * {@link org.springframework.beans.factory.InitializingBean InitializingBean's} - * {@link org.springframework.beans.factory.InitializingBean#afterPropertiesSet()} + * {@link InitializingBean InitializingBean's} + * {@link InitializingBean#afterPropertiesSet()} * method or a custom init-method. - * @param classLoader the owning class loader; may be null in - * which case a default ClassLoader must be used, for example - * the ClassLoader obtained via + * @param classLoader the owning class loader; may be {@code null} in + * which case a default {@code ClassLoader} must be used, for example + * the {@code ClassLoader} obtained via * {@link org.springframework.util.ClassUtils#getDefaultClassLoader()} */ void setBeanClassLoader(ClassLoader classLoader); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java index 486f9248e7..2ffe909a94 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.core.NestedRuntimeException; * * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class BeanCreationException extends FatalBeanException { private String beanName; @@ -135,7 +136,7 @@ public class BeanCreationException extends FatalBeanException { /** * Return the related causes, if any. - * @return the array of related causes, or null if none + * @return the array of related causes, or {@code null} if none */ public Throwable[] getRelatedCauses() { if (this.relatedCauses == null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationNotAllowedException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationNotAllowedException.java index 2a078c5fb1..480ff82857 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationNotAllowedException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationNotAllowedException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ package org.springframework.beans.factory; * @author Juergen Hoeller * @since 2.0 */ +@SuppressWarnings("serial") public class BeanCreationNotAllowedException extends BeanCreationException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCurrentlyInCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCurrentlyInCreationException.java index 1e014c8563..050444bb4e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCurrentlyInCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCurrentlyInCreationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ package org.springframework.beans.factory; * @author Juergen Hoeller * @since 1.1 */ +@SuppressWarnings("serial") public class BeanCurrentlyInCreationException extends BeanCreationException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java index be86fbd860..47a2ec8c14 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanDefinitionStoreException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.beans.FatalBeanException; * @author Juergen Hoeller * @author Rob Harrop */ +@SuppressWarnings("serial") public class BeanDefinitionStoreException extends FatalBeanException { private String resourceDescription; @@ -44,7 +45,7 @@ public class BeanDefinitionStoreException extends FatalBeanException { /** * Create a new BeanDefinitionStoreException. * @param msg the detail message (used as exception message as-is) - * @param cause the root cause (may be null) + * @param cause the root cause (may be {@code null}) */ public BeanDefinitionStoreException(String msg, Throwable cause) { super(msg, cause); @@ -64,7 +65,7 @@ public class BeanDefinitionStoreException extends FatalBeanException { * Create a new BeanDefinitionStoreException. * @param resourceDescription description of the resource that the bean definition came from * @param msg the detail message (used as exception message as-is) - * @param cause the root cause (may be null) + * @param cause the root cause (may be {@code null}) */ public BeanDefinitionStoreException(String resourceDescription, String msg, Throwable cause) { super(msg, cause); @@ -88,7 +89,7 @@ public class BeanDefinitionStoreException extends FatalBeanException { * @param beanName the name of the bean requested * @param msg the detail message (appended to an introductory message that indicates * the resource and the name of the bean) - * @param cause the root cause (may be null) + * @param cause the root cause (may be {@code null}) */ public BeanDefinitionStoreException(String resourceDescription, String beanName, String msg, Throwable cause) { super("Invalid bean definition with name '" + beanName + "' defined in " + resourceDescription + ": " + msg, cause); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanExpressionException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanExpressionException.java index ab2f2531b0..b935abfbb4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanExpressionException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanExpressionException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.beans.FatalBeanException; * @author Juergen Hoeller * @since 3.0 */ +@SuppressWarnings("serial") public class BeanExpressionException extends FatalBeanException { /** @@ -44,4 +45,4 @@ public class BeanExpressionException extends FatalBeanException { super(msg, cause); } -} \ No newline at end of file +} diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java index 58bba15a4f..2d18e67b1a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ import org.springframework.beans.BeansException; * implemented using this BeanFactory interface and its subinterfaces. * *

      Normally a BeanFactory will load bean definitions stored in a configuration - * source (such as an XML document), and use the org.springframework.beans + * source (such as an XML document), and use the {@code org.springframework.beans} * package to configure the beans. However, an implementation could simply return * Java objects it creates as necessary directly in Java code. There are no * constraints on how the definitions could be stored: LDAP, RDBMS, XML, @@ -63,26 +63,26 @@ import org.springframework.beans.BeansException; * *

      Bean factory implementations should support the standard bean lifecycle interfaces * as far as possible. The full set of initialization methods and their standard order is:
      - * 1. BeanNameAware's setBeanName
      - * 2. BeanClassLoaderAware's setBeanClassLoader
      - * 3. BeanFactoryAware's setBeanFactory
      - * 4. ResourceLoaderAware's setResourceLoader + * 1. BeanNameAware's {@code setBeanName}
      + * 2. BeanClassLoaderAware's {@code setBeanClassLoader}
      + * 3. BeanFactoryAware's {@code setBeanFactory}
      + * 4. ResourceLoaderAware's {@code setResourceLoader} * (only applicable when running in an application context)
      - * 5. ApplicationEventPublisherAware's setApplicationEventPublisher + * 5. ApplicationEventPublisherAware's {@code setApplicationEventPublisher} * (only applicable when running in an application context)
      - * 6. MessageSourceAware's setMessageSource + * 6. MessageSourceAware's {@code setMessageSource} * (only applicable when running in an application context)
      - * 7. ApplicationContextAware's setApplicationContext + * 7. ApplicationContextAware's {@code setApplicationContext} * (only applicable when running in an application context)
      - * 8. ServletContextAware's setServletContext + * 8. ServletContextAware's {@code setServletContext} * (only applicable when running in a web application context)
      - * 9. postProcessBeforeInitialization methods of BeanPostProcessors
      - * 10. InitializingBean's afterPropertiesSet
      + * 9. {@code postProcessBeforeInitialization} methods of BeanPostProcessors
      + * 10. InitializingBean's {@code afterPropertiesSet}
      * 11. a custom init-method definition
      - * 12. postProcessAfterInitialization methods of BeanPostProcessors + * 12. {@code postProcessAfterInitialization} methods of BeanPostProcessors * *

      On shutdown of a bean factory, the following lifecycle methods apply:
      - * 1. DisposableBean's destroy
      + * 1. DisposableBean's {@code destroy}
      * 2. a custom destroy-method definition * * @author Rod Johnson @@ -109,7 +109,7 @@ public interface BeanFactory { /** * Used to dereference a {@link FactoryBean} instance and distinguish it from * beans created by the FactoryBean. For example, if the bean named - * myJndiObject is a FactoryBean, getting &myJndiObject + * {@code myJndiObject} is a FactoryBean, getting {@code &myJndiObject} * will return the factory, not the instance returned by the factory. */ String FACTORY_BEAN_PREFIX = "&"; @@ -139,8 +139,8 @@ public interface BeanFactory { * Will ask the parent factory if the bean cannot be found in this factory instance. * @param name the name of the bean to retrieve * @param requiredType type the bean must match. Can be an interface or superclass - * of the actual class, or null for any match. For example, if the value - * is Object.class, this method will succeed whatever the class of the + * of the actual class, or {@code null} for any match. For example, if the value + * is {@code Object.class}, this method will succeed whatever the class of the * returned instance. * @return an instance of the bean * @throws NoSuchBeanDefinitionException if there's no such bean definition @@ -200,7 +200,7 @@ public interface BeanFactory { /** * Is this bean a shared singleton? That is, will {@link #getBean} always * return the same instance? - *

      Note: This method returning false does not clearly indicate + *

      Note: This method returning {@code false} does not clearly indicate * independent instances. It indicates non-singleton instances, which may correspond * to a scoped bean as well. Use the {@link #isPrototype} operation to explicitly * check for independent instances. @@ -217,7 +217,7 @@ public interface BeanFactory { /** * Is this bean a prototype? That is, will {@link #getBean} always return * independent instances? - *

      Note: This method returning false does not clearly indicate + *

      Note: This method returning {@code false} does not clearly indicate * a singleton object. It indicates non-independent instances, which may correspond * to a scoped bean as well. Use the {@link #isSingleton} operation to explicitly * check for a shared singleton instance. @@ -240,8 +240,8 @@ public interface BeanFactory { * Will ask the parent factory if the bean cannot be found in this factory instance. * @param name the name of the bean to query * @param targetType the type to match against - * @return true if the bean type matches, - * false if it doesn't match or cannot be determined yet + * @return {@code true} if the bean type matches, + * {@code false} if it doesn't match or cannot be determined yet * @throws NoSuchBeanDefinitionException if there is no bean with the given name * @since 2.0.1 * @see #getBean @@ -257,7 +257,7 @@ public interface BeanFactory { *

      Translates aliases back to the corresponding canonical bean name. * Will ask the parent factory if the bean cannot be found in this factory instance. * @param name the name of the bean to query - * @return the type of the bean, or null if not determinable + * @return the type of the bean, or {@code null} if not determinable * @throws NoSuchBeanDefinitionException if there is no bean with the given name * @since 1.1.2 * @see #getBean diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryAware.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryAware.java index f9ea34c86b..a283217c24 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryAware.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryAware.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public interface BeanFactoryAware extends Aware { *

      Invoked after the population of normal bean properties * but before an initialization callback such as * {@link InitializingBean#afterPropertiesSet()} or a custom init-method. - * @param beanFactory owning BeanFactory (never null). + * @param beanFactory owning BeanFactory (never {@code null}). * The bean can immediately call methods on the factory. * @throws BeansException in case of initialization errors * @see BeanInitializationException diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java index 0e58200ad9..2a4f577a1c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java @@ -115,7 +115,7 @@ public abstract class BeanFactoryUtils { public static int countBeansIncludingAncestors(ListableBeanFactory lbf) { return beanNamesIncludingAncestors(lbf).length; } - + /** * Return all bean names in the factory, including ancestor factories. * @param lbf the bean factory @@ -133,7 +133,7 @@ public abstract class BeanFactoryUtils { *

      Does consider objects created by FactoryBeans, which means that FactoryBeans * will get initialized. If the object created by the FactoryBean doesn't match, * the raw FactoryBean itself will be matched against the type. - *

      This version of beanNamesForTypeIncludingAncestors automatically + *

      This version of {@code beanNamesForTypeIncludingAncestors} automatically * includes prototypes and FactoryBeans. * @param lbf the bean factory * @param type the type that beans must match @@ -300,7 +300,7 @@ public abstract class BeanFactoryUtils { *

      Does consider objects created by FactoryBeans, which means that FactoryBeans * will get initialized. If the object created by the FactoryBean doesn't match, * the raw FactoryBean itself will be matched against the type. - *

      This version of beanOfTypeIncludingAncestors automatically includes + *

      This version of {@code beanOfTypeIncludingAncestors} automatically includes * prototypes and FactoryBeans. *

      Note: Beans of the same name will take precedence at the 'lowest' factory level, * i.e. such beans will be returned from the lowest factory that they are being found in, @@ -310,7 +310,7 @@ public abstract class BeanFactoryUtils { * @param lbf the bean factory * @param type type of bean to match * @return the matching bean instance - * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * @throws NoSuchBeanDefinitionException * if 0 or more than 1 beans of the given type were found * @throws BeansException if the bean could not be created */ @@ -375,12 +375,12 @@ public abstract class BeanFactoryUtils { *

      Does consider objects created by FactoryBeans, which means that FactoryBeans * will get initialized. If the object created by the FactoryBean doesn't match, * the raw FactoryBean itself will be matched against the type. - *

      This version of beanOfType automatically includes + *

      This version of {@code beanOfType} automatically includes * prototypes and FactoryBeans. * @param lbf the bean factory * @param type type of bean to match * @return the matching bean instance - * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * @throws NoSuchBeanDefinitionException * if 0 or more than 1 beans of the given type were found * @throws BeansException if the bean could not be created */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanInitializationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanInitializationException.java index 297e9be094..c52d0ae766 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanInitializationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanInitializationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.beans.FatalBeanException; * @see BeanFactoryAware#setBeanFactory * @see InitializingBean#afterPropertiesSet */ +@SuppressWarnings("serial") public class BeanInitializationException extends FatalBeanException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java index 26a5e8f3f3..f7020130e8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ package org.springframework.beans.factory; * @since 1.1 * @see org.springframework.beans.factory.support.AbstractBeanDefinition#setAbstract */ +@SuppressWarnings("serial") public class BeanIsAbstractException extends BeanCreationException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsNotAFactoryException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsNotAFactoryException.java index 7146ec7806..af47ab3f80 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsNotAFactoryException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanIsNotAFactoryException.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,7 @@ package org.springframework.beans.factory; * @since 10.03.2003 * @see org.springframework.beans.factory.FactoryBean */ +@SuppressWarnings("serial") public class BeanIsNotAFactoryException extends BeanNotOfRequiredTypeException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java index efdea3ab3d..3b2914e6c9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanNotOfRequiredTypeException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.beans.BeansException; * @author Rod Johnson * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class BeanNotOfRequiredTypeException extends BeansException { /** The name of the instance that was of the wrong type */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java index 3b15815ea6..772da666e2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.beans.FatalBeanException; * @author Juergen Hoeller * @since 2.0 */ +@SuppressWarnings("serial") public class CannotLoadBeanClassException extends FatalBeanException { private String resourceDescription; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/DisposableBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/DisposableBean.java index 12fdeb853b..5554afc2b3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/DisposableBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/DisposableBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBean.java index 5f30376f11..84763c37f6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -60,12 +60,12 @@ public interface FactoryBean { *

      If this FactoryBean is not fully initialized yet at the time of * the call (for example because it is involved in a circular reference), * throw a corresponding {@link FactoryBeanNotInitializedException}. - *

      As of Spring 2.0, FactoryBeans are allowed to return null + *

      As of Spring 2.0, FactoryBeans are allowed to return {@code null} * objects. The factory will consider this as normal value to be used; it * will not throw a FactoryBeanNotInitializedException in this case anymore. * FactoryBean implementations are encouraged to throw * FactoryBeanNotInitializedException themselves now, as appropriate. - * @return an instance of the bean (can be null) + * @return an instance of the bean (can be {@code null}) * @throws Exception in case of creation errors * @see FactoryBeanNotInitializedException */ @@ -73,7 +73,7 @@ public interface FactoryBean { /** * Return the type of object that this FactoryBean creates, - * or null if not known in advance. + * or {@code null} if not known in advance. *

      This allows one to check for specific types of beans without * instantiating objects, for example on autowiring. *

      In the case of implementations that are creating a singleton object, @@ -84,10 +84,10 @@ public interface FactoryBean { * been fully initialized. It must not rely on state created during * initialization; of course, it can still use such state if available. *

      NOTE: Autowiring will simply ignore FactoryBeans that return - * null here. Therefore it is highly recommended to implement + * {@code null} here. Therefore it is highly recommended to implement * this method properly, using the current state of the FactoryBean. * @return the type of object that this FactoryBean creates, - * or null if not known at the time of the call + * or {@code null} if not known at the time of the call * @see ListableBeanFactory#getBeansOfType */ Class getObjectType(); @@ -97,20 +97,20 @@ public interface FactoryBean { * will {@link #getObject()} always return the same object * (a reference that can be cached)? *

      NOTE: If a FactoryBean indicates to hold a singleton object, - * the object returned from getObject() might get cached - * by the owning BeanFactory. Hence, do not return true + * the object returned from {@code getObject()} might get cached + * by the owning BeanFactory. Hence, do not return {@code true} * unless the FactoryBean always exposes the same reference. *

      The singleton status of the FactoryBean itself will generally * be provided by the owning BeanFactory; usually, it has to be * defined as singleton there. - *

      NOTE: This method returning false does not + *

      NOTE: This method returning {@code false} does not * necessarily indicate that returned objects are independent instances. * An implementation of the extended {@link SmartFactoryBean} interface * may explicitly indicate independent instances through its * {@link SmartFactoryBean#isPrototype()} method. Plain {@link FactoryBean} * implementations which do not implement this extended interface are * simply assumed to always return independent instances if the - * isSingleton() implementation returns false. + * {@code isSingleton()} implementation returns {@code false}. * @return whether the exposed object is a singleton * @see #getObject() * @see SmartFactoryBean#isPrototype() diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBeanNotInitializedException.java b/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBeanNotInitializedException.java index bffb2c14f9..9e8e0e2073 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBeanNotInitializedException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/FactoryBeanNotInitializedException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.beans.factory; import org.springframework.beans.FatalBeanException; /** - * Exception to be thrown from a FactoryBean's getObject() method + * Exception to be thrown from a FactoryBean's {@code getObject()} method * if the bean is not fully initialized yet, for example because it is involved * in a circular reference. * @@ -34,6 +34,7 @@ import org.springframework.beans.FatalBeanException; * @since 30.10.2003 * @see FactoryBean#getObject() */ +@SuppressWarnings("serial") public class FactoryBeanNotInitializedException extends FatalBeanException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/HierarchicalBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/HierarchicalBeanFactory.java index 20eb7845b3..7e6a347afc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/HierarchicalBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/HierarchicalBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ package org.springframework.beans.factory; * Sub-interface implemented by bean factories that can be part * of a hierarchy. * - *

      The corresponding setParentBeanFactory method for bean + *

      The corresponding {@code setParentBeanFactory} method for bean * factories that allow setting the parent in a configurable * fashion can be found in the ConfigurableBeanFactory interface. * @@ -30,20 +30,20 @@ package org.springframework.beans.factory; * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory */ public interface HierarchicalBeanFactory extends BeanFactory { - + /** - * Return the parent bean factory, or null if there is none. + * Return the parent bean factory, or {@code null} if there is none. */ BeanFactory getParentBeanFactory(); /** * Return whether the local bean factory contains a bean of the given name, * ignoring beans defined in ancestor contexts. - *

      This is an alternative to containsBean, ignoring a bean + *

      This is an alternative to {@code containsBean}, ignoring a bean * of the given name from an ancestor bean factory. * @param name the name of the bean to query * @return whether a bean with the given name is defined in the local factory - * @see org.springframework.beans.factory.BeanFactory#containsBean + * @see BeanFactory#containsBean */ boolean containsLocalBean(String name); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/InitializingBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/InitializingBean.java index a21912d31c..365bf99bf1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/InitializingBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/InitializingBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ package org.springframework.beans.factory; * Interface to be implemented by beans that need to react once all their * properties have been set by a BeanFactory: for example, to perform custom * initialization, or merely to check that all mandatory properties have been set. - * + * *

      An alternative to implementing InitializingBean is specifying a custom * init-method, for example in an XML bean definition. * For a list of all bean lifecycle methods, see the BeanFactory javadocs. @@ -33,7 +33,7 @@ package org.springframework.beans.factory; * @see org.springframework.context.ApplicationContextAware */ public interface InitializingBean { - + /** * Invoked by a BeanFactory after it has set all bean properties supplied * (and satisfied BeanFactoryAware and ApplicationContextAware). diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java index e7c08c2dc5..5f5b643f15 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,15 +36,15 @@ import org.springframework.beans.BeansException; *

      The methods in this interface will just respect bean definitions of this factory. * They will ignore any singleton beans that have been registered by other means like * {@link org.springframework.beans.factory.config.ConfigurableBeanFactory}'s - * registerSingleton method, with the exception of - * getBeanNamesOfType and getBeansOfType which will check - * such manually registered singletons too. Of course, BeanFactory's getBean + * {@code registerSingleton} method, with the exception of + * {@code getBeanNamesOfType} and {@code getBeansOfType} which will check + * such manually registered singletons too. Of course, BeanFactory's {@code getBean} * does allow transparent access to such special beans as well. However, in typical * scenarios, all beans will be defined by external bean definitions anyway, so most * applications don't need to worry about this differentation. * - *

      NOTE: With the exception of getBeanDefinitionCount - * and containsBeanDefinition, the methods in this interface + *

      NOTE: With the exception of {@code getBeanDefinitionCount} + * and {@code containsBeanDefinition}, the methods in this interface * are not designed for frequent invocation. Implementations may be slow. * * @author Rod Johnson @@ -84,10 +84,10 @@ public interface ListableBeanFactory extends BeanFactory { * or an empty array if none defined */ String[] getBeanDefinitionNames(); - + /** * Return the names of beans matching the given type (including subclasses), - * judging from either bean definitions or the value of getObjectType + * judging from either bean definitions or the value of {@code getObjectType} * in the case of FactoryBeans. *

      NOTE: This method introspects top-level beans only. It does not * check nested beans which might match the specified type as well. @@ -95,16 +95,16 @@ public interface ListableBeanFactory extends BeanFactory { * will get initialized. If the object created by the FactoryBean doesn't match, * the raw FactoryBean itself will be matched against the type. *

      Does not consider any hierarchy this factory may participate in. - * Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors + * Use BeanFactoryUtils' {@code beanNamesForTypeIncludingAncestors} * to include beans in ancestor factories too. *

      Note: Does not ignore singleton beans that have been registered * by other means than bean definitions. - *

      This version of getBeanNamesForType matches all kinds of beans, + *

      This version of {@code getBeanNamesForType} matches all kinds of beans, * be it singletons, prototypes, or FactoryBeans. In most implementations, the - * result will be the same as for getBeanNamesOfType(type, true, true). + * result will be the same as for {@code getBeanNamesOfType(type, true, true)}. *

      Bean names returned by this method should always return bean names in the * order of definition in the backend configuration, as far as possible. - * @param type the class or interface to match, or null for all bean names + * @param type the class or interface to match, or {@code null} for all bean names * @return the names of beans (or objects created by FactoryBeans) matching * the given object type (including subclasses), or an empty array if none * @see FactoryBean#getObjectType @@ -114,7 +114,7 @@ public interface ListableBeanFactory extends BeanFactory { /** * Return the names of beans matching the given type (including subclasses), - * judging from either bean definitions or the value of getObjectType + * judging from either bean definitions or the value of {@code getObjectType} * in the case of FactoryBeans. *

      NOTE: This method introspects top-level beans only. It does not * check nested beans which might match the specified type as well. @@ -124,13 +124,13 @@ public interface ListableBeanFactory extends BeanFactory { * type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked * (which doesn't require initialization of each FactoryBean). *

      Does not consider any hierarchy this factory may participate in. - * Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors + * Use BeanFactoryUtils' {@code beanNamesForTypeIncludingAncestors} * to include beans in ancestor factories too. *

      Note: Does not ignore singleton beans that have been registered * by other means than bean definitions. *

      Bean names returned by this method should always return bean names in the * order of definition in the backend configuration, as far as possible. - * @param type the class or interface to match, or null for all bean names + * @param type the class or interface to match, or {@code null} for all bean names * @param includeNonSingletons whether to include prototype or scoped beans too * or just singletons (also applies to FactoryBeans) * @param allowEagerInit whether to initialize lazy-init singletons and @@ -148,24 +148,24 @@ public interface ListableBeanFactory extends BeanFactory { /** * Return the bean instances that match the given object type (including * subclasses), judging from either bean definitions or the value of - * getObjectType in the case of FactoryBeans. + * {@code getObjectType} in the case of FactoryBeans. *

      NOTE: This method introspects top-level beans only. It does not * check nested beans which might match the specified type as well. *

      Does consider objects created by FactoryBeans, which means that FactoryBeans * will get initialized. If the object created by the FactoryBean doesn't match, * the raw FactoryBean itself will be matched against the type. *

      Does not consider any hierarchy this factory may participate in. - * Use BeanFactoryUtils' beansOfTypeIncludingAncestors + * Use BeanFactoryUtils' {@code beansOfTypeIncludingAncestors} * to include beans in ancestor factories too. *

      Note: Does not ignore singleton beans that have been registered * by other means than bean definitions. *

      This version of getBeansOfType matches all kinds of beans, be it * singletons, prototypes, or FactoryBeans. In most implementations, the - * result will be the same as for getBeansOfType(type, true, true). + * result will be the same as for {@code getBeansOfType(type, true, true)}. *

      The Map returned by this method should always return bean names and * corresponding bean instances in the order of definition in the * backend configuration, as far as possible. - * @param type the class or interface to match, or null for all concrete beans + * @param type the class or interface to match, or {@code null} for all concrete beans * @return a Map with the matching beans, containing the bean names as * keys and the corresponding bean instances as values * @throws BeansException if a bean could not be created @@ -178,7 +178,7 @@ public interface ListableBeanFactory extends BeanFactory { /** * Return the bean instances that match the given object type (including * subclasses), judging from either bean definitions or the value of - * getObjectType in the case of FactoryBeans. + * {@code getObjectType} in the case of FactoryBeans. *

      NOTE: This method introspects top-level beans only. It does not * check nested beans which might match the specified type as well. *

      Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, @@ -187,14 +187,14 @@ public interface ListableBeanFactory extends BeanFactory { * type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked * (which doesn't require initialization of each FactoryBean). *

      Does not consider any hierarchy this factory may participate in. - * Use BeanFactoryUtils' beansOfTypeIncludingAncestors + * Use BeanFactoryUtils' {@code beansOfTypeIncludingAncestors} * to include beans in ancestor factories too. *

      Note: Does not ignore singleton beans that have been registered * by other means than bean definitions. *

      The Map returned by this method should always return bean names and * corresponding bean instances in the order of definition in the * backend configuration, as far as possible. - * @param type the class or interface to match, or null for all concrete beans + * @param type the class or interface to match, or {@code null} for all concrete beans * @param includeNonSingletons whether to include prototype or scoped beans too * or just singletons (also applies to FactoryBeans) * @param allowEagerInit whether to initialize lazy-init singletons and @@ -212,7 +212,7 @@ public interface ListableBeanFactory extends BeanFactory { throws BeansException; /** - * Find all beans whose Class has the supplied {@link java.lang.annotation.Annotation} type. + * Find all beans whose {@code Class} has the supplied {@link java.lang.annotation.Annotation} type. * @param annotationType the type of annotation to look for * @return a Map with the matching beans, containing the bean names as * keys and the corresponding bean instances as values @@ -222,12 +222,12 @@ public interface ListableBeanFactory extends BeanFactory { throws BeansException; /** - * Find a {@link Annotation} of annotationType on the specified + * Find a {@link Annotation} of {@code annotationType} on the specified * bean, traversing its interfaces and super classes if no annotation can be * found on the given class itself. * @param beanName the name of the bean to look for annotations on * @param annotationType the annotation class to look for - * @return the annotation of the given type found, or null + * @return the annotation of the given type found, or {@code null} */ A findAnnotationOnBean(String beanName, Class annotationType); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java b/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java index 7462089556..0157d08650 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java @@ -73,7 +73,7 @@ public class NoSuchBeanDefinitionException extends BeansException { super("No unique bean of type [" + type.getName() + "] is defined: " + message); this.beanType = type; } - + /** * Create a new {@code NoSuchBeanDefinitionException}. * @param type required type of the missing bean diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/ObjectFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/ObjectFactory.java index b81ee6ca37..40f807dd54 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/ObjectFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/ObjectFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.beans.BeansException; * of the latter are normally meant to be defined as SPI instances in a * {@link BeanFactory}, while implementations of this class are normally meant * to be fed as an API to other beans (through injection). As such, the - * getObject() method has different exception handling behavior. + * {@code getObject()} method has different exception handling behavior. * * @author Colin Sampaleanu * @since 1.0.2 @@ -40,7 +40,7 @@ public interface ObjectFactory { /** * Return an instance (possibly shared or independent) * of the object managed by this factory. - * @return an instance of the bean (should never be null) + * @return an instance of the bean (should never be {@code null}) * @throws BeansException in case of creation errors */ T getObject() throws BeansException; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/SmartFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/SmartFactoryBean.java index c54676eda1..143936f7b7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/SmartFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/SmartFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ package org.springframework.beans.factory; * Extension of the {@link FactoryBean} interface. Implementations may * indicate whether they always return independent instances, for the * case where their {@link #isSingleton()} implementation returning - * false does not clearly indicate independent instances. + * {@code false} does not clearly indicate independent instances. * *

      Plain {@link FactoryBean} implementations which do not implement * this extended interface are simply assumed to always return independent * instances if their {@link #isSingleton()} implementation returns - * false; the exposed object is only accessed on demand. + * {@code false}; the exposed object is only accessed on demand. * *

      NOTE: This interface is a special purpose interface, mainly for * internal use within the framework and within collaborating frameworks. @@ -47,7 +47,7 @@ public interface SmartFactoryBean extends FactoryBean { * be provided by the owning {@link BeanFactory}; usually, it has to be * defined as singleton there. *

      This method is supposed to strictly check for independent instances; - * it should not return true for scoped objects or other + * it should not return {@code true} for scoped objects or other * kinds of non-singleton, non-independent objects. For this reason, * this is not simply the inverted form of {@link #isSingleton()}. * @return whether the exposed object is a prototype @@ -62,7 +62,7 @@ public interface SmartFactoryBean extends FactoryBean { * of its singleton object (if any)? *

      A standard FactoryBean is not expected to initialize eagerly: * Its {@link #getObject()} will only be called for actual access, even - * in case of a singleton object. Returning true from this + * in case of a singleton object. Returning {@code true} from this * method suggests that {@link #getObject()} should be called eagerly, * also applying post-processors eagerly. This may make sense in case * of a {@link #isSingleton() singleton} object, in particular if diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java index ae2cc0de0a..5a455420d3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/UnsatisfiedDependencyException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.util.ClassUtils; * @author Juergen Hoeller * @since 03.09.2003 */ +@SuppressWarnings("serial") public class UnsatisfiedDependencyException extends BeanCreationException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryLocator.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryLocator.java index b4308aa7e9..b917de2a17 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryLocator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryLocator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.beans.BeansException; /** * Defines a contract for the lookup, use, and release of a * {@link org.springframework.beans.factory.BeanFactory}, - * or a BeanFactory subclass such as an + * or a {@code BeanFactory} subclass such as an * {@link org.springframework.context.ApplicationContext}. * *

      Where this interface is implemented as a singleton class such as @@ -29,20 +29,20 @@ import org.springframework.beans.BeansException; * suggests that it be used sparingly and with caution. By far the vast majority * of the code inside an application is best written in a Dependency Injection * style, where that code is served out of a - * BeanFactory/ApplicationContext container, and has + * {@code BeanFactory}/{@code ApplicationContext} container, and has * its own dependencies supplied by the container when it is created. However, * even such a singleton implementation sometimes has its use in the small glue * layers of code that is sometimes needed to tie other code together. For * example, third party code may try to construct new objects directly, without - * the ability to force it to get these objects out of a BeanFactory. + * the ability to force it to get these objects out of a {@code BeanFactory}. * If the object constructed by the third party code is just a small stub or * proxy, which then uses an implementation of this class to get a - * BeanFactory from which it gets the real object, to which it + * {@code BeanFactory} from which it gets the real object, to which it * delegates, then proper Dependency Injection has been achieved. * *

      As another example, in a complex J2EE app with multiple layers, with each - * layer having its own ApplicationContext definition (in a - * hierarchy), a class like SingletonBeanFactoryLocator may be used + * layer having its own {@code ApplicationContext} definition (in a + * hierarchy), a class like {@code SingletonBeanFactoryLocator} may be used * to demand load these contexts. * * @author Colin Sampaleanu @@ -55,13 +55,13 @@ public interface BeanFactoryLocator { /** * Use the {@link org.springframework.beans.factory.BeanFactory} (or derived * interface such as {@link org.springframework.context.ApplicationContext}) - * specified by the factoryKey parameter. + * specified by the {@code factoryKey} parameter. *

      The definition is possibly loaded/created as needed. - * @param factoryKey a resource name specifying which BeanFactory the - * BeanFactoryLocator must return for usage. The actual meaning of the - * resource name is specific to the implementation of BeanFactoryLocator. - * @return the BeanFactory instance, wrapped as a {@link BeanFactoryReference} object - * @throws BeansException if there is an error loading or accessing the BeanFactory + * @param factoryKey a resource name specifying which {@code BeanFactory} the + * {@code BeanFactoryLocator} must return for usage. The actual meaning of the + * resource name is specific to the implementation of {@code BeanFactoryLocator}. + * @return the {@code BeanFactory} instance, wrapped as a {@link BeanFactoryReference} object + * @throws BeansException if there is an error loading or accessing the {@code BeanFactory} */ BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java index 953b0cacf4..35c3d3f51f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public interface BeanFactoryReference { /** * Return the {@link BeanFactory} instance held by this reference. - * @throws IllegalStateException if invoked after release() has been called + * @throws IllegalStateException if invoked after {@code release()} has been called */ BeanFactory getFactory(); @@ -42,14 +42,14 @@ public interface BeanFactoryReference { * Indicate that the {@link BeanFactory} instance referred to by this object is not * needed any longer by the client code which obtained the {@link BeanFactoryReference}. *

      Depending on the actual implementation of {@link BeanFactoryLocator}, and - * the actual type of BeanFactory, this may possibly not actually - * do anything; alternately in the case of a 'closeable' BeanFactory + * the actual type of {@code BeanFactory}, this may possibly not actually + * do anything; alternately in the case of a 'closeable' {@code BeanFactory} * or derived class (such as {@link org.springframework.context.ApplicationContext}) * may 'close' it, or may 'close' it once no more references remain. *

      In an EJB usage scenario this would normally be called from - * ejbRemove() and ejbPassivate(). + * {@code ejbRemove()} and {@code ejbPassivate()}. *

      This is safe to call multiple times. - * @throws FatalBeanException if the BeanFactory cannot be released + * @throws FatalBeanException if the {@code BeanFactory} cannot be released * @see BeanFactoryLocator * @see org.springframework.context.access.ContextBeanFactoryReference * @see org.springframework.context.ConfigurableApplicationContext#close() diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/BootstrapException.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/BootstrapException.java index b502384d70..d2a72bc368 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/BootstrapException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/BootstrapException.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,6 +24,7 @@ import org.springframework.beans.FatalBeanException; * @author Rod Johnson * @since 02.12.2002 */ +@SuppressWarnings("serial") public class BootstrapException extends FatalBeanException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java index 8425921237..c9536c7729 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.core.io.support.ResourcePatternUtils; * which accesses shared Spring {@link BeanFactory} instances.

      * *

      Please see the warning in BeanFactoryLocator's javadoc about appropriate usage - * of singleton style BeanFactoryLocator implementations. It is the opinion of the + * of singleton style BeanFactoryLocator implementations. It is the opinion of the * Spring team that the use of this class and similar classes is unnecessary except * (sometimes) for a small amount of glue code. Excessive usage will lead to code * that is more tightly coupled, and harder to modify or test.

      @@ -50,11 +50,11 @@ import org.springframework.core.io.support.ResourcePatternUtils; * searched for is 'classpath*:beanRefFactory.xml', with the Spring-standard * 'classpath*:' prefix ensuring that if the classpath contains multiple copies * of this file (perhaps one in each component jar) they will be combined. To - * override the default resource name, instead of using the no-arg + * override the default resource name, instead of using the no-arg * {@link #getInstance()} method, use the {@link #getInstance(String selector)} * variant, which will treat the 'selector' argument as the resource name to * search for.

      - * + * *

      The purpose of this 'outer' BeanFactory is to create and hold a copy of one * or more 'inner' BeanFactory or ApplicationContext instances, and allow those * to be obtained either directly or via an alias. As such, this class provides @@ -66,12 +66,12 @@ import org.springframework.core.io.support.ResourcePatternUtils; *

      Consider an example application scenario: * *

        - *
      • com.mycompany.myapp.util.applicationContext.xml - + *
      • {@code com.mycompany.myapp.util.applicationContext.xml} - * ApplicationContext definition file which defines beans for 'util' layer. - *
      • com.mycompany.myapp.dataaccess-applicationContext.xml - + *
      • {@code com.mycompany.myapp.dataaccess-applicationContext.xml} - * ApplicationContext definition file which defines beans for 'data access' layer. * Depends on the above. - *
      • com.mycompany.myapp.services.applicationContext.xml - + *
      • {@code com.mycompany.myapp.services.applicationContext.xml} - * ApplicationContext definition file which defines beans for 'services' layer. * Depends on the above. *
      @@ -80,10 +80,10 @@ import org.springframework.core.io.support.ResourcePatternUtils; * or created as three hierarchical ApplicationContexts, by one piece of code * somewhere at application startup (perhaps a Servlet filter), from which all other * code in the application would flow, obtained as beans from the context(s). However - * when third party code enters into the picture, things can get problematic. If the + * when third party code enters into the picture, things can get problematic. If the * third party code needs to create user classes, which should normally be obtained * from a Spring BeanFactory/ApplicationContext, but can handle only newInstance() - * style object creation, then some extra work is required to actually access and + * style object creation, then some extra work is required to actually access and * use object from a BeanFactory/ApplicationContext. One solutions is to make the * class created by the third party code be just a stub or proxy, which gets the * real object from a BeanFactory/ApplicationContext, and delegates to it. However, @@ -101,19 +101,19 @@ import org.springframework.core.io.support.ResourcePatternUtils; * *

      Another use of SingletonBeanFactoryLocator, is to demand-load/use one or more * BeanFactories/ApplicationContexts. Because the definition can contain one of more - * BeanFactories/ApplicationContexts, which can be independent or in a hierarchy, if + * BeanFactories/ApplicationContexts, which can be independent or in a hierarchy, if * they are set to lazy-initialize, they will only be created when actually requested * for use. * *

      Given the above-mentioned three ApplicationContexts, consider the simplest * SingletonBeanFactoryLocator usage scenario, where there is only one single - * beanRefFactory.xml definition file: + * {@code beanRefFactory.xml} definition file: * *

      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
      - * 
      + *
        *   <bean id="com.mycompany.myapp"
        *         class="org.springframework.context.support.ClassPathXmlApplicationContext">
        *     <constructor-arg>
      @@ -124,7 +124,7 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *       </list>
        *     </constructor-arg>
        *   </bean>
      - * 
      + *
        * </beans>
        * 
      * @@ -133,24 +133,24 @@ import org.springframework.core.io.support.ResourcePatternUtils; *
        * BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance();
        * BeanFactoryReference bf = bfl.useBeanFactory("com.mycompany.myapp");
      - * // now use some bean from factory 
      + * // now use some bean from factory
        * MyClass zed = bf.getFactory().getBean("mybean");
        * 
      * - * Another relatively simple variation of the beanRefFactory.xml definition file could be: + * Another relatively simple variation of the {@code beanRefFactory.xml} definition file could be: * *
      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
      - * 
      + *
        *   <bean id="com.mycompany.myapp.util" lazy-init="true"
        *         class="org.springframework.context.support.ClassPathXmlApplicationContext">
        *     <constructor-arg>
        *       <value>com/mycompany/myapp/util/applicationContext.xml</value>
        *     </constructor-arg>
        *   </bean>
      - * 
      + *
        *   <!-- child of above -->
        *   <bean id="com.mycompany.myapp.dataaccess" lazy-init="true"
        *         class="org.springframework.context.support.ClassPathXmlApplicationContext">
      @@ -161,7 +161,7 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *       <ref bean="com.mycompany.myapp.util"/>
        *     </constructor-arg>
        *   </bean>
      - * 
      + *
        *   <!-- child of above -->
        *   <bean id="com.mycompany.myapp.services" lazy-init="true"
        *         class="org.springframework.context.support.ClassPathXmlApplicationContext">
      @@ -172,7 +172,7 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *       <ref bean="com.mycompany.myapp.dataaccess"/>
        *     </constructor-arg>
        *   </bean>
      - * 
      + *
        *   <!-- define an alias -->
        *   <bean id="com.mycompany.myapp.mypackage"
        *         class="java.lang.String">
      @@ -180,7 +180,7 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *       <value>com.mycompany.myapp.services</value>
        *     </constructor-arg>
        *   </bean>
      - * 
      + *
        * </beans>
        * 
      * @@ -193,14 +193,14 @@ import org.springframework.core.io.support.ResourcePatternUtils; * actual definition file(s) for the SingletonBeanFactoryLocator maps that id to * a real context id. * - *

      A final example is more complex, with a beanRefFactory.xml for every module. + *

      A final example is more complex, with a {@code beanRefFactory.xml} for every module. * All the files are automatically combined to create the final definition. * - *

      beanRefFactory.xml file inside jar for util module: + *

      {@code beanRefFactory.xml} file inside jar for util module: * *

      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
        *   <bean id="com.mycompany.myapp.util" lazy-init="true"
        *        class="org.springframework.context.support.ClassPathXmlApplicationContext">
      @@ -210,12 +210,12 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *   </bean>
        * </beans>
        * 
      - * - * beanRefFactory.xml file inside jar for data-access module:
      + * + * {@code beanRefFactory.xml} file inside jar for data-access module:
      * *
      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
        *   <!-- child of util -->
        *   <bean id="com.mycompany.myapp.dataaccess" lazy-init="true"
      @@ -229,12 +229,12 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *   </bean>
        * </beans>
        * 
      - * - * beanRefFactory.xml file inside jar for services module: + * + * {@code beanRefFactory.xml} file inside jar for services module: * *
      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
        *   <!-- child of data-access -->
        *   <bean id="com.mycompany.myapp.services" lazy-init="true"
      @@ -248,20 +248,20 @@ import org.springframework.core.io.support.ResourcePatternUtils;
        *   </bean>
        * </beans>
        * 
      - * - * beanRefFactory.xml file inside jar for mypackage module. This doesn't + * + * {@code beanRefFactory.xml} file inside jar for mypackage module. This doesn't * create any of its own contexts, but allows the other ones to be referred to be * a name known to this module: * *
      <?xml version="1.0" encoding="UTF-8"?>
        * <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
      - * 
      + *
        * <beans>
        *   <!-- define an alias for "com.mycompany.myapp.services" -->
        *   <alias name="com.mycompany.myapp.services" alias="com.mycompany.myapp.mypackage"/>
        * </beans>
        * 
      - * + * * @author Colin Sampaleanu * @author Juergen Hoeller * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator @@ -280,7 +280,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { /** * Returns an instance which uses the default "classpath*:beanRefFactory.xml", * as the name of the definition file(s). All resources returned by calling the - * current thread context ClassLoader's getResources method with + * current thread context ClassLoader's {@code getResources} method with * this name will be combined to create a BeanFactory definition set. * @return the corresponding BeanFactoryLocator instance * @throws BeansException in case of factory loading failure @@ -293,7 +293,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { * Returns an instance which uses the the specified selector, as the name of the * definition file(s). In the case of a name with a Spring 'classpath*:' prefix, * or with no prefix, which is treated the same, the current thread context - * ClassLoader's getResources method will be called with this value + * ClassLoader's {@code getResources} method will be called with this value * to get all resources having that name. These resources will then be combined to * form a definition. In the case where the name uses a Spring 'classpath:' prefix, * or a standard URL prefix, then only one resource file will be loaded as the @@ -349,6 +349,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { this.resourceLocation = resourceLocation; } + @Override public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException { synchronized (this.bfgInstancesByKey) { BeanFactoryGroup bfg = this.bfgInstancesByKey.get(this.resourceLocation); @@ -362,7 +363,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { logger.trace("Factory group with resource name [" + this.resourceLocation + "] requested. Creating new instance."); } - + // Create the BeanFactory but don't initialize it. BeanFactory groupContext = createDefinition(this.resourceLocation, factoryKey); @@ -446,7 +447,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { return factory; } - + /** * Instantiate singletons and do any other normal initialization of the factory. * Subclasses that override {@link #createDefinition createDefinition()} should @@ -500,11 +501,13 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { this.groupContextRef = groupContext; } + @Override public BeanFactory getFactory() { return this.beanFactory; } // Note that it's legal to call release more than once! + @Override public void release() throws FatalBeanException { synchronized (bfgInstancesByKey) { BeanFactory savedRef = this.groupContextRef; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java index 73a86c078c..e97329df74 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.BeanFactory; /** - * Unified EL ELResolver that delegates to a Spring BeanFactory, + * Unified EL {@code ELResolver} that delegates to a Spring BeanFactory, * resolving name references to Spring-defined beans. * * @author Juergen Hoeller @@ -110,7 +110,7 @@ public abstract class SpringBeanELResolver extends ELResolver { /** * Retrieve the Spring BeanFactory to delegate bean name resolution to. * @param elContext the current ELContext - * @return the Spring BeanFactory (never null) + * @return the Spring BeanFactory (never {@code null}) */ protected abstract BeanFactory getBeanFactory(ELContext elContext); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/package-info.java index 85e6b11a02..7c4a159d5f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/package-info.java @@ -2,7 +2,7 @@ /** * * Helper infrastructure to locate and access bean factories. - * + * *

      Note: This package is only relevant for special sharing of bean * factories, for example behind EJB facades. It is not used in a * typical web application or standalone application. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.java index 4e53fec1ad..7eef126d8d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedBeanDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public interface AnnotatedBeanDefinition extends BeanDefinition { /** * Obtain the annotation metadata (as well as basic class metadata) * for this bean definition's bean class. - * @return the annotation metadata object (never null) + * @return the annotation metadata object (never {@code null}) */ AnnotationMetadata getMetadata(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedGenericBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedGenericBeanDefinition.java index f0fd4c5cac..9cbd62ccf5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedGenericBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotatedGenericBeanDefinition.java @@ -71,6 +71,7 @@ public class AnnotatedGenericBeanDefinition extends GenericBeanDefinition implem } + @Override public final AnnotationMetadata getMetadata() { return this.metadata; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java index ef1a2e4b63..78fe8fe86a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.util.ClassUtils; */ public class AnnotationBeanWiringInfoResolver implements BeanWiringInfoResolver { + @Override public BeanWiringInfo resolveWiringInfo(Object beanInstance) { Assert.notNull(beanInstance, "Bean instance must not be null"); Configurable annotation = beanInstance.getClass().getAnnotation(Configurable.class); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java index 7d2178da0a..fc8b49bc20 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java @@ -71,7 +71,7 @@ public @interface Autowired { /** * Declares whether the annotated dependency is required. - *

      Defaults to true. + *

      Defaults to {@code true}. */ boolean required() default true; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 4d0b8b5bbf..6a0442c3d0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -67,13 +67,13 @@ import org.springframework.util.ReflectionUtils; * Spring's {@link Autowired @Autowired} and {@link Value @Value} annotations. * *

      Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation, - * if available, as a direct alternative to Spring's own @Autowired. + * if available, as a direct alternative to Spring's own {@code @Autowired}. * *

      Only one constructor (at max) of any given bean class may carry this - * annotation with the 'required' parameter set to true, - * indicating the constructor to autowire when used as a Spring bean. - * If multiple non-required constructors carry the annotation, they - * will be considered as candidates for autowiring. The constructor with + * annotation with the 'required' parameter set to {@code true}, + * indicating the constructor to autowire when used as a Spring bean. + * If multiple non-required constructors carry the annotation, they + * will be considered as candidates for autowiring. The constructor with * the greatest number of dependencies that can be satisfied by matching * beans in the Spring container will be chosen. If none of the candidates * can be satisfied, then a default constructor (if present) will be used. @@ -109,9 +109,9 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean private final Set> autowiredAnnotationTypes = new LinkedHashSet>(); - + private String requiredParameterName = "required"; - + private boolean requiredParameterValue = true; private int order = Ordered.LOWEST_PRECEDENCE - 2; @@ -185,10 +185,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean } /** - * Set the boolean value that marks a dependency as required - *

      For example if using 'required=true' (the default), - * this value should be true; but if using - * 'optional=false', this value should be false. + * Set the boolean value that marks a dependency as required + *

      For example if using 'required=true' (the default), + * this value should be {@code true}; but if using + * 'optional=false', this value should be {@code false}. * @see #setRequiredParameterName(String) */ public void setRequiredParameterValue(boolean requiredParameterValue) { @@ -199,10 +199,12 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalArgumentException( @@ -212,6 +214,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean } + @Override public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) { if (beanType != null) { InjectionMetadata metadata = findAutowiringMetadata(beanType); @@ -292,7 +295,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean /** * 'Native' processing method for direct calls with an arbitrary target instance, - * resolving all of its fields and methods which are annotated with @Autowired. + * resolving all of its fields and methods which are annotated with {@code @Autowired}. * @param bean the target instance to process * @throws BeansException if autowiring failed */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Configurable.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Configurable.java index 040a80981c..dc594157ae 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Configurable.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Configurable.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ import java.lang.annotation.Target; /** * Marks a class as being eligible for Spring-driven configuration. - * - *

      Typically used with the AspectJ AnnotationBeanConfigurerAspect. + * + *

      Typically used with the AspectJ {@code AnnotationBeanConfigurerAspect}. * * @author Rod Johnson * @author Rob Harrop @@ -54,7 +54,7 @@ public @interface Configurable { * Is dependency checking to be performed for configured objects? */ boolean dependencyCheck() default false; - + /** * Are dependencies to be injected prior to the construction of an object? */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java index 91bc3b5bfe..2d6934de0c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurer.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,10 +59,12 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } @@ -82,6 +84,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC } + @Override @SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (this.customQualifierTypes != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java index 74a5e59d24..2bc1537f9a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java @@ -112,11 +112,13 @@ public class InitDestroyAnnotationBeanPostProcessor this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) { if (beanType != null) { LifecycleMetadata metadata = findLifecycleMetadata(beanType); @@ -124,6 +126,7 @@ public class InitDestroyAnnotationBeanPostProcessor } } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { LifecycleMetadata metadata = findLifecycleMetadata(bean.getClass()); try { @@ -138,10 +141,12 @@ public class InitDestroyAnnotationBeanPostProcessor return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } + @Override public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { LifecycleMetadata metadata = findLifecycleMetadata(bean.getClass()); try { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java index 5bbed07d91..2a7f122f9d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java @@ -36,6 +36,7 @@ import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; /** * {@link AutowireCandidateResolver} implementation that matches bean definition qualifiers @@ -125,6 +126,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan this.valueAnnotationType = valueAnnotationType; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -142,6 +144,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan * attribute does not match. * @see Qualifier */ + @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { if (!bdHolder.getBeanDefinition().isAutowireCandidate()) { // if explicitly false, do not proceed with qualifier check @@ -192,7 +195,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan foundMeta = true; // Only accept fallback match if @Qualifier annotation has a value... // Otherwise it is just a marker for a custom qualifier annotation. - if ((fallbackToMeta && AnnotationUtils.getValue(metaAnn) == null) || + if ((fallbackToMeta && StringUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) || !checkQualifier(bdHolder, metaAnn, typeConverter)) { return false; } @@ -292,6 +295,7 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan * Determine whether the given dependency carries a value annotation. * @see Value */ + @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java index 91aff60e6f..bb342c7854 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Required.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.lang.annotation.Target; /** * Marks a method (typically a JavaBean setter method) as being 'required': that is, * the setter method must be configured to be dependency-injected with a value. - * + * *

      Please do consult the javadoc for the {@link RequiredAnnotationBeanPostProcessor} * class (which, by default, checks for the presence of this annotation). * diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java index e4db17e1eb..19f3035a36 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java @@ -57,7 +57,7 @@ import org.springframework.util.Assert; * still be desirable), because all that this class does is enforce that a * 'required' property has actually been configured with a value. It does * not check anything else... In particular, it does not check that a - * configured value is not null. + * configured value is not {@code null}. * *

      Note: A default RequiredAnnotationBeanPostProcessor will be registered * by the "context:annotation-config" and "context:component-scan" XML tags. @@ -116,6 +116,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP return this.requiredAnnotationType; } + @Override public void setBeanFactory(BeanFactory beanFactory) { if (beanFactory instanceof ConfigurableListableBeanFactory) { this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; @@ -126,11 +127,13 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) { } @@ -163,7 +166,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP * {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any. * @param beanFactory the BeanFactory to check against * @param beanName the name of the bean to check against - * @return true to skip the bean; false to process it + * @return {@code true} to skip the bean; {@code false} to process it */ protected boolean shouldSkip(ConfigurableListableBeanFactory beanFactory, String beanName) { if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) { @@ -178,9 +181,9 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP *

      This implementation looks for the existence of a * {@link #setRequiredAnnotationType "required" annotation} * on the supplied {@link PropertyDescriptor property}. - * @param propertyDescriptor the target PropertyDescriptor (never null) - * @return true if the supplied property has been marked as being required; - * false if not, or if the supplied property does not have a setter method + * @param propertyDescriptor the target PropertyDescriptor (never {@code null}) + * @return {@code true} if the supplied property has been marked as being required; + * {@code false} if not, or if the supplied property does not have a setter method */ protected boolean isRequiredProperty(PropertyDescriptor propertyDescriptor) { Method setter = propertyDescriptor.getWriteMethod(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java index 67d5245278..2dda2ca735 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,11 +41,11 @@ import org.springframework.util.ReflectionUtils; * Simple template superclass for {@link FactoryBean} implementations that * creates a singleton or a prototype object, depending on a flag. * - *

      If the "singleton" flag is true (the default), + *

      If the "singleton" flag is {@code true} (the default), * this class will create the object that it creates exactly once * on initialization and subsequently return said singleton instance * on all calls to the {@link #getObject()} method. - * + * *

      Else, this class will create a new instance every time the * {@link #getObject()} method is invoked. Subclasses are responsible * for implementing the abstract {@link #createInstance()} template @@ -78,20 +78,23 @@ public abstract class AbstractFactoryBean /** * Set if a singleton should be created, or a new object on each request - * otherwise. Default is true (a singleton). + * otherwise. Default is {@code true} (a singleton). */ public void setSingleton(boolean singleton) { this.singleton = singleton; } + @Override public boolean isSingleton() { return this.singleton; } + @Override public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -124,6 +127,7 @@ public abstract class AbstractFactoryBean /** * Eagerly create the singleton instance, if necessary. */ + @Override public void afterPropertiesSet() throws Exception { if (isSingleton()) { this.initialized = true; @@ -138,6 +142,7 @@ public abstract class AbstractFactoryBean * @see #createInstance() * @see #getEarlySingletonInterfaces() */ + @Override public final T getObject() throws Exception { if (isSingleton()) { return (this.initialized ? this.singletonInstance : getEarlySingletonInstance()); @@ -181,6 +186,7 @@ public abstract class AbstractFactoryBean * Destroy the singleton instance, if any. * @see #destroyInstance(Object) */ + @Override public void destroy() throws Exception { if (isSingleton()) { destroyInstance(this.singletonInstance); @@ -193,6 +199,7 @@ public abstract class AbstractFactoryBean * interface, for a consistent offering of abstract template methods. * @see org.springframework.beans.factory.FactoryBean#getObjectType() */ + @Override public abstract Class getObjectType(); /** @@ -211,11 +218,11 @@ public abstract class AbstractFactoryBean * FactoryBean is supposed to implement, for use with an 'early singleton * proxy' that will be exposed in case of a circular reference. *

      The default implementation returns this FactoryBean's object type, - * provided that it is an interface, or null else. The latter + * provided that it is an interface, or {@code null} else. The latter * indicates that early singleton access is not supported by this FactoryBean. * This will lead to a FactoryBeanNotInitializedException getting thrown. * @return the interfaces to use for 'early singletons', - * or null to indicate a FactoryBeanNotInitializedException + * or {@code null} to indicate a FactoryBeanNotInitializedException * @see org.springframework.beans.factory.FactoryBeanNotInitializedException */ protected Class[] getEarlySingletonInterfaces() { @@ -241,6 +248,7 @@ public abstract class AbstractFactoryBean */ private class EarlySingletonInvocationHandler implements InvocationHandler { + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (ReflectionUtils.isEqualsMethod(method)) { // Only consider equal when proxies are identical. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java index 050ca889ca..e71eb1a899 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -137,8 +137,8 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Configure the given raw bean: autowiring bean properties, applying - * bean property values, applying factory callbacks such as setBeanName - * and setBeanFactory, and also applying all bean post processors + * bean property values, applying factory callbacks such as {@code setBeanName} + * and {@code setBeanFactory}, and also applying all bean post processors * (including ones which might wrap the given raw bean). *

      This is effectively a superset of what {@link #initializeBean} provides, * fully applying the configuration specified by the corresponding bean definition. @@ -158,7 +158,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { * Resolve the specified dependency against the beans defined in this factory. * @param descriptor the descriptor for the dependency * @param beanName the name of the bean which declares the present dependency - * @return the resolved object, or null if none found + * @return the resolved object, or {@code null} if none found * @throws BeansException in dependency resolution failed */ Object resolveDependency(DependencyDescriptor descriptor, String beanName) throws BeansException; @@ -190,7 +190,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Instantiate a new bean instance of the given class with the specified autowire * strategy. All constants defined in this interface are supported here. - * Can also be invoked with AUTOWIRE_NO in order to just apply + * Can also be invoked with {@code AUTOWIRE_NO} in order to just apply * before-instantiation callbacks (e.g. for annotation-driven injection). *

      Does not apply standard {@link BeanPostProcessor BeanPostProcessors} * callbacks or perform any further initialization of the bean. This interface @@ -217,7 +217,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Autowire the bean properties of the given bean instance by name or type. - * Can also be invoked with AUTOWIRE_NO in order to just apply + * Can also be invoked with {@code AUTOWIRE_NO} in order to just apply * after-instantiation callbacks (e.g. for annotation-driven injection). *

      Does not apply standard {@link BeanPostProcessor BeanPostProcessors} * callbacks or perform any further initialization of the bean. This interface @@ -262,7 +262,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Initialize the given raw bean, applying factory callbacks - * such as setBeanName and setBeanFactory, + * such as {@code setBeanName} and {@code setBeanFactory}, * also applying all bean post processors (including ones which * might wrap the given raw bean). *

      Note that no bean definition of the given name has to exist @@ -278,7 +278,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean - * instance, invoking their postProcessBeforeInitialization methods. + * instance, invoking their {@code postProcessBeforeInitialization} methods. * The returned bean instance may be a wrapper around the original. * @param existingBean the new bean instance * @param beanName the name of the bean @@ -291,7 +291,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { /** * Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean - * instance, invoking their postProcessAfterInitialization methods. + * instance, invoking their {@code postProcessAfterInitialization} methods. * The returned bean instance may be a wrapper around the original. * @param existingBean the new bean instance * @param beanName the name of the bean @@ -310,7 +310,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory { * resolving the present dependency) are supposed to be added to * @param typeConverter the TypeConverter to use for populating arrays and * collections - * @return the resolved object, or null if none found + * @return the resolved object, or {@code null} if none found * @throws BeansException in dependency resolution failed */ Object resolveDependency(DependencyDescriptor descriptor, String beanName, diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java index f71ec5da20..b0b4142ec6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -54,16 +54,16 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { /** - * Role hint indicating that a BeanDefinition is a major part + * Role hint indicating that a {@code BeanDefinition} is a major part * of the application. Typically corresponds to a user-defined bean. */ int ROLE_APPLICATION = 0; /** - * Role hint indicating that a BeanDefinition is a supporting + * Role hint indicating that a {@code BeanDefinition} is a supporting * part of some larger configuration, typically an outer * {@link org.springframework.beans.factory.parsing.ComponentDefinition}. - * SUPPORT beans are considered important enough to be aware + * {@code SUPPORT} beans are considered important enough to be aware * of when looking more closely at a particular * {@link org.springframework.beans.factory.parsing.ComponentDefinition}, * but not when looking at the overall configuration of an application. @@ -71,7 +71,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { int ROLE_SUPPORT = 1; /** - * Role hint indicating that a BeanDefinition is providing an + * Role hint indicating that a {@code BeanDefinition} is providing an * entirely background role and has no relevance to the end-user. This hint is * used when registering beans that are completely part of the internal workings * of a {@link org.springframework.beans.factory.parsing.ComponentDefinition}. @@ -126,14 +126,14 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { * The method will be invoked on the specified factory bean, if any, * or otherwise as a static method on the local bean class. * @param factoryMethodName static factory method name, - * or null if normal constructor creation should be used + * or {@code null} if normal constructor creation should be used * @see #getBeanClassName() */ void setFactoryMethodName(String factoryMethodName); /** * Return the name of the current target scope for this bean, - * or null if not known yet. + * or {@code null} if not known yet. */ String getScope(); @@ -152,7 +152,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { /** * Set whether this bean should be lazily initialized. - *

      If false, the bean will get instantiated on startup by bean + *

      If {@code false}, the bean will get instantiated on startup by bean * factories that perform eager initialization of singletons. */ void setLazyInit(boolean lazyInit); @@ -196,14 +196,14 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { /** * Return the constructor argument values for this bean. *

      The returned instance can be modified during bean factory post-processing. - * @return the ConstructorArgumentValues object (never null) + * @return the ConstructorArgumentValues object (never {@code null}) */ ConstructorArgumentValues getConstructorArgumentValues(); /** * Return the property values to be applied to a new instance of the bean. *

      The returned instance can be modified during bean factory post-processing. - * @return the MutablePropertyValues object (never null) + * @return the MutablePropertyValues object (never {@code null}) */ MutablePropertyValues getPropertyValues(); @@ -228,9 +228,9 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { boolean isAbstract(); /** - * Get the role hint for this BeanDefinition. The role hint + * Get the role hint for this {@code BeanDefinition}. The role hint * provides tools with an indication of the importance of a particular - * BeanDefinition. + * {@code BeanDefinition}. * @see #ROLE_APPLICATION * @see #ROLE_INFRASTRUCTURE * @see #ROLE_SUPPORT @@ -249,7 +249,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement { String getResourceDescription(); /** - * Return the originating BeanDefinition, or null if none. + * Return the originating BeanDefinition, or {@code null} if none. * Allows for retrieving the decorated bean definition, if any. *

      Note that this method returns the immediate originator. Iterate through the * originator chain to find the original BeanDefinition as defined by the user. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java index cd2dd25093..0f8148f060 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionHolder.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement { * Create a new BeanDefinitionHolder. * @param beanDefinition the BeanDefinition to wrap * @param beanName the name of the bean, as specified for the bean definition - * @param aliases alias names for the bean, or null if none + * @param aliases alias names for the bean, or {@code null} if none */ public BeanDefinitionHolder(BeanDefinition beanDefinition, String beanName, String[] aliases) { Assert.notNull(beanDefinition, "BeanDefinition must not be null"); @@ -71,7 +71,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement { * Copy constructor: Create a new BeanDefinitionHolder with the * same contents as the given BeanDefinitionHolder instance. *

      Note: The wrapped BeanDefinition reference is taken as-is; - * it is not deeply copied. + * it is {@code not} deeply copied. * @param beanDefinitionHolder the BeanDefinitionHolder to copy */ public BeanDefinitionHolder(BeanDefinitionHolder beanDefinitionHolder) { @@ -98,7 +98,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement { /** * Return the alias names for the bean, as specified directly for the bean definition. - * @return the array of alias names, or null if none + * @return the array of alias names, or {@code null} if none */ public String[] getAliases() { return this.aliases; @@ -108,6 +108,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement { * Expose the bean definition's source object. * @see BeanDefinition#getSource() */ + @Override public Object getSource() { return this.beanDefinition.getSource(); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanFactoryPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanFactoryPostProcessor.java index 1619505c1f..8cfbb7645f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanFactoryPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanFactoryPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java index ee23681759..9739a62f8f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,13 +43,13 @@ public interface BeanPostProcessor { /** * Apply this BeanPostProcessor to the given new bean instance before any bean - * initialization callbacks (like InitializingBean's afterPropertiesSet + * initialization callbacks (like InitializingBean's {@code afterPropertiesSet} * or a custom init-method). The bean will already be populated with property values. * The returned bean instance may be a wrapper around the original. * @param bean the new bean instance * @param beanName the name of the bean * @return the bean instance to use, either the original or a wrapped one; if - * null, no subsequent BeanPostProcessors will be invoked + * {@code null}, no subsequent BeanPostProcessors will be invoked * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet */ @@ -57,20 +57,20 @@ public interface BeanPostProcessor { /** * Apply this BeanPostProcessor to the given new bean instance after any bean - * initialization callbacks (like InitializingBean's afterPropertiesSet + * initialization callbacks (like InitializingBean's {@code afterPropertiesSet} * or a custom init-method). The bean will already be populated with property values. * The returned bean instance may be a wrapper around the original. *

      In case of a FactoryBean, this callback will be invoked for both the FactoryBean * instance and the objects created by the FactoryBean (as of Spring 2.0). The * post-processor can decide whether to apply to either the FactoryBean or created - * objects or both through corresponding bean instanceof FactoryBean checks. + * objects or both through corresponding {@code bean instanceof FactoryBean} checks. *

      This callback will also be invoked after a short-circuiting triggered by a * {@link InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation} method, * in contrast to all other BeanPostProcessor callbacks. * @param bean the new bean instance * @param beanName the name of the bean * @return the bean instance to use, either the original or a wrapped one; if - * null, no subsequent BeanPostProcessors will be invoked + * {@code null}, no subsequent BeanPostProcessors will be invoked * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet * @see org.springframework.beans.factory.FactoryBean diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReference.java index 2dac38ecc7..80c22d87db 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReference.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.beans.BeanMetadataElement; public interface BeanReference extends BeanMetadataElement { /** - * Return the target bean name that this reference points to (never null). + * Return the target bean name that this reference points to (never {@code null}). */ String getBeanName(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReferenceFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReferenceFactoryBean.java index 1a382a6324..f637b891e1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReferenceFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanReferenceFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.beans.factory.SmartFactoryBean; * using this FactoryBean to link it in and expose it under a different name. * Effectively, this corresponds to an alias for the target bean. * - *

      NOTE: For XML bean definition files, an <alias> + *

      NOTE: For XML bean definition files, an {@code <alias>} * tag is available that effectively achieves the same. * *

      A special capability of this FactoryBean is enabled through its configuration @@ -65,6 +65,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw this.targetBeanName = targetBeanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; if (this.targetBeanName == null) { @@ -76,6 +77,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw } + @Override public Object getObject() throws BeansException { if (this.beanFactory == null) { throw new FactoryBeanNotInitializedException(); @@ -83,6 +85,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw return this.beanFactory.getBean(this.targetBeanName); } + @Override public Class getObjectType() { if (this.beanFactory == null) { return null; @@ -90,6 +93,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw return this.beanFactory.getType(this.targetBeanName); } + @Override public boolean isSingleton() { if (this.beanFactory == null) { throw new FactoryBeanNotInitializedException(); @@ -97,6 +101,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw return this.beanFactory.isSingleton(this.targetBeanName); } + @Override public boolean isPrototype() { if (this.beanFactory == null) { throw new FactoryBeanNotInitializedException(); @@ -104,6 +109,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw return this.beanFactory.isPrototype(this.targetBeanName); } + @Override public boolean isEagerInit() { return false; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/CommonsLogFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/CommonsLogFactoryBean.java index 70b2e00508..c49cb6db32 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/CommonsLogFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/CommonsLogFactoryBean.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -53,20 +53,24 @@ public class CommonsLogFactoryBean implements FactoryBean, InitializingBean } + @Override public void afterPropertiesSet() { if (this.log == null) { throw new IllegalArgumentException("'logName' is required"); } } + @Override public Log getObject() { return this.log; } + @Override public Class getObjectType() { return (this.log != null ? this.log.getClass() : Log.class); } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java index 35e44cfeee..d04eb15d81 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableBeanFactory.java @@ -51,14 +51,14 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single /** * Scope identifier for the standard singleton scope: "singleton". - * Custom scopes can be added via registerScope. + * Custom scopes can be added via {@code registerScope}. * @see #registerScope */ String SCOPE_SINGLETON = "singleton"; /** * Scope identifier for the standard prototype scope: "prototype". - * Custom scopes can be added via registerScope. + * Custom scopes can be added via {@code registerScope}. * @see #registerScope */ String SCOPE_PROTOTYPE = "prototype"; @@ -83,7 +83,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single * Spring 2.0 by default: Bean definitions only carry bean class names, * to be resolved once the factory processes the bean definition. * @param beanClassLoader the class loader to use, - * or null to suggest the default class loader + * or {@code null} to suggest the default class loader */ void setBeanClassLoader(ClassLoader beanClassLoader); @@ -255,14 +255,14 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single *

      This will only return explicitly registered scopes. * Built-in scopes such as "singleton" and "prototype" won't be exposed. * @param scopeName the name of the scope - * @return the registered Scope implementation, or null if none + * @return the registered Scope implementation, or {@code null} if none * @see #registerScope */ Scope getRegisteredScope(String scopeName); /** * Provides a security access control context relevant to this factory. - * @return the applicable AccessControlContext (never null) + * @return the applicable AccessControlContext (never {@code null}) * @since 3.0 */ AccessControlContext getAccessControlContext(); @@ -314,7 +314,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single * Determine whether the bean with the given name is a FactoryBean. * @param name the name of the bean to check * @return whether the bean is a FactoryBean - * (false means the bean exists but is not a FactoryBean) + * ({@code false} means the bean exists but is not a FactoryBean) * @throws NoSuchBeanDefinitionException if there is no bean with the given name * @since 2.5 */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java index 459003bb3d..2dc8ec6fae 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConfigurableListableBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ public interface ConfigurableListableBeanFactory /** * Return whether this factory's bean definitions are frozen, * i.e. are not supposed to be modified or post-processed any further. - * @return true if the factory's configuration is considered frozen + * @return {@code true} if the factory's configuration is considered frozen */ boolean isConfigurationFrozen(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java index 3a3aa9df17..795ef04a5c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java @@ -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"); * you may not use this file except in compliance with the License. @@ -142,9 +142,9 @@ public class ConstructorArgumentValues { /** * Get argument value for the given index in the constructor argument list. * @param index the index in the constructor argument list - * @param requiredType the type to match (can be null to match + * @param requiredType the type to match (can be {@code null} to match * untyped values only) - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getIndexedArgumentValue(int index, Class requiredType) { return getIndexedArgumentValue(index, requiredType, null); @@ -153,11 +153,11 @@ public class ConstructorArgumentValues { /** * Get argument value for the given index in the constructor argument list. * @param index the index in the constructor argument list - * @param requiredType the type to match (can be null to match + * @param requiredType the type to match (can be {@code null} to match * untyped values only) - * @param requiredName the type to match (can be null to match + * @param requiredName the type to match (can be {@code null} to match * unnamed values only) - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getIndexedArgumentValue(int index, Class requiredType, String requiredName) { Assert.isTrue(index >= 0, "Index must not be negative"); @@ -245,7 +245,7 @@ public class ConstructorArgumentValues { /** * Look for a generic argument value that matches the given type. * @param requiredType the type to match - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getGenericArgumentValue(Class requiredType) { return getGenericArgumentValue(requiredType, null, null); @@ -255,7 +255,7 @@ public class ConstructorArgumentValues { * Look for a generic argument value that matches the given type. * @param requiredType the type to match * @param requiredName the name to match - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getGenericArgumentValue(Class requiredType, String requiredName) { return getGenericArgumentValue(requiredType, requiredName, null); @@ -265,13 +265,13 @@ public class ConstructorArgumentValues { * Look for the next generic argument value that matches the given type, * ignoring argument values that have already been used in the current * resolution process. - * @param requiredType the type to match (can be null to find + * @param requiredType the type to match (can be {@code null} to find * an arbitrary next generic argument value) - * @param requiredName the name to match (can be null to not + * @param requiredName the name to match (can be {@code null} to not * match argument values by name) * @param usedValueHolders a Set of ValueHolder objects that have already been used * in the current resolution process and should therefore not be returned again - * @return the ValueHolder for the argument, or null if none found + * @return the ValueHolder for the argument, or {@code null} if none found */ public ValueHolder getGenericArgumentValue(Class requiredType, String requiredName, Set usedValueHolders) { for (ValueHolder valueHolder : this.genericArgumentValues) { @@ -310,7 +310,7 @@ public class ConstructorArgumentValues { * in the constructor argument list or generically matches by type. * @param index the index in the constructor argument list * @param requiredType the type to match - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getArgumentValue(int index, Class requiredType) { return getArgumentValue(index, requiredType, null, null); @@ -322,7 +322,7 @@ public class ConstructorArgumentValues { * @param index the index in the constructor argument list * @param requiredType the type to match * @param requiredName the name to match - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getArgumentValue(int index, Class requiredType, String requiredName) { return getArgumentValue(index, requiredType, requiredName, null); @@ -332,13 +332,13 @@ public class ConstructorArgumentValues { * Look for an argument value that either corresponds to the given index * in the constructor argument list or generically matches by type. * @param index the index in the constructor argument list - * @param requiredType the type to match (can be null to find + * @param requiredType the type to match (can be {@code null} to find * an untyped argument value) * @param usedValueHolders a Set of ValueHolder objects that have already * been used in the current resolution process and should therefore not * be returned again (allowing to return the next generic argument match * in case of multiple generic argument values of the same type) - * @return the ValueHolder for the argument, or null if none set + * @return the ValueHolder for the argument, or {@code null} if none set */ public ValueHolder getArgumentValue(int index, Class requiredType, String requiredName, Set usedValueHolders) { Assert.isTrue(index >= 0, "Index must not be negative"); @@ -512,20 +512,21 @@ public class ConstructorArgumentValues { } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } /** - * Return whether this holder contains a converted value already (true), - * or whether the value still needs to be converted (false). + * Return whether this holder contains a converted value already ({@code true}), + * or whether the value still needs to be converted ({@code false}). */ public synchronized boolean isConverted() { return this.converted; @@ -551,7 +552,7 @@ public class ConstructorArgumentValues { /** * Determine whether the content of this ValueHolder is equal * to the content of the given other ValueHolder. - *

      Note that ValueHolder does not implement equals + *

      Note that ValueHolder does not implement {@code equals} * directly, to allow for multiple ValueHolder instances with the * same content to reside in the same Set. */ @@ -562,7 +563,7 @@ public class ConstructorArgumentValues { /** * Determine whether the hash code of the content of this ValueHolder. - *

      Note that ValueHolder does not implement hashCode + *

      Note that ValueHolder does not implement {@code hashCode} * directly, to allow for multiple ValueHolder instances with the * same content to reside in the same Set. */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java index 641f6c7f26..b10c74c78b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomEditorConfigurer.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.springframework.util.ClassUtils; /** * {@link BeanFactoryPostProcessor} implementation that allows for convenient * registration of custom {@link PropertyEditor property editors}. - * + * *

      * In case you want to register {@link PropertyEditor} instances, the * recommended usage as of Spring 2.0 is to use custom @@ -43,7 +43,7 @@ import org.springframework.util.ClassUtils; * desired editor instances on a given * {@link org.springframework.beans.PropertyEditorRegistry registry}. Each * PropertyEditorRegistrar can register any number of custom editors. - * + * *

        * <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
        *   <property name="propertyEditorRegistrars">
      @@ -54,12 +54,12 @@ import org.springframework.util.ClassUtils;
        *   </property>
        * </bean>
        * 
      - * + * *

      * It's perfectly fine to register {@link PropertyEditor} classes via * the {@code customEditors} property. Spring will create fresh instances of * them for each editing attempt then: - * + * *

        * <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
        *   <property name="customEditors">
      @@ -70,7 +70,7 @@ import org.springframework.util.ClassUtils;
        *   </property>
        * </bean>
        * 
      - * + * *

      * Note, that you shouldn't register {@link PropertyEditor} bean instances via * the {@code customEditors} property as {@link PropertyEditor}s are stateful @@ -78,7 +78,7 @@ import org.springframework.util.ClassUtils; * attempt. In case you need control over the instantiation process of * {@link PropertyEditor}s, use a {@link PropertyEditorRegistrar} to register * them. - * + * *

      * Also supports "java.lang.String[]"-style array class names and primitive * class names (e.g. "boolean"). Delegates to {@link ClassUtils} for actual @@ -119,6 +119,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla this.order = order; } + @Override public int getOrder() { return this.order; } @@ -126,10 +127,10 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla /** * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars} * to apply to beans defined within the current application context. - *

      This allows for sharing PropertyEditorRegistrars with + *

      This allows for sharing {@code PropertyEditorRegistrars} with * {@link org.springframework.validation.DataBinder DataBinders}, etc. * Furthermore, it avoids the need for synchronization on custom editors: - * A PropertyEditorRegistrar will always create fresh editor + * A {@code PropertyEditorRegistrar} will always create fresh editor * instances for each bean creation attempt. * @see ConfigurableListableBeanFactory#addPropertyEditorRegistrar */ @@ -161,11 +162,13 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla this.ignoreUnresolvableEditors = ignoreUnresolvableEditors; } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } + @Override @SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (this.propertyEditorRegistrars != null) { @@ -197,7 +200,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla else if (value instanceof String) { Class editorClass = ClassUtils.forName((String) value, this.beanClassLoader); Assert.isAssignable(PropertyEditor.class, editorClass); - beanFactory.registerCustomEditor(requiredType, (Class) editorClass); + beanFactory.registerCustomEditor(requiredType, editorClass); } else { throw new IllegalArgumentException("Mapped value [" + value + "] for custom editor key [" + @@ -234,6 +237,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanCla this.sharedEditor = sharedEditor; } + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { if (!(registry instanceof PropertyEditorRegistrySupport)) { throw new IllegalArgumentException("Cannot registered shared editor " + diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java index 130387e552..0d5a281925 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java @@ -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"); * you may not use this file except in compliance with the License. @@ -65,15 +65,18 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas this.order = order; } + @Override public int getOrder() { return this.order; } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } + @Override @SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (this.scopes != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java index ba38a85c4b..2693f8246c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java @@ -37,6 +37,7 @@ import org.springframework.util.Assert; * @author Juergen Hoeller * @since 2.5 */ +@SuppressWarnings("serial") public class DependencyDescriptor implements Serializable { private transient MethodParameter methodParameter; @@ -143,7 +144,7 @@ public class DependencyDescriptor implements Serializable { /** * Return the wrapped MethodParameter, if any. *

      Note: Either MethodParameter or Field is available. - * @return the MethodParameter, or null if none + * @return the MethodParameter, or {@code null} if none */ public MethodParameter getMethodParameter() { return this.methodParameter; @@ -152,7 +153,7 @@ public class DependencyDescriptor implements Serializable { /** * Return the wrapped Field, if any. *

      Note: Either MethodParameter or Field is available. - * @return the Field, or null if none + * @return the Field, or {@code null} if none */ public Field getField() { return this.field; @@ -199,7 +200,7 @@ public class DependencyDescriptor implements Serializable { /** * Determine the name of the wrapped parameter/field. - * @return the declared name (never null) + * @return the declared name (never {@code null}) */ public String getDependencyName() { return (this.field != null ? this.field.getName() : this.methodParameter.getParameterName()); @@ -207,7 +208,7 @@ public class DependencyDescriptor implements Serializable { /** * Determine the declared (non-generic) type of the wrapped parameter/field. - * @return the declared type (never null) + * @return the declared type (never {@code null}) */ public Class getDependencyType() { if (this.field != null) { @@ -238,7 +239,7 @@ public class DependencyDescriptor implements Serializable { /** * Determine the generic element type of the wrapped Collection parameter/field, if any. - * @return the generic type, or null if none + * @return the generic type, or {@code null} if none */ public Class getCollectionType() { return (this.field != null ? @@ -248,7 +249,7 @@ public class DependencyDescriptor implements Serializable { /** * Determine the generic key type of the wrapped Map parameter/field, if any. - * @return the generic type, or null if none + * @return the generic type, or {@code null} if none */ public Class getMapKeyType() { return (this.field != null ? @@ -258,7 +259,7 @@ public class DependencyDescriptor implements Serializable { /** * Determine the generic value type of the wrapped Map parameter/field, if any. - * @return the generic type, or null if none + * @return the generic type, or {@code null} if none */ public Class getMapValueType() { return (this.field != null ? diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DeprecatedBeanWarner.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DeprecatedBeanWarner.java index 815173b6be..893e4c2016 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DeprecatedBeanWarner.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DeprecatedBeanWarner.java @@ -52,6 +52,7 @@ public class DeprecatedBeanWarner implements BeanFactoryPostProcessor { } + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (isLogEnabled()) { String[] beanNames = beanFactory.getBeanDefinitionNames(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/DestructionAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/DestructionAwareBeanPostProcessor.java index c7acb6bdff..76de13907f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/DestructionAwareBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/DestructionAwareBeanPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor { /** * Apply this BeanPostProcessor to the given bean instance before * its destruction. Can invoke custom destruction callbacks. - *

      Like DisposableBean's destroy and a custom destroy method, + *

      Like DisposableBean's {@code destroy} and a custom destroy method, * this callback just applies to singleton beans in the factory (including * inner beans). * @param bean the bean instance to be destroyed diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index 7b3c5ea5df..b5471cb4e1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.util.StringUtils; /** * {@link FactoryBean} which retrieves a static or non-static field value. - * + * *

      Typically used for retrieving public static final constants. Usage example: * *

      // standard definition for exposing a static field, specifying the "staticField" property
      @@ -42,10 +42,10 @@ import org.springframework.util.StringUtils;
        * <bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
        *       class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>
      * - * + * *

      If you are using Spring 2.0, you can also use the following style of configuration for * public static fields. - * + * *

      <util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
      * * @author Juergen Hoeller @@ -142,15 +142,18 @@ public class FieldRetrievingFactoryBean * nor "targetField" have been specified. * This allows for concise bean definitions with just an id/name. */ + @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); } + @Override public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } + @Override public void afterPropertiesSet() throws ClassNotFoundException, NoSuchFieldException { if (this.targetClass != null && this.targetObject != null) { throw new IllegalArgumentException("Specify either targetClass or targetObject, not both"); @@ -159,7 +162,7 @@ public class FieldRetrievingFactoryBean if (this.targetClass == null && this.targetObject == null) { if (this.targetField != null) { throw new IllegalArgumentException( - "Specify targetClass or targetObject in combination with targetField"); + "Specify targetClass or targetObject in combination with targetField"); } // If no other property specified, consider bean name as static field expression. @@ -191,6 +194,7 @@ public class FieldRetrievingFactoryBean } + @Override public Object getObject() throws IllegalAccessException { if (this.fieldObject == null) { throw new FactoryBeanNotInitializedException(); @@ -206,10 +210,12 @@ public class FieldRetrievingFactoryBean } } + @Override public Class getObjectType() { return (this.fieldObject != null ? this.fieldObject.getType() : null); } + @Override public boolean isSingleton() { return false; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java index f0d5b59a92..f508e3fff1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * @param beanClass the class of the bean to be instantiated * @param beanName the name of the bean * @return the bean object to expose instead of a default instance of the target bean, - * or null to proceed with default instantiation + * or {@code null} to proceed with default instantiation * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.factory.support.AbstractBeanDefinition#hasBeanClass * @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName @@ -76,9 +76,9 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { * for a typical example. * @param bean the bean instance created, with properties not having been set yet * @param beanName the name of the bean - * @return true if properties should be set on the bean; false - * if property population should be skipped. Normal implementations should return true. - * Returning false will also prevent any subsequent InstantiationAwareBeanPostProcessor + * @return {@code true} if properties should be set on the bean; {@code false} + * if property population should be skipped. Normal implementations should return {@code true}. + * Returning {@code false} will also prevent any subsequent InstantiationAwareBeanPostProcessor * instances being invoked on this bean instance. * @throws org.springframework.beans.BeansException in case of errors */ @@ -91,13 +91,13 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { *

      Also allows for replacing the property values to apply, typically through * creating a new MutablePropertyValues instance based on the original PropertyValues, * adding or removing specific values. - * @param pvs the property values that the factory is about to apply (never null) + * @param pvs the property values that the factory is about to apply (never {@code null}) * @param pds the relevant property descriptors for the target bean (with ignored * dependency types - which the factory handles specifically - already filtered out) * @param bean the bean instance created, but whose properties have not yet been set * @param beanName the name of the bean * @return the actual property values to apply to to the given bean - * (can be the passed-in PropertyValues instance), or null + * (can be the passed-in PropertyValues instance), or {@code null} * to skip property population * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.MutablePropertyValues diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java index 49eeaaf532..3e02846fcb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessorAdapter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,26 +39,32 @@ import org.springframework.beans.PropertyValues; */ public abstract class InstantiationAwareBeanPostProcessorAdapter implements SmartInstantiationAwareBeanPostProcessor { + @Override public Class predictBeanType(Class beanClass, String beanName) { return null; } + @Override public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException { return null; } + @Override public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { return bean; } + @Override public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { return null; } + @Override public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { return true; } + @Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { @@ -66,10 +72,12 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar return pvs; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java index 7ceb21f753..736868bed3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class ListFactoryBean extends AbstractFactoryBean { /** * Set the class to use for the target List. Can be populated with a fully * qualified class name when defined in a Spring application context. - *

      Default is a java.util.ArrayList. + *

      Default is a {@code java.util.ArrayList}. * @see java.util.ArrayList */ public void setTargetListClass(Class targetListClass) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java index 51440d47da..0e6ad68f07 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.util.ClassUtils; /** * {@link FactoryBean} which returns a value which is the result of a static or instance - * method invocation. For most use cases it is better to just use the container's + * method invocation. For most use cases it is better to just use the container's * built-in factory method support for the same purpose, since that is smarter at * converting arguments. This factory bean is still useful though when you need to * call a method which doesn't return any value (for example, a static class method @@ -55,7 +55,7 @@ import org.springframework.util.ClassUtils; * *

      This class depends on {@link #afterPropertiesSet()} being called once * all properties have been set, as per the InitializingBean contract. - * + * *

      An example (in an XML based bean factory definition) of a bean definition * which uses this class to call a static factory method: * @@ -82,7 +82,7 @@ import org.springframework.util.ClassUtils; * </list> * </property> * </bean> - * + * * @author Colin Sampaleanu * @author Juergen Hoeller * @since 21.11.2003 @@ -110,10 +110,12 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker this.singleton = singleton; } + @Override public boolean isSingleton() { return this.singleton; } + @Override public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } @@ -123,6 +125,7 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker return ClassUtils.forName(className, this.beanClassLoader); } + @Override public void setBeanFactory(BeanFactory beanFactory) { if (beanFactory instanceof ConfigurableBeanFactory) { this.beanFactory = (ConfigurableBeanFactory) beanFactory; @@ -145,6 +148,7 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker } + @Override public void afterPropertiesSet() throws Exception { prepare(); if (this.singleton) { @@ -178,6 +182,7 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker * to "true", otherwise returns the value returned from invoking the * specified method on the fly. */ + @Override public Object getObject() throws Exception { if (this.singleton) { if (!this.initialized) { @@ -194,8 +199,9 @@ public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker /** * Return the type of object that this FactoryBean creates, - * or null if not known in advance. + * or {@code null} if not known in advance. */ + @Override public Class getObjectType() { if (!isPrepared()) { // Not fully initialized yet -> return null to indicate "not known yet". diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBean.java index d2fc8ab259..5c3ed77257 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBean.java @@ -57,7 +57,7 @@ import org.springframework.util.Assert; * *</beans> * - *

      The attendant MyClientBean class implementation might look + *

      The attendant {@code MyClientBean} class implementation might look * something like this: * *

      package a.b.c;
      @@ -131,6 +131,7 @@ public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBeanjava.util.prefs).
      + * Preferences API ({@code java.util.prefs}).
        *
        * 

      Tries to resolve placeholders as keys first in the user preferences, * then in the system preferences, then in this configurer's properties. @@ -74,11 +74,12 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu * This implementation eagerly fetches the Preferences instances * for the required system and user tree nodes. */ + @Override public void afterPropertiesSet() { this.systemPrefs = (this.systemTreePath != null) ? - Preferences.systemRoot().node(this.systemTreePath) : Preferences.systemRoot(); + Preferences.systemRoot().node(this.systemTreePath) : Preferences.systemRoot(); this.userPrefs = (this.userTreePath != null) ? - Preferences.userRoot().node(this.userTreePath) : Preferences.userRoot(); + Preferences.userRoot().node(this.userTreePath) : Preferences.userRoot(); } /** @@ -110,7 +111,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu * @param path the preferences path (placeholder part before '/') * @param key the preferences key (placeholder part after '/') * @param preferences the Preferences to resolve against - * @return the value for the placeholder, or null if none found + * @return the value for the placeholder, or {@code null} if none found */ protected String resolvePlaceholder(String path, String key, Preferences preferences) { if (path != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java index 9e0673ccfb..71b3e85fb9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertiesFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,17 +59,20 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport this.singleton = singleton; } + @Override public final boolean isSingleton() { return this.singleton; } + @Override public final void afterPropertiesSet() throws IOException { if (this.singleton) { this.singletonInstance = createProperties(); } } + @Override public final Properties getObject() throws IOException { if (this.singleton) { return this.singletonInstance; @@ -79,6 +82,7 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport } } + @Override public Class getObjectType() { return Properties.class; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java index 736a7d14fd..9dbcb9becb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java @@ -52,7 +52,7 @@ import org.springframework.beans.factory.BeanInitializationException; * the same bean property, the last one will win (due to the overriding mechanism). * *

      Property values can be converted after reading them in, through overriding - * the convertPropertyValue method. For example, encrypted values + * the {@code convertPropertyValue} method. For example, encrypted values * can be detected and decrypted accordingly before processing them. * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java index 518ce93ff3..4b8703abf0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.util.StringUtils; /** * {@link FactoryBean} that evaluates a property path on a given target object. - * + * *

      The target object can be specified directly or via a bean name. * *

      Usage examples: @@ -64,12 +64,12 @@ import org.springframework.util.StringUtils; * * <!-- will result in 10, which is the value of property 'age' of bean 'tb' --> * <bean id="tb.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/> - * + * *

      If you are using Spring 2.0 and XML Schema support in your configuration file(s), * you can also use the following style of configuration for property path access. * (See also the appendix entitled 'XML Schema-based configuration' in the Spring * reference manual for more examples.) - * + * *

       <!-- will result in 10, which is the value of property 'age' of bean 'tb' -->
        * <util:property-path id="name" path="testBean.age"/>
      * @@ -147,11 +147,13 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAwa * "targetBeanName" nor "propertyPath" have been specified. * This allows for concise bean definitions with just an id/name. */ + @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; @@ -162,15 +164,15 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAwa if (this.targetBeanWrapper == null && this.targetBeanName == null) { if (this.propertyPath != null) { throw new IllegalArgumentException( - "Specify 'targetObject' or 'targetBeanName' in combination with 'propertyPath'"); + "Specify 'targetObject' or 'targetBeanName' in combination with 'propertyPath'"); } // No other properties specified: check bean name. int dotIndex = this.beanName.indexOf('.'); if (dotIndex == -1) { throw new IllegalArgumentException( - "Neither 'targetObject' nor 'targetBeanName' specified, and PropertyPathFactoryBean " + - "bean name '" + this.beanName + "' does not follow 'beanName.property' syntax"); + "Neither 'targetObject' nor 'targetBeanName' specified, and PropertyPathFactoryBean " + + "bean name '" + this.beanName + "' does not follow 'beanName.property' syntax"); } this.targetBeanName = this.beanName.substring(0, dotIndex); this.propertyPath = this.beanName.substring(dotIndex + 1); @@ -190,6 +192,7 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAwa } + @Override public Object getObject() throws BeansException { BeanWrapper target = this.targetBeanWrapper; if (target != null) { @@ -208,6 +211,7 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAwa return target.getPropertyValue(this.propertyPath); } + @Override public Class getObjectType() { return this.resultType; } @@ -218,6 +222,7 @@ public class PropertyPathFactoryBean implements FactoryBean, BeanNameAwa * for each call, so we have to assume that we're not returning the * same object for each {@link #getObject()} call. */ + @Override public boolean isSingleton() { return false; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java index 442f541c50..c9d39f3bf5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java @@ -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"); * you may not use this file except in compliance with the License. @@ -137,8 +137,8 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport /** * Resolve the given placeholder using the given properties, performing * a system properties check according to the given mode. - *

      The default implementation delegates to resolvePlaceholder - * (placeholder, props) before/after the system properties check. + *

      The default implementation delegates to {@code resolvePlaceholder + * (placeholder, props)} before/after the system properties check. *

      Subclasses can override this for custom resolution strategies, * including customized points for the system properties check. * @param placeholder the placeholder to resolve @@ -174,7 +174,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport * after this method is invoked, according to the system properties mode. * @param placeholder the placeholder to resolve * @param props the merged properties of this configurer - * @return the resolved value, of null if none + * @return the resolved value, of {@code null} if none * @see #setSystemPropertiesMode */ protected String resolvePlaceholder(String placeholder, Properties props) { @@ -185,10 +185,10 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport * Resolve the given key as JVM system property, and optionally also as * system environment variable if no matching system property has been found. * @param key the placeholder to resolve as system property key - * @return the system property value, or null if not found + * @return the system property value, or {@code null} if not found * @see #setSearchSystemEnvironment - * @see java.lang.System#getProperty(String) - * @see java.lang.System#getenv(String) + * @see System#getProperty(String) + * @see System#getenv(String) */ protected String resolveSystemProperty(String key) { try { @@ -251,6 +251,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport this.resolver = new PropertyPlaceholderConfigurerResolver(props); } + @Override public String resolveStringValue(String strVal) throws BeansException { String value = this.helper.replacePlaceholders(strVal, this.resolver); return (value.equals(nullValue) ? null : value); @@ -266,6 +267,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport this.props = props; } + @Override public String resolvePlaceholder(String placeholderName) { return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyResourceConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyResourceConfigurer.java index 8da5a7772b..a84bdc067a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyResourceConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyResourceConfigurer.java @@ -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"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public abstract class PropertyResourceConfigurer extends PropertiesLoaderSupport this.order = order; } + @Override public int getOrder() { return this.order; } @@ -73,6 +74,7 @@ public abstract class PropertyResourceConfigurer extends PropertiesLoaderSupport * {@linkplain #processProperties process} properties against the given bean factory. * @throws BeanInitializationException if any properties cannot be loaded */ + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { try { Properties mergedProps = mergeProperties(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ProviderCreatingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ProviderCreatingFactoryBean.java index 317defbe96..c0d2537042 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ProviderCreatingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ProviderCreatingFactoryBean.java @@ -31,8 +31,8 @@ import org.springframework.util.Assert; *

      This is basically a JSR-330 compliant variant of Spring's good old * {@link ObjectFactoryCreatingFactoryBean}. It can be used for traditional * external dependency injection configuration that targets a property or - * constructor argument of type javax.inject.Provider, as an - * alternative to JSR-330's @Inject annotation-driven approach. + * constructor argument of type {@code javax.inject.Provider}, as an + * alternative to JSR-330's {@code @Inject} annotation-driven approach. * * @author Juergen Hoeller * @since 3.0.2 @@ -76,6 +76,7 @@ public class ProviderCreatingFactoryBean extends AbstractFactoryBean { /** * Independent inner class - for serialization purposes. */ + @SuppressWarnings("serial") private static class TargetBeanProvider implements Provider, Serializable { private final BeanFactory beanFactory; @@ -87,6 +88,7 @@ public class ProviderCreatingFactoryBean extends AbstractFactoryBean { this.targetBeanName = targetBeanName; } + @Override public Object get() throws BeansException { return this.beanFactory.getBean(this.targetBeanName); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.java index 3df4a47c27..2e078aeb48 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanNameReference.java @@ -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"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.springframework.beans.factory.config; import org.springframework.util.Assert; -/** +/** * Immutable placeholder class used for a property value object when it's a * reference to another bean name in the factory, to be resolved at runtime. * @@ -29,7 +29,7 @@ import org.springframework.util.Assert; * @see org.springframework.beans.factory.BeanFactory#getBean */ public class RuntimeBeanNameReference implements BeanReference { - + private final String beanName; private Object source; @@ -44,18 +44,20 @@ public class RuntimeBeanNameReference implements BeanReference { this.beanName = beanName; } + @Override public String getBeanName() { return this.beanName; } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java index 822d98c43c..dd3648e3cc 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java @@ -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"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.springframework.beans.factory.config; import org.springframework.util.Assert; -/** +/** * Immutable placeholder class used for a property value object when it's * a reference to another bean in the factory, to be resolved at runtime. * @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * @see org.springframework.beans.factory.BeanFactory#getBean */ public class RuntimeBeanReference implements BeanReference { - + private final String beanName; private final boolean toParent; @@ -61,6 +61,7 @@ public class RuntimeBeanReference implements BeanReference { } + @Override public String getBeanName() { return this.beanName; } @@ -74,13 +75,14 @@ public class RuntimeBeanReference implements BeanReference { } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java index 9da178b2ef..8777fa61e0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/Scope.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,14 +38,14 @@ import org.springframework.beans.factory.ObjectFactory; * this SPI is completely generic: It provides the ability to get and put * objects from any underlying storage mechanism, such as an HTTP session * or a custom conversation mechanism. The name passed into this class's - * get and remove methods will identify the + * {@code get} and {@code remove} methods will identify the * target object in the current scope. * - *

      Scope implementations are expected to be thread-safe. - * One Scope instance can be used with multiple bean factories + *

      {@code Scope} implementations are expected to be thread-safe. + * One {@code Scope} instance can be used with multiple bean factories * at the same time, if desired (unless it explicitly wants to be aware of * the containing BeanFactory), with any number of threads accessing - * the Scope concurrently from any number of factories. + * the {@code Scope} concurrently from any number of factories. * * @author Juergen Hoeller * @author Rob Harrop @@ -67,14 +67,14 @@ public interface Scope { * @param name the name of the object to retrieve * @param objectFactory the {@link ObjectFactory} to use to create the scoped * object if it is not present in the underlying storage mechanism - * @return the desired object (never null) + * @return the desired object (never {@code null}) */ Object get(String name, ObjectFactory objectFactory); /** - * Remove the object with the given name from the underlying scope. - *

      Returns null if no object was found; otherwise - * returns the removed Object. + * Remove the object with the given {@code name} from the underlying scope. + *

      Returns {@code null} if no object was found; otherwise + * returns the removed {@code Object}. *

      Note that an implementation should also remove a registered destruction * callback for the specified object, if any. It does, however, not * need to execute a registered destruction callback in this case, @@ -83,7 +83,7 @@ public interface Scope { * {@link UnsupportedOperationException} if they do not support explicitly * removing an object. * @param name the name of the object to remove - * @return the removed object, or null if no object was present + * @return the removed object, or {@code null} if no object was present * @see #registerDestructionCallback */ Object remove(String name); @@ -122,7 +122,7 @@ public interface Scope { * Resolve the contextual object for the given key, if any. * E.g. the HttpServletRequest object for key "request". * @param key the contextual key - * @return the corresponding object, or null if none found + * @return the corresponding object, or {@code null} if none found */ Object resolveContextualObject(String key); @@ -135,9 +135,9 @@ public interface Scope { * case of a custom conversation that sits within the overall session, * the specific ID for the current conversation would be appropriate. *

      Note: This is an optional operation. It is perfectly valid to - * return null in an implementation of this method if the + * return {@code null} in an implementation of this method if the * underlying storage mechanism has no obvious candidate for such an ID. - * @return the conversation ID, or null if there is no + * @return the conversation ID, or {@code null} if there is no * conversation ID for the current scope */ String getConversationId(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java index 192f6b7e66..ef91b2b749 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ import org.springframework.util.StringUtils; /** * A {@link FactoryBean} implementation that takes an interface which must have one or more - * methods with the signatures MyType xxx() or MyType xxx(MyIdType id) - * (typically, MyService getService() or MyService getService(String id)) + * methods with the signatures {@code MyType xxx()} or {@code MyType xxx(MyIdType id)} + * (typically, {@code MyService getService()} or {@code MyService getService(String id)}) * and creates a dynamic proxy which implements that interface, delegating to an * underlying {@link org.springframework.beans.factory.BeanFactory}. * @@ -51,7 +51,7 @@ import org.springframework.util.StringUtils; * setter or constructor injection of the target bean is preferable. * *

      On invocation of the no-arg factory method, or the single-arg factory - * method with a String id of null or empty String, if exactly + * method with a String id of {@code null} or empty String, if exactly * one bean in the factory matches the return type of the factory * method, that bean is returned, otherwise a * {@link org.springframework.beans.factory.NoSuchBeanDefinitionException} @@ -64,7 +64,7 @@ import org.springframework.util.StringUtils; * *

      A factory method argument will usually be a String, but can also be an * int or a custom enumeration type, for example, stringified via - * toString. The resulting String can be used as bean name as-is, + * {@code toString}. The resulting String can be used as bean name as-is, * provided that corresponding beans are defined in the bean factory. * Alternatively, {@link #setServiceMappings(java.util.Properties) a custom mapping} * between service ids and bean names can be defined. @@ -99,7 +99,7 @@ import org.springframework.util.StringUtils; * *</beans> * - *

      The attendant MyClientBean class implementation might then + *

      The attendant {@code MyClientBean} class implementation might then * look something like this: * *

      package a.b.c;
      @@ -151,7 +151,7 @@ import org.springframework.util.StringUtils;
        *
        *</beans>
      * - *

      The attendant MyClientBean class implementation might then + *

      The attendant {@code MyClientBean} class implementation might then * look something like this: * *

      package a.b.c;
      @@ -202,8 +202,8 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto
       
       	/**
       	 * Set the service locator interface to use, which must have one or more methods with
      -	 * the signatures MyType xxx() or MyType xxx(MyIdType id)
      -	 * (typically, MyService getService() or MyService getService(String id)).
      +	 * the signatures {@code MyType xxx()} or {@code MyType xxx(MyIdType id)}
      +	 * (typically, {@code MyService getService()} or {@code MyService getService(String id)}).
       	 * See the {@link ServiceLocatorFactoryBean class-level Javadoc} for
       	 * information on the semantics of such methods.
       	 */
      @@ -214,8 +214,8 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto
       	/**
       	 * Set the exception class that the service locator should throw if service
       	 * lookup failed. The specified exception class must have a constructor
      -	 * with one of the following parameter types: (String, Throwable)
      -	 * or (Throwable) or (String).
      +	 * with one of the following parameter types: {@code (String, Throwable)}
      +	 * or {@code (Throwable)} or {@code (String)}.
       	 * 

      If not specified, subclasses of Spring's BeansException will be thrown, * for example NoSuchBeanDefinitionException. As those are unchecked, the * caller does not need to handle them, so it might be acceptable that @@ -236,7 +236,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto * Set mappings between service ids (passed into the service locator) * and bean names (in the bean factory). Service ids that are not defined * here will be treated as bean names as-is. - *

      The empty string as service id key defines the mapping for null and + *

      The empty string as service id key defines the mapping for {@code null} and * empty string, and for factory methods without parameter. If not defined, * a single matching bean will be retrieved from the bean factory. * @param serviceMappings mappings between service ids and bean names, @@ -246,6 +246,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto this.serviceMappings = serviceMappings; } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ListableBeanFactory)) { throw new FatalBeanException( @@ -254,6 +255,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto this.beanFactory = (ListableBeanFactory) beanFactory; } + @Override public void afterPropertiesSet() { if (this.serviceLocatorInterface == null) { throw new IllegalArgumentException("Property 'serviceLocatorInterface' is required"); @@ -271,8 +273,8 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto * Determine the constructor to use for the given service locator exception * class. Only called in case of a custom service locator exception. *

      The default implementation looks for a constructor with one of the - * following parameter types: (String, Throwable) - * or (Throwable) or (String). + * following parameter types: {@code (String, Throwable)} + * or {@code (Throwable)} or {@code (String)}. * @param exceptionClass the exception class * @return the constructor to use * @see #setServiceLocatorExceptionClass @@ -323,14 +325,17 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto } + @Override public Object getObject() { return this.proxy; } + @Override public Class getObjectType() { return this.serviceLocatorInterface; } + @Override public boolean isSingleton() { return true; } @@ -341,6 +346,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFacto */ private class ServiceLocatorInvocationHandler implements InvocationHandler { + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (ReflectionUtils.isEqualsMethod(method)) { // Only consider equal when proxies are identical. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java index 9bbc3ad07d..79d0234c37 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/SingletonBeanRegistry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -37,9 +37,9 @@ public interface SingletonBeanRegistry { * under the given bean name. *

      The given instance is supposed to be fully initialized; the registry * will not perform any initialization callbacks (in particular, it won't - * call InitializingBean's afterPropertiesSet method). + * call InitializingBean's {@code afterPropertiesSet} method). * The given instance will not receive any destruction callbacks - * (like DisposableBean's destroy method) either. + * (like DisposableBean's {@code destroy} method) either. *

      When running within a full BeanFactory: Register a bean definition * instead of an existing instance if your bean is supposed to receive * initialization and/or destruction callbacks. @@ -65,23 +65,23 @@ public interface SingletonBeanRegistry { *

      NOTE: This lookup method is not aware of FactoryBean prefixes or aliases. * You need to resolve the canonical bean name first before obtaining the singleton instance. * @param beanName the name of the bean to look for - * @return the registered singleton object, or null if none found + * @return the registered singleton object, or {@code null} if none found * @see ConfigurableListableBeanFactory#getBeanDefinition */ Object getSingleton(String beanName); /** * Check if this registry contains a singleton instance with the given name. - *

      Only checks already instantiated singletons; does not return true + *

      Only checks already instantiated singletons; does not return {@code true} * for singleton bean definitions which have not been instantiated yet. *

      The main purpose of this method is to check manually registered singletons * (see {@link #registerSingleton}). Can also be used to check whether a * singleton defined by a bean definition has already been created. *

      To check whether a bean factory contains a bean definition with a given name, - * use ListableBeanFactory's containsBeanDefinition. Calling both - * containsBeanDefinition and containsSingleton answers + * use ListableBeanFactory's {@code containsBeanDefinition}. Calling both + * {@code containsBeanDefinition} and {@code containsSingleton} answers * whether a specific bean factory contains a local bean instance with the given name. - *

      Use BeanFactory's containsBean for general checks whether the + *

      Use BeanFactory's {@code containsBean} for general checks whether the * factory knows about a bean with a given name (whether manually registered singleton * instance or created by bean definition), also checking ancestor factories. *

      NOTE: This lookup method is not aware of FactoryBean prefixes or aliases. @@ -101,7 +101,7 @@ public interface SingletonBeanRegistry { *

      The main purpose of this method is to check manually registered singletons * (see {@link #registerSingleton}). Can also be used to check which singletons * defined by a bean definition have already been created. - * @return the list of names as a String array (never null) + * @return the list of names as a String array (never {@code null}) * @see #registerSingleton * @see org.springframework.beans.factory.support.BeanDefinitionRegistry#getBeanDefinitionNames * @see org.springframework.beans.factory.ListableBeanFactory#getBeanDefinitionNames diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java index ff28d38b94..13f5a9be56 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/SmartInstantiationAwareBeanPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,16 +41,16 @@ public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationA * processor's {@link #postProcessBeforeInstantiation} callback. * @param beanClass the raw class of the bean * @param beanName the name of the bean - * @return the type of the bean, or null if not predictable + * @return the type of the bean, or {@code null} if not predictable * @throws org.springframework.beans.BeansException in case of errors */ Class predictBeanType(Class beanClass, String beanName) throws BeansException; /** * Determine the candidate constructors to use for the given bean. - * @param beanClass the raw class of the bean (never null) + * @param beanClass the raw class of the bean (never {@code null}) * @param beanName the name of the bean - * @return the candidate constructors, or null if none specified + * @return the candidate constructors, or {@code null} if none specified * @throws org.springframework.beans.BeansException in case of errors */ Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java index 01e7cb52e2..a9ff4fdbfb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/TypedStringValue.java @@ -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"); * you may not use this file except in compliance with the License. @@ -164,13 +164,14 @@ public class TypedStringValue implements BeanMetadataElement { /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java index bae3c67c50..d4454c46ee 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/package-info.java @@ -6,7 +6,7 @@ * Provides an alternative to the Singleton and Prototype design * patterns, including a consistent approach to configuration management. * Builds on the org.springframework.beans package. - * + * *

      This package and related packages are discussed in Chapter 11 of * Expert One-On-One J2EE Design and Development * by Rod Johnson (Wrox, 2002). diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AbstractComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AbstractComponentDefinition.java index 24a03a757f..08d4aa43c1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AbstractComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AbstractComponentDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ public abstract class AbstractComponentDefinition implements ComponentDefinition /** * Delegates to {@link #getName}. */ + @Override public String getDescription() { return getName(); } @@ -42,6 +43,7 @@ public abstract class AbstractComponentDefinition implements ComponentDefinition /** * Returns an empty array. */ + @Override public BeanDefinition[] getBeanDefinitions() { return new BeanDefinition[0]; } @@ -49,6 +51,7 @@ public abstract class AbstractComponentDefinition implements ComponentDefinition /** * Returns an empty array. */ + @Override public BeanDefinition[] getInnerBeanDefinitions() { return new BeanDefinition[0]; } @@ -56,6 +59,7 @@ public abstract class AbstractComponentDefinition implements ComponentDefinition /** * Returns an empty array. */ + @Override public BeanReference[] getBeanReferences() { return new BeanReference[0]; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java index dd81c9d9b9..06d037c5d7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/AliasDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public class AliasDefinition implements BeanMetadataElement { * Create a new AliasDefinition. * @param beanName the canonical name of the bean * @param alias the alias registered for the bean - * @param source the source object (may be null) + * @param source the source object (may be {@code null}) */ public AliasDefinition(String beanName, String alias, Object source) { Assert.notNull(beanName, "Bean name must not be null"); @@ -73,6 +73,7 @@ public class AliasDefinition implements BeanMetadataElement { return this.alias; } + @Override public final Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java index 83dcab0f14..2b88d82765 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com * Create a new BeanComponentDefinition for the given bean. * @param beanDefinition the BeanDefinition * @param beanName the name of the bean - * @param aliases alias names for the bean, or null if none + * @param aliases alias names for the bean, or {@code null} if none */ public BeanComponentDefinition(BeanDefinition beanDefinition, String beanName, String[] aliases) { super(beanDefinition, beanName, aliases); @@ -94,22 +94,27 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com } + @Override public String getName() { return getBeanName(); } + @Override public String getDescription() { return getShortDescription(); } + @Override public BeanDefinition[] getBeanDefinitions() { return new BeanDefinition[] {getBeanDefinition()}; } + @Override public BeanDefinition[] getInnerBeanDefinitions() { return this.innerBeanDefinitions; } + @Override public BeanReference[] getBeanReferences() { return this.beanReferences; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanDefinitionParsingException.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanDefinitionParsingException.java index 43b537dd05..2d01b986a1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanDefinitionParsingException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanDefinitionParsingException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; * @author Rob Harrop * @since 2.0 */ +@SuppressWarnings("serial") public class BeanDefinitionParsingException extends BeanDefinitionStoreException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ComponentDefinition.java index b20786a201..49c5f9f7b5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ComponentDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,18 +33,18 @@ import org.springframework.beans.factory.config.BeanReference; * applications it is important that there is some mechanism in place to tie the {@link BeanDefinition BeanDefinitions} * in the {@link org.springframework.beans.factory.BeanFactory} back to the configuration data in a way * that has concrete meaning to the end user. As such, {@link org.springframework.beans.factory.xml.NamespaceHandler} - * implementations are able to publish events in the form of a ComponentDefinition for each - * logical entity being configured. Third parties can then {@link org.springframework.beans.factory.parsing.ReaderEventListener subscribe to these events}, + * implementations are able to publish events in the form of a {@code ComponentDefinition} for each + * logical entity being configured. Third parties can then {@link ReaderEventListener subscribe to these events}, * allowing for a user-centric view of the bean metadata. * - *

      Each ComponentDefinition has a {@link #getSource source object} which is configuration-specific. + *

      Each {@code ComponentDefinition} has a {@link #getSource source object} which is configuration-specific. * In the case of XML-based configuration this is typically the {@link org.w3c.dom.Node} which contains the user * supplied configuration information. In addition to this, each {@link BeanDefinition} enclosed in a - * ComponentDefinition has its own {@link BeanDefinition#getSource() source object} which may point + * {@code ComponentDefinition} has its own {@link BeanDefinition#getSource() source object} which may point * to a different, more specific, set of configuration data. Beyond this, individual pieces of bean metadata such * as the {@link org.springframework.beans.PropertyValue PropertyValues} may also have a source object giving an * even greater level of detail. Source object extraction is handled through the - * {@link org.springframework.beans.factory.parsing.SourceExtractor} which can be customized as required. + * {@link SourceExtractor} which can be customized as required. * *

      Whilst direct access to important {@link BeanReference BeanReferences} is provided through * {@link #getBeanReferences}, tools may wish to inspect all {@link BeanDefinition BeanDefinitions} to gather @@ -60,7 +60,7 @@ import org.springframework.beans.factory.config.BeanReference; * {@link BeanDefinition#getRole role identifier}. The role is essentially a hint to the tool as to how * important the configuration provider believes a {@link BeanDefinition} is to the end user. It is expected * that tools will not display all {@link BeanDefinition BeanDefinitions} for a given - * ComponentDefinition choosing instead to filter based on the role. Tools may choose to make + * {@code ComponentDefinition} choosing instead to filter based on the role. Tools may choose to make * this filtering user configurable. Particular notice should be given to the * {@link BeanDefinition#ROLE_INFRASTRUCTURE INFRASTRUCTURE role identifier}. {@link BeanDefinition BeanDefinitions} * classified with this role are completely unimportant to the end user and are required only for @@ -77,7 +77,7 @@ import org.springframework.beans.factory.config.BeanReference; public interface ComponentDefinition extends BeanMetadataElement { /** - * Get the user-visible name of this ComponentDefinition. + * Get the user-visible name of this {@code ComponentDefinition}. *

      This should link back directly to the corresponding configuration data * for this component in a given context. */ @@ -86,14 +86,14 @@ public interface ComponentDefinition extends BeanMetadataElement { /** * Return a friendly description of the described component. *

      Implementations are encouraged to return the same value from - * toString(). + * {@code toString()}. */ String getDescription(); /** * Return the {@link BeanDefinition BeanDefinitions} that were registered - * to form this ComponentDefinition. - *

      It should be noted that a ComponentDefinition may well be related with + * to form this {@code ComponentDefinition}. + *

      It should be noted that a {@code ComponentDefinition} may well be related with * other {@link BeanDefinition BeanDefinitions} via {@link BeanReference references}, * however these are not included as they may be not available immediately. * Important {@link BeanReference BeanReferences} are available from {@link #getBeanReferences()}. @@ -112,7 +112,7 @@ public interface ComponentDefinition extends BeanMetadataElement { /** * Return the set of {@link BeanReference BeanReferences} that are considered - * to be important to this ComponentDefinition. + * to be important to this {@code ComponentDefinition}. *

      Other {@link BeanReference BeanReferences} may exist within the associated * {@link BeanDefinition BeanDefinitions}, however these are not considered * to be needed for validation or for user visualization. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java index e8589d0889..550ae761c2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,10 +51,12 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition { } + @Override public String getName() { return this.name; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntry.java index 86540ef078..72357a8cc7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,9 +41,9 @@ public class ConstructorArgumentEntry implements ParseState.Entry { /** * Creates a new instance of the {@link ConstructorArgumentEntry} class - * representing a constructor argument at the supplied index. + * representing a constructor argument at the supplied {@code index}. * @param index the index of the constructor argument - * @throws IllegalArgumentException if the supplied index + * @throws IllegalArgumentException if the supplied {@code index} * is less than zero */ public ConstructorArgumentEntry(int index) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/EmptyReaderEventListener.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/EmptyReaderEventListener.java index b5d49c09a1..f27831a63f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/EmptyReaderEventListener.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/EmptyReaderEventListener.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,18 +25,22 @@ package org.springframework.beans.factory.parsing; */ public class EmptyReaderEventListener implements ReaderEventListener { + @Override public void defaultsRegistered(DefaultsDefinition defaultsDefinition) { // no-op } + @Override public void componentRegistered(ComponentDefinition componentDefinition) { // no-op } + @Override public void aliasRegistered(AliasDefinition aliasDefinition) { // no-op } + @Override public void importProcessed(ImportDefinition importDefinition) { // no-op } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java index 9b3311f512..859d611f14 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory; /** * Simple {@link ProblemReporter} implementation that exhibits fail-fast * behavior when errors are encountered. - * + * *

      The first error encountered results in a {@link BeanDefinitionParsingException} * being thrown. * @@ -41,7 +41,7 @@ public class FailFastProblemReporter implements ProblemReporter { /** * Set the {@link Log logger} that is to be used to report warnings. - *

      If set to null then a default {@link Log logger} set to + *

      If set to {@code null} then a default {@link Log logger} set to * the name of the instance class will be used. * @param logger the {@link Log logger} that is to be used to report warnings */ @@ -55,6 +55,7 @@ public class FailFastProblemReporter implements ProblemReporter { * that has occurred. * @param problem the source of the error */ + @Override public void fatal(Problem problem) { throw new BeanDefinitionParsingException(problem); } @@ -64,14 +65,16 @@ public class FailFastProblemReporter implements ProblemReporter { * that has occurred. * @param problem the source of the error */ + @Override public void error(Problem problem) { throw new BeanDefinitionParsingException(problem); } /** - * Writes the supplied {@link Problem} to the {@link Log} at WARN level. + * Writes the supplied {@link Problem} to the {@link Log} at {@code WARN} level. * @param problem the source of the warning */ + @Override public void warning(Problem problem) { this.logger.warn(problem, problem.getRootCause()); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java index 4b7a834d08..85eea69610 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ImportDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class ImportDefinition implements BeanMetadataElement { /** * Create a new ImportDefinition. * @param importedResource the location of the imported resource - * @param source the source object (may be null) + * @param source the source object (may be {@code null}) */ public ImportDefinition(String importedResource, Object source) { this(importedResource, null, source); @@ -56,7 +56,7 @@ public class ImportDefinition implements BeanMetadataElement { /** * Create a new ImportDefinition. * @param importedResource the location of the imported resource - * @param source the source object (may be null) + * @param source the source object (may be {@code null}) */ public ImportDefinition(String importedResource, Resource[] actualResources, Object source) { Assert.notNull(importedResource, "Imported resource must not be null"); @@ -77,6 +77,7 @@ public class ImportDefinition implements BeanMetadataElement { return this.actualResources; } + @Override public final Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java index c5cbcbecbe..9ff54665c7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Location.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.util.Assert; * {@link #getSource() source} location might be 'The bean defined on * line 76 of beans.properties has an invalid Class'; another source might * be the actual DOM Element from a parsed XML {@link org.w3c.dom.Document}; - * or the source object might simply be null. + * or the source object might simply be {@code null}. * * @author Rob Harrop * @since 2.0 @@ -51,7 +51,7 @@ public class Location { * Create a new instance of the {@link Location} class. * @param resource the resource with which this location is associated * @param source the actual location within the associated resource - * (may be null) + * (may be {@code null}) */ public Location(Resource resource, Object source) { Assert.notNull(resource, "Resource must not be null"); @@ -69,7 +69,7 @@ public class Location { /** * Get the actual location within the associated {@link #getResource() resource} - * (may be null). + * (may be {@code null}). *

      See the {@link Location class level javadoc for this class} for examples * of what the actual type of the returned object may be. */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/NullSourceExtractor.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/NullSourceExtractor.java index d95cf1ff1c..3e3fa62524 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/NullSourceExtractor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/NullSourceExtractor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.beans.factory.parsing; import org.springframework.core.io.Resource; /** - * Simple implementation of {@link SourceExtractor} that returns null + * Simple implementation of {@link SourceExtractor} that returns {@code null} * as the source metadata. * *

      This is the default implementation and prevents too much metadata from being @@ -31,8 +31,9 @@ import org.springframework.core.io.Resource; public class NullSourceExtractor implements SourceExtractor { /** - * This implementation simply returns null for any input. + * This implementation simply returns {@code null} for any input. */ + @Override public Object extractSource(Object sourceCandidate, Resource definitionResource) { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 7ef3254da7..3c4b68e339 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -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"); * you may not use this file except in compliance with the License. @@ -44,15 +44,15 @@ public final class ParseState { /** - * Create a new ParseState with an empty {@link Stack}. + * Create a new {@code ParseState} with an empty {@link Stack}. */ public ParseState() { this.state = new Stack(); } /** - * Create a new ParseState whose {@link Stack} is a {@link Object#clone clone} - * of that of the passed in ParseState. + * Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone} + * of that of the passed in {@code ParseState}. */ private ParseState(ParseState other) { this.state = (Stack) other.state.clone(); @@ -75,7 +75,7 @@ public final class ParseState { /** * Return the {@link Entry} currently at the top of the {@link Stack} or - * null if the {@link Stack} is empty. + * {@code null} if the {@link Stack} is empty. */ public Entry peek() { return (Entry) (this.state.empty() ? null : this.state.peek()); @@ -91,7 +91,7 @@ public final class ParseState { /** - * Returns a tree-style representation of the current ParseState. + * Returns a tree-style representation of the current {@code ParseState}. */ @Override public String toString() { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractor.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractor.java index 573244001d..a9f56dbfbb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,10 +35,11 @@ import org.springframework.core.io.Resource; public class PassThroughSourceExtractor implements SourceExtractor { /** - * Simply returns the supplied sourceCandidate as-is. + * Simply returns the supplied {@code sourceCandidate} as-is. * @param sourceCandidate the source metadata - * @return the supplied sourceCandidate + * @return the supplied {@code sourceCandidate} */ + @Override public Object extractSource(Object sourceCandidate, Resource definingResource) { return sourceCandidate; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java index b895ad23ba..9f78a2909d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java @@ -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"); * you may not use this file except in compliance with the License. @@ -61,8 +61,8 @@ public class Problem { /** * Create a new instance of the {@link Problem} class. - * @param message a message detailing the problem - * @param rootCause the underlying expection that caused the error (may be null) + * @param message a message detailing the problem + * @param rootCause the underlying expection that caused the error (may be {@code null}) * @param parseState the {@link ParseState} at the time of the error * @param location the location within a bean configuration source that triggered the error */ @@ -100,14 +100,14 @@ public class Problem { } /** - * Get the {@link ParseState} at the time of the error (may be null). + * Get the {@link ParseState} at the time of the error (may be {@code null}). */ public ParseState getParseState() { return this.parseState; } /** - * Get the underlying expection that caused the error (may be null). + * Get the underlying expection that caused the error (may be {@code null}). */ public Throwable getRootCause() { return this.rootCause; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ProblemReporter.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ProblemReporter.java index a9e1bedbe9..649b17123a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ProblemReporter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ProblemReporter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,21 +31,21 @@ public interface ProblemReporter { * Called when a fatal error is encountered during the parsing process. *

      Implementations must treat the given problem as fatal, * i.e. they have to eventually raise an exception. - * @param problem the source of the error (never null) + * @param problem the source of the error (never {@code null}) */ void fatal(Problem problem); /** * Called when an error is encountered during the parsing process. *

      Implementations may choose to treat errors as fatal. - * @param problem the source of the error (never null) + * @param problem the source of the error (never {@code null}) */ void error(Problem problem); /** * Called when a warning is raised during the parsing process. *

      Warnings are never considered to be fatal. - * @param problem the source of the warning (never null) + * @param problem the source of the warning (never {@code null}) */ void warning(Problem problem); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java index c1737e456c..2f940269eb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,8 +32,8 @@ public class PropertyEntry implements ParseState.Entry { /** * Creates a new instance of the {@link PropertyEntry} class. * @param name the name of the JavaBean property represented by this instance - * @throws IllegalArgumentException if the supplied name is null - * or consists wholly of whitespace + * @throws IllegalArgumentException if the supplied {@code name} is {@code null} + * or consists wholly of whitespace */ public PropertyEntry(String name) { if (!StringUtils.hasText(name)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java index 2c80092fb1..e21707376e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.util.StringUtils; /** * {@link ParseState} entry representing an autowire candidate qualifier. - * + * * @author Mark Fisher * @since 2.5 */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java index 55988c3726..0b0fe96658 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/SourceExtractor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,10 +38,10 @@ public interface SourceExtractor { /** * Extract the source metadata from the candidate object supplied * by the configuration parser. - * @param sourceCandidate the original source metadata (never null) + * @param sourceCandidate the original source metadata (never {@code null}) * @param definingResource the resource that defines the given source object - * (may be null) - * @return the source metadata object to store (may be null) + * (may be {@code null}) + * @return the source metadata object to store (may be {@code null}) */ Object extractSource(Object sourceCandidate, Resource definingResource); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 1cf82fc690..4bb0f75145 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -164,7 +164,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Create a new AbstractAutowireCapableBeanFactory with the given parent. - * @param parentBeanFactory parent bean factory, or null if none + * @param parentBeanFactory parent bean factory, or {@code null} if none */ public AbstractAutowireCapableBeanFactory(BeanFactory parentBeanFactory) { this(); @@ -280,6 +280,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Typical methods for creating and populating external bean instances //------------------------------------------------------------------------- + @Override @SuppressWarnings("unchecked") public T createBean(Class beanClass) throws BeansException { // Use prototype bean definition, to avoid registering bean as dependent bean. @@ -289,6 +290,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac return (T) createBean(beanClass.getName(), bd, null); } + @Override public void autowireBean(Object existingBean) { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean)); @@ -299,6 +301,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac populateBean(bd.getBeanClass().getName(), bd, bw); } + @Override public Object configureBean(Object existingBean, String beanName) throws BeansException { markBeanAsCreated(beanName); BeanDefinition mbd = getMergedBeanDefinition(beanName); @@ -320,6 +323,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac return initializeBean(beanName, existingBean, bd); } + @Override public Object resolveDependency(DependencyDescriptor descriptor, String beanName) throws BeansException { return resolveDependency(descriptor, beanName, null, null); } @@ -329,6 +333,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Specialized methods for fine-grained control over the bean lifecycle //------------------------------------------------------------------------- + @Override public Object createBean(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); @@ -336,6 +341,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac return createBean(beanClass.getName(), bd, null); } + @Override public Object autowire(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. final RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); @@ -346,10 +352,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac else { Object bean; final BeanFactory parent = this; - + if (System.getSecurityManager() != null) { bean = AccessController.doPrivileged(new PrivilegedAction() { - + + @Override public Object run() { return getInstantiationStrategy().instantiate(bd, null, parent); } @@ -358,12 +365,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac else { bean = getInstantiationStrategy().instantiate(bd, null, parent); } - + populateBean(beanClass.getName(), bd, new BeanWrapperImpl(bean)); return bean; } } + @Override public void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck) throws BeansException { @@ -379,6 +387,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac populateBean(bd.getBeanClass().getName(), bd, bw); } + @Override public void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException { markBeanAsCreated(beanName); BeanDefinition bd = getMergedBeanDefinition(beanName); @@ -387,10 +396,12 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac applyPropertyValues(beanName, bd, bw, bd.getPropertyValues()); } + @Override public Object initializeBean(Object existingBean, String beanName) { return initializeBean(beanName, existingBean, null); } + @Override public Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws BeansException { @@ -404,6 +415,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac return result; } + @Override public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws BeansException { @@ -467,13 +479,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Actually create the specified bean. Pre-creation processing has already happened - * at this point, e.g. checking postProcessBeforeInstantiation callbacks. + * at this point, e.g. checking {@code postProcessBeforeInstantiation} callbacks. *

      Differentiates between default bean instantiation, use of a * factory method, and autowiring a constructor. * @param beanName the name of the bean * @param mbd the merged bean definition for the bean * @param args arguments to use if creating a prototype using explicit arguments to a - * static factory method. This parameter must be null except in this case. + * static factory method. This parameter must be {@code null} except in this case. * @return a new instance of the bean * @throws BeanCreationException if the bean could not be created * @see #instantiateBean @@ -510,6 +522,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac "' to allow for resolving potential circular references"); } addSingletonFactory(beanName, new ObjectFactory() { + @Override public Object getObject() throws BeansException { return getEarlyBeanReference(beanName, mbd, bean); } @@ -606,8 +619,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @param beanName the name of the bean (for error handling purposes) * @param mbd the merged bean definition for the bean * @param typesToMatch the types to match in case of internal type matching purposes - * (also signals that the returned Class will never be exposed to application code) - * @return the type for the bean if determinable, or null else + * (also signals that the returned {@code Class} will never be exposed to application code) + * @return the type for the bean if determinable, or {@code null} else * @see #createBean */ protected Class getTypeForFactoryMethod(String beanName, RootBeanDefinition mbd, Class[] typesToMatch) { @@ -668,7 +681,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * This implementation attempts to query the FactoryBean's generic parameter metadata * if present to determine the object type. If not present, i.e. the FactoryBean is - * declared as a raw type, checks the FactoryBean's getObjectType method + * declared as a raw type, checks the FactoryBean's {@code getObjectType} method * on a plain instance of the FactoryBean, without bean properties applied yet. * If this doesn't return a type yet, a full creation of the FactoryBean is * used as fallback (through delegation to the superclass's implementation). @@ -695,6 +708,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // @Bean methods, there may be parameters present. ReflectionUtils.doWithMethods(fbClass, new ReflectionUtils.MethodCallback() { + @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { if (method.getName().equals(factoryMethodName) && FactoryBean.class.isAssignableFrom(method.getReturnType())) { @@ -755,11 +769,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Obtain a "shortcut" singleton FactoryBean instance to use for a - * getObjectType() call, without full initialization + * {@code getObjectType()} call, without full initialization * of the FactoryBean. * @param beanName the name of the bean * @param mbd the bean definition for the bean - * @return the FactoryBean instance, or null to indicate + * @return the FactoryBean instance, or {@code null} to indicate * that we couldn't obtain a shortcut FactoryBean instance */ private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { @@ -796,11 +810,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Obtain a "shortcut" non-singleton FactoryBean instance to use for a - * getObjectType() call, without full initialization + * {@code getObjectType()} call, without full initialization * of the FactoryBean. * @param beanName the name of the bean * @param mbd the bean definition for the bean - * @return the FactoryBean instance, or null to indicate + * @return the FactoryBean instance, or {@code null} to indicate * that we couldn't obtain a shortcut FactoryBean instance */ private FactoryBean getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { @@ -827,7 +841,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Apply MergedBeanDefinitionPostProcessors to the specified bean definition, - * invoking their postProcessMergedBeanDefinition methods. + * invoking their {@code postProcessMergedBeanDefinition} methods. * @param mbd the merged bean definition for the bean * @param beanType the actual type of the managed bean instance * @param beanName the name of the bean @@ -856,7 +870,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * before-instantiation shortcut for the specified bean. * @param beanName the name of the bean * @param mbd the bean definition for the bean - * @return the shortcut-determined bean instance, or null if none + * @return the shortcut-determined bean instance, or {@code null} if none */ protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) { Object bean = null; @@ -875,13 +889,13 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** * Apply InstantiationAwareBeanPostProcessors to the specified bean definition - * (by class and name), invoking their postProcessBeforeInstantiation methods. + * (by class and name), invoking their {@code postProcessBeforeInstantiation} methods. *

      Any returned object will be used as the bean instead of actually instantiating - * the target bean. A null return value from the post-processor will + * the target bean. A {@code null} return value from the post-processor will * result in the target bean being instantiated. * @param beanClass the class of the bean to be instantiated * @param beanName the name of the bean - * @return the bean object to use instead of a default instance of the target bean, or null + * @return the bean object to use instead of a default instance of the target bean, or {@code null} * @throws BeansException if any post-processing failed * @see InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation */ @@ -962,7 +976,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * {@link SmartInstantiationAwareBeanPostProcessor SmartInstantiationAwareBeanPostProcessors}. * @param beanClass the raw class of the bean * @param beanName the name of the bean - * @return the candidate constructors, or null if none specified + * @return the candidate constructors, or {@code null} if none specified * @throws org.springframework.beans.BeansException in case of errors * @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors */ @@ -995,6 +1009,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac final BeanFactory parent = this; if (System.getSecurityManager() != null) { beanInstance = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { return getInstantiationStrategy().instantiate(mbd, beanName, parent); } @@ -1019,7 +1034,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @param beanName the name of the bean * @param mbd the bean definition for the bean * @param explicitArgs argument values passed in programmatically via the getBean method, - * or null if none (-> use constructor argument values from bean definition) + * or {@code null} if none (-> use constructor argument values from bean definition) * @return BeanWrapper for the new instance * @see #getBean(String, Object[]) */ @@ -1040,7 +1055,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @param mbd the bean definition for the bean * @param ctors the chosen candidate constructors * @param explicitArgs argument values passed in programmatically via the getBean method, - * or null if none (-> use constructor argument values from bean definition) + * or {@code null} if none (-> use constructor argument values from bean definition) * @return BeanWrapper for the new instance */ protected BeanWrapper autowireConstructor( @@ -1346,7 +1361,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac MutablePropertyValues mpvs = null; List original; - + if (System.getSecurityManager()!= null) { if (bw instanceof BeanWrapperImpl) { ((BeanWrapperImpl) bw).setSecurityContext(getAccessControlContext()); @@ -1452,7 +1467,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @param beanName the bean name in the factory (for debugging purposes) * @param bean the new bean instance we may need to initialize * @param mbd the bean definition that the bean was created with - * (can also be null, if given an existing bean instance) + * (can also be {@code null}, if given an existing bean instance) * @return the initialized bean instance (potentially wrapped) * @see BeanNameAware * @see BeanClassLoaderAware @@ -1464,6 +1479,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac protected Object initializeBean(final String beanName, final Object bean, RootBeanDefinition mbd) { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { invokeAwareMethods(beanName, bean); return null; @@ -1473,7 +1489,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac else { invokeAwareMethods(beanName, bean); } - + Object wrappedBean = bean; if (mbd == null || !mbd.isSynthetic()) { wrappedBean = applyBeanPostProcessorsBeforeInitialization(wrappedBean, beanName); @@ -1516,7 +1532,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @param beanName the bean name in the factory (for debugging purposes) * @param bean the new bean instance we may need to initialize * @param mbd the merged bean definition that the bean was created with - * (can also be null, if given an existing bean instance) + * (can also be {@code null}, if given an existing bean instance) * @throws Throwable if thrown by init methods or by the invocation process * @see #invokeCustomInitMethod */ @@ -1531,6 +1547,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac if (System.getSecurityManager() != null) { try { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { ((InitializingBean) bean).afterPropertiesSet(); return null; @@ -1540,7 +1557,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac catch (PrivilegedActionException pae) { throw pae.getException(); } - } + } else { ((InitializingBean) bean).afterPropertiesSet(); } @@ -1585,9 +1602,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac if (logger.isDebugEnabled()) { logger.debug("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'"); } - + if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { ReflectionUtils.makeAccessible(initMethod); return null; @@ -1595,6 +1613,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac }); try { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { initMethod.invoke(bean); return null; @@ -1610,7 +1629,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac try { ReflectionUtils.makeAccessible(initMethod); initMethod.invoke(bean); - } + } catch (InvocationTargetException ex) { throw ex.getTargetException(); } @@ -1619,7 +1638,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac /** - * Applies the postProcessAfterInitialization callback of all + * Applies the {@code postProcessAfterInitialization} callback of all * registered BeanPostProcessors, giving them a chance to post-process the * object obtained from FactoryBeans (for example, to auto-proxy them). * @see #applyBeanPostProcessorsAfterInitialization @@ -1643,6 +1662,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * Special DependencyDescriptor variant for autowire="byType". * Always optional; never considering the parameter name for choosing a primary candidate. */ + @SuppressWarnings("serial") private static class AutowireByTypeDependencyDescriptor extends DependencyDescriptor { public AutowireByTypeDependencyDescriptor(MethodParameter methodParameter, boolean eager) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index 652d45afb2..3d1895aa78 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -52,6 +52,7 @@ import org.springframework.util.StringUtils; * @see RootBeanDefinition * @see ChildBeanDefinition */ +@SuppressWarnings("serial") public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccessor implements BeanDefinition, Cloneable { @@ -277,13 +278,13 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * definition (presumably the child). *
        *
      • Will override beanClass if specified in the given bean definition. - *
      • Will always take abstract, scope, - * lazyInit, autowireMode, dependencyCheck, - * and dependsOn from the given bean definition. - *
      • Will add constructorArgumentValues, propertyValues, - * methodOverrides from the given bean definition to existing ones. - *
      • Will override factoryBeanName, factoryMethodName, - * initMethodName, and destroyMethodName if specified + *
      • Will always take {@code abstract}, {@code scope}, + * {@code lazyInit}, {@code autowireMode}, {@code dependencyCheck}, + * and {@code dependsOn} from the given bean definition. + *
      • Will add {@code constructorArgumentValues}, {@code propertyValues}, + * {@code methodOverrides} from the given bean definition to existing ones. + *
      • Will override {@code factoryBeanName}, {@code factoryMethodName}, + * {@code initMethodName}, and {@code destroyMethodName} if specified * in the given bean definition. *
      */ @@ -369,7 +370,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Return the class of the wrapped bean, if already resolved. - * @return the bean class, or null if none defined + * @return the bean class, or {@code null} if none defined * @throws IllegalStateException if the bean definition does not define a bean class, * or a specified bean class name has not been resolved into an actual Class */ @@ -385,10 +386,12 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess return (Class) beanClassObject; } + @Override public void setBeanClassName(String beanClassName) { this.beanClass = beanClassName; } + @Override public String getBeanClassName() { Object beanClassObject = this.beanClass; if (beanClassObject instanceof Class) { @@ -428,6 +431,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * @see #SCOPE_SINGLETON * @see #SCOPE_PROTOTYPE */ + @Override public void setScope(String scope) { this.scope = scope; this.singleton = SCOPE_SINGLETON.equals(scope) || SCOPE_DEFAULT.equals(scope); @@ -437,6 +441,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Return the name of the target scope for the bean. */ + @Override public String getScope() { return this.scope; } @@ -466,6 +471,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * returned from all calls. * @see #SCOPE_SINGLETON */ + @Override public boolean isSingleton() { return this.singleton; } @@ -475,6 +481,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * returned for each call. * @see #SCOPE_PROTOTYPE */ + @Override public boolean isPrototype() { return this.prototype; } @@ -493,15 +500,17 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * Return whether this bean is "abstract", i.e. not meant to be instantiated * itself but rather just serving as parent for concrete child bean definitions. */ + @Override public boolean isAbstract() { return this.abstractFlag; } /** * Set whether this bean should be lazily initialized. - *

      If false, the bean will get instantiated on startup by bean + *

      If {@code false}, the bean will get instantiated on startup by bean * factories that perform eager initialization of singletons. */ + @Override public void setLazyInit(boolean lazyInit) { this.lazyInit = lazyInit; } @@ -510,6 +519,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * Return whether this bean should be lazily initialized, i.e. not * eagerly instantiated on startup. Only applicable to a singleton bean. */ + @Override public boolean isLazyInit() { return this.lazyInit; } @@ -590,6 +600,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * constructor arguments. This property should just be necessary for other kinds * of dependencies like statics (*ugh*) or database preparation on startup. */ + @Override public void setDependsOn(String[] dependsOn) { this.dependsOn = dependsOn; } @@ -597,6 +608,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Return the bean names that this bean depends on. */ + @Override public String[] getDependsOn() { return this.dependsOn; } @@ -604,6 +616,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Set whether this bean is a candidate for getting autowired into some other bean. */ + @Override public void setAutowireCandidate(boolean autowireCandidate) { this.autowireCandidate = autowireCandidate; } @@ -611,6 +624,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Return whether this bean is a candidate for getting autowired into some other bean. */ + @Override public boolean isAutowireCandidate() { return this.autowireCandidate; } @@ -620,6 +634,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * If this value is true for exactly one bean among multiple * matching candidates, it will serve as a tie-breaker. */ + @Override public void setPrimary(boolean primary) { this.primary = primary; } @@ -629,6 +644,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * If this value is true for exactly one bean among multiple * matching candidates, it will serve as a tie-breaker. */ + @Override public boolean isPrimary() { return this.primary; } @@ -696,7 +712,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } /** - * Specify whether to resolve constructors in lenient mode (true, + * Specify whether to resolve constructors in lenient mode ({@code true}, * which is the default) or to switch to strict resolution (throwing an exception * in case of ambigious constructors that all match when converting the arguments, * whereas lenient mode would use the one with the 'closest' type matches). @@ -721,8 +737,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } /** - * Return constructor argument values for this bean (never null). + * Return constructor argument values for this bean (never {@code null}). */ + @Override public ConstructorArgumentValues getConstructorArgumentValues() { return this.constructorArgumentValues; } @@ -742,8 +759,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } /** - * Return property values for this bean (never null). + * Return property values for this bean (never {@code null}). */ + @Override public MutablePropertyValues getPropertyValues() { return this.propertyValues; } @@ -765,24 +783,28 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } + @Override public void setFactoryBeanName(String factoryBeanName) { this.factoryBeanName = factoryBeanName; } + @Override public String getFactoryBeanName() { return this.factoryBeanName; } + @Override public void setFactoryMethodName(String factoryMethodName) { this.factoryMethodName = factoryMethodName; } + @Override public String getFactoryMethodName() { return this.factoryMethodName; } /** - * Set the name of the initializer method. The default is null + * Set the name of the initializer method. The default is {@code null} * in which case there is no initializer method. */ public void setInitMethodName(String initMethodName) { @@ -798,7 +820,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Specify whether or not the configured init method is the default. - * Default value is false. + * Default value is {@code false}. * @see #setInitMethodName */ public void setEnforceInitMethod(boolean enforceInitMethod) { @@ -814,7 +836,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } /** - * Set the name of the destroy method. The default is null + * Set the name of the destroy method. The default is {@code null} * in which case there is no destroy method. */ public void setDestroyMethodName(String destroyMethodName) { @@ -830,7 +852,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Specify whether or not the configured destroy method is the default. - * Default value is false. + * Default value is {@code false}. * @see #setDestroyMethodName */ public void setEnforceDestroyMethod(boolean enforceDestroyMethod) { @@ -849,7 +871,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Set whether this bean definition is 'synthetic', that is, not defined * by the application itself (for example, an infrastructure bean such - * as a helper for auto-proxying, created through <aop:config>). + * as a helper for auto-proxying, created through {@code <aop:config>}). */ public void setSynthetic(boolean synthetic) { this.synthetic = synthetic; @@ -864,15 +886,16 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess } /** - * Set the role hint for this BeanDefinition. + * Set the role hint for this {@code BeanDefinition}. */ public void setRole(int role) { this.role = role; } /** - * Return the role hint for this BeanDefinition. + * Return the role hint for this {@code BeanDefinition}. */ + @Override public int getRole() { return this.role; } @@ -885,6 +908,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess this.description = description; } + @Override public String getDescription() { return this.description; } @@ -912,6 +936,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess this.resource = new DescriptiveResource(resourceDescription); } + @Override public String getResourceDescription() { return (this.resource != null ? this.resource.getDescription() : null); } @@ -923,6 +948,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess this.resource = new BeanDefinitionResource(originatingBd); } + @Override public BeanDefinition getOriginatingBeanDefinition() { return (this.resource instanceof BeanDefinitionResource ? ((BeanDefinitionResource) this.resource).getBeanDefinition() : null); @@ -981,9 +1007,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** - * Public declaration of Object's clone() method. + * Public declaration of Object's {@code clone()} method. * Delegates to {@link #cloneBeanDefinition()}. - * @see java.lang.Object#clone() + * @see Object#clone() */ @Override public Object clone() { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java index d0f524ed7d..3f81a2a2b0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -102,6 +102,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable return this.registry; } + @Override public final BeanDefinitionRegistry getRegistry() { return this.registry; } @@ -112,7 +113,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable * will be capable of resolving resource patterns to Resource arrays. *

      Default is PathMatchingResourcePatternResolver, also capable of * resource pattern resolving through the ResourcePatternResolver interface. - *

      Setting this to null suggests that absolute resource loading + *

      Setting this to {@code null} suggests that absolute resource loading * is not available for this bean definition reader. * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver @@ -121,21 +122,23 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable this.resourceLoader = resourceLoader; } + @Override public ResourceLoader getResourceLoader() { return this.resourceLoader; } /** * Set the ClassLoader to use for bean classes. - *

      Default is null, which suggests to not load bean classes + *

      Default is {@code null}, which suggests to not load bean classes * eagerly but rather to just register bean definitions with class names, * with the corresponding Classes to be resolved later (or never). - * @see java.lang.Thread#getContextClassLoader() + * @see Thread#getContextClassLoader() */ public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } + @Override public ClassLoader getBeanClassLoader() { return this.beanClassLoader; } @@ -149,6 +152,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable this.environment = environment; } + @Override public Environment getEnvironment() { return this.environment; } @@ -162,11 +166,13 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable this.beanNameGenerator = (beanNameGenerator != null ? beanNameGenerator : new DefaultBeanNameGenerator()); } + @Override public BeanNameGenerator getBeanNameGenerator() { return this.beanNameGenerator; } + @Override public int loadBeanDefinitions(Resource... resources) throws BeanDefinitionStoreException { Assert.notNull(resources, "Resource array must not be null"); int counter = 0; @@ -176,6 +182,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable return counter; } + @Override public int loadBeanDefinitions(String location) throws BeanDefinitionStoreException { return loadBeanDefinitions(location, null); } @@ -187,7 +194,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable * @param location the resource location, to be loaded with the ResourceLoader * (or ResourcePatternResolver) of this bean definition reader * @param actualResources a Set to be filled with the actual Resource objects - * that have been resolved during the loading process. May be null + * that have been resolved during the loading process. May be {@code null} * to indicate that the caller is not interested in those Resource objects. * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors @@ -236,6 +243,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable } } + @Override public int loadBeanDefinitions(String... locations) throws BeanDefinitionStoreException { Assert.notNull(locations, "Location array must not be null"); int counter = 0; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index b5699c2fb8..1d73ee4734 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -178,7 +178,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** * Create a new AbstractBeanFactory with the given parent. - * @param parentBeanFactory parent bean factory, or null if none + * @param parentBeanFactory parent bean factory, or {@code null} if none * @see #getBean */ public AbstractBeanFactory(BeanFactory parentBeanFactory) { @@ -190,14 +190,17 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp // Implementation of BeanFactory interface //--------------------------------------------------------------------- + @Override public Object getBean(String name) throws BeansException { return doGetBean(name, null, null, false); } + @Override public T getBean(String name, Class requiredType) throws BeansException { return doGetBean(name, requiredType, null, false); } + @Override public Object getBean(String name, Object... args) throws BeansException { return doGetBean(name, null, args, false); } @@ -290,6 +293,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp // Create bean instance. if (mbd.isSingleton()) { sharedInstance = getSingleton(beanName, new ObjectFactory() { + @Override public Object getObject() throws BeansException { try { return createBean(beanName, mbd, args); @@ -327,6 +331,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } try { Object scopedInstance = scope.get(beanName, new ObjectFactory() { + @Override public Object getObject() throws BeansException { beforePrototypeCreation(beanName); try { @@ -364,6 +369,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return (T) bean; } + @Override public boolean containsBean(String name) { String beanName = transformedBeanName(name); if (containsSingleton(beanName) || containsBeanDefinition(beanName)) { @@ -374,6 +380,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return (parentBeanFactory != null && parentBeanFactory.containsBean(originalBeanName(name))); } + @Override public boolean isSingleton(String name) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); @@ -419,6 +426,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public boolean isPrototype(String name) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); @@ -443,6 +451,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp final FactoryBean factoryBean = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName); if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Boolean run() { return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) || !factoryBean.isSingleton()); @@ -460,6 +469,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); Class typeToMatch = (targetType != null ? targetType : Object.class); @@ -531,6 +541,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public Class getType(String name) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); @@ -621,10 +632,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp // Implementation of HierarchicalBeanFactory interface //--------------------------------------------------------------------- + @Override public BeanFactory getParentBeanFactory() { return this.parentBeanFactory; } + @Override public boolean containsLocalBean(String name) { String beanName = transformedBeanName(name); return ((containsSingleton(beanName) || containsBeanDefinition(beanName)) && @@ -636,6 +649,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp // Implementation of ConfigurableBeanFactory interface //--------------------------------------------------------------------- + @Override public void setParentBeanFactory(BeanFactory parentBeanFactory) { if (this.parentBeanFactory != null && this.parentBeanFactory != parentBeanFactory) { throw new IllegalStateException("Already associated with parent BeanFactory: " + this.parentBeanFactory); @@ -643,46 +657,57 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp this.parentBeanFactory = parentBeanFactory; } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = (beanClassLoader != null ? beanClassLoader : ClassUtils.getDefaultClassLoader()); } + @Override public ClassLoader getBeanClassLoader() { return this.beanClassLoader; } + @Override public void setTempClassLoader(ClassLoader tempClassLoader) { this.tempClassLoader = tempClassLoader; } + @Override public ClassLoader getTempClassLoader() { return this.tempClassLoader; } + @Override public void setCacheBeanMetadata(boolean cacheBeanMetadata) { this.cacheBeanMetadata = cacheBeanMetadata; } + @Override public boolean isCacheBeanMetadata() { return this.cacheBeanMetadata; } + @Override public void setBeanExpressionResolver(BeanExpressionResolver resolver) { this.beanExpressionResolver = resolver; } + @Override public BeanExpressionResolver getBeanExpressionResolver() { return this.beanExpressionResolver; } + @Override public void setConversionService(ConversionService conversionService) { this.conversionService = conversionService; } + @Override public ConversionService getConversionService() { return this.conversionService; } + @Override public void addPropertyEditorRegistrar(PropertyEditorRegistrar registrar) { Assert.notNull(registrar, "PropertyEditorRegistrar must not be null"); this.propertyEditorRegistrars.add(registrar); @@ -695,12 +720,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return this.propertyEditorRegistrars; } + @Override public void registerCustomEditor(Class requiredType, Class propertyEditorClass) { Assert.notNull(requiredType, "Required type must not be null"); Assert.isAssignable(PropertyEditor.class, propertyEditorClass); this.customEditors.put(requiredType, propertyEditorClass); } + @Override public void copyRegisteredEditorsTo(PropertyEditorRegistry registry) { registerCustomEditors(registry); } @@ -712,18 +739,20 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return this.customEditors; } + @Override public void setTypeConverter(TypeConverter typeConverter) { this.typeConverter = typeConverter; } /** * Return the custom TypeConverter to use, if any. - * @return the custom TypeConverter, or null if none specified + * @return the custom TypeConverter, or {@code null} if none specified */ protected TypeConverter getCustomTypeConverter() { return this.typeConverter; } + @Override public TypeConverter getTypeConverter() { TypeConverter customConverter = getCustomTypeConverter(); if (customConverter != null) { @@ -738,11 +767,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public void addEmbeddedValueResolver(StringValueResolver valueResolver) { Assert.notNull(valueResolver, "StringValueResolver must not be null"); this.embeddedValueResolvers.add(valueResolver); } + @Override public String resolveEmbeddedValue(String value) { String result = value; for (StringValueResolver resolver : this.embeddedValueResolvers) { @@ -751,6 +782,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return result; } + @Override public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) { Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null"); this.beanPostProcessors.remove(beanPostProcessor); @@ -763,6 +795,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public int getBeanPostProcessorCount() { return this.beanPostProcessors.size(); } @@ -795,6 +828,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return this.hasDestructionAwareBeanPostProcessors; } + @Override public void registerScope(String scopeName, Scope scope) { Assert.notNull(scopeName, "Scope identifier must not be null"); Assert.notNull(scope, "Scope must not be null"); @@ -804,10 +838,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp this.scopes.put(scopeName, scope); } + @Override public String[] getRegisteredScopeNames() { return StringUtils.toStringArray(this.scopes.keySet()); } + @Override public Scope getRegisteredScope(String scopeName) { Assert.notNull(scopeName, "Scope identifier must not be null"); return this.scopes.get(scopeName); @@ -833,6 +869,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp AccessController.getContext()); } + @Override public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) { Assert.notNull(otherFactory, "BeanFactory must not be null"); setBeanClassLoader(otherFactory.getBeanClassLoader()); @@ -858,7 +895,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** * Return a 'merged' BeanDefinition for the given bean name, * merging a child bean definition with its parent if necessary. - *

      This getMergedBeanDefinition considers bean definition + *

      This {@code getMergedBeanDefinition} considers bean definition * in ancestors as well. * @param name the name of the bean to retrieve the merged definition for * (may be an alias) @@ -866,6 +903,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @throws NoSuchBeanDefinitionException if there is no bean with the given name * @throws BeanDefinitionStoreException in case of an invalid bean definition */ + @Override public BeanDefinition getMergedBeanDefinition(String name) throws BeansException { String beanName = transformedBeanName(name); @@ -877,6 +915,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp return getMergedLocalBeanDefinition(beanName); } + @Override public boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException { String beanName = transformedBeanName(name); @@ -959,6 +998,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } } + @Override public void destroyBean(String beanName, Object beanInstance) { destroyBean(beanName, beanInstance, getMergedLocalBeanDefinition(beanName)); } @@ -974,6 +1014,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp new DisposableBeanAdapter(beanInstance, beanName, mbd, getBeanPostProcessors(), getAccessControlContext()).destroy(); } + @Override public void destroyScopedBean(String beanName) { RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); if (mbd.isSingleton() || mbd.isPrototype()) { @@ -1116,7 +1157,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @param beanName the name of the bean definition * @param bd the original bean definition (Root/ChildBeanDefinition) * @param containingBd the containing bean definition in case of inner bean, - * or null in case of a top-level bean + * or {@code null} in case of a top-level bean * @return a (potentially merged) RootBeanDefinition for the given bean * @throws BeanDefinitionStoreException in case of an invalid bean definition */ @@ -1234,8 +1275,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @param mbd the merged bean definition to determine the class for * @param beanName the name of the bean (for error handling purposes) * @param typesToMatch the types to match in case of internal type matching purposes - * (also signals that the returned Class will never be exposed to application code) - * @return the resolved bean class (or null if none) + * (also signals that the returned {@code Class} will never be exposed to application code) + * @return the resolved bean class (or {@code null} if none) * @throws CannotLoadBeanClassException if we failed to load the class */ protected Class resolveBeanClass(final RootBeanDefinition mbd, String beanName, final Class... typesToMatch) @@ -1246,6 +1287,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp } if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedExceptionAction>() { + @Override public Class run() throws Exception { return doResolveBeanClass(mbd, typesToMatch); } @@ -1313,8 +1355,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @param beanName the name of the bean * @param mbd the merged bean definition to determine the type for * @param typesToMatch the types to match in case of internal type matching purposes - * (also signals that the returned Class will never be exposed to application code) - * @return the type of the bean, or null if not predictable + * (also signals that the returned {@code Class} will never be exposed to application code) + * @return the type of the bean, or {@code null} if not predictable */ protected Class predictBeanType(String beanName, RootBeanDefinition mbd, Class... typesToMatch) { if (mbd.getFactoryMethodName() != null) { @@ -1337,15 +1379,15 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** * Determine the bean type for the given FactoryBean definition, as far as possible. * Only called if there is no singleton instance registered for the target bean already. - *

      The default implementation creates the FactoryBean via getBean - * to call its getObjectType method. Subclasses are encouraged to optimize + *

      The default implementation creates the FactoryBean via {@code getBean} + * to call its {@code getObjectType} method. Subclasses are encouraged to optimize * this, typically by just instantiating the FactoryBean but not populating it yet, - * trying whether its getObjectType method already returns a type. + * trying whether its {@code getObjectType} method already returns a type. * If no type found, a full FactoryBean creation as performed by this implementation * should be used as fallback. * @param beanName the name of the bean * @param mbd the merged bean definition for the bean - * @return the type for the bean if determinable, or null else + * @return the type for the bean if determinable, or {@code null} else * @see org.springframework.beans.factory.FactoryBean#getObjectType() * @see #getBean(String) */ @@ -1381,7 +1423,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * Determine whether the specified bean is eligible for having * its bean definition metadata cached. * @param beanName the name of the bean - * @return true if the bean's metadata may be cached + * @return {@code true} if the bean's metadata may be cached * at this point already */ protected boolean isBeanEligibleForMetadataCaching(String beanName) { @@ -1392,7 +1434,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * Remove the singleton instance (if any) for the given bean name, * but only if it hasn't been used for other purposes than type checking. * @param beanName the name of the bean - * @return true if actually removed, false otherwise + * @return {@code true} if actually removed, {@code false} otherwise */ protected boolean removeSingletonIfCreatedForTypeCheckOnly(String beanName) { if (!this.alreadyCreated.containsKey(beanName)) { @@ -1512,7 +1554,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** * Check if this bean factory contains a bean definition with the given name. * Does not consider any hierarchy this factory may participate in. - * Invoked by containsBean when no cached singleton instance is found. + * Invoked by {@code containsBean} when no cached singleton instance is found. *

      Depending on the nature of the concrete bean factory implementation, * this operation might be expensive (for example, because of directory lookups * in external registries). However, for listable bean factories, this usually @@ -1537,7 +1579,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * public interface there. The same implementation can serve for both this * template method and the public interface method in that case. * @param beanName the name of the bean to find a definition for - * @return the BeanDefinition for this prototype name (never null) + * @return the BeanDefinition for this prototype name (never {@code null}) * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException * if the bean definition cannot be resolved * @throws BeansException in case of errors @@ -1557,7 +1599,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp * @param beanName the name of the bean * @param mbd the merged bean definition for the bean * @param args arguments to use if creating a prototype using explicit arguments to a - * static factory method. This parameter must be null except in this case. + * static factory method. This parameter must be {@code null} except in this case. * @return a new instance of the bean * @throws BeanCreationException if the bean could not be created */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java index 58c560c917..6846390e1b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.util.Assert; * @since 2.5 * @see org.springframework.beans.factory.annotation.Qualifier */ +@SuppressWarnings("serial") public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor { public static String VALUE_KEY = "value"; @@ -59,7 +60,7 @@ public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor { /** * Construct a qualifier to match against an annotation of the - * given type whose value attribute also matches + * given type whose {@code value} attribute also matches * the specified value. * @param type the annotation type * @param value the annotation value to match @@ -70,7 +71,7 @@ public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor { /** * Construct a qualifier to match against an annotation of the - * given type name whose value attribute also matches + * given type name whose {@code value} attribute also matches * the specified value. *

      The type name may match the fully-qualified class name of * the annotation or the short class name (without the package). diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java index 0f30540e67..cd2c41e115 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public interface AutowireCandidateResolver { * Determine whether a default value is suggested for the given dependency. * @param descriptor the descriptor for the target method parameter or field * @return the value suggested (typically an expression String), - * or null if none found + * or {@code null} if none found * @since 3.0 */ Object getSuggestedValue(DependencyDescriptor descriptor); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java index cb1bce28ee..140e11569c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ abstract class AutowireUtils { */ public static void sortConstructors(Constructor[] constructors) { Arrays.sort(constructors, new Comparator() { + @Override public int compare(Constructor c1, Constructor c2) { boolean p1 = Modifier.isPublic(c1.getModifiers()); boolean p2 = Modifier.isPublic(c2.getModifiers()); @@ -73,6 +74,7 @@ abstract class AutowireUtils { */ public static void sortFactoryMethods(Method[] factoryMethods) { Arrays.sort(factoryMethods, new Comparator() { + @Override public int compare(Method fm1, Method fm2) { boolean p1 = Modifier.isPublic(fm1.getModifiers()); boolean p2 = Modifier.isPublic(fm2.getModifiers()); @@ -153,6 +155,7 @@ abstract class AutowireUtils { /** * Reflective InvocationHandler for lazy access to the current target object. */ + @SuppressWarnings("serial") private static class ObjectFactoryDelegatingInvocationHandler implements InvocationHandler, Serializable { private final ObjectFactory objectFactory; @@ -161,6 +164,7 @@ abstract class AutowireUtils { this.objectFactory = objectFactory; } + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (methodName.equals("equals")) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java index 3b338d5b27..6a2cb27e49 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.util.ObjectUtils; public class BeanDefinitionBuilder { /** - * Create a new BeanDefinitionBuilder used to construct a {@link GenericBeanDefinition}. + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}. */ public static BeanDefinitionBuilder genericBeanDefinition() { BeanDefinitionBuilder builder = new BeanDefinitionBuilder(); @@ -42,8 +42,8 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link GenericBeanDefinition}. - * @param beanClass the Class of the bean that the definition is being created for + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}. + * @param beanClass the {@code Class} of the bean that the definition is being created for */ public static BeanDefinitionBuilder genericBeanDefinition(Class beanClass) { BeanDefinitionBuilder builder = new BeanDefinitionBuilder(); @@ -53,7 +53,7 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link GenericBeanDefinition}. + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}. * @param beanClassName the class name for the bean that the definition is being created for */ public static BeanDefinitionBuilder genericBeanDefinition(String beanClassName) { @@ -64,16 +64,16 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link RootBeanDefinition}. - * @param beanClass the Class of the bean that the definition is being created for + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}. + * @param beanClass the {@code Class} of the bean that the definition is being created for */ public static BeanDefinitionBuilder rootBeanDefinition(Class beanClass) { return rootBeanDefinition(beanClass, null); } /** - * Create a new BeanDefinitionBuilder used to construct a {@link RootBeanDefinition}. - * @param beanClass the Class of the bean that the definition is being created for + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}. + * @param beanClass the {@code Class} of the bean that the definition is being created for * @param factoryMethodName the name of the method to use to construct the bean instance */ public static BeanDefinitionBuilder rootBeanDefinition(Class beanClass, String factoryMethodName) { @@ -85,7 +85,7 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link RootBeanDefinition}. + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}. * @param beanClassName the class name for the bean that the definition is being created for */ public static BeanDefinitionBuilder rootBeanDefinition(String beanClassName) { @@ -93,7 +93,7 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link RootBeanDefinition}. + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}. * @param beanClassName the class name for the bean that the definition is being created for * @param factoryMethodName the name of the method to use to construct the bean instance */ @@ -106,7 +106,7 @@ public class BeanDefinitionBuilder { } /** - * Create a new BeanDefinitionBuilder used to construct a {@link ChildBeanDefinition}. + * Create a new {@code BeanDefinitionBuilder} used to construct a {@link ChildBeanDefinition}. * @param parentName the name of the parent bean */ public static BeanDefinitionBuilder childBeanDefinition(String parentName) { @@ -117,7 +117,7 @@ public class BeanDefinitionBuilder { /** - * The BeanDefinition instance we are creating. + * The {@code BeanDefinition} instance we are creating. */ private AbstractBeanDefinition beanDefinition; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java index 382cc32069..db7ccda800 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ package org.springframework.beans.factory.support; import org.springframework.util.StringUtils; /** - * A simple holder for BeanDefinition property defaults. - * + * A simple holder for {@code BeanDefinition} property defaults. + * * @author Mark Fisher * @since 2.5 */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReader.java index e9ff9c9abe..f5d1e77781 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,27 +46,27 @@ public interface BeanDefinitionReader { BeanDefinitionRegistry getRegistry(); /** - * Return the resource loader to use for resource locations. - * Can be checked for the ResourcePatternResolver interface and cast - * accordingly, for loading multiple resources for a given resource pattern. - *

      Null suggests that absolute resource loading is not available - * for this bean definition reader. - *

      This is mainly meant to be used for importing further resources - * from within a bean definition resource, for example via the "import" - * tag in XML bean definitions. It is recommended, however, to apply - * such imports relative to the defining resource; only explicit full - * resource locations will trigger absolute resource loading. - *

      There is also a loadBeanDefinitions(String) method available, - * for loading bean definitions from a resource location (or location pattern). - * This is a convenience to avoid explicit ResourceLoader handling. - * @see #loadBeanDefinitions(String) - * @see org.springframework.core.io.support.ResourcePatternResolver - */ + * Return the resource loader to use for resource locations. + * Can be checked for the ResourcePatternResolver interface and cast + * accordingly, for loading multiple resources for a given resource pattern. + *

      Null suggests that absolute resource loading is not available + * for this bean definition reader. + *

      This is mainly meant to be used for importing further resources + * from within a bean definition resource, for example via the "import" + * tag in XML bean definitions. It is recommended, however, to apply + * such imports relative to the defining resource; only explicit full + * resource locations will trigger absolute resource loading. + *

      There is also a {@code loadBeanDefinitions(String)} method available, + * for loading bean definitions from a resource location (or location pattern). + * This is a convenience to avoid explicit ResourceLoader handling. + * @see #loadBeanDefinitions(String) + * @see org.springframework.core.io.support.ResourcePatternResolver + */ ResourceLoader getResourceLoader(); /** * Return the class loader to use for bean classes. - *

      null suggests to not load bean classes eagerly + *

      {@code null} suggests to not load bean classes eagerly * but rather to just register bean definitions with class names, * with the corresponding Classes to be resolved later (or never). */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java index 1d80a290cf..aa9bbe94e8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionReaderUtils.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class BeanDefinitionReaderUtils { * @param parentName the name of the parent bean, if any * @param className the name of the bean class, if any * @param classLoader the ClassLoader to use for loading bean classes - * (can be null to just register bean classes by name) + * (can be {@code null} to just register bean classes by name) * @return the bean definition * @throws ClassNotFoundException if the bean class could not be loaded */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java index 23191913de..326e1fb58c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionRegistry.java @@ -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"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public interface BeanDefinitionRegistry extends AliasRegistry { /** * Return the BeanDefinition for the given bean name. * @param beanName name of the bean to find a definition for - * @return the BeanDefinition for the given name (never null) + * @return the BeanDefinition for the given name (never {@code null}) * @throws NoSuchBeanDefinitionException if there is no such bean definition */ BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java index e5fb9c6afb..7de75a1be6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionResource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -64,11 +64,13 @@ class BeanDefinitionResource extends AbstractResource { return false; } + @Override public InputStream getInputStream() throws IOException { throw new FileNotFoundException( "Resource cannot be opened because it points to " + getDescription()); } + @Override public String getDescription() { return "BeanDefinition defined in " + this.beanDefinition.getResourceDescription(); } @@ -80,7 +82,7 @@ class BeanDefinitionResource extends AbstractResource { @Override public boolean equals(Object obj) { return (obj == this || - (obj instanceof BeanDefinitionResource && + (obj instanceof BeanDefinitionResource && ((BeanDefinitionResource) obj).beanDefinition.equals(this.beanDefinition))); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValidationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValidationException.java index 79d0d1e005..04e96a7578 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValidationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValidationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.beans.FatalBeanException; * @since 21.11.2003 * @see AbstractBeanDefinition#validate() */ +@SuppressWarnings("serial") public class BeanDefinitionValidationException extends FatalBeanException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java index d794b3a4ef..4ee6d218fa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java @@ -94,7 +94,7 @@ class BeanDefinitionValueResolver { * Collections that will need to be resolved. *

    1. A ManagedMap. In this case the value may be a RuntimeBeanReference * or Collection that will need to be resolved. - *
    2. An ordinary object or null, in which case it's left alone. + *
    3. An ordinary object or {@code null}, in which case it's left alone. * @param argName the name of the argument that the value is defined for * @param value the value object to resolve * @return the resolved object @@ -232,7 +232,7 @@ class BeanDefinitionValueResolver { /** * Resolve the target type in the given TypedStringValue. * @param value the TypedStringValue to resolve - * @return the resolved target type (or null if none specified) + * @return the resolved target type (or {@code null} if none specified) * @throws ClassNotFoundException if the specified type cannot be resolved * @see TypedStringValue#resolveTargetType */ @@ -339,7 +339,7 @@ class BeanDefinitionValueResolver { Object resolved = Array.newInstance(elementType, ml.size()); for (int i = 0; i < ml.size(); i++) { Array.set(resolved, i, - resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); + resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); } return resolved; } @@ -351,7 +351,7 @@ class BeanDefinitionValueResolver { List resolved = new ArrayList(ml.size()); for (int i = 0; i < ml.size(); i++) { resolved.add( - resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); + resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); } return resolved; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java index 2d3ce41f37..8c802f09d2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java @@ -53,7 +53,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt * be overridden to provide method lookup. */ private static final int LOOKUP_OVERRIDE = 1; - + /** * Index in the CGLIB callback array for a method that should * be overridden using generic Methodreplacer functionality. @@ -98,10 +98,10 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt /** * Create a new instance of a dynamically generated subclasses implementing the * required lookups. - * @param ctor constructor to use. If this is null, use the + * @param ctor constructor to use. If this is {@code null}, use the * no-arg constructor (no parameterization, or Setter Injection) * @param args arguments to use for the constructor. - * Ignored if the ctor parameter is null. + * Ignored if the ctor parameter is {@code null}. * @return new instance of the dynamically generated class */ public Object instantiate(Constructor ctor, Object[] args) { @@ -114,8 +114,8 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt new ReplaceOverrideMethodInterceptor() }); - return (ctor == null) ? - enhancer.create() : + return (ctor == null) ? + enhancer.create() : enhancer.create(ctor.getParameterTypes(), args); } @@ -123,7 +123,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt /** * Class providing hashCode and equals methods required by CGLIB to * ensure that CGLIB doesn't generate a distinct class per bean. - * Identity is based on class and bean definition. + * Identity is based on class and bean definition. */ private class CglibIdentitySupport { @@ -153,11 +153,12 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt */ private class LookupOverrideMethodInterceptor extends CglibIdentitySupport implements MethodInterceptor { + @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy mp) throws Throwable { // Cast is safe, as CallbackFilter filters are used selectively. LookupOverride lo = (LookupOverride) beanDefinition.getMethodOverrides().getOverride(method); return owner.getBean(lo.getBeanName()); - } + } } @@ -167,6 +168,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt */ private class ReplaceOverrideMethodInterceptor extends CglibIdentitySupport implements MethodInterceptor { + @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy mp) throws Throwable { ReplaceOverride ro = (ReplaceOverride) beanDefinition.getMethodOverrides().getOverride(method); // TODO could cache if a singleton for minor performance optimization @@ -180,7 +182,8 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt * CGLIB object to filter method interception behavior. */ private class CallbackFilterImpl extends CglibIdentitySupport implements CallbackFilter { - + + @Override public int accept(Method method) { MethodOverride methodOverride = beanDefinition.getMethodOverrides().getOverride(method); if (logger.isTraceEnabled()) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.java index 6effd4031e..cbc43acfbe 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ChildBeanDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.util.ObjectUtils; * @see GenericBeanDefinition * @see RootBeanDefinition */ +@SuppressWarnings("serial") public class ChildBeanDefinition extends AbstractBeanDefinition { private String parentName; @@ -131,10 +132,12 @@ public class ChildBeanDefinition extends AbstractBeanDefinition { } + @Override public void setParentName(String parentName) { this.parentName = parentName; } + @Override public String getParentName() { return this.parentName; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 3a769c85d2..994c0d6e95 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -97,9 +97,9 @@ class ConstructorResolver { * dependency resolution. * @param beanName the name of the bean * @param mbd the merged bean definition for the bean - * @param chosenCtors chosen candidate constructors (or null if none) + * @param chosenCtors chosen candidate constructors (or {@code null} if none) * @param explicitArgs argument values passed in programmatically via the getBean method, - * or null if none (-> use constructor argument values from bean definition) + * or {@code null} if none (-> use constructor argument values from bean definition) * @return a BeanWrapper for the new instance */ public BeanWrapper autowireConstructor( @@ -270,6 +270,7 @@ class ConstructorResolver { final Constructor ctorToUse = constructorToUse; final Object[] argumentsToUse = argsToUse; beanInstance = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { return beanFactory.getInstantiationStrategy().instantiate( mbd, beanName, beanFactory, ctorToUse, argumentsToUse); @@ -280,7 +281,7 @@ class ConstructorResolver { beanInstance = this.beanFactory.getInstantiationStrategy().instantiate( mbd, beanName, this.beanFactory, constructorToUse, argsToUse); } - + bw.setWrappedInstance(beanInstance); return bw; } @@ -333,7 +334,7 @@ class ConstructorResolver { * @param beanName the name of the bean * @param mbd the merged bean definition for the bean * @param explicitArgs argument values passed in programmatically via the getBean - * method, or null if none (-> use constructor argument values from bean definition) + * method, or {@code null} if none (-> use constructor argument values from bean definition) * @return a BeanWrapper for the new instance */ public BeanWrapper instantiateUsingFactoryMethod(final String beanName, final RootBeanDefinition mbd, final Object[] explicitArgs) { @@ -402,6 +403,7 @@ class ConstructorResolver { final Class factoryClazz = factoryClass; if (System.getSecurityManager() != null) { rawCandidates = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Method[] run() { return (mbd.isNonPublicAccessAllowed() ? ReflectionUtils.getAllDeclaredMethods(factoryClazz) : factoryClazz.getMethods()); @@ -412,7 +414,7 @@ class ConstructorResolver { rawCandidates = (mbd.isNonPublicAccessAllowed() ? ReflectionUtils.getAllDeclaredMethods(factoryClazz) : factoryClazz.getMethods()); } - + List candidateSet = new ArrayList(); for (Method candidate : rawCandidates) { if (Modifier.isStatic(candidate.getModifiers()) == isStatic && @@ -560,6 +562,7 @@ class ConstructorResolver { final Method factoryMethod = factoryMethodToUse; final Object[] args = argsToUse; beanInstance = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { return beanFactory.getInstantiationStrategy().instantiate( mbd, beanName, beanFactory, fb, factoryMethod, args); @@ -570,7 +573,7 @@ class ConstructorResolver { beanInstance = beanFactory.getInstantiationStrategy().instantiate( mbd, beanName, beanFactory, factoryBean, factoryMethodToUse, argsToUse); } - + if (beanInstance == null) { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultBeanNameGenerator.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultBeanNameGenerator.java index 065c4e2163..ebd7a7022d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultBeanNameGenerator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultBeanNameGenerator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.beans.factory.config.BeanDefinition; */ public class DefaultBeanNameGenerator implements BeanNameGenerator { + @Override public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) { return BeanDefinitionReaderUtils.generateBeanName(definition, registry); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 3dfa8e893e..cb2e9fe4df 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -94,6 +94,7 @@ import org.springframework.util.StringUtils; * @see PropertiesBeanDefinitionReader * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader */ +@SuppressWarnings("serial") public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable { @@ -214,6 +215,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (System.getSecurityManager() != null) { final BeanFactory target = this; AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { ((BeanFactoryAware) autowireCandidateResolver).setBeanFactory(target); return null; @@ -228,7 +230,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } /** - * Return the autowire candidate resolver for this BeanFactory (never null). + * Return the autowire candidate resolver for this BeanFactory (never {@code null}). */ public AutowireCandidateResolver getAutowireCandidateResolver() { return this.autowireCandidateResolver; @@ -252,6 +254,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Implementation of ListableBeanFactory interface //--------------------------------------------------------------------- + @Override public T getBean(Class requiredType) throws BeansException { Assert.notNull(requiredType, "Required type must not be null"); String[] beanNames = getBeanNamesForType(requiredType); @@ -284,10 +287,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return this.beanDefinitionMap.containsKey(beanName); } + @Override public int getBeanDefinitionCount() { return this.beanDefinitionMap.size(); } + @Override public String[] getBeanDefinitionNames() { synchronized (this.beanDefinitionMap) { if (this.frozenBeanDefinitionNames != null) { @@ -299,10 +304,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } + @Override public String[] getBeanNamesForType(Class type) { return getBeanNamesForType(type, true, true); } + @Override public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) { if (!isConfigurationFrozen() || type == null || !allowEagerInit) { return doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); @@ -406,10 +413,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return (factoryBeanName != null && isFactoryBean(factoryBeanName) && !containsSingleton(factoryBeanName)); } + @Override public Map getBeansOfType(Class type) throws BeansException { return getBeansOfType(type, true, true); } + @Override public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException { @@ -440,6 +449,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return result; } + @Override public Map getBeansWithAnnotation(Class annotationType) { Set beanNames = new LinkedHashSet(getBeanDefinitionCount()); beanNames.addAll(Arrays.asList(getBeanDefinitionNames())); @@ -454,11 +464,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } /** - * Find a {@link Annotation} of annotationType on the specified + * Find a {@link Annotation} of {@code annotationType} on the specified * bean, traversing its interfaces and super classes if no annotation can be * found on the given class itself, as well as checking its raw bean class * if not found on the exposed bean reference (e.g. in case of a proxy). */ + @Override public A findAnnotationOnBean(String beanName, Class annotationType) { A ann = null; Class beanType = getType(beanName); @@ -482,6 +493,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Implementation of ConfigurableListableBeanFactory interface //--------------------------------------------------------------------- + @Override public void registerResolvableDependency(Class dependencyType, Object autowiredValue) { Assert.notNull(dependencyType, "Type must not be null"); if (autowiredValue != null) { @@ -491,6 +503,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } + @Override public boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException { @@ -551,6 +564,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return bd; } + @Override public void freezeConfiguration() { this.configurationFrozen = true; synchronized (this.beanDefinitionMap) { @@ -558,6 +572,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } + @Override public boolean isConfigurationFrozen() { return this.configurationFrozen; } @@ -572,6 +587,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return (this.configurationFrozen || super.isBeanEligibleForMetadataCaching(beanName)); } + @Override public void preInstantiateSingletons() throws BeansException { if (this.logger.isInfoEnabled()) { this.logger.info("Pre-instantiating singletons in " + this); @@ -590,6 +606,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto boolean isEagerInit; if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) { isEagerInit = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Boolean run() { return ((SmartFactoryBean) factory).isEagerInit(); } @@ -615,6 +632,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Implementation of BeanDefinitionRegistry interface //--------------------------------------------------------------------- + @Override public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException { @@ -656,6 +674,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto resetBeanDefinition(beanName); } + @Override public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { Assert.hasText(beanName, "'beanName' must not be empty"); @@ -716,6 +735,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Dependency resolution functionality //--------------------------------------------------------------------- + @Override public Object resolveDependency(DependencyDescriptor descriptor, String beanName, Set autowiredBeanNames, TypeConverter typeConverter) throws BeansException { @@ -744,7 +764,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto TypeConverter converter = (typeConverter != null ? typeConverter : getTypeConverter()); return (descriptor.getField() != null ? converter.convertIfNecessary(value, type, descriptor.getField()) : - converter.convertIfNecessary(value, type, descriptor.getMethodParameter())); + converter.convertIfNecessary(value, type, descriptor.getMethodParameter())); } if (type.isArray()) { @@ -847,7 +867,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto * (may be an array component type or collection element type) * @param descriptor the descriptor of the dependency to resolve * @return a Map of candidate names and candidate instances that match - * the required type (never null) + * the required type (never {@code null}) * @throws BeansException in case of errors * @see #autowireByType * @see #autowireConstructor @@ -881,7 +901,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto * @param candidateBeans a Map of candidate names and candidate instances * that match the required type, as returned by {@link #findAutowireCandidates} * @param descriptor the target dependency to match against - * @return the name of the primary candidate, or null if none found + * @return the name of the primary candidate, or {@code null} if none found */ protected String determinePrimaryCandidate(Map candidateBeans, DependencyDescriptor descriptor) { String primaryBeanName = null; @@ -992,7 +1012,6 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto * Minimal id reference to the factory. * Resolved to the actual factory instance on deserialization. */ - @SuppressWarnings("serial") private static class SerializedBeanFactoryReference implements Serializable { private final String id; @@ -1020,7 +1039,6 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto /** * Serializable ObjectFactory for lazy resolution of a dependency. */ - @SuppressWarnings("serial") private class DependencyObjectFactory implements ObjectFactory, Serializable { private final DependencyDescriptor descriptor; @@ -1033,6 +1051,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto this.beanName = beanName; } + @Override public Object getObject() throws BeansException { return doResolveDependency(this.descriptor, this.descriptor.getDependencyType(), this.beanName, null, null); } @@ -1042,13 +1061,13 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto /** * Serializable ObjectFactory for lazy resolution of a dependency. */ - @SuppressWarnings("serial") private class DependencyProvider extends DependencyObjectFactory implements Provider { public DependencyProvider(DependencyDescriptor descriptor, String beanName) { super(descriptor, beanName); } + @Override public Object get() throws BeansException { return getObject(); } @@ -1056,7 +1075,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto /** - * Separate inner class for avoiding a hard dependency on the javax.inject API. + * Separate inner class for avoiding a hard dependency on the {@code javax.inject} API. */ private class DependencyProviderFactory { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java index 64346bd9f2..a087466cb4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java @@ -117,6 +117,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements private final Map> dependenciesForBeanMap = new ConcurrentHashMap>(64); + @Override public void registerSingleton(String beanName, Object singletonObject) throws IllegalStateException { Assert.notNull(beanName, "'beanName' must not be null"); synchronized (this.singletonObjects) { @@ -163,6 +164,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements } } + @Override public Object getSingleton(String beanName) { return getSingleton(beanName, true); } @@ -173,7 +175,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements * reference to a currently created singleton (resolving a circular reference). * @param beanName the name of the bean to look for * @param allowEarlyReference whether early references should be created or not - * @return the registered singleton object, or null if none found + * @return the registered singleton object, or {@code null} if none found */ protected Object getSingleton(String beanName, boolean allowEarlyReference) { Object singletonObject = this.singletonObjects.get(beanName); @@ -270,16 +272,19 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements } } + @Override public boolean containsSingleton(String beanName) { return (this.singletonObjects.containsKey(beanName)); } + @Override public String[] getSingletonNames() { synchronized (this.singletonObjects) { return StringUtils.toStringArray(this.registeredSingletons); } } + @Override public int getSingletonCount() { synchronized (this.singletonObjects) { return this.registeredSingletons.size(); @@ -469,7 +474,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements } /** - * Destroy the given bean. Delegates to destroyBean + * Destroy the given bean. Delegates to {@code destroyBean} * if a corresponding disposable bean instance is found. * @param beanName the name of the bean * @see #destroyBean diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index d493bc80d0..e5186e4334 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -94,7 +94,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { /** * Create a new DisposableBeanAdapter for the given bean. - * @param bean the bean instance (never null) + * @param bean the bean instance (never {@code null}) * @param beanName the name of the bean * @param beanDefinition the merged bean definition * @param postProcessors the List of BeanPostProcessors @@ -203,10 +203,12 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { } + @Override public void run() { destroy(); } + @Override public void destroy() { if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) { for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) { @@ -221,6 +223,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { try { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { ((DisposableBean) bean).destroy(); return null; @@ -258,6 +261,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { try { if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Method run() { return findDestroyMethod(); } @@ -298,6 +302,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { try { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { ReflectionUtils.makeAccessible(destroyMethod); return null; @@ -305,6 +310,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { }); try { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { destroyMethod.invoke(bean, args); return null; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java index 9517497ac9..286765a80d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java @@ -50,12 +50,13 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg * Determine the type for the given FactoryBean. * @param factoryBean the FactoryBean instance to check * @return the FactoryBean's object type, - * or null if the type cannot be determined yet + * or {@code null} if the type cannot be determined yet */ protected Class getTypeForFactoryBean(final FactoryBean factoryBean) { try { if (System.getSecurityManager() != null) { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Class run() { return factoryBean.getObjectType(); } @@ -78,7 +79,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg * in cached form. Quick check for minimal synchronization. * @param beanName the name of the bean * @return the object obtained from the FactoryBean, - * or null if not available + * or {@code null} if not available */ protected Object getCachedObjectForFactoryBean(String beanName) { Object object = this.factoryBeanObjectCache.get(beanName); @@ -129,6 +130,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg AccessControlContext acc = getAccessControlContext(); try { object = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { return factory.getObject(); } @@ -149,7 +151,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex); } - + // Do not accept a null value for a FactoryBean that's not fully // initialized yet: Many FactoryBeans just return null then. if (object == null && isSingletonCurrentlyInCreation(beanName)) { @@ -206,7 +208,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg super.removeSingleton(beanName); this.factoryBeanObjectCache.remove(beanName); } - + /** * Returns the security context for this bean factory. If a security manager * is set, interaction with the user code will be executed using the privileged diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java index 84dc678991..5953236d6c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import org.springframework.beans.factory.config.BeanDefinition; * constructor argument values and property values. Additionally, deriving from a * parent bean definition can be flexibly configured through the "parentName" property. * - *

      In general, use this GenericBeanDefinition class for the purpose of + *

      In general, use this {@code GenericBeanDefinition} class for the purpose of * registering user-visible bean definitions (which a post-processor might operate on, - * potentially even reconfiguring the parent name). Use RootBeanDefinition / - * ChildBeanDefinition where parent/child relationships happen to be pre-determined. + * potentially even reconfiguring the parent name). Use {@code RootBeanDefinition} / + * {@code ChildBeanDefinition} where parent/child relationships happen to be pre-determined. * * @author Juergen Hoeller * @since 2.5 @@ -35,6 +35,7 @@ import org.springframework.beans.factory.config.BeanDefinition; * @see RootBeanDefinition * @see ChildBeanDefinition */ +@SuppressWarnings("serial") public class GenericBeanDefinition extends AbstractBeanDefinition { private String parentName; @@ -65,10 +66,12 @@ public class GenericBeanDefinition extends AbstractBeanDefinition { } + @Override public void setParentName(String parentName) { this.parentName = parentName; } + @Override public String getParentName() { return this.parentName; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java index eed3665757..884ee9c3d9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/InstantiationStrategy.java @@ -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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public interface InstantiationStrategy { * Return an instance of the bean with the given name in this factory. * @param beanDefinition the bean definition * @param beanName name of the bean when it's created in this context. - * The name can be null if we're autowiring a bean that + * The name can be {@code null} if we're autowiring a bean that * doesn't belong to the factory. * @param owner owning BeanFactory * @return a bean instance for this bean definition @@ -51,7 +51,7 @@ public interface InstantiationStrategy { * creating it via the given constructor. * @param beanDefinition the bean definition * @param beanName name of the bean when it's created in this context. - * The name can be null if we're autowiring a bean + * The name can be {@code null} if we're autowiring a bean * that doesn't belong to the factory. * @param owner owning BeanFactory * @param ctor the constructor to use @@ -67,11 +67,11 @@ public interface InstantiationStrategy { * creating it via the given factory method. * @param beanDefinition bean definition * @param beanName name of the bean when it's created in this context. - * The name can be null if we're autowiring a bean + * The name can be {@code null} if we're autowiring a bean * that doesn't belong to the factory. * @param owner owning BeanFactory * @param factoryBean the factory bean instance to call the factory method on, - * or null in case of a static factory method + * or {@code null} in case of a static factory method * @param factoryMethod the factory method to use * @param args the factory method arguments to apply * @return a bean instance for this bean definition diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java index 2a34093cf6..560943d309 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/LookupOverride.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.util.ObjectUtils; * @since 1.1 */ public class LookupOverride extends MethodOverride { - + private final String beanName; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedArray.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedArray.java index 2be0e4152d..e7e7ec7dca 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedArray.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedArray.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.util.Assert; * @author Juergen Hoeller * @since 3.0 */ +@SuppressWarnings("serial") public class ManagedArray extends ManagedList { /** Resolved element type for runtime creation of the target array */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java index 682e2a9548..d01b649bca 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.beans.Mergeable; * @author Juergen Hoeller * @since 27.05.2003 */ +@SuppressWarnings("serial") public class ManagedList extends ArrayList implements Mergeable, BeanMetadataElement { private Object source; @@ -49,13 +50,14 @@ public class ManagedList extends ArrayList implements Mergeable, BeanMetad /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } @@ -82,10 +84,12 @@ public class ManagedList extends ArrayList implements Mergeable, BeanMetad this.mergeEnabled = mergeEnabled; } + @Override public boolean isMergeEnabled() { return this.mergeEnabled; } + @Override @SuppressWarnings("unchecked") public List merge(Object parent) { if (!this.mergeEnabled) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java index ccf1e1641d..4646766596 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.beans.Mergeable; * @author Rob Harrop * @since 27.05.2003 */ +@SuppressWarnings("serial") public class ManagedMap extends LinkedHashMap implements Mergeable, BeanMetadataElement { private Object source; @@ -50,13 +51,14 @@ public class ManagedMap extends LinkedHashMap implements Mergeable, /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } @@ -97,10 +99,12 @@ public class ManagedMap extends LinkedHashMap implements Mergeable, this.mergeEnabled = mergeEnabled; } + @Override public boolean isMergeEnabled() { return this.mergeEnabled; } + @Override @SuppressWarnings("unchecked") public Object merge(Object parent) { if (!this.mergeEnabled) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedProperties.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedProperties.java index 91a433bc6c..dadaac3e0c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedProperties.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedProperties.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.beans.Mergeable; * @author Juergen Hoeller * @since 2.0 */ +@SuppressWarnings("serial") public class ManagedProperties extends Properties implements Mergeable, BeanMetadataElement { private Object source; @@ -37,13 +38,14 @@ public class ManagedProperties extends Properties implements Mergeable, BeanMeta /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } @@ -56,11 +58,13 @@ public class ManagedProperties extends Properties implements Mergeable, BeanMeta this.mergeEnabled = mergeEnabled; } + @Override public boolean isMergeEnabled() { return this.mergeEnabled; } + @Override public Object merge(Object parent) { if (!this.mergeEnabled) { throw new IllegalStateException("Not allowed to merge when the 'mergeEnabled' property is set to 'false'"); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java index 70f53f05a8..570963c17a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.beans.Mergeable; * @author Rob Harrop * @since 21.01.2004 */ +@SuppressWarnings("serial") public class ManagedSet extends LinkedHashSet implements Mergeable, BeanMetadataElement { private Object source; @@ -48,13 +49,14 @@ public class ManagedSet extends LinkedHashSet implements Mergeable, BeanMe /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } @@ -81,10 +83,12 @@ public class ManagedSet extends LinkedHashSet implements Mergeable, BeanMe this.mergeEnabled = mergeEnabled; } + @Override public boolean isMergeEnabled() { return this.mergeEnabled; } + @Override @SuppressWarnings("unchecked") public Set merge(Object parent) { if (!this.mergeEnabled) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java index a2b85bb2fe..96f41279f2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverride.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.ObjectUtils; * @since 1.1 */ public abstract class MethodOverride implements BeanMetadataElement { - + private final String methodName; private boolean overloaded = true; @@ -76,13 +76,14 @@ public abstract class MethodOverride implements BeanMetadataElement { } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java index c8ba6e4b07..fc64caf648 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodOverrides.java @@ -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"); * you may not use this file except in compliance with the License. @@ -82,11 +82,11 @@ public class MethodOverrides { public boolean isEmpty() { return this.overrides.isEmpty(); } - + /** * Return the override for the given method, if any. * @param method method to check for overrides for - * @return the method override, or null if none + * @return the method override, or {@code null} if none */ public MethodOverride getOverride(Method method) { for (MethodOverride override : this.overrides) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodReplacer.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodReplacer.java index 7e04f826d6..d3c630491b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodReplacer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/MethodReplacer.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import java.lang.reflect.Method; * @since 1.1 */ public interface MethodReplacer { - + /** * Reimplement the given method. * @param obj the instance we're reimplementing the method for diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 71b673c8d8..51e4209de4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ import org.springframework.util.StringUtils; * ceo.$0(ref)=secretary // inject 'secretary' bean as 0th constructor arg * ceo.$1=1000000 // inject value '1000000' at 1st constructor arg * - * + * * @author Rod Johnson * @author Juergen Hoeller * @author Rob Harrop @@ -88,42 +88,42 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader public static final String SEPARATOR = "."; /** - * Special key to distinguish owner.(class)=com.myapp.MyClass- + * Special key to distinguish {@code owner.(class)=com.myapp.MyClass}- */ public static final String CLASS_KEY = "(class)"; /** - * Special key to distinguish owner.(parent)=parentBeanName. + * Special key to distinguish {@code owner.(parent)=parentBeanName}. */ public static final String PARENT_KEY = "(parent)"; /** - * Special key to distinguish owner.(scope)=prototype. + * Special key to distinguish {@code owner.(scope)=prototype}. * Default is "true". */ public static final String SCOPE_KEY = "(scope)"; /** - * Special key to distinguish owner.(singleton)=false. + * Special key to distinguish {@code owner.(singleton)=false}. * Default is "true". */ public static final String SINGLETON_KEY = "(singleton)"; /** - * Special key to distinguish owner.(abstract)=true + * Special key to distinguish {@code owner.(abstract)=true} * Default is "false". */ public static final String ABSTRACT_KEY = "(abstract)"; /** - * Special key to distinguish owner.(lazy-init)=true + * Special key to distinguish {@code owner.(lazy-init)=true} * Default is "false". */ public static final String LAZY_INIT_KEY = "(lazy-init)"; /** * Property suffix for references to other beans in the current - * BeanFactory: e.g. owner.dog(ref)=fido. + * BeanFactory: e.g. {@code owner.dog(ref)=fido}. * Whether this is a reference to a singleton or a prototype * will depend on the definition of the target bean. */ @@ -204,6 +204,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * @throws BeanDefinitionStoreException in case of loading or parsing errors * @see #loadBeanDefinitions(org.springframework.core.io.Resource, String) */ + @Override public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException { return loadBeanDefinitions(new EncodedResource(resource), null); } @@ -212,7 +213,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * Load bean definitions from the specified properties file. * @param resource the resource descriptor for the properties file * @param prefix a filter within the keys in the map: e.g. 'beans.' - * (can be empty or null) + * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ @@ -236,7 +237,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * @param encodedResource the resource descriptor for the properties file, * allowing to specify an encoding to use for parsing the file * @param prefix a filter within the keys in the map: e.g. 'beans.' - * (can be empty or null) + * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ @@ -282,7 +283,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * standard Java internationalization support. * @param rb the ResourceBundle to load from * @param prefix a filter within the keys in the map: e.g. 'beans.' - * (can be empty or null) + * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ @@ -319,7 +320,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * will be strings if coming from a Properties file etc. Property names * (keys) must be Strings. Class keys must be Strings. * @param prefix a filter within the keys in the map: e.g. 'beans.' - * (can be empty or null) + * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeansException in case of loading or parsing errors */ @@ -334,7 +335,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader * will be strings if coming from a Properties file etc. Property names * (keys) must be strings. Class keys must be Strings. * @param prefix a filter within the keys in the map: e.g. 'beans.' - * (can be empty or null) + * (can be empty or {@code null}) * @param resourceDescription description of the resource that the * Map came from (for logging purposes) * @return the number of bean definitions found diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java index 3faa967b2b..e570a24c57 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java @@ -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"); * you may not use this file except in compliance with the License. @@ -76,12 +76,12 @@ public class ReplaceOverride extends MethodOverride { // It can't match. return false; } - + if (!isOverloaded()) { // No overloaded: don't worry about arg type matching. return true; } - + // If we get to here, we need to insist on precise argument matching. if (this.typeIdentifiers.size() != method.getParameterTypes().length) { return false; @@ -93,7 +93,7 @@ public class ReplaceOverride extends MethodOverride { return false; } } - return true; + return true; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java index aaa6597275..d400b01cac 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java @@ -45,6 +45,7 @@ import org.springframework.util.Assert; * @see GenericBeanDefinition * @see ChildBeanDefinition */ +@SuppressWarnings("serial") public class RootBeanDefinition extends AbstractBeanDefinition { // using a ConcurrentHashMap as a Set @@ -240,10 +241,12 @@ public class RootBeanDefinition extends AbstractBeanDefinition { } + @Override public String getParentName() { return null; } + @Override public void setParentName(String parentName) { if (parentName != null) { throw new IllegalArgumentException("Root bean cannot be changed into a child bean with parent reference"); @@ -268,7 +271,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { /** * Return the resolved factory method as a Java Method object, if available. - * @return the factory method, or null if not found or not resolved yet + * @return the factory method, or {@code null} if not found or not resolved yet */ public Method getResolvedFactoryMethod() { synchronized (this.constructorArgumentLock) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SecurityContextProvider.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SecurityContextProvider.java index 0403b8900f..ac001c639e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SecurityContextProvider.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SecurityContextProvider.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleAutowireCandidateResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleAutowireCandidateResolver.java index 735def6654..3570305d9d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleAutowireCandidateResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleAutowireCandidateResolver.java @@ -1,6 +1,6 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -37,10 +37,12 @@ public class SimpleAutowireCandidateResolver implements AutowireCandidateResolve *

      To be considered a candidate the bean's autowire-candidate * attribute must not have been set to 'false'. */ + @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { return bdHolder.getBeanDefinition().isAutowireCandidate(); } + @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java index 8a42fc233e..b792c6cda8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java @@ -40,6 +40,7 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements private final Map beanDefinitionMap = new ConcurrentHashMap(64); + @Override public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException { @@ -48,12 +49,14 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements this.beanDefinitionMap.put(beanName, beanDefinition); } + @Override public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { if (this.beanDefinitionMap.remove(beanName) == null) { throw new NoSuchBeanDefinitionException(beanName); } } + @Override public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { BeanDefinition bd = this.beanDefinitionMap.get(beanName); if (bd == null) { @@ -62,18 +65,22 @@ public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements return bd; } + @Override public boolean containsBeanDefinition(String beanName) { return this.beanDefinitionMap.containsKey(beanName); } + @Override public String[] getBeanDefinitionNames() { return StringUtils.toStringArray(this.beanDefinitionMap.keySet()); } + @Override public int getBeanDefinitionCount() { return this.beanDefinitionMap.size(); } + @Override public boolean isBeanNameInUse(String beanName) { return isAlias(beanName) || containsBeanDefinition(beanName); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java index b06904221f..4dd5a1a1ca 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java @@ -55,6 +55,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { } + @Override public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { // Don't override the class with CGLIB if no overrides. if (beanDefinition.getMethodOverrides().isEmpty()) { @@ -69,6 +70,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { try { if (System.getSecurityManager() != null) { constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Constructor run() throws Exception { return clazz.getDeclaredConstructor((Class[]) null); } @@ -105,6 +107,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { "Method Injection not supported in SimpleInstantiationStrategy"); } + @Override public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, final Constructor ctor, Object[] args) { @@ -112,6 +115,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { if (System.getSecurityManager() != null) { // use own privileged to change accessibility (when security is on) AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { ReflectionUtils.makeAccessible(ctor); return null; @@ -138,12 +142,14 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { "Method Injection not supported in SimpleInstantiationStrategy"); } + @Override public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Object factoryBean, final Method factoryMethod, Object[] args) { try { if (System.getSecurityManager() != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { ReflectionUtils.makeAccessible(factoryMethod); return null; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleSecurityContextProvider.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleSecurityContextProvider.java index 78b62938da..15aed4c50d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleSecurityContextProvider.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleSecurityContextProvider.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ import java.security.AccessController; /** * Simple {@link SecurityContextProvider} implementation. - * + * * @author Costin Leau * @since 3.0 */ @@ -31,7 +31,7 @@ public class SimpleSecurityContextProvider implements SecurityContextProvider { /** - * Construct a new SimpleSecurityContextProvider instance. + * Construct a new {@code SimpleSecurityContextProvider} instance. *

      The security context will be retrieved on each call from the current * thread. */ @@ -40,10 +40,10 @@ public class SimpleSecurityContextProvider implements SecurityContextProvider { } /** - * Construct a new SimpleSecurityContextProvider instance. + * Construct a new {@code SimpleSecurityContextProvider} instance. *

      If the given control context is null, the security context will be * retrieved on each call from the current thread. - * @param acc access control context (can be null) + * @param acc access control context (can be {@code null}) * @see AccessController#getContext() */ public SimpleSecurityContextProvider(AccessControlContext acc) { @@ -51,6 +51,7 @@ public class SimpleSecurityContextProvider implements SecurityContextProvider { } + @Override public AccessControlContext getAccessControlContext() { return (this.acc != null ? acc : AccessController.getContext()); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java index 3e8784b181..dc84919149 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -75,6 +75,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { // Implementation of BeanFactory interface //--------------------------------------------------------------------- + @Override public Object getBean(String name) throws BeansException { String beanName = BeanFactoryUtils.transformedBeanName(name); Object bean = this.beans.get(beanName); @@ -103,6 +104,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { } } + @Override @SuppressWarnings("unchecked") public T getBean(String name, Class requiredType) throws BeansException { Object bean = getBean(name); @@ -112,6 +114,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return (T) bean; } + @Override public T getBean(Class requiredType) throws BeansException { String[] beanNames = getBeanNamesForType(requiredType); if (beanNames.length == 1) { @@ -122,6 +125,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { } } + @Override public Object getBean(String name, Object... args) throws BeansException { if (args != null) { throw new UnsupportedOperationException( @@ -130,16 +134,19 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return getBean(name); } + @Override public boolean containsBean(String name) { return this.beans.containsKey(name); } + @Override public boolean isSingleton(String name) throws NoSuchBeanDefinitionException { Object bean = getBean(name); // In case of FactoryBean, return singleton status of created object. return (bean instanceof FactoryBean && ((FactoryBean) bean).isSingleton()); } + @Override public boolean isPrototype(String name) throws NoSuchBeanDefinitionException { Object bean = getBean(name); // In case of FactoryBean, return prototype status of created object. @@ -147,11 +154,13 @@ public class StaticListableBeanFactory implements ListableBeanFactory { (bean instanceof FactoryBean && !((FactoryBean) bean).isSingleton())); } + @Override public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { Class type = getType(name); return (targetType == null || (type != null && targetType.isAssignableFrom(type))); } + @Override public Class getType(String name) throws NoSuchBeanDefinitionException { String beanName = BeanFactoryUtils.transformedBeanName(name); @@ -168,6 +177,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return bean.getClass(); } + @Override public String[] getAliases(String name) { return new String[0]; } @@ -177,22 +187,27 @@ public class StaticListableBeanFactory implements ListableBeanFactory { // Implementation of ListableBeanFactory interface //--------------------------------------------------------------------- + @Override public boolean containsBeanDefinition(String name) { return this.beans.containsKey(name); } + @Override public int getBeanDefinitionCount() { return this.beans.size(); } + @Override public String[] getBeanDefinitionNames() { return StringUtils.toStringArray(this.beans.keySet()); } + @Override public String[] getBeanNamesForType(Class type) { return getBeanNamesForType(type, true, true); } + @Override public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean includeFactoryBeans) { boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type)); List matches = new ArrayList(); @@ -215,10 +230,12 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return StringUtils.toStringArray(matches); } + @Override public Map getBeansOfType(Class type) throws BeansException { return getBeansOfType(type, true, true); } + @Override @SuppressWarnings("unchecked") public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean includeFactoryBeans) throws BeansException { @@ -255,6 +272,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return matches; } + @Override public Map getBeansWithAnnotation(Class annotationType) throws BeansException { @@ -267,6 +285,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { return results; } + @Override public A findAnnotationOnBean(String beanName, Class annotationType) { return AnnotationUtils.findAnnotation(getType(beanName), annotationType); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/package-info.java index 71a483e483..89971b330a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/package-info.java @@ -1,9 +1,8 @@ - /** * - * Classes supporting the org.springframework.beans.factory package. - * Contains abstract base classes for BeanFactory implementations. - * + * Classes supporting the {@code org.springframework.beans.factory} package. + * Contains abstract base classes for {@code BeanFactory} implementations. + * * */ package org.springframework.beans.factory.support; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanConfigurerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanConfigurerSupport.java index 6bc42d0137..3be2b8b2fb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanConfigurerSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanConfigurerSupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.util.ClassUtils; *

      Subclasses may also need a custom metadata resolution strategy, in the * {@link BeanWiringInfoResolver} interface. The default implementation looks * for a bean with the same name as the fully-qualified class name. (This is - * the default name of the bean in a Spring XML file if the 'id' + * the default name of the bean in a Spring XML file if the '{@code id}' * attribute is not used.) * @author Rob Harrop @@ -72,6 +72,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean /** * Set the {@link BeanFactory} in which this aspect must configure beans. */ + @Override public void setBeanFactory(BeanFactory beanFactory) { if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalArgumentException( @@ -87,7 +88,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean * Create the default BeanWiringInfoResolver to be used if none was * specified explicitly. *

      The default implementation builds a {@link ClassNameBeanWiringInfoResolver}. - * @return the default BeanWiringInfoResolver (never null) + * @return the default BeanWiringInfoResolver (never {@code null}) */ protected BeanWiringInfoResolver createDefaultBeanWiringInfoResolver() { return new ClassNameBeanWiringInfoResolver(); @@ -96,6 +97,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean /** * Check that a {@link BeanFactory} has been set. */ + @Override public void afterPropertiesSet() { Assert.notNull(this.beanFactory, "BeanFactory must be set"); } @@ -104,6 +106,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean * Release references to the {@link BeanFactory} and * {@link BeanWiringInfoResolver} when the container is destroyed. */ + @Override public void destroy() { this.beanFactory = null; this.beanWiringInfoResolver = null; @@ -115,7 +118,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean *

      Subclasses can override this to provide custom configuration logic. * Typically called by an aspect, for all bean instances matched by a * pointcut. - * @param beanInstance the bean instance to configure (must not be null) + * @param beanInstance the bean instance to configure (must not be {@code null}) */ public void configureBean(Object beanInstance) { if (this.beanFactory == null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfo.java b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfo.java index 5ed7b79f11..67f32d5d2c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfo.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.util.Assert; /** * Holder for bean wiring metadata information about a particular class. Used in * conjunction with the {@link org.springframework.beans.factory.annotation.Configurable} - * annotation and the AspectJ AnnotationBeanConfigurerAspect. + * annotation and the AspectJ {@code AnnotationBeanConfigurerAspect}. * * @author Rod Johnson * @author Juergen Hoeller @@ -67,7 +67,7 @@ public class BeanWiringInfo { /** * Create a new BeanWiringInfo that points to the given bean name. * @param beanName the name of the bean definition to take the property values from - * @throws IllegalArgumentException if the supplied beanName is null, + * @throws IllegalArgumentException if the supplied beanName is {@code null}, * is empty, or consists wholly of whitespace */ public BeanWiringInfo(String beanName) { @@ -79,7 +79,7 @@ public class BeanWiringInfo { * @param beanName the name of the bean definition to take the property values from * @param isDefaultBeanName whether the given bean name is a suggested * default bean name, not necessarily matching an actual bean definition - * @throws IllegalArgumentException if the supplied beanName is null, + * @throws IllegalArgumentException if the supplied beanName is {@code null}, * is empty, or consists wholly of whitespace */ public BeanWiringInfo(String beanName, boolean isDefaultBeanName) { @@ -94,7 +94,7 @@ public class BeanWiringInfo { * {@link #AUTOWIRE_BY_TYPE} * @param dependencyCheck whether to perform a dependency check for object * references in the bean instance (after autowiring) - * @throws IllegalArgumentException if the supplied autowireMode + * @throws IllegalArgumentException if the supplied {@code autowireMode} * is not one of the allowed values * @see #AUTOWIRE_BY_NAME * @see #AUTOWIRE_BY_TYPE diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfoResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfoResolver.java index a8b0873da4..c306cb70bb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfoResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/BeanWiringInfoResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public interface BeanWiringInfoResolver { /** * Resolve the BeanWiringInfo for the given bean instance. * @param beanInstance the bean instance to resolve info for - * @return the BeanWiringInfo, or null if not found + * @return the BeanWiringInfo, or {@code null} if not found */ BeanWiringInfo resolveWiringInfo(Object beanInstance); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolver.java index 4ba5a99d43..b458dfe84a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.util.ClassUtils; */ public class ClassNameBeanWiringInfoResolver implements BeanWiringInfoResolver { + @Override public BeanWiringInfo resolveWiringInfo(Object beanInstance) { Assert.notNull(beanInstance, "Bean instance must not be null"); return new BeanWiringInfo(ClassUtils.getUserClass(beanInstance).getName(), true); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractBeanDefinitionParser.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractBeanDefinitionParser.java index d624b2331e..38dba2c10e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractBeanDefinitionParser.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.util.StringUtils; *

      Use this {@link BeanDefinitionParser} implementation when you want * to parse some arbitrarily complex XML into one or more * {@link BeanDefinition BeanDefinitions}. If you just want to parse some - * XML into a single BeanDefinition, you may wish to consider + * XML into a single {@code BeanDefinition}, you may wish to consider * the simpler convenience extensions of this class, namely * {@link AbstractSingleBeanDefinitionParser} and * {@link AbstractSimpleBeanDefinitionParser}. @@ -55,6 +55,7 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars /** Constant for the name attribute */ public static final String NAME_ATTRIBUTE = "name"; + @Override public final BeanDefinition parse(Element element, ParserContext parserContext) { AbstractBeanDefinition definition = parseInternal(element, parserContext); if (definition != null && !parserContext.isNested()) { @@ -121,11 +122,11 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars * {@link BeanDefinitionHolder bean} is actually even registered, or to * register even more beans. *

      The default implementation registers the supplied {@link BeanDefinitionHolder bean} - * with the supplied {@link BeanDefinitionRegistry registry} only if the isNested - * parameter is false, because one typically does not want inner beans + * with the supplied {@link BeanDefinitionRegistry registry} only if the {@code isNested} + * parameter is {@code false}, because one typically does not want inner beans * to be registered as top level beans. * @param definition the bean definition to be registered - * @param registry the registry that the bean is to be registered with + * @param registry the registry that the bean is to be registered with * @see BeanDefinitionReaderUtils#registerBeanDefinition(BeanDefinitionHolder, BeanDefinitionRegistry) */ protected void registerBeanDefinition(BeanDefinitionHolder definition, BeanDefinitionRegistry registry) { @@ -172,11 +173,11 @@ public abstract class AbstractBeanDefinitionParser implements BeanDefinitionPars * Controls whether this parser is supposed to fire a * {@link org.springframework.beans.factory.parsing.BeanComponentDefinition} * event after parsing the bean definition. - *

      This implementation returns true by default; that is, + *

      This implementation returns {@code true} by default; that is, * an event will be fired when a bean definition has been completely parsed. - * Override this to return false in order to suppress the event. - * @return true in order to fire a component registration event - * after parsing the bean definition; false to suppress the event + * Override this to return {@code false} in order to suppress the event. + * @return {@code true} in order to fire a component registration event + * after parsing the bean definition; {@code false} to suppress the event * @see #postProcessComponentDefinition * @see org.springframework.beans.factory.parsing.ReaderContext#fireComponentRegistered */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java index 20c96bba68..0bfcb375da 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import org.springframework.util.StringUtils; * *

      Extend this parser class when you want to create a single * bean definition from a relatively simple custom XML element. The - * resulting BeanDefinition will be automatically + * resulting {@code BeanDefinition} will be automatically * registered with the relevant * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. * @@ -40,11 +40,11 @@ import org.springframework.util.StringUtils; * class immediately clear. Consider the following class definition: * *

      public class SimpleCache implements Cache {
      - * 
      + *
        *     public void setName(String name) {...}
        *     public void setTimeout(int timeout) {...}
        *     public void setEvictionPolicy(EvictionPolicy policy) {...}
      - * 
      + *
        *     // remaining class definition elided for clarity...
        * }
      * @@ -55,16 +55,16 @@ import org.springframework.util.StringUtils; * *

      All that is required of the Java developer tasked with writing * the parser to parse the above XML tag into an actual - * SimpleCache bean definition is the following: + * {@code SimpleCache} bean definition is the following: * *

      public class SimpleCacheBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
        *
        *     protected Class getBeanClass(Element element) {
        *         return SimpleCache.class;
        *     }
      - * }
      + * } * - *

      Please note that the AbstractSimpleBeanDefinitionParser + *

      Please note that the {@code AbstractSimpleBeanDefinitionParser} * is limited to populating the created bean definition with property values. * if you want to parse constructor arguments and nested elements from the * supplied XML element, then you will have to implement the @@ -74,7 +74,7 @@ import org.springframework.util.StringUtils; * classes directly. * *

      The process of actually registering the - * SimpleCacheBeanDefinitionParser with the Spring XML parsing + * {@code SimpleCacheBeanDefinitionParser} with the Spring XML parsing * infrastructure is described in the Spring Framework reference documentation * (in one of the appendices). * @@ -83,21 +83,21 @@ import org.springframework.util.StringUtils; * {@link org.springframework.beans.factory.xml.UtilNamespaceHandler.PropertiesBeanDefinitionParser}; * the observant (and even not so observant) reader will immediately notice that * there is next to no code in the implementation. The - * PropertiesBeanDefinitionParser populates a + * {@code PropertiesBeanDefinitionParser} populates a * {@link org.springframework.beans.factory.config.PropertiesFactoryBean} * from an XML element that looks like this: * *

      <util:properties location="jdbc.properties"/>
      * *

      The observant reader will notice that the sole attribute on the - * <util:properties/> element matches the + * {@code <util:properties/>} element matches the * {@link org.springframework.beans.factory.config.PropertiesFactoryBean#setLocation(org.springframework.core.io.Resource)} - * method name on the PropertiesFactoryBean (the general + * method name on the {@code PropertiesFactoryBean} (the general * usage thus illustrated holds true for any number of attributes). - * All that the PropertiesBeanDefinitionParser needs + * All that the {@code PropertiesBeanDefinitionParser} needs * actually do is supply an implementation of the * {@link #getBeanClass(org.w3c.dom.Element)} method to return the - * PropertiesFactoryBean type. + * {@code PropertiesFactoryBean} type. * * @author Rob Harrop * @author Rick Evans @@ -120,8 +120,8 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed - * @param builder used to define the BeanDefinition - * @see #extractPropertyName(String) + * @param builder used to define the {@code BeanDefinition} + * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { @@ -144,7 +144,7 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB *

      The default implementation considers any attribute as eligible, * except for the "id" attribute and namespace declaration attributes. * @param attribute the XML attribute to check - * @param parserContext the ParserContext + * @param parserContext the {@code ParserContext} * @see #isEligibleAttribute(String) */ protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) { @@ -177,7 +177,7 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB *

      The default implementation considers any attribute as eligible, * except for the "id" attribute. * @param attributeName the attribute name taken straight from the - * XML element being parsed (never null) + * XML element being parsed (never {@code null}) */ protected boolean isEligibleAttribute(String attributeName) { return !ID_ATTRIBUTE.equals(attributeName); @@ -190,11 +190,11 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB * method to perform the extraction. *

      The name returned must obey the standard JavaBean property name * conventions. For example for a class with a setter method - * 'setBingoHallFavourite(String)', the name returned had - * better be 'bingoHallFavourite' (with that exact casing). + * '{@code setBingoHallFavourite(String)}', the name returned had + * better be '{@code bingoHallFavourite}' (with that exact casing). * @param attributeName the attribute name taken straight from the - * XML element being parsed (never null) - * @return the extracted JavaBean property name (must never be null) + * XML element being parsed (never {@code null}) + * @return the extracted JavaBean property name (must never be {@code null}) */ protected String extractPropertyName(String attributeName) { return Conventions.attributeNameToPropertyName(attributeName); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser.java index 1c32c4f22d..ec5d368740 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSingleBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,17 +23,17 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; /** * Base class for those {@link BeanDefinitionParser} implementations that - * need to parse and define just a single BeanDefinition. + * need to parse and define just a single {@code BeanDefinition}. * *

      Extend this parser class when you want to create a single bean definition * from an arbitrarily complex XML element. You may wish to consider extending * the {@link AbstractSimpleBeanDefinitionParser} when you want to create a * single bean definition from a relatively simple custom XML element. * - *

      The resulting BeanDefinition will be automatically registered + *

      The resulting {@code BeanDefinition} will be automatically registered * with the {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}. * Your job simply is to {@link #doParse parse} the custom XML {@link Element} - * into a single BeanDefinition. + * into a single {@code BeanDefinition}. * * @author Rob Harrop * @author Juergen Hoeller @@ -53,7 +53,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef * @param parserContext the object encapsulating the current state of the parsing process * @return the BeanDefinition resulting from the parsing of the supplied {@link Element} * @throws IllegalStateException if the bean {@link Class} returned from - * {@link #getBeanClass(org.w3c.dom.Element)} is null + * {@link #getBeanClass(org.w3c.dom.Element)} is {@code null} * @see #doParse */ @Override @@ -89,11 +89,11 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef /** * Determine the name for the parent of the currently parsed bean, * in case of the current bean being defined as a child bean. - *

      The default implementation returns null, + *

      The default implementation returns {@code null}, * indicating a root bean definition. - * @param element the Element that is being parsed + * @param element the {@code Element} that is being parsed * @return the name of the parent bean for the currently parsed bean, - * or null if none + * or {@code null} if none */ protected String getParentName(Element element) { return null; @@ -106,9 +106,9 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef * dependence on the bean implementation class. The BeanDefinitionParser * and its NamespaceHandler can be used within an IDE plugin then, even * if the application classes are not available on the plugin's classpath. - * @param element the Element that is being parsed + * @param element the {@code Element} that is being parsed * @return the {@link Class} of the bean that is being defined via parsing - * the supplied Element, or null if none + * the supplied {@code Element}, or {@code null} if none * @see #getBeanClassName */ protected Class getBeanClass(Element element) { @@ -117,9 +117,9 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef /** * Determine the bean class name corresponding to the supplied {@link Element}. - * @param element the Element that is being parsed + * @param element the {@code Element} that is being parsed * @return the class name of the bean that is being defined via parsing - * the supplied Element, or null if none + * the supplied {@code Element}, or {@code null} if none * @see #getBeanClass */ protected String getBeanClassName(Element element) { @@ -129,11 +129,11 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef /** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. - *

      The default implementation delegates to the doParse + *

      The default implementation delegates to the {@code doParse} * version without ParserContext argument. * @param element the XML element being parsed * @param parserContext the object encapsulating the current state of the parsing process - * @param builder used to define the BeanDefinition + * @param builder used to define the {@code BeanDefinition} * @see #doParse(Element, BeanDefinitionBuilder) */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { @@ -145,7 +145,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef * {@link BeanDefinitionBuilder} as required. *

      The default implementation does nothing. * @param element the XML element being parsed - * @param builder used to define the BeanDefinition + * @param builder used to define the {@code BeanDefinition} */ protected void doParse(Element element, BeanDefinitionBuilder builder) { } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDecorator.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDecorator.java index b1a1d2c9e6..c5e4d9128a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDecorator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDecorator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,16 +21,16 @@ import org.w3c.dom.Node; import org.springframework.beans.factory.config.BeanDefinitionHolder; /** - * Interface used by the {@link org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader} - * to handle custom, nested (directly under a <bean>) tags. + * Interface used by the {@link DefaultBeanDefinitionDocumentReader} + * to handle custom, nested (directly under a {@code <bean>}) tags. * *

      Decoration may also occur based on custom attributes applied to the - * <bean> tag. Implementations are free to turn the metadata in the + * {@code <bean>} tag. Implementations are free to turn the metadata in the * custom tag into as many * {@link org.springframework.beans.factory.config.BeanDefinition BeanDefinitions} as * required and to transform the * {@link org.springframework.beans.factory.config.BeanDefinition} of the enclosing - * <bean> tag, potentially even returning a completely different + * {@code <bean>} tag, potentially even returning a completely different * {@link org.springframework.beans.factory.config.BeanDefinition} to replace the * original. * diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java index ec161a0684..37ef1b4090 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.w3c.dom.Document; * *

      Instantiated per document to parse: Implementations can hold * state in instance variables during the execution of the - * registerBeanDefinitions method, for example global + * {@code registerBeanDefinitions} method, for example global * settings that are defined for all bean definitions in the document. * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index 1109ed3b8c..359975c1ce 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -90,6 +90,7 @@ public class BeanDefinitionParserDelegate { public static final String MULTI_VALUE_ATTRIBUTE_DELIMITERS = ",; "; /** @deprecated as of Spring 3.1 in favor of {@link #MULTI_VALUE_ATTRIBUTE_DELIMITERS} */ + @Deprecated public static final String BEAN_NAME_DELIMITERS = MULTI_VALUE_ATTRIBUTE_DELIMITERS; /** @@ -343,6 +344,7 @@ public class BeanDefinitionParserDelegate { * @deprecated in Spring 3.1 in favor of * {@link #initDefaults(Element, BeanDefinitionParserDelegate)} */ + @Deprecated public void initDefaults(Element root) { initDefaults(root, null); } @@ -406,7 +408,7 @@ public class BeanDefinitionParserDelegate { } /** - * Return the defaults definition object, or null if the + * Return the defaults definition object, or {@code null} if the * defaults have been initialized yet. */ public DocumentDefaultsDefinition getDefaults() { @@ -415,7 +417,7 @@ public class BeanDefinitionParserDelegate { /** * Return the default settings for bean definitions as indicated within - * the attributes of the top-level <beans/> element. + * the attributes of the top-level {@code <beans/>} element. */ public BeanDefinitionDefaults getBeanDefinitionDefaults() { BeanDefinitionDefaults bdd = new BeanDefinitionDefaults(); @@ -429,7 +431,7 @@ public class BeanDefinitionParserDelegate { /** * Return any patterns provided in the 'default-autowire-candidates' - * attribute of the top-level <beans/> element. + * attribute of the top-level {@code <beans/>} element. */ public String[] getAutowireCandidatePatterns() { String candidatePattern = this.defaults.getAutowireCandidates(); @@ -438,7 +440,7 @@ public class BeanDefinitionParserDelegate { /** - * Parses the supplied <bean> element. May return null + * Parses the supplied {@code <bean>} element. May return {@code null} * if there were errors during parse. Errors are reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ @@ -447,7 +449,7 @@ public class BeanDefinitionParserDelegate { } /** - * Parses the supplied <bean> element. May return null + * Parses the supplied {@code <bean>} element. May return {@code null} * if there were errors during parse. Errors are reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ @@ -534,7 +536,7 @@ public class BeanDefinitionParserDelegate { /** * Parse the bean definition itself, without regard to name or aliases. May return - * null if problems occurred during the parsing of the bean definition. + * {@code null} if problems occurred during the parsing of the bean definition. */ public AbstractBeanDefinition parseBeanDefinitionElement( Element ele, String beanName, BeanDefinition containingBean) { @@ -1035,7 +1037,7 @@ public class BeanDefinitionParserDelegate { * constructor-arg element. * @param ele subelement of property element; we don't know which yet * @param defaultValueType the default type (class name) for any - * <value> tag that might be created + * {@code <value>} tag that might be created */ public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) { if (!isDefaultNamespace(ele)) { @@ -1513,7 +1515,7 @@ public class BeanDefinitionParserDelegate { /** * Ges the local name for the supplied {@link Node}. The default implementation calls {@link Node#getLocalName}. * Subclasses may override the default implementation to provide a different mechanism for getting the local name. - * @param node the Node + * @param node the {@code Node} */ public String getLocalName(Node node) { return node.getLocalName(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java index fcf9af9001..6f3386cb86 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeansDtdResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.core.io.Resource; * @see ResourceEntityResolver */ public class BeansDtdResolver implements EntityResolver { - + private static final String DTD_EXTENSION = ".dtd"; private static final String[] DTD_NAMES = {"spring-beans-2.0", "spring-beans"}; @@ -50,6 +50,7 @@ public class BeansDtdResolver implements EntityResolver { private static final Log logger = LogFactory.getLog(BeansDtdResolver.class); + @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Trying to resolve XML entity with public ID [" + publicId + diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java index 4bcc94a22a..81497416aa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ import org.springframework.util.StringUtils; * *

      The structure, elements and attribute names of the required XML document * are hard-coded in this class. (Of course a transform could be run if necessary - * to produce this format). <beans> doesn't need to be the root + * to produce this format). {@code <beans>} doesn't need to be the root * element of the XML document: This class will parse all bean definition elements * in the XML file, not regarding the actual root element. * @@ -91,6 +91,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume * {@code } element with a {@code profile} attribute present. * @see #doRegisterBeanDefinitions */ + @Override public void setEnvironment(Environment environment) { this.environment = environment; } @@ -102,6 +103,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume *

      Opens a DOM Document; then initializes the default settings * specified at the {@code } level; then parses the contained bean definitions. */ + @Override public void registerBeanDefinitions(Document doc, XmlReaderContext readerContext) { this.readerContext = readerContext; @@ -223,7 +225,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume Set actualResources = new LinkedHashSet(4); - // Discover whether the location is an absolute or relative URI + // Discover whether the location is an absolute or relative URI boolean absoluteLocation = false; try { absoluteLocation = ResourcePatternUtils.isUrl(location) || ResourceUtils.toURI(location).isAbsolute(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultDocumentLoader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultDocumentLoader.java index d057cf7e51..f86765cb62 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultDocumentLoader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultDocumentLoader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -64,6 +64,7 @@ public class DefaultDocumentLoader implements DocumentLoader { * Load the {@link Document} at the supplied {@link InputSource} using the standard JAXP-configured * XML parser. */ + @Override public Document loadDocument(InputSource inputSource, EntityResolver entityResolver, ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java index 56fe15eb80..fd7d64cc8c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java @@ -37,7 +37,7 @@ import org.springframework.util.CollectionUtils; * contained in mapping file. * *

      By default, this implementation looks for the mapping file at - * META-INF/spring.handlers, but this can be changed using the + * {@code META-INF/spring.handlers}, but this can be changed using the * {@link #DefaultNamespaceHandlerResolver(ClassLoader, String)} constructor. * * @author Rob Harrop @@ -68,7 +68,7 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver /** - * Create a new DefaultNamespaceHandlerResolver using the + * Create a new {@code DefaultNamespaceHandlerResolver} using the * default mapping file location. *

      This constructor will result in the thread context ClassLoader being used * to load resources. @@ -79,10 +79,10 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver } /** - * Create a new DefaultNamespaceHandlerResolver using the + * Create a new {@code DefaultNamespaceHandlerResolver} using the * default mapping file location. * @param classLoader the {@link ClassLoader} instance used to load mapping resources - * (may be null, in which case the thread context ClassLoader will be used) + * (may be {@code null}, in which case the thread context ClassLoader will be used) * @see #DEFAULT_HANDLER_MAPPINGS_LOCATION */ public DefaultNamespaceHandlerResolver(ClassLoader classLoader) { @@ -90,10 +90,10 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver } /** - * Create a new DefaultNamespaceHandlerResolver using the + * Create a new {@code DefaultNamespaceHandlerResolver} using the * supplied mapping file location. * @param classLoader the {@link ClassLoader} instance used to load mapping resources - * may be null, in which case the thread context ClassLoader will be used) + * may be {@code null}, in which case the thread context ClassLoader will be used) * @param handlerMappingsLocation the mapping file location */ public DefaultNamespaceHandlerResolver(ClassLoader classLoader, String handlerMappingsLocation) { @@ -107,8 +107,9 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver * Locate the {@link NamespaceHandler} for the supplied namespace URI * from the configured mappings. * @param namespaceUri the relevant namespace URI - * @return the located {@link NamespaceHandler}, or null if none found + * @return the located {@link NamespaceHandler}, or {@code null} if none found */ + @Override public NamespaceHandler resolve(String namespaceUri) { Map handlerMappings = getHandlerMappings(); Object handlerOrClassName = handlerMappings.get(namespaceUri); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java index cd33ef1476..c6f8daff90 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DelegatingEntityResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class DelegatingEntityResolver implements EntityResolver { *

      Configures the {@link PluggableSchemaResolver} with the supplied * {@link ClassLoader}. * @param classLoader the ClassLoader to use for loading - * (can be null) to use the default ClassLoader) + * (can be {@code null}) to use the default ClassLoader) */ public DelegatingEntityResolver(ClassLoader classLoader) { this.dtdResolver = new BeansDtdResolver(); @@ -76,6 +76,7 @@ public class DelegatingEntityResolver implements EntityResolver { } + @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId != null) { if (systemId.endsWith(DTD_SUFFIX)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentDefaultsDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentDefaultsDefinition.java index 163e4ce9e9..ba31c92aaa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentDefaultsDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentDefaultsDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ package org.springframework.beans.factory.xml; import org.springframework.beans.factory.parsing.DefaultsDefinition; /** - * Simple JavaBean that holds the defaults specified at the <beans> + * Simple JavaBean that holds the defaults specified at the {@code <beans>} * level in a standard Spring XML bean definition document: - * default-lazy-init, default-autowire, etc. + * {@code default-lazy-init}, {@code default-autowire}, etc. * * @author Juergen Hoeller * @since 2.0.2 @@ -146,13 +146,14 @@ public class DocumentDefaultsDefinition implements DefaultsDefinition { } /** - * Set the configuration source Object for this metadata element. + * Set the configuration source {@code Object} for this metadata element. *

      The exact type of the object will depend on the configuration mechanism used. */ public void setSource(Object source) { this.source = source; } + @Override public Object getSource() { return this.source; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentLoader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentLoader.java index 676eacd289..a7ebdb9c57 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentLoader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DocumentLoader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public interface DocumentLoader { * @param validationMode the type of validation * {@link org.springframework.util.xml.XmlValidationModeDetector#VALIDATION_DTD DTD} * or {@link org.springframework.util.xml.XmlValidationModeDetector#VALIDATION_XSD XSD}) - * @param namespaceAware true if support for XML namespaces is to be provided + * @param namespaceAware {@code true} if support for XML namespaces is to be provided * @return the loaded {@link Document document} * @throws Exception if an error occurs */ diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandler.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandler.java index a6553b1ce4..8da64b6070 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandler.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandler.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,8 +32,8 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder; * custom nested tags. * *

      The parser will call {@link #parse} when it encounters a custom tag - * directly under the <beans> tags and {@link #decorate} when - * it encounters a custom tag directly under a <bean> tag. + * directly under the {@code <beans>} tags and {@link #decorate} when + * it encounters a custom tag directly under a {@code <bean>} tag. * *

      Developers writing their own custom element extensions typically will * not implement this interface drectly, but rather make use of the provided @@ -50,7 +50,7 @@ public interface NamespaceHandler { /** * Invoked by the {@link DefaultBeanDefinitionDocumentReader} after * construction but before any custom elements are parsed. - * @see NamespaceHandlerSupport#registerBeanDefinitionParser(String, BeanDefinitionParser) + * @see NamespaceHandlerSupport#registerBeanDefinitionParser(String, BeanDefinitionParser) */ void init(); @@ -59,14 +59,14 @@ public interface NamespaceHandler { * {@link BeanDefinition BeanDefinitions} with the * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry} * that is embedded in the supplied {@link ParserContext}. - *

      Implementations should return the primary BeanDefinition + *

      Implementations should return the primary {@code BeanDefinition} * that results from the parse phase if they wish to be used nested - * inside (for example) a <property> tag. - *

      Implementations may return null if they will + * inside (for example) a {@code <property>} tag. + *

      Implementations may return {@code null} if they will * not be used in a nested scenario. - * @param element the element that is to be parsed into one or more BeanDefinitions + * @param element the element that is to be parsed into one or more {@code BeanDefinitions} * @param parserContext the object encapsulating the current state of the parsing process - * @return the primary BeanDefinition (can be null as explained above) + * @return the primary {@code BeanDefinition} (can be {@code null} as explained above) */ BeanDefinition parse(Element element, ParserContext parserContext); @@ -86,7 +86,7 @@ public interface NamespaceHandler { * @param parserContext the object encapsulating the current state of the parsing process * @return the decorated definition (to be registered in the BeanFactory), * or simply the original bean definition if no decoration is required. - * A null value is strictly speaking invalid, but will be leniently + * A {@code null} value is strictly speaking invalid, but will be leniently * treated like the case where the original bean definition gets returned. */ BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder definition, ParserContext parserContext); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerResolver.java index ba9d173b1d..d8ccc41050 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public interface NamespaceHandlerResolver { * Resolve the namespace URI and return the located {@link NamespaceHandler} * implementation. * @param namespaceUri the relevant namespace URI - * @return the located {@link NamespaceHandler} (may be null) + * @return the located {@link NamespaceHandler} (may be {@code null}) */ NamespaceHandler resolve(String namespaceUri); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java index 1ad13daf09..b9f89b2369 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -69,6 +69,7 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler { * Parses the supplied {@link Element} by delegating to the {@link BeanDefinitionParser} that is * registered for that {@link Element}. */ + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { return findParserForElement(element, parserContext).parse(element, parserContext); } @@ -91,6 +92,7 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler { * Decorates the supplied {@link Node} by delegating to the {@link BeanDefinitionDecorator} that * is registered to handle that {@link Node}. */ + @Override public BeanDefinitionHolder decorate( Node node, BeanDefinitionHolder definition, ParserContext parserContext) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java index d4f1f1bbf6..6cfefe7559 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java @@ -38,12 +38,12 @@ import org.springframework.util.CollectionUtils; * local {@link ClassPathResource classpath resources} using a set of mappings files. * *

      By default, this class will look for mapping files in the classpath using the pattern: - * META-INF/spring.schemas allowing for multiple files to exist on the + * {@code META-INF/spring.schemas} allowing for multiple files to exist on the * classpath at any one time. * - * The format of META-INF/spring.schemas is a properties - * file where each line should be of the form systemId=schema-location - * where schema-location should also be a schema file in the classpath. + * The format of {@code META-INF/spring.schemas} is a properties + * file where each line should be of the form {@code systemId=schema-location} + * where {@code schema-location} should also be a schema file in the classpath. * Since systemId is commonly a URL, one must be careful to escape any ':' characters * which are treated as delimiters in properties files. * @@ -77,7 +77,7 @@ public class PluggableSchemaResolver implements EntityResolver { * Loads the schema URL -> schema file location mappings using the default * mapping file pattern "META-INF/spring.schemas". * @param classLoader the ClassLoader to use for loading - * (can be null) to use the default ClassLoader) + * (can be {@code null}) to use the default ClassLoader) * @see PropertiesLoaderUtils#loadAllProperties(String, ClassLoader) */ public PluggableSchemaResolver(ClassLoader classLoader) { @@ -89,7 +89,7 @@ public class PluggableSchemaResolver implements EntityResolver { * Loads the schema URL -> schema file location mappings using the given * mapping file pattern. * @param classLoader the ClassLoader to use for loading - * (can be null) to use the default ClassLoader) + * (can be {@code null}) to use the default ClassLoader) * @param schemaMappingsLocation the location of the file that defines schema mappings * (must not be empty) * @see PropertiesLoaderUtils#loadAllProperties(String, ClassLoader) @@ -100,6 +100,7 @@ public class PluggableSchemaResolver implements EntityResolver { this.schemaMappingsLocation = schemaMappingsLocation; } + @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Trying to resolve XML entity with public id [" + publicId + diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java index a3656ec8bb..02aef0f045 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java @@ -1,12 +1,12 @@ /* - * Copyright 2010 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,28 +29,28 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; /** - * Simple NamespaceHandler implementation that maps custom + * Simple {@code NamespaceHandler} implementation that maps custom * attributes directly through to bean properties. An important point to note is - * that this NamespaceHandler does not have a corresponding schema + * that this {@code NamespaceHandler} does not have a corresponding schema * since there is no way to know in advance all possible attribute names. - * + * *

      - * An example of the usage of this NamespaceHandler is shown below: - * + * An example of the usage of this {@code NamespaceHandler} is shown below: + * *

        * <bean id="author" class="..TestBean" c:name="Enescu" c:work-ref="compositions"/>
        * 
      - * - * Here the 'c:name' corresponds directly to the 'name - * ' argument declared on the constructor of class 'TestBean'. The - * 'c:work-ref' attributes corresponds to the 'work' + * + * Here the '{@code c:name}' corresponds directly to the '{@code name} + * ' argument declared on the constructor of class '{@code TestBean}'. The + * '{@code c:work-ref}' attributes corresponds to the '{@code work}' * argument and, rather than being the concrete value, it contains the name of * the bean that will be considered as a parameter. - * + * * Note: This implementation supports only named parameters - there is no * support for indexes or types. Further more, the names are used as hints by * the container which, by default, does type introspection. - * + * * @see SimplePropertyNamespaceHandler * @author Costin Leau */ @@ -59,15 +59,18 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { private static final String REF_SUFFIX = "-ref"; private static final String DELIMITER_PREFIX = "_"; + @Override public void init() { } + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; } + @Override public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { if (node instanceof Attr) { Attr attr = (Attr) node; @@ -90,7 +93,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { if (argName.startsWith(DELIMITER_PREFIX)) { String arg = argName.substring(1).trim(); - // fast default check + // fast default check if (!StringUtils.hasText(arg)) { cvs.addGenericArgumentValue(valueHolder); } @@ -107,13 +110,13 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { parserContext.getReaderContext().error( "Constructor argument '" + argName + "' specifies a negative index", attr); } - + if (cvs.hasIndexedArgumentValue(index)){ parserContext.getReaderContext().error( "Constructor argument '" + argName + "' with index "+ index+" already defined using ." + " Only one approach may be used per argument.", attr); } - + cvs.addIndexedArgumentValue(index, valueHolder); } } @@ -139,7 +142,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { return true; } - + private boolean checkName(String name, Collection values) { for (ValueHolder holder : values) { if (name.equals(holder.getName())) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandler.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandler.java index ee8101b46e..e6716d2900 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandler.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandler.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,19 +27,19 @@ import org.springframework.beans.factory.config.RuntimeBeanReference; import org.springframework.core.Conventions; /** - * Simple NamespaceHandler implementation that maps custom attributes + * Simple {@code NamespaceHandler} implementation that maps custom attributes * directly through to bean properties. An important point to note is that this - * NamespaceHandler does not have a corresponding schema since there + * {@code NamespaceHandler} does not have a corresponding schema since there * is no way to know in advance all possible attribute names. * - *

      An example of the usage of this NamespaceHandler is shown below: + *

      An example of the usage of this {@code NamespaceHandler} is shown below: * *

        * <bean id="rob" class="..TestBean" p:name="Rob Harrop" p:spouse-ref="sally"/>
      * - * Here the 'p:name' corresponds directly to the 'name' - * property on class 'TestBean'. The 'p:spouse-ref' - * attributes corresponds to the 'spouse' property and, rather + * Here the '{@code p:name}' corresponds directly to the '{@code name}' + * property on class '{@code TestBean}'. The '{@code p:spouse-ref}' + * attributes corresponds to the '{@code spouse}' property and, rather * than being the concrete value, it contains the name of the bean that will * be injected into that property. * @@ -52,15 +52,18 @@ public class SimplePropertyNamespaceHandler implements NamespaceHandler { private static final String REF_SUFFIX = "-ref"; + @Override public void init() { } + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; } + @Override public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { if (node instanceof Attr) { Attr attr = (Attr) node; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/UtilNamespaceHandler.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/UtilNamespaceHandler.java index 128da8a46f..4d33f236ce 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/UtilNamespaceHandler.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/UtilNamespaceHandler.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.util.StringUtils; /** - * {@link NamespaceHandler} for the util namespace. + * {@link NamespaceHandler} for the {@code util} namespace. * * @author Rob Harrop * @author Juergen Hoeller @@ -45,6 +45,7 @@ public class UtilNamespaceHandler extends NamespaceHandlerSupport { private static final String SCOPE_ATTRIBUTE = "scope"; + @Override public void init() { registerBeanDefinitionParser("constant", new ConstantBeanDefinitionParser()); registerBeanDefinitionParser("property-path", new PropertyPathBeanDefinitionParser()); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java index d858fe4def..0021ed45b0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -136,7 +136,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { } /** - * Set whether to use XML validation. Default is true. + * Set whether to use XML validation. Default is {@code true}. *

      This method switches namespace awareness on if validation is turned off, * in order to still process schema namespaces properly in such a scenario. * @see #setValidationMode @@ -212,7 +212,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { /** * Specify the {@link SourceExtractor} to use. - *

      The default implementation is {@link NullSourceExtractor} which simply returns null + *

      The default implementation is {@link NullSourceExtractor} which simply returns {@code null} * as the source object. This means that - during normal runtime execution - * no additional source metadata is attached to the bean configuration metadata. */ @@ -266,7 +266,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { } /** - * Set an implementation of the org.xml.sax.ErrorHandler + * Set an implementation of the {@code org.xml.sax.ErrorHandler} * interface for custom handling of XML parsing errors and warnings. *

      If not set, a default SimpleSaxErrorHandler is used that simply * logs warnings using the logger instance of the view class, @@ -298,6 +298,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ + @Override public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException { return loadBeanDefinitions(new EncodedResource(resource)); } @@ -363,7 +364,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { * Load bean definitions from the specified XML file. * @param inputSource the SAX InputSource to read from * @param resourceDescription a description of the resource - * (can be null or empty) + * (can be {@code null} or empty) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ @@ -439,7 +440,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { /** * Detects which kind of validation to perform on the XML file identified - * by the supplied {@link Resource}. If the file has a DOCTYPE + * by the supplied {@link Resource}. If the file has a {@code DOCTYPE} * definition then DTD validation is used otherwise XSD validation is assumed. *

      Override this method if you would like to customize resolution * of the {@link #VALIDATION_AUTO} mode. @@ -475,9 +476,9 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { /** * Register the bean definitions contained in the given DOM document. - * Called by loadBeanDefinitions. + * Called by {@code loadBeanDefinitions}. *

      Creates a new instance of the parser class and invokes - * registerBeanDefinitions on it. + * {@code registerBeanDefinitions} on it. * @param doc the DOM document * @param resource the resource descriptor (for context information) * @return the number of bean definitions found diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionStoreException.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionStoreException.java index 87c4617c4d..ceec57615e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionStoreException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionStoreException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException; * @see #getLineNumber() * @see org.xml.sax.SAXParseException */ +@SuppressWarnings("serial") public class XmlBeanDefinitionStoreException extends BeanDefinitionStoreException { /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java index 077d76cdae..fb6889226c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ import org.springframework.core.io.Resource; * {@link XmlBeanDefinitionReader} */ @Deprecated +@SuppressWarnings({"serial", "all"}) public class XmlBeanFactory extends DefaultListableBeanFactory { private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/package-info.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/package-info.java index c3c0379244..1d2043d258 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/package-info.java @@ -1,7 +1,6 @@ - /** * - * Contains an abstract XML-based BeanFactory implementation, + * Contains an abstract XML-based {@code BeanFactory} implementation, * including a standard "spring-beans" DTD. * */ diff --git a/spring-beans/src/main/java/org/springframework/beans/package-info.java b/spring-beans/src/main/java/org/springframework/beans/package-info.java index 1af0af8956..11d8730cd9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/package-info.java @@ -3,10 +3,10 @@ * * This package contains interfaces and classes for manipulating Java beans. * It is used by most other Spring packages. - * + * *

      A BeanWrapper object may be used to set and get bean properties, * singly or in bulk. - * + * *

      The classes in this package are discussed in Chapter 11 of * Expert One-On-One J2EE Design and Development * by Rod Johnson (Wrox, 2002). diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharacterEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharacterEditor.java index bf20a7544c..aee26b0ded 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharacterEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharacterEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,22 +21,22 @@ import java.beans.PropertyEditorSupport; import org.springframework.util.StringUtils; /** - * Editor for a {@link java.lang.Character}, to populate a property - * of type Character or char from a String value. + * Editor for a {@link Character}, to populate a property + * of type {@code Character} or {@code char} from a String value. * *

      Note that the JDK does not contain a default - * {@link java.beans.PropertyEditor property editor} for char! + * {@link java.beans.PropertyEditor property editor} for {@code char}! * {@link org.springframework.beans.BeanWrapperImpl} will register this * editor by default. - * + * *

      Also supports conversion from a Unicode character sequence; e.g. - * u0041 ('A'). + * {@code u0041} ('A'). * * @author Juergen Hoeller * @author Rob Harrop * @author Rick Evans * @since 1.2 - * @see java.lang.Character + * @see Character * @see org.springframework.beans.BeanWrapperImpl */ public class CharacterEditor extends PropertyEditorSupport { @@ -58,9 +58,9 @@ public class CharacterEditor extends PropertyEditorSupport { /** * Create a new CharacterEditor instance. *

      The "allowEmpty" parameter controls whether an empty String is - * to be allowed in parsing, i.e. be interpreted as the null + * to be allowed in parsing, i.e. be interpreted as the {@code null} * value when {@link #setAsText(String) text is being converted}. If - * false, an {@link IllegalArgumentException} will be thrown + * {@code false}, an {@link IllegalArgumentException} will be thrown * at that time. * @param allowEmpty if empty strings are to be allowed */ diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharsetEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharsetEditor.java index 5d742a9253..e45a34149e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharsetEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CharsetEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,11 +22,11 @@ import java.nio.charset.Charset; import org.springframework.util.StringUtils; /** - * Editor for java.nio.charset.Charset, translating charset + * Editor for {@code java.nio.charset.Charset}, translating charset * String representations into Charset objects and back. * *

      Expects the same syntax as Charset's {@link java.nio.charset.Charset#name()}, - * e.g. UTF-8, ISO-8859-16, etc. + * e.g. {@code UTF-8}, {@code ISO-8859-16}, etc. * * @author Arjen Poutsma * @since 2.5.4 diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassArrayEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassArrayEditor.java index 4db48197f8..68ab64d576 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassArrayEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassArrayEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** - * Property editor for an array of {@link java.lang.Class Classes}, to enable - * the direct population of a Class[] property without having to - * use a String class name property as bridge. + * Property editor for an array of {@link Class Classes}, to enable + * the direct population of a {@code Class[]} property without having to + * use a {@code String} class name property as bridge. * *

      Also supports "java.lang.String[]"-style array class names, in contrast * to the standard {@link Class#forName(String)} method. @@ -40,18 +40,18 @@ public class ClassArrayEditor extends PropertyEditorSupport { /** - * Create a default ClassEditor, using the thread - * context ClassLoader. + * Create a default {@code ClassEditor}, using the thread + * context {@code ClassLoader}. */ public ClassArrayEditor() { this(null); } /** - * Create a default ClassArrayEditor, using the given - * ClassLoader. - * @param classLoader the ClassLoader to use - * (or pass null for the thread context ClassLoader) + * Create a default {@code ClassArrayEditor}, using the given + * {@code ClassLoader}. + * @param classLoader the {@code ClassLoader} to use + * (or pass {@code null} for the thread context {@code ClassLoader}) */ public ClassArrayEditor(ClassLoader classLoader) { this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader()); diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassEditor.java index 4f5fffce46..a6214171a5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ClassEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** - * Property editor for {@link java.lang.Class java.lang.Class}, to enable the direct - * population of a Class property without recourse to having to use a + * Property editor for {@link Class java.lang.Class}, to enable the direct + * population of a {@code Class} property without recourse to having to use a * String class name property as bridge. * *

      Also supports "java.lang.String[]"-style array class names, in contrast to the @@ -32,7 +32,7 @@ import org.springframework.util.StringUtils; * @author Juergen Hoeller * @author Rick Evans * @since 13.05.2003 - * @see java.lang.Class#forName + * @see Class#forName * @see org.springframework.util.ClassUtils#forName(String, ClassLoader) */ public class ClassEditor extends PropertyEditorSupport { @@ -50,7 +50,7 @@ public class ClassEditor extends PropertyEditorSupport { /** * Create a default ClassEditor, using the given ClassLoader. * @param classLoader the ClassLoader to use - * (or null for the thread context ClassLoader) + * (or {@code null} for the thread context ClassLoader) */ public ClassEditor(ClassLoader classLoader) { this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader()); diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CurrencyEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CurrencyEditor.java index 910016ac86..5d5eea0de1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CurrencyEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CurrencyEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.beans.PropertyEditorSupport; import java.util.Currency; /** - * Editor for java.util.Currency, translating currency codes into Currency + * Editor for {@code java.util.Currency}, translating currency codes into Currency * objects. Exposes the currency code as text representation of a Currency object. * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomBooleanEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomBooleanEditor.java index b75520e06a..985ba1723c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomBooleanEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomBooleanEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ import org.springframework.util.StringUtils; * them in the UI form. * *

      In web MVC code, this editor will typically be registered with - * binder.registerCustomEditor calls in an implementation - * of BaseCommandController's initBinder method. + * {@code binder.registerCustomEditor} calls in an implementation + * of BaseCommandController's {@code initBinder} method. * * @author Juergen Hoeller * @since 10.06.2003 diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java index a355ffcb7a..cbf10da7a4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class CustomCollectionEditor extends PropertyEditorSupport { /** * Create a new CustomCollectionEditor for the given target type, - * keeping an incoming null as-is. + * keeping an incoming {@code null} as-is. * @param collectionType the target type, which needs to be a * sub-interface of Collection or a concrete Collection class * @see java.util.Collection @@ -72,7 +72,7 @@ public class CustomCollectionEditor extends PropertyEditorSupport { * TreeSet for SortedSet, and LinkedHashSet for Set. * @param collectionType the target type, which needs to be a * sub-interface of Collection or a concrete Collection class - * @param nullAsEmptyCollection whether to convert an incoming null + * @param nullAsEmptyCollection whether to convert an incoming {@code null} * value to an empty Collection (of the appropriate type) * @see java.util.Collection * @see java.util.ArrayList @@ -198,7 +198,7 @@ public class CustomCollectionEditor extends PropertyEditorSupport { /** - * This implementation returns null to indicate that + * This implementation returns {@code null} to indicate that * there is no appropriate text representation. */ @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomDateEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomDateEditor.java index 5f4acc9151..36718b20e9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomDateEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomDateEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ import java.util.Date; import org.springframework.util.StringUtils; /** - * Property editor for java.util.Date, - * supporting a custom java.text.DateFormat. + * Property editor for {@code java.util.Date}, + * supporting a custom {@code java.text.DateFormat}. * *

      This is not meant to be used as system PropertyEditor but rather * as locale-specific date editor within custom controller code, @@ -33,8 +33,8 @@ import org.springframework.util.StringUtils; * and rendering them in the UI form. * *

      In web MVC code, this editor will typically be registered with - * binder.registerCustomEditor calls in a custom - * initBinder method. + * {@code binder.registerCustomEditor} calls in a custom + * {@code initBinder} method. * * @author Juergen Hoeller * @since 28.04.2003 @@ -76,7 +76,7 @@ public class CustomDateEditor extends PropertyEditorSupport { *

      The "exactDateLength" parameter states that IllegalArgumentException gets * thrown if the String does not exactly match the length specified. This is useful * because SimpleDateFormat does not enforce strict parsing of the year part, - * not even with setLenient(false). Without an "exactDateLength" + * not even with {@code setLenient(false)}. Without an "exactDateLength" * specified, the "01/01/05" would get parsed to "01/01/0005". However, even * with an "exactDateLength" specified, prepended zeros in the day or month * part may still allow for a shorter year part, so consider this as just diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java index d66eca4f17..14871687de 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class CustomMapEditor extends PropertyEditorSupport { /** * Create a new CustomMapEditor for the given target type, - * keeping an incoming null as-is. + * keeping an incoming {@code null} as-is. * @param mapType the target type, which needs to be a * sub-interface of Map or a concrete Map class * @see java.util.Map @@ -63,7 +63,7 @@ public class CustomMapEditor extends PropertyEditorSupport { * and LinkedHashMap for Map. * @param mapType the target type, which needs to be a * sub-interface of Map or a concrete Map class - * @param nullAsEmptyMap ap whether to convert an incoming null + * @param nullAsEmptyMap ap whether to convert an incoming {@code null} * value to an empty Map (of the appropriate type) * @see java.util.Map * @see java.util.TreeMap @@ -189,7 +189,7 @@ public class CustomMapEditor extends PropertyEditorSupport { /** - * This implementation returns null to indicate that + * This implementation returns {@code null} to indicate that * there is no appropriate text representation. */ @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomNumberEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomNumberEditor.java index b1d960bbfc..c946c621fb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomNumberEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomNumberEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.util.StringUtils; * Property editor for any Number subclass such as Short, Integer, Long, * BigInteger, Float, Double, BigDecimal. Can use a given NumberFormat for * (locale-specific) parsing and rendering, or alternatively the default - * decode / valueOf / toString methods. + * {@code decode} / {@code valueOf} / {@code toString} methods. * *

      This is not meant to be used as system PropertyEditor but rather * as locale-specific number editor within custom controller code, @@ -34,12 +34,12 @@ import org.springframework.util.StringUtils; * and rendering them in the UI form. * *

      In web MVC code, this editor will typically be registered with - * binder.registerCustomEditor calls in a custom - * initBinder method. + * {@code binder.registerCustomEditor} calls in a custom + * {@code initBinder} method. * * @author Juergen Hoeller * @since 06.06.2003 - * @see java.lang.Number + * @see Number * @see java.text.NumberFormat * @see org.springframework.validation.DataBinder#registerCustomEditor * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder @@ -55,10 +55,10 @@ public class CustomNumberEditor extends PropertyEditorSupport { /** * Create a new CustomNumberEditor instance, using the default - * valueOf methods for parsing and toString + * {@code valueOf} methods for parsing and {@code toString} * methods for rendering. *

      The "allowEmpty" parameter states if an empty String should - * be allowed for parsing, i.e. get interpreted as null value. + * be allowed for parsing, i.e. get interpreted as {@code null} value. * Else, an IllegalArgumentException gets thrown in that case. * @param numberClass Number subclass to generate * @param allowEmpty if empty strings should be allowed @@ -75,7 +75,7 @@ public class CustomNumberEditor extends PropertyEditorSupport { * Create a new CustomNumberEditor instance, using the given NumberFormat * for parsing and rendering. *

      The allowEmpty parameter states if an empty String should - * be allowed for parsing, i.e. get interpreted as null value. + * be allowed for parsing, i.e. get interpreted as {@code null} value. * Else, an IllegalArgumentException gets thrown in that case. * @param numberClass Number subclass to generate * @param numberFormat NumberFormat to use for parsing and rendering @@ -85,8 +85,8 @@ public class CustomNumberEditor extends PropertyEditorSupport { * @see java.text.NumberFormat#parse * @see java.text.NumberFormat#format */ - public CustomNumberEditor(Class numberClass, NumberFormat numberFormat, boolean allowEmpty) - throws IllegalArgumentException { + public CustomNumberEditor(Class numberClass, + NumberFormat numberFormat, boolean allowEmpty) throws IllegalArgumentException { if (numberClass == null || !Number.class.isAssignableFrom(numberClass)) { throw new IllegalArgumentException("Property class must be a subclass of Number"); diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/FileEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/FileEditor.java index f21053e868..a57b69eaed 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/FileEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/FileEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; /** - * Editor for java.io.File, to directly populate a File property + * Editor for {@code java.io.File}, to directly populate a File property * from a Spring resource location. * *

      Supports Spring-style URL notation: any fully qualified standard URL diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputSourceEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputSourceEditor.java index 3701b55cc3..92f47df1f1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputSourceEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputSourceEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.core.io.ResourceEditor; import org.springframework.util.Assert; /** - * Editor for org.xml.sax.InputSource, converting from a + * Editor for {@code org.xml.sax.InputSource}, converting from a * Spring resource location String to a SAX InputSource object. * *

      Supports Spring-style URL notation: any fully qualified standard URL @@ -37,8 +37,8 @@ import org.springframework.util.Assert; * @see org.xml.sax.InputSource * @see org.springframework.core.io.ResourceEditor * @see org.springframework.core.io.ResourceLoader - * @see org.springframework.beans.propertyeditors.URLEditor - * @see org.springframework.beans.propertyeditors.FileEditor + * @see URLEditor + * @see FileEditor */ public class InputSourceEditor extends PropertyEditorSupport { diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputStreamEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputStreamEditor.java index 7099897730..220f381e88 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputStreamEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/InputStreamEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.util.Assert; /** * One-way PropertyEditor which can convert from a text String to a - * java.io.InputStream, interpreting the given String + * {@code java.io.InputStream}, interpreting the given String * as Spring resource location (e.g. a URL String). * *

      Supports Spring-style URL notation: any fully qualified standard URL @@ -79,7 +79,7 @@ public class InputStreamEditor extends PropertyEditorSupport { } /** - * This implementation returns null to indicate that + * This implementation returns {@code null} to indicate that * there is no appropriate text representation. */ @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/LocaleEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/LocaleEditor.java index 49df579168..25af77b5dd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/LocaleEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/LocaleEditor.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,9 +21,9 @@ import java.beans.PropertyEditorSupport; import org.springframework.util.StringUtils; /** - * Editor for java.util.Locale, to directly populate a Locale property. + * Editor for {@code java.util.Locale}, to directly populate a Locale property. * - *

      Expects the same syntax as Locale's toString, i.e. language + + *

      Expects the same syntax as Locale's {@code toString}, i.e. language + * optionally country + optionally variant, separated by "_" (e.g. "en", "en_US"). * Also accepts spaces as separators, as alternative to underscores. * diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PatternEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PatternEditor.java index 41f9952b5c..0c4c971fea 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PatternEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PatternEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import java.beans.PropertyEditorSupport; import java.util.regex.Pattern; /** - * Editor for java.util.regex.Pattern, to directly populate a Pattern property. - * Expects the same syntax as Pattern's compile method. + * Editor for {@code java.util.regex.Pattern}, to directly populate a Pattern property. + * Expects the same syntax as Pattern's {@code compile} method. * * @author Juergen Hoeller * @since 2.0.1 @@ -42,7 +42,7 @@ public class PatternEditor extends PropertyEditorSupport { /** * Create a new PatternEditor with the given settings. - * @param flags the java.util.regex.Pattern flags to apply + * @param flags the {@code java.util.regex.Pattern} flags to apply * @see java.util.regex.Pattern#compile(String, int) * @see java.util.regex.Pattern#CASE_INSENSITIVE * @see java.util.regex.Pattern#MULTILINE diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PropertiesEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PropertiesEditor.java index 7f5f291b70..977c2b0a6c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PropertiesEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/PropertiesEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,11 +25,11 @@ import java.util.Properties; /** * Custom {@link java.beans.PropertyEditor} for {@link Properties} objects. * - *

      Handles conversion from content {@link String} to Properties object. - * Also handles {@link Map} to Properties conversion, for populating - * a Properties object via XML "map" entries. + *

      Handles conversion from content {@link String} to {@code Properties} object. + * Also handles {@link Map} to {@code Properties} conversion, for populating + * a {@code Properties} object via XML "map" entries. * - *

      The required format is defined in the standard Properties + *

      The required format is defined in the standard {@code Properties} * documentation. Each property must be on a new line. * * @author Rod Johnson @@ -61,7 +61,7 @@ public class PropertiesEditor extends PropertyEditorSupport { } /** - * Take {@link Properties} as-is; convert {@link Map} into Properties. + * Take {@link Properties} as-is; convert {@link Map} into {@code Properties}. */ @Override public void setValue(Object value) { diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java index 4f0f404d82..24467400fa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/ResourceBundleEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,13 +26,13 @@ import java.util.ResourceBundle; /** * {@link java.beans.PropertyEditor} implementation for * {@link java.util.ResourceBundle ResourceBundles}. - * + * *

      Only supports conversion from a String, but not * to a String. - * - * Find below some examples of using this class in a + * + * Find below some examples of using this class in a * (properly configured) Spring container using XML-based metadata: - * + * *

       <bean id="errorDialog" class="...">
        *    <!--
        *        the 'messages' property is of type java.util.ResourceBundle.
      @@ -40,18 +40,18 @@ import java.util.ResourceBundle;
        *    -->
        *    <property name="messages" value="DialogMessages"/>
        * </bean>
      - * + * *
       <bean id="errorDialog" class="...">
        *    <!--
        *        the 'DialogMessages.properties' file exists in the 'com/messages' package
        *    -->
        *    <property name="messages" value="com/messages/DialogMessages"/>
        * </bean>
      - * + * *

      A 'properly configured' Spring {@link org.springframework.context.ApplicationContext container} * might contain a {@link org.springframework.beans.factory.config.CustomEditorConfigurer} * definition such that the conversion can be effected transparently: - * + * *

       <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
        *    <property name="customEditors">
        *        <map>
      @@ -61,10 +61,10 @@ import java.util.ResourceBundle;
        *        </map>
        *    </property>
        * </bean>
      - * + * *

      Please note that this {@link java.beans.PropertyEditor} is * not registered by default with any of the Spring infrastructure. - * + * *

      Thanks to David Leal Valmana for the suggestion and initial prototype. * * @author Rick Evans diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java index c715f61e4c..c8875b388b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { private final String charsToDelete; private final boolean emptyArrayAsNull; - + private final boolean trimValues; @@ -71,8 +71,8 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { /** * Create a new StringArrayPropertyEditor with the given separator. * @param separator the separator to use for splitting a {@link String} - * @param emptyArrayAsNull true if an empty String array - * is to be transformed into null + * @param emptyArrayAsNull {@code true} if an empty String array + * is to be transformed into {@code null} */ public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull) { this(separator, null, emptyArrayAsNull); @@ -81,9 +81,9 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { /** * Create a new StringArrayPropertyEditor with the given separator. * @param separator the separator to use for splitting a {@link String} - * @param emptyArrayAsNull true if an empty String array - * is to be transformed into null - * @param trimValues true if the values in the parsed arrays + * @param emptyArrayAsNull {@code true} if an empty String array + * is to be transformed into {@code null} + * @param trimValues {@code true} if the values in the parsed arrays * are to be be trimmed of whitespace (default is true). */ public StringArrayPropertyEditor(String separator, boolean emptyArrayAsNull, boolean trimValues) { @@ -96,8 +96,8 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { * @param charsToDelete a set of characters to delete, in addition to * trimming an input String. Useful for deleting unwanted line breaks: * e.g. "\r\n\f" will delete all new lines and line feeds in a String. - * @param emptyArrayAsNull true if an empty String array - * is to be transformed into null + * @param emptyArrayAsNull {@code true} if an empty String array + * is to be transformed into {@code null} */ public StringArrayPropertyEditor(String separator, String charsToDelete, boolean emptyArrayAsNull) { this(separator, charsToDelete, emptyArrayAsNull, true); @@ -109,9 +109,9 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport { * @param charsToDelete a set of characters to delete, in addition to * trimming an input String. Useful for deleting unwanted line breaks: * e.g. "\r\n\f" will delete all new lines and line feeds in a String. - * @param emptyArrayAsNull true if an empty String array - * is to be transformed into null - * @param trimValues true if the values in the parsed arrays + * @param emptyArrayAsNull {@code true} if an empty String array + * is to be transformed into {@code null} + * @param trimValues {@code true} if the values in the parsed arrays * are to be be trimmed of whitespace (default is true). */ public StringArrayPropertyEditor(String separator, String charsToDelete, boolean emptyArrayAsNull, boolean trimValues) { diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java index c277c44f74..da9c1eea94 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/StringTrimmerEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.springframework.util.StringUtils; /** * Property editor that trims Strings. * - *

      Optionally allows transforming an empty string into a null value. + *

      Optionally allows transforming an empty string into a {@code null} value. * Needs to be explicitly registered, e.g. for command binding. * * @author Juergen Hoeller @@ -39,8 +39,8 @@ public class StringTrimmerEditor extends PropertyEditorSupport { /** * Create a new StringTrimmerEditor. - * @param emptyAsNull true if an empty String is to be - * transformed into null + * @param emptyAsNull {@code true} if an empty String is to be + * transformed into {@code null} */ public StringTrimmerEditor(boolean emptyAsNull) { this.charsToDelete = null; @@ -52,8 +52,8 @@ public class StringTrimmerEditor extends PropertyEditorSupport { * @param charsToDelete a set of characters to delete, in addition to * trimming an input String. Useful for deleting unwanted line breaks: * e.g. "\r\n\f" will delete all new lines and line feeds in a String. - * @param emptyAsNull true if an empty String is to be - * transformed into null + * @param emptyAsNull {@code true} if an empty String is to be + * transformed into {@code null} */ public StringTrimmerEditor(String charsToDelete, boolean emptyAsNull) { this.charsToDelete = charsToDelete; diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/TimeZoneEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/TimeZoneEditor.java index 832488ffaf..632f60127c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/TimeZoneEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/TimeZoneEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.beans.PropertyEditorSupport; import java.util.TimeZone; /** - * Editor for java.util.TimeZone, translating timezone IDs into + * Editor for {@code java.util.TimeZone}, translating timezone IDs into * TimeZone objects. Does not expose a text representation for TimeZone objects. * * @author Juergen Hoeller @@ -35,7 +35,7 @@ public class TimeZoneEditor extends PropertyEditorSupport { } /** - * This implementation returns null to indicate that + * This implementation returns {@code null} to indicate that * there is no appropriate text representation. */ @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URIEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URIEditor.java index add95f10c3..f5ac6d6a48 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URIEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URIEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; /** - * Editor for java.net.URI, to directly populate a URI property + * Editor for {@code java.net.URI}, to directly populate a URI property * instead of using a String property as bridge. * *

      Supports Spring-style URI notation: any fully qualified standard URI @@ -79,7 +79,7 @@ public class URIEditor extends PropertyEditorSupport { * Create a new URIEditor, using the given ClassLoader to resolve * "classpath:" locations into physical resource URLs. * @param classLoader the ClassLoader to use for resolving "classpath:" locations - * (may be null to indicate the default ClassLoader) + * (may be {@code null} to indicate the default ClassLoader) */ public URIEditor(ClassLoader classLoader) { this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader()); @@ -90,7 +90,7 @@ public class URIEditor extends PropertyEditorSupport { * Create a new URIEditor, using the given ClassLoader to resolve * "classpath:" locations into physical resource URLs. * @param classLoader the ClassLoader to use for resolving "classpath:" locations - * (may be null to indicate the default ClassLoader) + * (may be {@code null} to indicate the default ClassLoader) * @param encode indicates whether Strings will be encoded or not */ public URIEditor(ClassLoader classLoader, boolean encode) { diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URLEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URLEditor.java index bffeffc1ef..c5f9755d85 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URLEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/URLEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.core.io.ResourceEditor; import org.springframework.util.Assert; /** - * Editor for java.net.URL, to directly populate a URL property + * Editor for {@code java.net.URL}, to directly populate a URL property * instead of using a String property as bridge. * *

      Supports Spring-style URL notation: any fully qualified standard URL diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/UUIDEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/UUIDEditor.java index 98c9ea54f5..3662903df8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/UUIDEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/UUIDEditor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.UUID; import org.springframework.util.StringUtils; /** - * Editor for java.util.UUID, translating UUID + * Editor for {@code java.util.UUID}, translating UUID * String representations into UUID objects and back. * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/package-info.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/package-info.java index 40aa76e11e..376e3c6d3f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/package-info.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/package-info.java @@ -3,7 +3,7 @@ * * Properties editors used to convert from String values to object * types such as java.util.Properties. - * + * *

      Some of these editors are registered automatically by BeanWrapperImpl. * "CustomXxxEditor" classes are intended for manual registration in * specific binding processes, as they are localized or the like. diff --git a/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java b/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java index 36c185f919..a9ed9984aa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/ArgumentConvertingMethodInvoker.java @@ -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"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ public class ArgumentConvertingMethodInvoker extends MethodInvoker { * Actually find a method with matching parameter type, i.e. where each * argument value is assignable to the corresponding parameter type. * @param arguments the argument values to match against method parameters - * @return a matching method, or null if none + * @return a matching method, or {@code null} if none */ protected Method doFindMatchingMethod(Object[] arguments) { TypeConverter converter = getTypeConverter(); diff --git a/spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.java b/spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.java index e227dd59af..4f59e4d30e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/MutableSortDefinition.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.util.StringUtils; * @since 26.05.2003 * @see #setToggleAscendingOnProperty */ +@SuppressWarnings("serial") public class MutableSortDefinition implements SortDefinition, Serializable { private String property = ""; @@ -76,7 +77,7 @@ public class MutableSortDefinition implements SortDefinition, Serializable { /** * Create a new MutableSortDefinition. * @param toggleAscendingOnSameProperty whether to toggle the ascending flag - * if the same property gets set again (that is, setProperty gets + * if the same property gets set again (that is, {@code setProperty} gets * called with already set property name again). */ public MutableSortDefinition(boolean toggleAscendingOnSameProperty) { @@ -103,6 +104,7 @@ public class MutableSortDefinition implements SortDefinition, Serializable { } } + @Override public String getProperty() { return this.property; } @@ -114,6 +116,7 @@ public class MutableSortDefinition implements SortDefinition, Serializable { this.ignoreCase = ignoreCase; } + @Override public boolean isIgnoreCase() { return this.ignoreCase; } @@ -125,6 +128,7 @@ public class MutableSortDefinition implements SortDefinition, Serializable { this.ascending = ascending; } + @Override public boolean isAscending() { return this.ascending; } @@ -159,7 +163,8 @@ public class MutableSortDefinition implements SortDefinition, Serializable { } SortDefinition otherSd = (SortDefinition) other; return (getProperty().equals(otherSd.getProperty()) && - isAscending() == otherSd.isAscending() && isIgnoreCase() == otherSd.isIgnoreCase()); + isAscending() == otherSd.isAscending() && + isIgnoreCase() == otherSd.isIgnoreCase()); } @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java b/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java index 2ed2c98955..4d7ff96013 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ import org.springframework.util.Assert; * @see #getPageList() * @see org.springframework.beans.support.MutableSortDefinition */ +@SuppressWarnings("serial") public class PagedListHolder implements Serializable { public static final int DEFAULT_PAGE_SIZE = 10; @@ -288,9 +289,9 @@ public class PagedListHolder implements Serializable { /** - * Resort the list if necessary, i.e. if the current sort instance - * isn't equal to the backed-up sortUsed instance. - *

      Calls doSort to trigger actual sorting. + * Resort the list if necessary, i.e. if the current {@code sort} instance + * isn't equal to the backed-up {@code sortUsed} instance. + *

      Calls {@code doSort} to trigger actual sorting. * @see #doSort */ public void resort() { @@ -309,7 +310,7 @@ public class PagedListHolder implements Serializable { * Can be overridden in subclasses, in particular in case of custom * extensions to the SortDefinition interface. Is allowed to return * null, which means that no sort state will be held, triggering - * actual sorting for each resort call. + * actual sorting for each {@code resort} call. * @param sort the current SortDefinition object * @return a deep copy of the SortDefinition object * @see MutableSortDefinition#MutableSortDefinition(SortDefinition) diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java index d9f9a95bbb..bbea12861a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -72,6 +72,7 @@ public class PropertyComparator implements Comparator { } + @Override public int compare(Object o1, Object o2) { Object v1 = getPropertyValue(o1); Object v2 = getPropertyValue(o2); @@ -81,7 +82,7 @@ public class PropertyComparator implements Comparator { } int result; - + // Put an object with null property at the end of the sort result. try { if (v1 != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java index bcf6c8931c..2db246e47d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java @@ -91,7 +91,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { /** - * Populate the given registry with the following resource editors: + * Populate the given {@code registry} with the following resource editors: * ResourceEditor, InputStreamEditor, InputSourceEditor, FileEditor, URLEditor, * URIEditor, ClassEditor, ClassArrayEditor. *

      If this registrar has been configured with a {@link ResourcePatternResolver}, @@ -106,6 +106,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { * @see org.springframework.beans.propertyeditors.ClassArrayEditor * @see org.springframework.core.io.support.ResourceArrayPropertyEditor */ + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { ResourceEditor baseEditor = new ResourceEditor(this.resourceLoader, this.propertyResolver); doRegisterEditor(registry, Resource.class, baseEditor); diff --git a/spring-beans/src/main/java/org/springframework/beans/support/SortDefinition.java b/spring-beans/src/main/java/org/springframework/beans/support/SortDefinition.java index 869701bc59..406e3b6faa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/SortDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/SortDefinition.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParser.java b/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParser.java index 3483077e85..94dd439bfb 100644 --- a/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParser.java +++ b/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParser.java @@ -13,6 +13,7 @@ import org.w3c.dom.Element; public class ComponentBeanDefinitionParser extends AbstractBeanDefinitionParser { + @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { return parseComponentElement(element); diff --git a/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java b/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java index aec54454ec..b3e62ba2b8 100644 --- a/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java +++ b/spring-beans/src/test/java/com/foo/ComponentBeanDefinitionParserTest.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2010 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/com/foo/ComponentFactoryBean.java b/spring-beans/src/test/java/com/foo/ComponentFactoryBean.java index e62eab786e..ac47c4efea 100644 --- a/spring-beans/src/test/java/com/foo/ComponentFactoryBean.java +++ b/spring-beans/src/test/java/com/foo/ComponentFactoryBean.java @@ -16,6 +16,7 @@ public class ComponentFactoryBean implements FactoryBean { this.children = children; } + @Override public Component getObject() throws Exception { if (this.children != null && this.children.size() > 0) { for (Component child : children) { @@ -25,10 +26,12 @@ public class ComponentFactoryBean implements FactoryBean { return this.parent; } + @Override public Class getObjectType() { return Component.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/com/foo/ComponentNamespaceHandler.java b/spring-beans/src/test/java/com/foo/ComponentNamespaceHandler.java index 3ccc7f167b..b29eeca061 100644 --- a/spring-beans/src/test/java/com/foo/ComponentNamespaceHandler.java +++ b/spring-beans/src/test/java/com/foo/ComponentNamespaceHandler.java @@ -3,6 +3,7 @@ package com.foo; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; public class ComponentNamespaceHandler extends NamespaceHandlerSupport { + @Override public void init() { registerBeanDefinitionParser("component", new ComponentBeanDefinitionParser()); diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java index f85c45233d..51ea30bb54 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import java.util.Map; * @author Rod Johnson * @author Chris Beams */ -public abstract class AbstractPropertyValuesTests { +public abstract class AbstractPropertyValuesTests { /** * Must contain: forname=Tony surname=Blair age=50 diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index a8abdd95f2..f49f63182c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import test.beans.TestBean; /** * Unit tests for {@link BeanUtils}. - * + * * @author Juergen Hoeller * @author Rob Harrop * @author Chris Beams @@ -250,17 +250,17 @@ public final class BeanUtilsTests { } @Test - public void testSPR6063() { - PropertyDescriptor[] descrs = BeanUtils.getPropertyDescriptors(Bean.class); + public void testSPR6063() { + PropertyDescriptor[] descrs = BeanUtils.getPropertyDescriptors(Bean.class); - PropertyDescriptor keyDescr = BeanUtils.getPropertyDescriptor(Bean.class, "value"); - assertEquals(String.class, keyDescr.getPropertyType()); - for (PropertyDescriptor propertyDescriptor : descrs) { - if (propertyDescriptor.getName().equals(keyDescr.getName())) { - assertEquals(propertyDescriptor.getName() + " has unexpected type", keyDescr.getPropertyType(), propertyDescriptor.getPropertyType()); - } - } - } + PropertyDescriptor keyDescr = BeanUtils.getPropertyDescriptor(Bean.class, "value"); + assertEquals(String.class, keyDescr.getPropertyType()); + for (PropertyDescriptor propertyDescriptor : descrs) { + if (propertyDescriptor.getName().equals(keyDescr.getName())) { + assertEquals(propertyDescriptor.getName() + " has unexpected type", keyDescr.getPropertyType(), propertyDescriptor.getPropertyType()); + } + } + } private void assertSignatureEquals(Method desiredMethod, String signature) { assertEquals(desiredMethod, BeanUtils.resolveSignature(signature, MethodSignatureBean.class)); @@ -360,18 +360,22 @@ public final class BeanUtilsTests { private String value; + @Override public String getKey() { return key; } + @Override public void setKey(String aKey) { key = aKey; } + @Override public String getValue() { return value; } + @Override public void setValue(String aValue) { value = aValue; } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java index 469b22cdaf..73bdeaee1c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -71,12 +71,12 @@ public class BeanWrapperAutoGrowingTests { @Test public void getPropertyValueAutoGrowArrayBySeveralElements() { assertNotNull(wrapper.getPropertyValue("array[4]")); - assertEquals(5, bean.getArray().length); - assertTrue(bean.getArray()[0] instanceof Bean); - assertTrue(bean.getArray()[1] instanceof Bean); - assertTrue(bean.getArray()[2] instanceof Bean); - assertTrue(bean.getArray()[3] instanceof Bean); - assertTrue(bean.getArray()[4] instanceof Bean); + assertEquals(5, bean.getArray().length); + assertTrue(bean.getArray()[0] instanceof Bean); + assertTrue(bean.getArray()[1] instanceof Bean); + assertTrue(bean.getArray()[2] instanceof Bean); + assertTrue(bean.getArray()[3] instanceof Bean); + assertTrue(bean.getArray()[4] instanceof Bean); assertNotNull(wrapper.getPropertyValue("array[0]")); assertNotNull(wrapper.getPropertyValue("array[1]")); assertNotNull(wrapper.getPropertyValue("array[2]")); @@ -94,7 +94,7 @@ public class BeanWrapperAutoGrowingTests { public void getPropertyValueAutoGrowList() { assertNotNull(wrapper.getPropertyValue("list[0]")); assertEquals(1, bean.getList().size()); - assertTrue(bean.getList().get(0) instanceof Bean); + assertTrue(bean.getList().get(0) instanceof Bean); } @Test @@ -107,11 +107,11 @@ public class BeanWrapperAutoGrowingTests { public void getPropertyValueAutoGrowListBySeveralElements() { assertNotNull(wrapper.getPropertyValue("list[4]")); assertEquals(5, bean.getList().size()); - assertTrue(bean.getList().get(0) instanceof Bean); - assertTrue(bean.getList().get(1) instanceof Bean); - assertTrue(bean.getList().get(2) instanceof Bean); - assertTrue(bean.getList().get(3) instanceof Bean); - assertTrue(bean.getList().get(4) instanceof Bean); + assertTrue(bean.getList().get(0) instanceof Bean); + assertTrue(bean.getList().get(1) instanceof Bean); + assertTrue(bean.getList().get(2) instanceof Bean); + assertTrue(bean.getList().get(3) instanceof Bean); + assertTrue(bean.getList().get(4) instanceof Bean); assertNotNull(wrapper.getPropertyValue("list[0]")); assertNotNull(wrapper.getPropertyValue("list[1]")); assertNotNull(wrapper.getPropertyValue("list[2]")); @@ -167,9 +167,9 @@ public class BeanWrapperAutoGrowingTests { private Bean[] array; private Bean[][] multiArray; - + private List list; - + private List> multiList; private List listNotParameterized; @@ -215,7 +215,7 @@ public class BeanWrapperAutoGrowingTests { public void setList(List list) { this.list = list; } - + public List> getMultiList() { return multiList; } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index c1f3b5e3ac..a1752458c4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -507,6 +507,7 @@ public class BeanWrapperGenericsTests { private Map>> mapOfListOfListOfInteger; + @Override public Map getMapOfInteger() { return mapOfInteger; } @@ -515,10 +516,12 @@ public class BeanWrapperGenericsTests { this.mapOfInteger = mapOfInteger; } + @Override public Map> getMapOfListOfInteger() { return mapOfListOfInteger; } + @Override public void setMapOfListOfInteger(Map> mapOfListOfInteger) { this.mapOfListOfInteger = mapOfListOfInteger; } @@ -591,6 +594,7 @@ public class BeanWrapperGenericsTests { private double version; + @Override public Double getVersion() { return this.version; } @@ -613,10 +617,12 @@ public class BeanWrapperGenericsTests { private Long id; + @Override public Long getId() { return id; } + @Override public void setId(Long aId) { this.id = aId; } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java index b584e4a51e..7da9710417 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java @@ -49,6 +49,8 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.beans.support.DerivedFromProtectedBaseBean; +import org.springframework.build.junit.Assume; +import org.springframework.build.junit.TestGroup; import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; @@ -329,6 +331,7 @@ public final class BeanWrapperTests { TestBean tb = new TestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, new PropertyEditorSupport() { + @Override public void setValue(Object value) { super.setValue(value.toString()); } @@ -500,6 +503,7 @@ public final class BeanWrapperTests { PropsTester pt = new PropsTester(); BeanWrapper bw = new BeanWrapperImpl(pt); bw.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() { + @Override public void setAsText(String text) { setValue(text.substring(1)); } @@ -559,6 +563,7 @@ public final class BeanWrapperTests { TestBean tb = new TestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() { + @Override public void setValue(Object value) { if (value instanceof String[]) { setValue(StringUtils.arrayToDelimitedString(((String[]) value), "-")); @@ -636,6 +641,7 @@ public final class BeanWrapperTests { PropsTester pt = new PropsTester(); BeanWrapper bw = new BeanWrapperImpl(pt); bw.registerCustomEditor(int.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) { setValue(new Integer(Integer.parseInt(text) + 1)); } @@ -995,15 +1001,15 @@ public final class BeanWrapperTests { bw.setPropertyValues(pvs); assertEquals(tb5, bean.getArray()[0]); assertEquals(tb4, bean.getArray()[1]); - assertEquals(tb3, ((TestBean) bean.getList().get(0))); - assertEquals(tb2, ((TestBean) bean.getList().get(1))); - assertEquals(tb0, ((TestBean) bean.getList().get(2))); - assertEquals(null, ((TestBean) bean.getList().get(3))); - assertEquals(tb1, ((TestBean) bean.getList().get(4))); - assertEquals(tb1, ((TestBean) bean.getMap().get("key1"))); - assertEquals(tb0, ((TestBean) bean.getMap().get("key2"))); - assertEquals(tb4, ((TestBean) bean.getMap().get("key5"))); - assertEquals(tb5, ((TestBean) bean.getMap().get("key9"))); + assertEquals(tb3, (bean.getList().get(0))); + assertEquals(tb2, (bean.getList().get(1))); + assertEquals(tb0, (bean.getList().get(2))); + assertEquals(null, (bean.getList().get(3))); + assertEquals(tb1, (bean.getList().get(4))); + assertEquals(tb1, (bean.getMap().get("key1"))); + assertEquals(tb0, (bean.getMap().get("key2"))); + assertEquals(tb4, (bean.getMap().get("key5"))); + assertEquals(tb5, (bean.getMap().get("key9"))); assertEquals(tb5, bw.getPropertyValue("array[0]")); assertEquals(tb4, bw.getPropertyValue("array[1]")); assertEquals(tb3, bw.getPropertyValue("list[0]")); @@ -1022,6 +1028,7 @@ public final class BeanWrapperTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasLength(text)) { throw new IllegalArgumentException(); @@ -1055,6 +1062,7 @@ public final class BeanWrapperTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasLength(text)) { throw new IllegalArgumentException(); @@ -1078,6 +1086,7 @@ public final class BeanWrapperTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasLength(text)) { throw new IllegalArgumentException(); @@ -1132,10 +1141,8 @@ public final class BeanWrapperTests { @Test public void testLargeMatchingPrimitiveArray() { - if (LogFactory.getLog(BeanWrapperTests.class).isTraceEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(LogFactory.getLog(BeanWrapperTests.class)); PrimitiveArrayBean tb = new PrimitiveArrayBean(); BeanWrapper bw = new BeanWrapperImpl(tb); @@ -1191,6 +1198,7 @@ public final class BeanWrapperTests { PrimitiveArrayBean tb = new PrimitiveArrayBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(int.class, "array", new PropertyEditorSupport() { + @Override public void setValue(Object value) { if (value instanceof Integer) { super.setValue(new Integer(((Integer) value).intValue() + 1)); @@ -1209,6 +1217,7 @@ public final class BeanWrapperTests { PrimitiveArrayBean tb = new PrimitiveArrayBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(int.class, "array[1]", new PropertyEditorSupport() { + @Override public void setValue(Object value) { if (value instanceof Integer) { super.setValue(new Integer(((Integer) value).intValue() + 1)); @@ -1821,6 +1830,7 @@ public final class BeanWrapperTests { this.frozen = true; } + @Override public V put(K key, V value) { if (this.frozen) { throw new UnsupportedOperationException(); @@ -1830,16 +1840,19 @@ public final class BeanWrapperTests { } } + @Override public Set> entrySet() { this.accessed = true; return super.entrySet(); } + @Override public Set keySet() { this.accessed = true; return super.keySet(); } + @Override public int size() { this.accessed = true; return super.size(); @@ -1851,6 +1864,7 @@ public final class BeanWrapperTests { } + @SuppressWarnings("serial") public static class TypedReadOnlyMap extends ReadOnlyMap { public TypedReadOnlyMap() { diff --git a/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java index 4866cc101b..95c3fbb8cc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ public final class ConcurrentBeanWrapperTests { performSet(); } } - + @Test public void testConcurrent() { for (int i = 0; i < 10; i++) { @@ -115,6 +115,7 @@ public final class ConcurrentBeanWrapperTests { this.test = test; } + @Override public void run() { try { for (int i = 0; i < 100; i++) { diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index b0343230e8..788ee5c85c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -215,6 +215,7 @@ public class ExtendedBeanInfoTests { @Test public void cornerSpr9453() throws IntrospectionException { final class Bean implements Spr9453> { + @Override public Class getProp() { return null; } @@ -604,7 +605,9 @@ public class ExtendedBeanInfoTests { public Number setFoo(String foo) { return null; } } class C extends B { + @Override public String getFoo() { return null; } + @Override public Integer setFoo(String foo) { return null; } } @@ -876,6 +879,7 @@ public class ExtendedBeanInfoTests { } interface TextBookOperations extends BookOperations { + @Override TextBook getBook(); } @@ -885,6 +889,7 @@ public class ExtendedBeanInfoTests { } class LawLibrary extends Library implements TextBookOperations { + @Override public LawBook getBook() { return null; } } diff --git a/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java b/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java index 8eeb96e36c..bc53e02ae2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public final class MutablePropertyValuesTests extends AbstractPropertyValuesTest pvs.addPropertyValue(new PropertyValue("surname", "Blair")); pvs.addPropertyValue(new PropertyValue("age", "50")); doTestTony(pvs); - + MutablePropertyValues deepCopy = new MutablePropertyValues(pvs); doTestTony(deepCopy); deepCopy.setPropertyValueAt(new PropertyValue("name", "Gordon"), 0); diff --git a/spring-beans/src/test/java/org/springframework/beans/annotation/RequiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/annotation/RequiredAnnotationBeanPostProcessorTests.java index dd52eea7b8..7c728a55a2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/annotation/RequiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/annotation/RequiredAnnotationBeanPostProcessorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -182,10 +182,12 @@ class RequiredTestBean implements BeanNameAware, BeanFactoryAware { this.jobTitle = jobTitle; } + @Override @Required public void setBeanName(String name) { } + @Override @Required public void setBeanFactory(BeanFactory beanFactory) { } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index 4094dd3974..636fbda545 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -45,12 +45,12 @@ import static test.util.TestResourceUtils.qualifiedResource; * @since 04.07.2003 */ public final class BeanFactoryUtilsTests { - + private static final Class CLASS = BeanFactoryUtilsTests.class; - private static final Resource ROOT_CONTEXT = qualifiedResource(CLASS, "root.xml"); - private static final Resource MIDDLE_CONTEXT = qualifiedResource(CLASS, "middle.xml"); - private static final Resource LEAF_CONTEXT = qualifiedResource(CLASS, "leaf.xml"); - private static final Resource DEPENDENT_BEANS_CONTEXT = qualifiedResource(CLASS, "dependentBeans.xml"); + private static final Resource ROOT_CONTEXT = qualifiedResource(CLASS, "root.xml"); + private static final Resource MIDDLE_CONTEXT = qualifiedResource(CLASS, "middle.xml"); + private static final Resource LEAF_CONTEXT = qualifiedResource(CLASS, "leaf.xml"); + private static final Resource DEPENDENT_BEANS_CONTEXT = qualifiedResource(CLASS, "dependentBeans.xml"); private ConfigurableListableBeanFactory listableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java index 563b56fca8..967cd5d2b8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public final class ConcurrentBeanFactoryTests { private static final Log logger = LogFactory.getLog(ConcurrentBeanFactoryTests.class); private static final Resource CONTEXT = qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml"); - + private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd"); private static final Date DATE_1, DATE_2; @@ -72,6 +72,7 @@ public final class ConcurrentBeanFactoryTests { public void setUp() throws Exception { XmlBeanFactory factory = new XmlBeanFactory(CONTEXT); factory.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Date.class, new CustomDateEditor((DateFormat) DATE_FORMAT.clone(), false)); } @@ -125,6 +126,7 @@ public final class ConcurrentBeanFactoryTests { private class TestRun extends Thread { + @Override public void run() { try { for (int i = 0; i < 10000; i++) { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 1acfc0a504..35f3420ca0 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -72,6 +72,8 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.xml.ConstructorDependenciesBean; import org.springframework.beans.factory.xml.DependenciesBean; import org.springframework.beans.propertyeditors.CustomNumberEditor; +import org.springframework.build.junit.Assume; +import org.springframework.build.junit.TestGroup; import org.springframework.core.MethodParameter; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.support.DefaultConversionService; @@ -497,7 +499,7 @@ public class DefaultListableBeanFactoryTests { int count = (new PropertiesBeanDefinitionReader(lbf)).registerBeanDefinitions(p, PREFIX); assertTrue("2 beans registered, not " + count, count == 2); - TestBean kerry = (TestBean) lbf.getBean("kerry", TestBean.class); + TestBean kerry = lbf.getBean("kerry", TestBean.class); assertTrue("Kerry name is Kerry", "Kerry".equals(kerry.getName())); ITestBean spouse = kerry.getSpouse(); assertTrue("Kerry spouse is non null", spouse != null); @@ -516,7 +518,7 @@ public class DefaultListableBeanFactoryTests { assertTrue("1 beans registered, not " + count, count == 1); assertEquals(1, lbf.getBeanDefinitionCount()); - TestBean tb = (TestBean) lbf.getBean("tb", TestBean.class); + TestBean tb = lbf.getBean("tb", TestBean.class); assertEquals("my.value", tb.getSomeMap().get("my.key")); } @@ -836,6 +838,7 @@ public class DefaultListableBeanFactoryTests { public void testCustomEditor() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true)); @@ -853,6 +856,7 @@ public class DefaultListableBeanFactoryTests { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); GenericConversionService conversionService = new DefaultConversionService(); conversionService.addConverter(new Converter() { + @Override public Float convert(String source) { try { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); @@ -875,6 +879,7 @@ public class DefaultListableBeanFactoryTests { public void testCustomEditorWithBeanReference() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN); registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true)); @@ -1310,7 +1315,7 @@ public class DefaultListableBeanFactoryTests { * Verifies that a dependency on a {@link FactoryBean} can not * be autowired by name, as & is an illegal character in * Java method names. In other words, you can't name a method - * set&FactoryBean(...). + * {@code set&FactoryBean(...)}. */ @Test(expected=TypeMismatchException.class) public void testAutowireBeanWithFactoryBeanByName() { @@ -1690,10 +1695,8 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeCreationIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1710,10 +1713,8 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeCreationWithDependencyCheckIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1756,10 +1757,8 @@ public class DefaultListableBeanFactoryTests { @Test @Ignore // TODO re-enable when ConstructorResolver TODO sorted out public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1806,10 +1805,8 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1830,10 +1827,8 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeCreationWithPropertiesIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1879,10 +1874,8 @@ public class DefaultListableBeanFactoryTests { */ @Test public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() { - if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { - // Skip this test: Trace logging blows the time limit. - return; - } + Assume.group(TestGroup.PERFORMANCE); + Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); @@ -1907,9 +1900,11 @@ public class DefaultListableBeanFactoryTests { RootBeanDefinition bd = new RootBeanDefinition(BeanWithDisposableBean.class); lbf.registerBeanDefinition("test", bd); lbf.addBeanPostProcessor(new BeanPostProcessor() { + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return new TestBean(); } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { return bean; } @@ -1926,9 +1921,11 @@ public class DefaultListableBeanFactoryTests { RootBeanDefinition bd = new RootBeanDefinition(BeanWithCloseable.class); lbf.registerBeanDefinition("test", bd); lbf.addBeanPostProcessor(new BeanPostProcessor() { + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return new TestBean(); } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { return bean; } @@ -1946,9 +1943,11 @@ public class DefaultListableBeanFactoryTests { bd.setDestroyMethodName("close"); lbf.registerBeanDefinition("test", bd); lbf.addBeanPostProcessor(new BeanPostProcessor() { + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return new TestBean(); } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { return bean; } @@ -2117,6 +2116,7 @@ public class DefaultListableBeanFactoryTests { lbf.registerBeanDefinition("test", bd); final String nameSetOnField = "nameSetOnField"; lbf.addBeanPostProcessor(new InstantiationAwareBeanPostProcessorAdapter() { + @Override public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { TestBean tb = (TestBean) bean; try { @@ -2156,6 +2156,7 @@ public class DefaultListableBeanFactoryTests { TestSecuredBean bean = (TestSecuredBean) Subject.doAsPrivileged(subject, new PrivilegedAction() { + @Override public Object run() { return lbf.getBean("test"); } @@ -2189,6 +2190,7 @@ public class DefaultListableBeanFactoryTests { */ @Test(timeout=1000) public void testByTypeLookupIsFastEnough() { + Assume.group(TestGroup.PERFORMANCE); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); for (int i = 0; i < 1000; i++) { @@ -2244,14 +2246,17 @@ public class DefaultListableBeanFactoryTests { public ConstructorDependencyFactoryBean(String dependency) { } + @Override public Object getObject() { return "test"; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } @@ -2262,6 +2267,7 @@ public class DefaultListableBeanFactoryTests { private static boolean closed; + @Override public void destroy() { closed = true; } @@ -2272,6 +2278,7 @@ public class DefaultListableBeanFactoryTests { private static boolean closed; + @Override public void close() { closed = true; } @@ -2316,14 +2323,17 @@ public class DefaultListableBeanFactoryTests { public static class FactoryBeanThatShouldntBeCalled implements FactoryBean { + @Override public Object getObject() { throw new IllegalStateException(); } + @Override public Class getObjectType() { return null; } + @Override public boolean isSingleton() { return false; } @@ -2334,15 +2344,18 @@ public class DefaultListableBeanFactoryTests { public boolean initialized = false; + @Override public Object getObject() throws Exception { this.initialized = true; return ""; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } @@ -2353,23 +2366,28 @@ public class DefaultListableBeanFactoryTests { public boolean initialized = false; + @Override public Object getObject() throws Exception { this.initialized = true; return ""; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } + @Override public boolean isPrototype() { return false; } + @Override public boolean isEagerInit() { return true; } @@ -2452,6 +2470,7 @@ public class DefaultListableBeanFactoryTests { this.numberFormat = numberFormat; } + @Override @SuppressWarnings("unchecked") public Object convertIfNecessary(Object value, Class requiredType) { if (value instanceof String && Float.class.isAssignableFrom(requiredType)) { @@ -2470,11 +2489,13 @@ public class DefaultListableBeanFactoryTests { } } + @Override @SuppressWarnings("unchecked") public Object convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam) { return convertIfNecessary(value, requiredType); } + @Override @SuppressWarnings("unchecked") public Object convertIfNecessary(Object value, Class requiredType, Field field) { return convertIfNecessary(value, requiredType); @@ -2490,6 +2511,7 @@ public class DefaultListableBeanFactoryTests { this.name = name; } + @Override public String getName() { return this.name; } @@ -2539,38 +2561,38 @@ public class DefaultListableBeanFactoryTests { return this.userName; } } - + /** * Bean that changes state on a business invocation, so that * we can check whether it's been invoked * @author Rod Johnson */ private static class SideEffectBean { - + private int count; - + public void setCount(int count) { this.count = count; } - + public int getCount() { return this.count; } - + public void doWork() { ++count; } } - + private static class KnowsIfInstantiated { - + private static boolean instantiated; - + public static void clearInstantiationRecord() { instantiated = false; } - + public static boolean wasInstantiated() { return instantiated; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java index 127b162110..3f7e69e4f4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,31 +40,31 @@ public class FactoryBeanLookupTests { beanFactory = new XmlBeanFactory( new ClassPathResource("FactoryBeanLookupTests-context.xml", this.getClass())); } - + @Test public void factoryBeanLookupByNameDereferencing() { Object fooFactory = beanFactory.getBean("&fooFactory"); assertThat(fooFactory, instanceOf(FooFactoryBean.class)); } - + @Test public void factoryBeanLookupByType() { FooFactoryBean fooFactory = beanFactory.getBean(FooFactoryBean.class); assertNotNull(fooFactory); } - + @Test public void factoryBeanLookupByTypeAndNameDereference() { FooFactoryBean fooFactory = beanFactory.getBean("&fooFactory", FooFactoryBean.class); assertNotNull(fooFactory); } - + @Test public void factoryBeanObjectLookupByName() { Object fooFactory = beanFactory.getBean("fooFactory"); assertThat(fooFactory, instanceOf(Foo.class)); } - + @Test public void factoryBeanObjectLookupByNameAndType() { Foo foo = beanFactory.getBean("fooFactory", Foo.class); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java index 9d1123fe1c..0a50c2e617 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,9 +33,9 @@ import org.springframework.util.Assert; public final class FactoryBeanTests { private static final Class CLASS = FactoryBeanTests.class; - private static final Resource RETURNS_NULL_CONTEXT = qualifiedResource(CLASS, "returnsNull.xml"); - private static final Resource WITH_AUTOWIRING_CONTEXT = qualifiedResource(CLASS, "withAutowiring.xml"); - + private static final Resource RETURNS_NULL_CONTEXT = qualifiedResource(CLASS, "returnsNull.xml"); + private static final Resource WITH_AUTOWIRING_CONTEXT = qualifiedResource(CLASS, "withAutowiring.xml"); + @Test public void testFactoryBeanReturnsNull() throws Exception { XmlBeanFactory factory = new XmlBeanFactory(RETURNS_NULL_CONTEXT); @@ -46,10 +46,10 @@ public final class FactoryBeanTests { @Test public void testFactoryBeansWithAutowiring() throws Exception { XmlBeanFactory factory = new XmlBeanFactory(WITH_AUTOWIRING_CONTEXT); - + BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer"); ppc.postProcessBeanFactory(factory); - + Alpha alpha = (Alpha) factory.getBean("alpha"); Beta beta = (Beta) factory.getBean("beta"); Gamma gamma = (Gamma) factory.getBean("gamma"); @@ -63,10 +63,10 @@ public final class FactoryBeanTests { @Test public void testFactoryBeansWithIntermediateFactoryBeanAutowiringFailure() throws Exception { XmlBeanFactory factory = new XmlBeanFactory(WITH_AUTOWIRING_CONTEXT); - + BeanFactoryPostProcessor ppc = (BeanFactoryPostProcessor) factory.getBean("propertyPlaceholderConfigurer"); ppc.postProcessBeanFactory(factory); - + Beta beta = (Beta) factory.getBean("beta"); Alpha alpha = (Alpha) factory.getBean("alpha"); Gamma gamma = (Gamma) factory.getBean("gamma"); @@ -77,14 +77,17 @@ public final class FactoryBeanTests { public static class NullReturningFactoryBean implements FactoryBean { + @Override public Object getObject() { return null; } + @Override public Class getObjectType() { return null; } + @Override public boolean isSingleton() { return true; } @@ -103,6 +106,7 @@ public final class FactoryBeanTests { return beta; } + @Override public void afterPropertiesSet() { Assert.notNull(beta, "'beta' property is required"); } @@ -131,6 +135,7 @@ public final class FactoryBeanTests { return name; } + @Override public void afterPropertiesSet() { Assert.notNull(gamma, "'gamma' property is required"); } @@ -149,14 +154,17 @@ public final class FactoryBeanTests { this.beta = beta; } + @Override public Object getObject() { return this.beta; } + @Override public Class getObjectType() { return null; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/SharedBeanRegistryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/SharedBeanRegistryTests.java index 15dd2bcf93..c5f365f799 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/SharedBeanRegistryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/SharedBeanRegistryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ public final class SharedBeanRegistryTests { assertSame(tb, beanRegistry.getSingleton("tb")); TestBean tb2 = (TestBean) beanRegistry.getSingleton("tb2", new ObjectFactory() { + @Override public Object getObject() throws BeansException { return new TestBean(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java index ff63ff84d5..460559b068 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocatorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ import org.springframework.util.ClassUtils; /** * Unit tests for {@link SingletonBeanFactoryLocator}. - * + * * @author Colin Sampaleanu * @author Chris Beams */ -public final class SingletonBeanFactoryLocatorTests { +public class SingletonBeanFactoryLocatorTests { private static final Class CLASS = SingletonBeanFactoryLocatorTests.class; private static final String REF1_XML = CLASS.getSimpleName() + "-ref1.xml"; @@ -38,7 +38,7 @@ public final class SingletonBeanFactoryLocatorTests { public void testBasicFunctionality() { SingletonBeanFactoryLocator facLoc = new SingletonBeanFactoryLocator( "classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML)); - + basicFunctionalityTest(facLoc); } @@ -81,7 +81,7 @@ public final class SingletonBeanFactoryLocatorTests { BeanFactoryLocator facLoc = SingletonBeanFactoryLocator.getInstance( ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML)); getInstanceTest1(facLoc); - + facLoc = SingletonBeanFactoryLocator.getInstance( "classpath*:/" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML)); getInstanceTest2(facLoc); @@ -90,7 +90,7 @@ public final class SingletonBeanFactoryLocatorTests { facLoc = SingletonBeanFactoryLocator.getInstance( "classpath:" + ClassUtils.addResourcePathToPackagePath(CLASS, REF1_XML)); getInstanceTest3(facLoc); - + } /** @@ -109,12 +109,12 @@ public final class SingletonBeanFactoryLocatorTests { fac = bfr3.getFactory(); tb = (TestBean) fac.getBean("beans1.bean1"); assertTrue(tb.getName().equals("was beans1.bean1")); - + BeanFactoryReference bfr4 = facLoc.useBeanFactory("a.qualified.name.which.is.an.alias"); fac = bfr4.getFactory(); tb = (TestBean) fac.getBean("beans1.bean1"); assertTrue(tb.getName().equals("was beans1.bean1")); - + bfr.release(); bfr3.release(); bfr2.release(); @@ -152,7 +152,7 @@ public final class SingletonBeanFactoryLocatorTests { bfr4.release(); bfr3.release(); } - + /** * Worker method so subclass can use it too */ diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 0e798b9e41..9df0cbc309 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -45,7 +45,7 @@ import static org.junit.Assert.*; /** * Unit tests for {@link AutowiredAnnotationBeanPostProcessor}. - * + * * @author Juergen Hoeller * @author Mark Fisher * @author Sam Brannen @@ -989,6 +989,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests { public ExtendedResourceInjectionBean() { } + @Override @Autowired @Required public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -1068,6 +1069,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests { private ITestBean testBean4; + @Override @Autowired(required = false) public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -1114,6 +1116,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests { private ITestBean testBean4; + @Override @Autowired(required = false) public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -1185,6 +1188,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests { throw new UnsupportedOperationException(); } + @Override @Autowired public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -1346,6 +1350,7 @@ public final class AutowiredAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryInjectionBean implements Serializable { @Autowired @@ -1446,14 +1451,17 @@ public final class AutowiredAnnotationBeanPostProcessorTests { public static class StringFactoryBean implements FactoryBean { + @Override public String getObject() throws Exception { return ""; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java index 6beb38ada1..f9295e4ee6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.core.io.Resource; /** * Unit tests for {@link CustomAutowireConfigurer}. - * + * * @author Mark Fisher * @author Juergen Hoeller * @author Chris Beams @@ -69,6 +69,7 @@ public final class CustomAutowireConfigurerTests { public static class CustomResolver implements AutowireCandidateResolver { + @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { if (!bdHolder.getBeanDefinition().isAutowireCandidate()) { return false; @@ -82,6 +83,7 @@ public final class CustomAutowireConfigurerTests { return false; } + @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { return null; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index 7ef18579bf..9760821441 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -609,6 +609,7 @@ public class InjectAnnotationBeanPostProcessorTests { public ExtendedResourceInjectionBean() { } + @Override @Inject @Required public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -662,6 +663,7 @@ public class InjectAnnotationBeanPostProcessorTests { private ITestBean testBean4; + @Override @Inject public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -708,6 +710,7 @@ public class InjectAnnotationBeanPostProcessorTests { private ITestBean testBean4; + @Override @Inject public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -779,6 +782,7 @@ public class InjectAnnotationBeanPostProcessorTests { throw new UnsupportedOperationException(); } + @Override @Inject public void setTestBean2(TestBean testBean2) { super.setTestBean2(testBean2); @@ -938,6 +942,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryFieldInjectionBean implements Serializable { @Inject @@ -949,6 +954,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryMethodInjectionBean implements Serializable { private Provider testBeanFactory; @@ -992,6 +998,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryListFieldInjectionBean implements Serializable { @Inject @@ -1007,6 +1014,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryListMethodInjectionBean implements Serializable { private Provider> testBeanFactory; @@ -1022,6 +1030,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryMapFieldInjectionBean implements Serializable { @Inject @@ -1037,6 +1046,7 @@ public class InjectAnnotationBeanPostProcessorTests { } + @SuppressWarnings("serial") public static class ObjectFactoryMapMethodInjectionBean implements Serializable { private Provider> testBeanFactory; @@ -1068,14 +1078,17 @@ public class InjectAnnotationBeanPostProcessorTests { public static class StringFactoryBean implements FactoryBean { + @Override public String getObject() throws Exception { return ""; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java index c7870b3236..6691e2401f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import org.springframework.beans.propertyeditors.CustomDateEditor; /** * Unit tests for {@link CustomEditorConfigurer}. - * + * * @author Juergen Hoeller * @author Chris Beams * @since 31.07.2004 @@ -53,6 +53,7 @@ public final class CustomEditorConfigurerTests { final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN); cec.setPropertyEditorRegistrars(new PropertyEditorRegistrar[] { new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Date.class, new CustomDateEditor(df, true)); } @@ -189,6 +190,7 @@ public final class CustomEditorConfigurerTests { public static class MyTestEditor extends PropertyEditorSupport { + @Override public void setAsText(String text) { setValue(new String[] {"test"}); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java index 0e31d83c10..65e6debd15 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.beans.factory.config; -import static org.easymock.EasyMock.*; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; import java.util.HashMap; import java.util.Map; @@ -45,24 +45,20 @@ public final class CustomScopeConfigurerTests { @Test public void testWithNoScopes() throws Exception { - Scope scope = createMock(Scope.class); - replay(scope); + Scope scope = mock(Scope.class); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.postProcessBeanFactory(factory); - verify(scope); } @Test public void testSunnyDayWithBonaFideScopeInstance() throws Exception { - Scope scope = createMock(Scope.class); - replay(scope); + Scope scope = mock(Scope.class); factory.registerScope(FOO_SCOPE, scope); Map scopes = new HashMap(); scopes.put(FOO_SCOPE, scope); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); figurer.postProcessBeanFactory(factory); - verify(scope); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index 29aa612110..d5569c3fd3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,13 +30,13 @@ import test.beans.TestBean; /** * Unit tests for {@link FieldRetrievingFactoryBean}. - * + * * @author Juergen Hoeller * @author Chris Beams * @since 31.07.2004 */ public final class FieldRetrievingFactoryBeanTests { - + private static final Resource CONTEXT = qualifiedResource(FieldRetrievingFactoryBeanTests.class, "context.xml"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java index bd11117a4a..a35b1e2948 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.util.MethodInvoker; /** * Unit tests for {@link MethodInvokingFactoryBean}. - * + * * @author Colin Sampaleanu * @author Juergen Hoeller * @author Chris Beams diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java index 41c9ce811f..8b1a7079c7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,9 +19,11 @@ package org.springframework.beans.factory.config; import java.util.Date; import javax.inject.Provider; -import static org.easymock.EasyMock.*; import org.junit.After; import static org.junit.Assert.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; + import org.junit.Before; import org.junit.Test; import static test.util.TestResourceUtils.*; @@ -42,7 +44,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { private static final Resource CONTEXT = qualifiedResource(ObjectFactoryCreatingFactoryBeanTests.class, "context.xml"); - + private XmlBeanFactory beanFactory; @Before @@ -105,19 +107,16 @@ public class ObjectFactoryCreatingFactoryBeanTests { final String targetBeanName = "singleton"; final String expectedSingleton = "Alicia Keys"; - BeanFactory beanFactory = createMock(BeanFactory.class); - expect(beanFactory.getBean(targetBeanName)).andReturn(expectedSingleton); - replay(beanFactory); + BeanFactory beanFactory = mock(BeanFactory.class); + given(beanFactory.getBean(targetBeanName)).willReturn(expectedSingleton); ObjectFactoryCreatingFactoryBean factory = new ObjectFactoryCreatingFactoryBean(); factory.setTargetBeanName(targetBeanName); factory.setBeanFactory(beanFactory); factory.afterPropertiesSet(); - ObjectFactory objectFactory = (ObjectFactory) factory.getObject(); + ObjectFactory objectFactory = factory.getObject(); Object actualSingleton = objectFactory.getObject(); assertSame(expectedSingleton, actualSingleton); - - verify(beanFactory); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java index ca972f349a..409e3f8325 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,13 +26,13 @@ import org.springframework.core.io.Resource; /** * Unit tests for {@link PropertiesFactoryBean}. - * + * * @author Juergen Hoeller * @author Chris Beams * @since 01.11.2003 */ public final class PropertiesFactoryBeanTests { - + private static final Class CLASS = PropertiesFactoryBeanTests.class; private static final Resource TEST_PROPS = qualifiedResource(CLASS, "test.properties"); private static final Resource TEST_PROPS_XML = qualifiedResource(CLASS, "test.properties.xml"); @@ -42,7 +42,7 @@ public final class PropertiesFactoryBeanTests { PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(TEST_PROPS); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("99", props.getProperty("tb.array[0].age")); } @@ -51,7 +51,7 @@ public final class PropertiesFactoryBeanTests { PropertiesFactoryBean pfb = new PropertiesFactoryBean(); pfb.setLocation(TEST_PROPS_XML); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("99", props.getProperty("tb.array[0].age")); } @@ -62,7 +62,7 @@ public final class PropertiesFactoryBeanTests { localProps.setProperty("key2", "value2"); pfb.setProperties(localProps); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("value2", props.getProperty("key2")); } @@ -75,7 +75,7 @@ public final class PropertiesFactoryBeanTests { localProps.setProperty("tb.array[0].age", "0"); pfb.setProperties(localProps); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("99", props.getProperty("tb.array[0].age")); assertEquals("value2", props.getProperty("key2")); } @@ -100,7 +100,7 @@ public final class PropertiesFactoryBeanTests { pfb.setPropertiesArray(new Properties[] {props1, props2, props3}); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("99", props.getProperty("tb.array[0].age")); assertEquals("value2", props.getProperty("key2")); assertEquals("framework", props.getProperty("spring")); @@ -119,7 +119,7 @@ public final class PropertiesFactoryBeanTests { pfb.setProperties(localProps); pfb.setLocalOverride(true); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("0", props.getProperty("tb.array[0].age")); assertEquals("value2", props.getProperty("key2")); } @@ -133,10 +133,10 @@ public final class PropertiesFactoryBeanTests { localProps.setProperty("key2", "value2"); pfb.setProperties(localProps); pfb.afterPropertiesSet(); - Properties props = (Properties) pfb.getObject(); + Properties props = pfb.getObject(); assertEquals("99", props.getProperty("tb.array[0].age")); assertEquals("value2", props.getProperty("key2")); - Properties newProps = (Properties) pfb.getObject(); + Properties newProps = pfb.getObject(); assertTrue(props != newProps); assertEquals("99", newProps.getProperty("tb.array[0].age")); assertEquals("value2", newProps.getProperty("key2")); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index fd3891bf99..73daf724a3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ import test.beans.TestBean; /** * Unit tests for {@link PropertyPathFactoryBean}. - * + * * @author Juergen Hoeller * @author Chris Beams * @since 04.10.2004 */ public class PropertyPathFactoryBeanTests { - + private static final Resource CONTEXT = qualifiedResource(PropertyPathFactoryBeanTests.class, "context.xml"); @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 1f080734bc..931dd10e8e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -812,6 +812,7 @@ public final class PropertyResourceConfigurerTests { private static class ConvertingOverrideConfigurer extends PropertyOverrideConfigurer { + @Override protected String convertPropertyValue(String originalValue) { return "X" + originalValue; } @@ -826,10 +827,12 @@ public final class PropertyResourceConfigurerTests { private Preferences userRoot = new MockPreferences(); + @Override public Preferences systemRoot() { return systemRoot; } + @Override public Preferences userRoot() { return userRoot; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java index afb273a5b5..f7ab438e76 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.springframework.beans.factory.config; -import static org.easymock.EasyMock.*; import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition; import org.junit.Before; @@ -32,7 +32,7 @@ import org.springframework.core.NestedRuntimeException; /** * Unit tests for {@link ServiceLocatorFactoryBean}. - * + * * @author Colin Sampaleanu * @author Rick Evans * @author Chris Beams @@ -40,7 +40,7 @@ import org.springframework.core.NestedRuntimeException; public final class ServiceLocatorFactoryBeanTests { private DefaultListableBeanFactory bf; - + @Before public void setUp() { bf = new DefaultListableBeanFactory(); @@ -53,7 +53,7 @@ public final class ServiceLocatorFactoryBeanTests { genericBeanDefinition(ServiceLocatorFactoryBean.class) .addPropertyValue("serviceLocatorInterface", TestServiceLocator.class) .getBeanDefinition()); - + TestServiceLocator factory = (TestServiceLocator) bf.getBean("factory"); TestService testService = factory.getTestService(); assertNotNull(testService); @@ -75,13 +75,13 @@ public final class ServiceLocatorFactoryBeanTests { genericBeanDefinition(ServiceLocatorFactoryBean.class) .addPropertyValue("serviceLocatorInterface", TestService2Locator.class) .getBeanDefinition()); - + try { TestServiceLocator factory = (TestServiceLocator) bf.getBean("factory"); factory.getTestService(); fail("Must fail on more than one matching type"); } catch (NoSuchBeanDefinitionException ex) { /* expected */ } - + try { TestServiceLocator2 factory = (TestServiceLocator2) bf.getBean("factory2"); factory.getTestService(null); @@ -114,7 +114,7 @@ public final class ServiceLocatorFactoryBeanTests { .addPropertyValue("serviceLocatorInterface", TestService2Locator.class) .addPropertyValue("serviceLocatorExceptionClass", CustomServiceLocatorException3.class) .getBeanDefinition()); - + try { TestServiceLocator factory = (TestServiceLocator) bf.getBean("factory"); factory.getTestService(); @@ -123,7 +123,7 @@ public final class ServiceLocatorFactoryBeanTests { catch (CustomServiceLocatorException1 expected) { assertTrue(expected.getCause() instanceof NoSuchBeanDefinitionException); } - + try { TestServiceLocator2 factory2 = (TestServiceLocator2) bf.getBean("factory2"); factory2.getTestService(null); @@ -132,7 +132,7 @@ public final class ServiceLocatorFactoryBeanTests { catch (CustomServiceLocatorException2 expected) { assertTrue(expected.getCause() instanceof NoSuchBeanDefinitionException); } - + try { TestService2Locator factory3 = (TestService2Locator) bf.getBean("factory3"); factory3.getTestService(); @@ -150,7 +150,7 @@ public final class ServiceLocatorFactoryBeanTests { // test string-arg getter with null id TestServiceLocator2 factory = (TestServiceLocator2) bf.getBean("factory"); - + @SuppressWarnings("unused") TestService testBean = factory.getTestService(null); // now test with explicit id @@ -166,12 +166,12 @@ public final class ServiceLocatorFactoryBeanTests { public void testCombinedLocatorInterface() { bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition()); bf.registerAlias("testService", "1"); - + bf.registerBeanDefinition("factory", genericBeanDefinition(ServiceLocatorFactoryBean.class) .addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class) .getBeanDefinition()); - + // StaticApplicationContext ctx = new StaticApplicationContext(); // ctx.registerPrototype("testService", TestService.class, new MutablePropertyValues()); // ctx.registerAlias("testService", "1"); @@ -204,7 +204,7 @@ public final class ServiceLocatorFactoryBeanTests { .addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class) .addPropertyValue("serviceMappings", "=testService1\n1=testService1\n2=testService2") .getBeanDefinition()); - + // StaticApplicationContext ctx = new StaticApplicationContext(); // ctx.registerPrototype("testService1", TestService.class, new MutablePropertyValues()); // ctx.registerPrototype("testService2", ExtendedTestService.class, new MutablePropertyValues()); @@ -269,17 +269,13 @@ public final class ServiceLocatorFactoryBeanTests { @Test public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception { - final BeanFactory beanFactory = createMock(BeanFactory.class); - replay(beanFactory); - + BeanFactory beanFactory = mock(BeanFactory.class); try { ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); factory.setBeanFactory(beanFactory); } catch (FatalBeanException ex) { // expected } - - verify(beanFactory); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index 6833092119..861cafa68d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,11 +39,11 @@ import test.beans.TestBean; * @author Chris Beams */ public final class SimpleScopeTests { - + private static final Resource CONTEXT = qualifiedResource(SimpleScopeTests.class, "context.xml"); private DefaultListableBeanFactory beanFactory; - + @Before public void setUp() { beanFactory = new DefaultListableBeanFactory(); @@ -53,6 +53,7 @@ public final class SimpleScopeTests { objects.add(new TestBean()); objects.add(new TestBean()); } + @Override public Object get(String name, ObjectFactory objectFactory) { if (index >= objects.size()) { index = 0; @@ -71,7 +72,7 @@ public final class SimpleScopeTests { XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(beanFactory); xbdr.loadBeanDefinitions(CONTEXT); } - + @Test public void testCanGetScopedObject() { TestBean tb1 = (TestBean) beanFactory.getBean("usesScope"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java index 2aec11ef71..e9ff4c6a31 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/TestTypes.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.ObjectFactory; /** * Shared test types for this package. - * + * * @author Chris Beams */ final class TestTypes {} @@ -30,21 +30,26 @@ final class TestTypes {} */ class NoOpScope implements Scope { + @Override public Object get(String name, ObjectFactory objectFactory) { throw new UnsupportedOperationException(); } + @Override public Object remove(String name) { throw new UnsupportedOperationException(); } + @Override public void registerDestructionCallback(String name, Runnable callback) { } + @Override public Object resolveContextualObject(String key) { return null; } + @Override public String getConversationId() { return null; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index 774fb0b5a8..82a35dc064 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import test.beans.TestBean; * @since 2.0 */ public final class CustomProblemReporterTests { - + private static final Resource CONTEXT = qualifiedResource(CustomProblemReporterTests.class, "context.xml"); private CollatingProblemReporter problemReporter; @@ -71,10 +71,12 @@ public final class CustomProblemReporterTests { private List warnings = new ArrayList(); + @Override public void fatal(Problem problem) { throw new BeanDefinitionParsingException(problem); } + @Override public void error(Problem problem) { System.out.println(problem); this.errors.add(problem); @@ -84,6 +86,7 @@ public final class CustomProblemReporterTests { return this.errors.toArray(new Problem[this.errors.size()]); } + @Override public void warning(Problem problem) { System.out.println(problem); this.warnings.add(problem); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java index 3ebe8ec705..622b7fda5d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,7 +16,10 @@ package org.springframework.beans.factory.parsing; -import static org.easymock.EasyMock.*; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import org.apache.commons.logging.Log; import org.junit.Test; @@ -41,15 +44,13 @@ public final class FailFastProblemReporterTests { Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException()); - Log log = createMock(Log.class); - log.warn(anyObject(), isA(IllegalArgumentException.class)); - replay(log); + Log log = mock(Log.class); FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.setLogger(log); reporter.warning(problem); - verify(log); + verify(log).warn(any(), isA(IllegalArgumentException.class)); } } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java index c8d5e9c1ec..fe85b49123 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.junit.Test; /** * Unit tests for {@link PassThroughSourceExtractor}. - * + * * @author Rick Evans * @author Chris Beams */ diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index be2cfdf297..2849614541 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -30,8 +30,9 @@ import java.util.Set; import static org.junit.Assert.*; -import org.easymock.EasyMock; import org.junit.Test; +import org.mockito.Mockito; + import test.beans.GenericBean; import test.beans.GenericIntegerBean; import test.beans.GenericSetOfIntegerBean; @@ -391,6 +392,7 @@ public class BeanFactoryGenericsTests { public void testGenericMapWithCollectionValueConstructor() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)); } @@ -547,6 +549,7 @@ public class BeanFactoryGenericsTests { public void testGenericMapWithCollectionValueFactoryMethod() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() { + @Override public void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)); } @@ -624,23 +627,23 @@ public class BeanFactoryGenericsTests { /** * Tests support for parameterized {@code factory-method} declarations such - * as EasyMock's {@code createMock()} method which has the following signature. + * as Mockito {@code mock()} method which has the following signature. * *
      {@code
      -	 * public static  T createMock(Class toMock)
      +	 * public static  T mock(Class classToMock)
       	 * }
      * + * See SPR-9493 * @since 3.2 - * @see SPR-9493 */ @Test public void parameterizedFactoryMethod() { - RootBeanDefinition rbd = new RootBeanDefinition(EasyMock.class); - rbd.setFactoryMethodName("createMock"); + RootBeanDefinition rbd = new RootBeanDefinition(Mockito.class); + rbd.setFactoryMethodName("mock"); rbd.getConstructorArgumentValues().addGenericArgumentValue(Runnable.class); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); - bf.registerBeanDefinition("easyMock", rbd); + bf.registerBeanDefinition("mock", rbd); Map beans = bf.getBeansOfType(Runnable.class); assertEquals(1, beans.size()); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java index 884b2bc232..2e4025d304 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import test.beans.TestBean; */ public class DefinitionMetadataEqualsHashCodeTests extends TestCase { + @SuppressWarnings("serial") public void testRootBeanDefinitionEqualsAndHashCode() throws Exception { RootBeanDefinition master = new RootBeanDefinition(TestBean.class); RootBeanDefinition equal = new RootBeanDefinition(TestBean.class); @@ -42,6 +43,7 @@ public class DefinitionMetadataEqualsHashCodeTests extends TestCase { assertEquals("Hash code for equal instances should match", master.hashCode(), equal.hashCode()); } + @SuppressWarnings("serial") public void testChildBeanDefinitionEqualsAndHashCode() throws Exception { ChildBeanDefinition master = new ChildBeanDefinition("foo"); ChildBeanDefinition equal = new ChildBeanDefinition("foo"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java index 9dc27c7f37..ee00efdec9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class ManagedListTests extends TestCase { ManagedList child = new ManagedList(); child.add("three"); child.setMergeEnabled(true); - List mergedList = (List) child.merge(parent); + List mergedList = child.merge(parent); assertEquals("merge() obviously did not work.", 3, mergedList.size()); } @@ -72,7 +72,7 @@ public class ManagedListTests extends TestCase { parent.add("two"); ManagedList child = new ManagedList(); child.setMergeEnabled(true); - List mergedList = (List) child.merge(parent); + List mergedList = child.merge(parent); assertEquals("merge() obviously did not work.", 2, mergedList.size()); } @@ -84,7 +84,7 @@ public class ManagedListTests extends TestCase { ManagedList child = new ManagedList(); child.add("one"); child.setMergeEnabled(true); - List mergedList = (List) child.merge(parent); + List mergedList = child.merge(parent); assertEquals("merge() obviously did not work.", 3, mergedList.size()); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java index 0eea409ab8..22972e96fd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class ManagedSetTests extends TestCase { ManagedSet child = new ManagedSet(); child.add("three"); child.setMergeEnabled(true); - Set mergedSet = (Set) child.merge(parent); + Set mergedSet = child.merge(parent); assertEquals("merge() obviously did not work.", 3, mergedSet.size()); } @@ -72,7 +72,7 @@ public class ManagedSetTests extends TestCase { parent.add("two"); ManagedSet child = new ManagedSet(); child.setMergeEnabled(true); - Set mergedSet = (Set) child.merge(parent); + Set mergedSet = child.merge(parent); assertEquals("merge() obviously did not work.", 2, mergedSet.size()); } @@ -84,7 +84,7 @@ public class ManagedSetTests extends TestCase { ManagedSet child = new ManagedSet(); child.add("one"); child.setMergeEnabled(true); - Set mergedSet = (Set) child.merge(parent); + Set mergedSet = child.merge(parent); assertEquals("merge() obviously did not work.", 2, mergedSet.size()); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java index 3442e720d4..51e8dd7012 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ public class PropertiesBeanDefinitionReaderTests extends TestCase { private PropertiesBeanDefinitionReader reader; + @Override protected void setUp() throws Exception { this.beanFactory = new DefaultListableBeanFactory(); this.reader = new PropertiesBeanDefinitionReader(beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java index b995560e5f..195ad77529 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -53,9 +53,9 @@ public class QualifierAnnotationAutowireBeanFactoryTests { RootBeanDefinition rbd = new RootBeanDefinition(Person.class, cavs, null); lbf.registerBeanDefinition(JUERGEN, rbd); assertTrue(lbf.isAutowireCandidate(JUERGEN, null)); - assertTrue(lbf.isAutowireCandidate(JUERGEN, + assertTrue(lbf.isAutowireCandidate(JUERGEN, new DependencyDescriptor(Person.class.getDeclaredField("name"), false))); - assertTrue(lbf.isAutowireCandidate(JUERGEN, + assertTrue(lbf.isAutowireCandidate(JUERGEN, new DependencyDescriptor(Person.class.getDeclaredField("name"), true))); } @@ -68,16 +68,16 @@ public class QualifierAnnotationAutowireBeanFactoryTests { rbd.setAutowireCandidate(false); lbf.registerBeanDefinition(JUERGEN, rbd); assertFalse(lbf.isAutowireCandidate(JUERGEN, null)); - assertFalse(lbf.isAutowireCandidate(JUERGEN, + assertFalse(lbf.isAutowireCandidate(JUERGEN, new DependencyDescriptor(Person.class.getDeclaredField("name"), false))); - assertFalse(lbf.isAutowireCandidate(JUERGEN, + assertFalse(lbf.isAutowireCandidate(JUERGEN, new DependencyDescriptor(Person.class.getDeclaredField("name"), true))); } @Ignore @Test public void testAutowireCandidateWithFieldDescriptor() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null); @@ -101,7 +101,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @Test public void testAutowireCandidateExplicitlyFalseWithFieldDescriptor() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null); @@ -119,7 +119,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @Test public void testAutowireCandidateWithShortClassName() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null); @@ -137,7 +137,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @Ignore @Test public void testAutowireCandidateWithConstructorDescriptor() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null); @@ -159,7 +159,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @Ignore @Test public void testAutowireCandidateWithMethodDescriptor() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null); @@ -189,7 +189,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { @Test public void testAutowireCandidateWithMultipleCandidatesDescriptor() throws Exception { - DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); + DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java index 0cd040b469..5c1368c461 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java @@ -61,14 +61,17 @@ public class Spr8954Tests { static class FooFactoryBean implements FactoryBean, AnInterface { + @Override public Foo getObject() throws Exception { return new Foo(); } + @Override public Class getObjectType() { return Foo.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index 497352028a..d4c80b410d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -1,12 +1,12 @@ /* * Copyright 2002-2012 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -63,11 +63,11 @@ import org.springframework.core.io.Resource; /** * Security test case. Checks whether the container uses its privileges for its * internal work but does not leak them when touching/calling user code. - * + * *t The first half of the test case checks that permissions are downgraded when * calling user code while the second half that the caller code permission get * through and Spring doesn't override the permission stack. - * + * * @author Costin Leau */ public class CallbacksSecurityTests { @@ -97,7 +97,7 @@ public class CallbacksSecurityTests { public void setProperty(Object value) { checkCurrentContext(); } - + public Object getProperty() { checkCurrentContext(); return null; @@ -111,7 +111,7 @@ public class CallbacksSecurityTests { checkCurrentContext(); return null; } - + private void checkCurrentContext() { assertEquals(expectedName, getCurrentSubjectName()); } @@ -129,23 +129,28 @@ public class CallbacksSecurityTests { checkCurrentContext(); } + @Override public void afterPropertiesSet() { checkCurrentContext(); } + @Override public void destroy() { checkCurrentContext(); destroyed = true; } + @Override public void setBeanName(String name) { checkCurrentContext(); } + @Override public void setBeanClassLoader(ClassLoader classLoader) { checkCurrentContext(); } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { checkCurrentContext(); @@ -164,26 +169,31 @@ public class CallbacksSecurityTests { checkCurrentContext(); } + @Override public boolean isEagerInit() { checkCurrentContext(); return false; } + @Override public boolean isPrototype() { checkCurrentContext(); return true; } + @Override public Object getObject() throws Exception { checkCurrentContext(); return new Object(); } + @Override public Class getObjectType() { checkCurrentContext(); return Object.class; } + @Override public boolean isSingleton() { checkCurrentContext(); return false; @@ -219,6 +229,7 @@ public class CallbacksSecurityTests { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public String run() { Subject subject = Subject.getSubject(acc); if (subject == null) { @@ -246,6 +257,7 @@ public class CallbacksSecurityTests { this.name = name; } + @Override public String getName() { return this.name; } @@ -291,6 +303,7 @@ public class CallbacksSecurityTests { private final AccessControlContext acc = new AccessControlContext( new ProtectionDomain[] { empty }); + @Override public AccessControlContext getAccessControlContext() { return acc; } @@ -314,14 +327,15 @@ public class CallbacksSecurityTests { } final CustomCallbackBean bean = new CustomCallbackBean(); - final Method method = bean.getClass().getMethod("destroy", null); + final Method method = bean.getClass().getMethod("destroy"); method.setAccessible(true); try { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { - method.invoke(bean, null); + method.invoke(bean); return null; } }, acc); @@ -334,6 +348,7 @@ public class CallbacksSecurityTests { AccessController.doPrivileged( new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { return cl.newInstance(); } @@ -352,7 +367,7 @@ public class CallbacksSecurityTests { assertTrue(ex.getCause() instanceof SecurityException); } } - + @Test public void testCustomInitBean() throws Exception { try { @@ -444,6 +459,7 @@ public class CallbacksSecurityTests { AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { beanFactory.getBean("working-factory-method"); beanFactory.getBean("container-execution"); @@ -478,6 +494,7 @@ public class CallbacksSecurityTests { NonPrivilegedBean bean = Subject.doAsPrivileged( subject, new PrivilegedAction() { + @Override public NonPrivilegedBean run() { return lbf.getBean("test", NonPrivilegedBean.class); } @@ -502,6 +519,7 @@ public class CallbacksSecurityTests { // request the beans from non-privileged code Subject.doAsPrivileged(subject, new PrivilegedAction() { + @Override public Object run() { // sanity check assertEquals("user1", getCurrentSubjectName()); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/ConstructorBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/ConstructorBean.java index 95cf5df4da..0b65929fdd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/ConstructorBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/ConstructorBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomCallbackBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomCallbackBean.java index 80c09aff2b..cf72ae3a95 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomCallbackBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomCallbackBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ public class CustomCallbackBean { public void init() { System.getProperties(); } - + public void destroy() { System.setProperty("security.destroy", "true"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomFactoryBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomFactoryBean.java index 93a8c344ba..4df91dc136 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomFactoryBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/CustomFactoryBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,15 +24,18 @@ import org.springframework.beans.factory.FactoryBean; */ public class CustomFactoryBean implements FactoryBean { + @Override public Object getObject() throws Exception { return System.getProperties(); } + @Override public Class getObjectType() { System.setProperty("factory.object.type", "true"); return Properties.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/DestroyBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/DestroyBean.java index d24ff22474..41bc80b8ab 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/DestroyBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/DestroyBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ import org.springframework.beans.factory.DisposableBean; */ public class DestroyBean implements DisposableBean { + @Override public void destroy() throws Exception { System.setProperty("security.destroy", "true"); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/FactoryBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/FactoryBean.java index 43efd6fd8b..87a4ec27fc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/FactoryBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/FactoryBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,12 +19,12 @@ package org.springframework.beans.factory.support.security.support; * @author Costin Leau */ public class FactoryBean { - + public static Object makeStaticInstance() { System.getProperties(); return new Object(); } - + protected static Object protectedStaticInstance() { return "protectedStaticInstance"; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/InitBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/InitBean.java index acd4343d21..2c371011e3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/InitBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/InitBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,6 +22,7 @@ import org.springframework.beans.factory.InitializingBean; */ public class InitBean implements InitializingBean { + @Override public void afterPropertiesSet() throws Exception { System.getProperties(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/PropertyBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/PropertyBean.java index ced0d45b93..22131ab9ad 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/PropertyBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/support/PropertyBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2006-2009 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,6 +25,6 @@ public class PropertyBean { } public void setProperty(Object property) { - + } } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java index 6deeeb47c9..ded4bb5eae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,10 @@ package org.springframework.beans.factory.wiring; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import junit.framework.TestCase; -import org.easymock.MockControl; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -32,31 +34,24 @@ import test.beans.TestBean; public class BeanConfigurerSupportTests extends TestCase { public void testSupplyIncompatibleBeanFactoryImplementation() throws Exception { - MockControl mock = MockControl.createControl(BeanFactory.class); - mock.replay(); try { - new StubBeanConfigurerSupport().setBeanFactory((BeanFactory) mock.getMock()); + new StubBeanConfigurerSupport().setBeanFactory(mock(BeanFactory.class)); fail("Must have thrown an IllegalArgumentException by this point (incompatible BeanFactory implementation supplied)"); } catch (IllegalArgumentException expected) { } - mock.verify(); } public void testConfigureBeanDoesNothingIfBeanWiringInfoResolverResolvesToNull() throws Exception { TestBean beanInstance = new TestBean(); - MockControl mock = MockControl.createControl(BeanWiringInfoResolver.class); - BeanWiringInfoResolver resolver = (BeanWiringInfoResolver) mock.getMock(); - resolver.resolveWiringInfo(beanInstance); - mock.setReturnValue(null); - mock.replay(); + BeanWiringInfoResolver resolver = mock(BeanWiringInfoResolver.class); BeanConfigurerSupport configurer = new StubBeanConfigurerSupport(); configurer.setBeanWiringInfoResolver(resolver); configurer.setBeanFactory(new DefaultListableBeanFactory()); configurer.configureBean(beanInstance); - mock.verify(); + verify(resolver).resolveWiringInfo(beanInstance); assertNull(beanInstance.getName()); } @@ -91,19 +86,14 @@ public class BeanConfigurerSupportTests extends TestCase { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("spouse", builder.getBeanDefinition()); - MockControl mock = MockControl.createControl(BeanWiringInfoResolver.class); - BeanWiringInfoResolver resolver = (BeanWiringInfoResolver) mock.getMock(); - resolver.resolveWiringInfo(beanInstance); - mock.setReturnValue(new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, false)); - mock.replay(); + BeanWiringInfoResolver resolver = mock(BeanWiringInfoResolver.class); + given(resolver.resolveWiringInfo(beanInstance)).willReturn(new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_NAME, false)); BeanConfigurerSupport configurer = new StubBeanConfigurerSupport(); configurer.setBeanFactory(factory); configurer.setBeanWiringInfoResolver(resolver); configurer.configureBean(beanInstance); assertEquals("Bean is evidently not being configured (for some reason)", "David Gavurin", beanInstance.getSpouse().getName()); - - mock.verify(); } public void testConfigureBeanPerformsAutowiringByTypeIfAppropriateBeanWiringInfoResolverIsPluggedIn() throws Exception { @@ -115,19 +105,14 @@ public class BeanConfigurerSupportTests extends TestCase { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("Mmm, I fancy a salad!", builder.getBeanDefinition()); - MockControl mock = MockControl.createControl(BeanWiringInfoResolver.class); - BeanWiringInfoResolver resolver = (BeanWiringInfoResolver) mock.getMock(); - resolver.resolveWiringInfo(beanInstance); - mock.setReturnValue(new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_TYPE, false)); - mock.replay(); + BeanWiringInfoResolver resolver = mock(BeanWiringInfoResolver.class); + given(resolver.resolveWiringInfo(beanInstance)).willReturn(new BeanWiringInfo(BeanWiringInfo.AUTOWIRE_BY_TYPE, false)); BeanConfigurerSupport configurer = new StubBeanConfigurerSupport(); configurer.setBeanFactory(factory); configurer.setBeanWiringInfoResolver(resolver); configurer.configureBean(beanInstance); assertEquals("Bean is evidently not being configured (for some reason)", "David Gavurin", beanInstance.getSpouse().getName()); - - mock.verify(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java index eba0541e09..e2a0071022 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -326,6 +326,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase { public static class TestBeanEditor extends PropertyEditorSupport { + @Override public void setAsText(String text) { TestBean tb = new TestBean(); StringTokenizer st = new StringTokenizer(text, "_"); @@ -350,6 +351,7 @@ class MustBeInitialized implements InitializingBean { /** * @see InitializingBean#afterPropertiesSet() */ + @Override public void afterPropertiesSet() throws Exception { this.inited = true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java index ba05c51675..cfe24570a3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ public class BeanNameGenerationTests extends TestCase { private DefaultListableBeanFactory beanFactory; + @Override public void setUp() { this.beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); @@ -58,5 +59,5 @@ public class BeanNameGenerationTests extends TestCase { assertFalse(child1.getBeanName().equals(child2.getBeanName())); } - + } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectingReaderEventListener.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectingReaderEventListener.java index 2be0637cf6..021f9bb81d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectingReaderEventListener.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectingReaderEventListener.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { private final List imports = new LinkedList(); + @Override public void defaultsRegistered(DefaultsDefinition defaultsDefinition) { this.defaults.add(defaultsDefinition); } @@ -53,6 +54,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return Collections.unmodifiableList(this.defaults); } + @Override public void componentRegistered(ComponentDefinition componentDefinition) { this.componentDefinitions.put(componentDefinition.getName(), componentDefinition); } @@ -66,6 +68,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]); } + @Override public void aliasRegistered(AliasDefinition aliasDefinition) { List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName()); if(aliases == null) { @@ -80,6 +83,7 @@ public class CollectingReaderEventListener implements ReaderEventListener { return aliases == null ? null : Collections.unmodifiableList(aliases); } + @Override public void importProcessed(ImportDefinition importDefinition) { this.imports.add(importDefinition); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java index 55f7f920f5..72de2d65d1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class CollectionMergingTests extends TestCase { private DefaultListableBeanFactory beanFactory; + @Override protected void setUp() throws Exception { this.beanFactory = new DefaultListableBeanFactory(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java index 72f32f07ef..6a31f91e1a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ConstructorDependenciesBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,12 +27,13 @@ import test.beans.TestBean; * @author Juergen Hoeller * @since 09.11.2003 */ +@SuppressWarnings("serial") public class ConstructorDependenciesBean implements Serializable { - + private int age; - + private String name; - + private TestBean spouse1; private TestBean spouse2; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java index 27ea4461be..75bcc94d84 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CountingFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,14 +51,17 @@ public class CountingFactory implements FactoryBean { } + @Override public Object getObject() { return "myString"; } + @Override public Class getObjectType() { return String.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java index 8662e52c78..558e58681a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ public class DefaultLifecycleMethodsTests extends TestCase { private XmlBeanFactory beanFactory; + @Override protected void setUp() throws Exception { this.beanFactory = new XmlBeanFactory(new ClassPathResource("defaultLifecycleMethods.xml", getClass())); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java index 5975365161..6b396933ae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.springframework.beans.factory.xml; -import junit.framework.TestCase; - import org.junit.Test; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -47,6 +45,7 @@ public final class DelegatingEntityResolverTests { private static final class NoOpEntityResolver implements EntityResolver { + @Override public InputSource resolveEntity(String publicId, String systemId) { return null; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean.java index 2a2b5dcdab..8bed2eeeab 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DependenciesBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,11 +28,11 @@ import test.beans.TestBean; * @since 04.09.2003 */ public class DependenciesBean implements BeanFactoryAware { - + private int age; - + private String name; - + private TestBean spouse; private BeanFactory beanFactory; @@ -62,6 +62,7 @@ public class DependenciesBean implements BeanFactoryAware { return spouse; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java index d42ab430eb..d1449fdb0b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DummyReferencer.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 1c9e484182..58c392ddca 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,11 +31,11 @@ import test.beans.TestBean; * With Spring 3.1, bean id attributes (and all other id attributes across the * core schemas) are no longer typed as xsd:id, but as xsd:string. This allows * for using the same bean id within nested elements. - * + * * Duplicate ids *within the same level of nesting* will still be treated as an * error through the ProblemReporter, as this could never be an intended/valid * situation. - * + * * @author Chris Beams * @since 3.1 * @see org.springframework.beans.factory.xml.XmlBeanFactoryTests#testWithDuplicateName diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java index a9e9925d51..62f4e654b6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ public class EventPublicationTests extends TestCase { private final CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); + @Override protected void setUp() throws Exception { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); reader.setEventListener(this.eventListener); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java index 38666e188c..1623cf3ac5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethods.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import test.beans.TestBean; * @author Juergen Hoeller */ public class FactoryMethods { - + public static FactoryMethods nullInstance() { return null; } @@ -39,21 +39,21 @@ public class FactoryMethods { tb.setName("defaultInstance"); return new FactoryMethods(tb, "default", 0); } - + /** * Note that overloaded methods are supported. */ public static FactoryMethods newInstance(TestBean tb) { return new FactoryMethods(tb, "default", 0); } - + protected static FactoryMethods newInstance(TestBean tb, int num, String name) { if (name == null) { throw new IllegalStateException("Should never be called with null value"); } return new FactoryMethods(tb, name, num); } - + static FactoryMethods newInstance(TestBean tb, int num, Integer something) { if (something != null) { throw new IllegalStateException("Should never be called with non-null value"); @@ -81,35 +81,35 @@ public class FactoryMethods { this.name = name; this.num = num; } - + public void setStringValue(String stringValue) { this.stringValue = stringValue; } - + public String getStringValue() { return this.stringValue; } - + public TestBean getTestBean() { return this.tb; } - + protected TestBean protectedGetTestBean() { return this.tb; } - + private TestBean privateGetTestBean() { return this.tb; } - + public int getNum() { return num; } - + public String getName() { return name; } - + /** * Set via Setter Injection once instance is created. */ diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/GeneratedNameBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/GeneratedNameBean.java index 52eb2b2938..fdf65f88d7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/GeneratedNameBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/GeneratedNameBean.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ public class GeneratedNameBean implements BeanNameAware { private GeneratedNameBean child; + @Override public void setBeanName(String beanName) { this.beanName = beanName; } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java index f67a718949..25ab86c641 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/InstanceFactory.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,26 +37,26 @@ public class InstanceFactory { public void setFactoryBeanProperty(String s) { this.factoryBeanProperty = s; } - + public String getFactoryBeanProperty() { return this.factoryBeanProperty; } - + public FactoryMethods defaultInstance() { TestBean tb = new TestBean(); tb.setName(this.factoryBeanProperty); return FactoryMethods.newInstance(tb); } - + /** * Note that overloaded methods are supported. */ public FactoryMethods newInstance(TestBean tb) { return FactoryMethods.newInstance(tb); } - + public FactoryMethods newInstance(TestBean tb, int num, String name) { return FactoryMethods.newInstance(tb, num, name); } - + } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java index b943361f1a..8cb697a755 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ public class MetadataAttachmentTests extends TestCase { private XmlBeanFactory beanFactory; + @Override protected void setUp() throws Exception { this.beanFactory = new XmlBeanFactory(new ClassPathResource("withMeta.xml", getClass())); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java index bc4e58426f..33788f98db 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -171,6 +171,7 @@ public class ProfileXmlBeanDefinitionTests { private static Matcher containsBeanDefinition(final String beanName) { return new TypeSafeMatcher() { + @Override public void describeTo(Description desc) { desc.appendText("a BeanDefinitionRegistry containing bean named ") .appendValue(beanName); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProtectedLifecycleBean.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProtectedLifecycleBean.java index ed8167b112..231ca93a3d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProtectedLifecycleBean.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProtectedLifecycleBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial return initMethodDeclared; } + @Override public void setBeanName(String name) { this.beanName = name; } @@ -65,6 +66,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial return beanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.owningFactory = beanFactory; } @@ -79,6 +81,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial this.postProcessedBeforeInit = true; } + @Override public void afterPropertiesSet() { if (this.owningFactory == null) { throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean"); @@ -130,6 +133,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial } } + @Override public void destroy() { if (this.destroyed) { throw new IllegalStateException("Already destroyed"); @@ -144,6 +148,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial public static class PostProcessor implements BeanPostProcessor { + @Override public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof ProtectedLifecycleBean) { ((ProtectedLifecycleBean) bean).postProcessBeforeInit(); @@ -151,6 +156,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { if (bean instanceof ProtectedLifecycleBean) { ((ProtectedLifecycleBean) bean).postProcessAfterInit(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java index 8cc4596a33..c031ae52e9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.io.ClassPathResource; import test.beans.DummyBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java index ffd13f4630..438a4b7e9e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/TestBeanCreator.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,18 +21,18 @@ import test.beans.TestBean; /** * Test class for Spring's ability to create * objects using static factory methods, rather - * than constructors. + * than constructors. * @author Rod Johnson */ public class TestBeanCreator { - + public static TestBean createTestBean(String name, int age) { TestBean tb = new TestBean(); tb.setName(name); tb.setAge(age); return tb; } - + public static TestBean createTestBean() { TestBean tb = new TestBean(); tb.setName("Tristan"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java index 3345bf52fb..d042952a88 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public class UtilNamespaceHandlerTests extends TestCase { private CollectingReaderEventListener listener = new CollectingReaderEventListener(); + @Override public void setUp() { this.beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java index 460c18a9f6..eacf97579e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java @@ -454,7 +454,7 @@ public class XmlBeanCollectionTests { * @since 05.06.2003 */ class HasMap { - + private Map map; private IdentityHashMap identityMap; @@ -464,11 +464,11 @@ class HasMap { private CopyOnWriteArraySet concurrentSet; private Properties props; - + private Object[] objectArray; - + private Class[] classArray; - + private Integer[] intArray; public Map getMap() { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java index 8af531ca8f..76baf7366f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class XmlBeanDefinitionReaderTests extends TestCase { catch (BeanDefinitionStoreException expected) { } } - + public void testWithInputSourceAndExplicitValidationMode() { SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();; InputSource resource = new InputSource(getClass().getResourceAsStream("test.xml")); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java index 22d4fcb30c..1025fffe40 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest private XmlBeanFactory factory; + @Override protected void setUp() { parent = new DefaultListableBeanFactory(); Map m = new HashMap(); @@ -59,6 +60,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest this.factory = new XmlBeanFactory(new ClassPathResource("test.xml", getClass()), parent); this.factory.addBeanPostProcessor(new BeanPostProcessor() { + @Override public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof TestBean) { ((TestBean) bean).setPostProcessed(true); @@ -68,6 +70,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest } return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { return bean; } @@ -77,10 +80,12 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest //this.factory.preInstantiateSingletons(); } + @Override protected BeanFactory getBeanFactory() { return factory; } + @Override public void testCount() { assertCount(24); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java index e491b3ef88..2b2ee692e6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.beans.factory.xml.UtilNamespaceHandler; /** * Unit and integration tests for the {@link DefaultNamespaceHandlerResolver} class. - * + * * @author Rob Harrop * @author Rick Evans */ diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java index 9be6a107f3..a66734f625 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -70,6 +70,7 @@ public class BeanInfoTests extends TestCase { public static class ValueBeanBeanInfo extends SimpleBeanInfo { + @Override public PropertyDescriptor[] getPropertyDescriptors() { try { PropertyDescriptor pd = new PropertyDescriptor("value", ValueBean.class); @@ -96,6 +97,7 @@ public class BeanInfoTests extends TestCase { this.target = target; } + @Override public void setAsText(String text) throws IllegalArgumentException { if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_15) { Assert.isTrue(this.target instanceof ValueBean, "Target must be available on JDK 1.5+"); diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java index 7c8ab4a56f..f2d77a2b68 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public final class ByteArrayPropertyEditorTests extends TestCase { public void testGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception { PropertyEditor byteEditor = new ByteArrayPropertyEditor(); assertEquals("", byteEditor.getAsText()); - + byteEditor.setAsText(null); assertEquals("", byteEditor.getAsText()); } diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index ea5a69fb46..ca477008cd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ import test.beans.TestBean; * @author Rob Harrop * @author Arjen Poutsma * @author Chris Beams - * + * * @since 10.06.2003 */ public class CustomEditorTests { @@ -113,6 +113,7 @@ public class CustomEditorTests { TestBean tb = new TestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("prefix" + text); } @@ -130,6 +131,7 @@ public class CustomEditorTests { TestBean tb = new TestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("prefix" + text); } @@ -148,6 +150,7 @@ public class CustomEditorTests { tb.setSpouse(new TestBean()); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, "spouse.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("prefix" + text); } @@ -166,6 +169,7 @@ public class CustomEditorTests { tb.setSpouse(new TestBean()); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("prefix" + text); } @@ -511,7 +515,7 @@ public class CustomEditorTests { bw.setPropertyValue("myChar", "\\u0022"); assertEquals('"', cb.getMyChar()); - + CharacterEditor editor = new CharacterEditor(false); editor.setAsText("M"); assertEquals("M", editor.getAsText()); @@ -672,7 +676,7 @@ public class CustomEditorTests { patternEditor = new PatternEditor(); assertEquals("", patternEditor.getAsText()); - + patternEditor = new PatternEditor(); patternEditor.setAsText(null); assertEquals("", patternEditor.getAsText()); @@ -853,6 +857,7 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(String.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("prefix" + text); } @@ -905,16 +910,19 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(false); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(String.class, "array.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("array" + text); } }); bw.registerCustomEditor(String.class, "list.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("list" + text); } }); bw.registerCustomEditor(String.class, "map.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("map" + text); } @@ -969,31 +977,37 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(false); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(String.class, "array[0].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("array0" + text); } }); bw.registerCustomEditor(String.class, "array[1].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("array1" + text); } }); bw.registerCustomEditor(String.class, "list[0].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("list0" + text); } }); bw.registerCustomEditor(String.class, "list[1].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("list1" + text); } }); bw.registerCustomEditor(String.class, "map[key1].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("mapkey1" + text); } }); bw.registerCustomEditor(String.class, "map[key2].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("mapkey2" + text); } @@ -1060,28 +1074,34 @@ public class CustomEditorTests { tb5.setNestedIndexedBean(new IndexedTestBean()); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(String.class, "array.nestedIndexedBean.array.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("array" + text); } + @Override public String getAsText() { return ((String) getValue()).substring(5); } }); bw.registerCustomEditor(String.class, "list.nestedIndexedBean.list.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("list" + text); } + @Override public String getAsText() { return ((String) getValue()).substring(4); } }); bw.registerCustomEditor(String.class, "map.nestedIndexedBean.map.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("map" + text); } + @Override public String getAsText() { return ((String) getValue()).substring(4); } @@ -1138,16 +1158,19 @@ public class CustomEditorTests { tb5.setNestedIndexedBean(new IndexedTestBean()); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(String.class, "array[0].nestedIndexedBean.array[0].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("array" + text); } }); bw.registerCustomEditor(String.class, "list.nestedIndexedBean.list[1].name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("list" + text); } }); bw.registerCustomEditor(String.class, "map[key1].nestedIndexedBean.map.name", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("map" + text); } @@ -1174,28 +1197,34 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(TestBean.class, "array", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("array" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "list", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("list" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("map" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } @@ -1222,55 +1251,67 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(TestBean.class, "array[0]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("array0" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "array[1]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("array1" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "list[0]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("list0" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "list[1]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("list1" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "map[key1]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("mapkey1" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } }); bw.registerCustomEditor(TestBean.class, "map[key2]", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean("mapkey2" + text, 99)); } + @Override public String getAsText() { return ((TestBean) getValue()).getName(); } @@ -1297,6 +1338,7 @@ public class CustomEditorTests { IndexedTestBean bean = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(bean); bw.registerCustomEditor(List.class, "list", new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { List result = new ArrayList(); result.add(new TestBean("list" + text, 99)); @@ -1347,6 +1389,7 @@ public class CustomEditorTests { IndexedTestBean tb = new IndexedTestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(TestBean.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue(new TestBean(text, 99)); } @@ -1362,6 +1405,7 @@ public class CustomEditorTests { TestBean tb = new TestBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(String.class, new PropertyEditorSupport() { + @Override public void setAsText(String text) throws IllegalArgumentException { setValue("-" + text + "-"); } @@ -1436,6 +1480,7 @@ public class CustomEditorTests { private static class TestBeanEditor extends PropertyEditorSupport { + @Override public void setAsText(String text) { TestBean tb = new TestBean(); StringTokenizer st = new StringTokenizer(text, "_"); @@ -1448,6 +1493,7 @@ public class CustomEditorTests { private static class OldValueAccessingTestBeanEditor extends PropertyEditorSupport { + @Override public void setAsText(String text) { TestBean tb = new TestBean(); StringTokenizer st = new StringTokenizer(text, "_"); diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java index 3e8266ea2d..b1cc7ee18d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class PropertiesEditorTests extends TestCase { assertTrue("contains one entry", p.entrySet().size() == 1); assertTrue("foo=bar", p.get("foo").equals("bar")); } - + public void testTwoProperties() { String s = "foo=bar with whitespace\n" + "me=mi"; @@ -51,7 +51,7 @@ public class PropertiesEditorTests extends TestCase { assertTrue("foo=bar with whitespace", p.get("foo").equals("bar with whitespace")); assertTrue("me=mi", p.get("me").equals("mi")); } - + public void testHandlesEqualsInValue() { String s = "foo=bar\n" + "me=mi\n" + @@ -64,7 +64,7 @@ public class PropertiesEditorTests extends TestCase { assertTrue("me=mi", p.get("me").equals("mi")); assertTrue("x='y=z'", p.get("x").equals("y=z")); } - + public void testHandlesEmptyProperty() { String s = "foo=bar\nme=mi\nx="; PropertiesEditor pe= new PropertiesEditor(); @@ -75,7 +75,7 @@ public class PropertiesEditorTests extends TestCase { assertTrue("me=mi", p.get("me").equals("mi")); assertTrue("x='y=z'", p.get("x").equals("")); } - + public void testHandlesEmptyPropertyWithoutEquals() { String s = "foo\nme=mi\nx=x"; PropertiesEditor pe= new PropertiesEditor(); @@ -85,7 +85,7 @@ public class PropertiesEditorTests extends TestCase { assertTrue("foo is empty", p.get("foo").equals("")); assertTrue("me=mi", p.get("me").equals("mi")); } - + /** * Comments begin with # */ @@ -124,14 +124,14 @@ public class PropertiesEditorTests extends TestCase { assertTrue("foo is bar", p.get("foo").equals("bar")); assertTrue("me=mi", p.get("me").equals("mi")); } - + public void testNull() { PropertiesEditor pe= new PropertiesEditor(); pe.setAsText(null); Properties p = (Properties) pe.getValue(); assertEquals(0, p.size()); } - + public void testEmptyString() { PropertiesEditor pe = new PropertiesEditor(); pe.setAsText(""); diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java index 0d1712048f..ef03607658 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,9 @@ package org.springframework.beans.support; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Locale; -import java.util.Map; - import junit.framework.TestCase; -import org.springframework.beans.BeanWrapper; -import org.springframework.beans.BeanWrapperImpl; - import test.beans.TestBean; /** diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java index 6d74ebe739..320759d1b8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -23,9 +23,9 @@ import org.springframework.util.comparator.CompoundComparator; /** * Unit tests for {@link PropertyComparator} - * + * * @see org.springframework.util.comparator.ComparatorTests - * + * * @author Keith Donald * @author Chris Beams */ @@ -104,6 +104,7 @@ public class PropertyComparatorTests { private String lastName; + @Override public int compareTo(Object o) { return nickName.compareTo(((Dog)o).nickName); } diff --git a/spring-beans/src/test/java/test/beans/BooleanTestBean.java b/spring-beans/src/test/java/test/beans/BooleanTestBean.java index 37a022b661..4ea2f67d3b 100644 --- a/spring-beans/src/test/java/test/beans/BooleanTestBean.java +++ b/spring-beans/src/test/java/test/beans/BooleanTestBean.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/test/beans/Colour.java b/spring-beans/src/test/java/test/beans/Colour.java index f67b96cc0a..533d0df36e 100644 --- a/spring-beans/src/test/java/test/beans/Colour.java +++ b/spring-beans/src/test/java/test/beans/Colour.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum; /** * @author Rob Harrop */ +@SuppressWarnings("serial") public class Colour extends ShortCodedLabeledEnum { public static final Colour RED = new Colour(0, "RED"); @@ -32,4 +33,4 @@ public class Colour extends ShortCodedLabeledEnum { super(code, label); } -} \ No newline at end of file +} diff --git a/spring-beans/src/test/java/test/beans/DerivedTestBean.java b/spring-beans/src/test/java/test/beans/DerivedTestBean.java index 74aebf7515..c0f63181ab 100644 --- a/spring-beans/src/test/java/test/beans/DerivedTestBean.java +++ b/spring-beans/src/test/java/test/beans/DerivedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.beans.factory.DisposableBean; * @author Juergen Hoeller * @since 21.08.2003 */ +@SuppressWarnings("serial") public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean { private String beanName; @@ -50,12 +51,14 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA } + @Override public void setBeanName(String beanName) { if (this.beanName == null || beanName == null) { this.beanName = beanName; } } + @Override public String getBeanName() { return beanName; } @@ -78,10 +81,12 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA } + @Override public void destroy() { this.destroyed = true; } + @Override public boolean wasDestroyed() { return destroyed; } diff --git a/spring-beans/src/test/java/test/beans/DummyBean.java b/spring-beans/src/test/java/test/beans/DummyBean.java index 54ae5e65d6..a8428c7f78 100644 --- a/spring-beans/src/test/java/test/beans/DummyBean.java +++ b/spring-beans/src/test/java/test/beans/DummyBean.java @@ -1,12 +1,12 @@ /* - * Copyright 2010 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ public class DummyBean { private String name; private int age; private TestBean spouse; - + public DummyBean(Object value) { this.value = value; } diff --git a/spring-beans/src/test/java/test/beans/DummyFactory.java b/spring-beans/src/test/java/test/beans/DummyFactory.java index 75b585a498..60f7966d9a 100644 --- a/spring-beans/src/test/java/test/beans/DummyFactory.java +++ b/spring-beans/src/test/java/test/beans/DummyFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -81,6 +81,7 @@ public class DummyFactory * Return if the bean managed by this factory is a singleton. * @see FactoryBean#isSingleton() */ + @Override public boolean isSingleton() { return this.singleton; } @@ -92,6 +93,7 @@ public class DummyFactory this.singleton = singleton; } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } @@ -100,6 +102,7 @@ public class DummyFactory return beanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = (AutowireCapableBeanFactory) beanFactory; this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName); @@ -126,6 +129,7 @@ public class DummyFactory return otherTestBean; } + @Override public void afterPropertiesSet() { if (initialized) { throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean"); @@ -151,6 +155,7 @@ public class DummyFactory * and prototype mode. * @see FactoryBean#getObject() */ + @Override public Object getObject() throws BeansException { if (isSingleton()) { return this.testBean; @@ -165,11 +170,13 @@ public class DummyFactory } } + @Override public Class getObjectType() { return TestBean.class; } + @Override public void destroy() { if (this.testBean != null) { this.testBean.setName(null); diff --git a/spring-beans/src/test/java/test/beans/INestedTestBean.java b/spring-beans/src/test/java/test/beans/INestedTestBean.java index 228109c284..56c9d829ee 100644 --- a/spring-beans/src/test/java/test/beans/INestedTestBean.java +++ b/spring-beans/src/test/java/test/beans/INestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/test/beans/IOther.java b/spring-beans/src/test/java/test/beans/IOther.java index 734235aa06..f3c6263261 100644 --- a/spring-beans/src/test/java/test/beans/IOther.java +++ b/spring-beans/src/test/java/test/beans/IOther.java @@ -1,13 +1,13 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/test/beans/LifecycleBean.java b/spring-beans/src/test/java/test/beans/LifecycleBean.java index 145413deef..cd1dcd6e5e 100644 --- a/spring-beans/src/test/java/test/beans/LifecycleBean.java +++ b/spring-beans/src/test/java/test/beans/LifecycleBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ return initMethodDeclared; } + @Override public void setBeanName(String name) { this.beanName = name; } @@ -67,6 +68,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ return beanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.owningFactory = beanFactory; } @@ -81,6 +83,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ this.postProcessedBeforeInit = true; } + @Override public void afterPropertiesSet() { if (this.owningFactory == null) { throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean"); @@ -132,6 +135,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ } } + @Override public void destroy() { if (this.destroyed) { throw new IllegalStateException("Already destroyed"); @@ -146,6 +150,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ public static class PostProcessor implements BeanPostProcessor { + @Override public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof LifecycleBean) { ((LifecycleBean) bean).postProcessBeforeInit(); @@ -153,6 +158,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { if (bean instanceof LifecycleBean) { ((LifecycleBean) bean).postProcessAfterInit(); diff --git a/spring-beans/src/test/java/test/beans/NestedTestBean.java b/spring-beans/src/test/java/test/beans/NestedTestBean.java index d3fde438b6..edc145ad7d 100644 --- a/spring-beans/src/test/java/test/beans/NestedTestBean.java +++ b/spring-beans/src/test/java/test/beans/NestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean { this.company = (company != null ? company : ""); } + @Override public String getCompany() { return company; } diff --git a/spring-beans/src/test/java/test/beans/NumberTestBean.java b/spring-beans/src/test/java/test/beans/NumberTestBean.java index 2a4db759b6..cdd80bd27b 100644 --- a/spring-beans/src/test/java/test/beans/NumberTestBean.java +++ b/spring-beans/src/test/java/test/beans/NumberTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-beans/src/test/java/test/beans/PackageLevelVisibleBean.java b/spring-beans/src/test/java/test/beans/PackageLevelVisibleBean.java index 167211091f..eeb4b7325d 100644 --- a/spring-beans/src/test/java/test/beans/PackageLevelVisibleBean.java +++ b/spring-beans/src/test/java/test/beans/PackageLevelVisibleBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,5 +25,5 @@ package test.beans; class PackageLevelVisibleBean { public static final String CONSTANT = "Wuby"; - + } diff --git a/spring-beans/src/test/java/test/beans/TestBean.java b/spring-beans/src/test/java/test/beans/TestBean.java index 7e8089e6e7..5b94f078b5 100644 --- a/spring-beans/src/test/java/test/beans/TestBean.java +++ b/spring-beans/src/test/java/test/beans/TestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -137,6 +137,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } @@ -145,6 +146,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return beanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -161,10 +163,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return postProcessed; } + @Override public String getName() { return name; } + @Override public void setName(String name) { this.name = name; } @@ -180,10 +184,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt } } + @Override public int getAge() { return age; } + @Override public void setAge(int age) { this.age = age; } @@ -196,14 +202,17 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.jedi = jedi; } + @Override public void setSpouse(ITestBean spouse) { this.spouses = new ITestBean[] {spouse}; } + @Override public ITestBean getSpouse() { return (spouses != null ? spouses[0] : null); } + @Override public ITestBean[] getSpouses() { return spouses; } @@ -230,10 +239,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.country = country; } + @Override public String[] getStringArray() { return stringArray; } + @Override public void setStringArray(String[] stringArray) { this.stringArray = stringArray; } @@ -302,6 +313,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.someProperties = someProperties; } + @Override public INestedTestBean getDoctor() { return doctor; } @@ -310,6 +322,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.doctor = doctor; } + @Override public INestedTestBean getLawyer() { return lawyer; } @@ -342,6 +355,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.someBoolean = someBoolean; } + @Override public IndexedTestBean getNestedIndexedBean() { return nestedIndexedBean; } @@ -370,18 +384,21 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt /** * @see ITestBean#exceptional(Throwable) */ + @Override public void exceptional(Throwable t) throws Throwable { if (t != null) { throw t; } } + @Override public void unreliableFileOperation() throws IOException { throw new IOException(); } /** * @see ITestBean#returnsThis() */ + @Override public Object returnsThis() { return this; } @@ -389,9 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt /** * @see IOther#absquatulate() */ + @Override public void absquatulate() { } + @Override public int haveBirthday() { return age++; } @@ -421,6 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return this.age; } + @Override public int compareTo(Object other) { if (this.name != null && other instanceof TestBean) { return this.name.compareTo(((TestBean) other).getName()); diff --git a/spring-beans/src/test/java/test/util/TestResourceUtils.java b/spring-beans/src/test/java/test/util/TestResourceUtils.java index 410788d2c1..4843151231 100644 --- a/spring-beans/src/test/java/test/util/TestResourceUtils.java +++ b/spring-beans/src/test/java/test/util/TestResourceUtils.java @@ -1,12 +1,12 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,20 +27,20 @@ import org.springframework.core.io.ClassPathResource; */ public class TestResourceUtils { - /** - * Loads a {@link ClassPathResource} qualified by the simple name of clazz, - * and relative to the package for clazz. - * - *

      Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', - * this method will return a ClassPathResource representing com/foo/BarTests-context.xml - * - *

      Intended for use loading context configuration XML files within JUnit tests. - * - * @param clazz - * @param resourceSuffix - */ - public static ClassPathResource qualifiedResource(Class clazz, String resourceSuffix) { - return new ClassPathResource(format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz); - } + /** + * Loads a {@link ClassPathResource} qualified by the simple name of clazz, + * and relative to the package for clazz. + * + *

      Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', + * this method will return a ClassPathResource representing com/foo/BarTests-context.xml + * + *

      Intended for use loading context configuration XML files within JUnit tests. + * + * @param clazz + * @param resourceSuffix + */ + public static ClassPathResource qualifiedResource(Class clazz, String resourceSuffix) { + return new ClassPathResource(format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz); + } } diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java b/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java new file mode 100644 index 0000000000..7b916d0b59 --- /dev/null +++ b/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java @@ -0,0 +1,111 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.build.junit; + +import static org.junit.Assume.assumeFalse; + +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.junit.internal.AssumptionViolatedException; + +/** + * Provides utility methods that allow JUnit tests to {@link Assume} certain conditions + * hold {@code true}. If the assumption fails, it means the test should be skipped. + * + *

      For example, if a set of tests require at least JDK 1.7 it can use + * {@code Assume#atLeast(JdkVersion.JAVA_17)} as shown below: + * + *

      + * public void MyTests {
      + *
      + *   @BeforeClass
      + *   public static assumptions() {
      + *       Assume.atLeast(JdkVersion.JAVA_17);
      + *   }
      + *
      + *   // ... all the test methods that require at least JDK 1.7
      + * }
      + * 
      + * + * If only a single test requires at least JDK 1.7 it can use the + * {@code Assume#atLeast(JdkVersion.JAVA_17)} as shown below: + * + *
      + * public void MyTests {
      + *
      + *   @Test
      + *   public void requiresJdk17 {
      + *       Assume.atLeast(JdkVersion.JAVA_17);
      + *       // ... perform the actual test
      + *   }
      + * }
      + * 
      + * + * In addition to assumptions based on the JDK version, tests can be categorized into + * {@link TestGroup}s. Active groups are enabled using the 'testGroups' system property, + * usually activated from the gradle command line: + *
      + * gradle test -PtestGroups="performance"
      + * 
      + * + * Groups can be specified as a comma separated list of values, or using the pseudo group + * 'all'. See {@link TestGroup} for a list of valid groups. + * + * @author Rob Winch + * @author Phillip Webb + * @since 3.2 + * @see #atLeast(JavaVersion) + * @see #group(TestGroup) + */ +public abstract class Assume { + + + private static final Set GROUPS = TestGroup.parse(System.getProperty("testGroups")); + + + /** + * Assume a minimum {@link JavaVersion} is running. + * @param version the minimum version for the test to run + */ + public static void atLeast(JavaVersion version) { + if (!JavaVersion.runningVersion().isAtLeast(version)) { + throw new AssumptionViolatedException("Requires JDK " + version + " but running " + + JavaVersion.runningVersion()); + } + } + + /** + * Assume that a particular {@link TestGroup} has been specified. + * @param group the group that must be specified. + */ + public static void group(TestGroup group) { + if (!GROUPS.contains(group)) { + throw new AssumptionViolatedException("Requires unspecified group " + group + + " from " + GROUPS); + } + } + + /** + * Assume that the specified log is not set to Trace or Debug. + * @param log the log to test + */ + public static void notLogging(Log log) { + assumeFalse(log.isTraceEnabled()); + assumeFalse(log.isDebugEnabled()); + } +} diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java b/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java new file mode 100644 index 0000000000..db9fee370f --- /dev/null +++ b/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java @@ -0,0 +1,96 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.build.junit; + +/** + * Enumeration of known JDK versions. + * + * @author Phillip Webb + * @see #runningVersion() + */ +public enum JavaVersion { + + + /** + * Java 1.5 + */ + JAVA_15("1.5", 15), + + /** + * Java 1.6 + */ + JAVA_16("1.6", 16), + + /** + * Java 1.7 + */ + JAVA_17("1.7", 17), + + /** + * Java 1.8 + */ + JAVA_18("1.8", 18); + + + private static final JavaVersion runningVersion = findRunningVersion(); + + private static JavaVersion findRunningVersion() { + String version = System.getProperty("java.version"); + for (JavaVersion candidate : values()) { + if (version.startsWith(candidate.version)) { + return candidate; + } + } + return JavaVersion.JAVA_15; + } + + + private String version; + + private int value; + + + private JavaVersion(String version, int value) { + this.version = version; + this.value = value; + } + + + @Override + public String toString() { + return version; + } + + /** + * Determines if the specified version is the same as or greater than this version. + * @param version the version to check + * @return {@code true} if the specified version is at least this version + */ + public boolean isAtLeast(JavaVersion version) { + return this.value >= version.value; + } + + + /** + * Returns the current running JDK version. If the current version cannot be + * determined {@link #JAVA_15} will be returned. + * @return the JDK version + */ + public static JavaVersion runningVersion() { + return runningVersion; + } +} diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java b/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java new file mode 100644 index 0000000000..3be8b83514 --- /dev/null +++ b/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java @@ -0,0 +1,62 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.build.junit; + +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + +/** + * A test group used to limit when certain tests are run. + * + * @see Assume#group(TestGroup) + * @author Phillip Webb + */ +public enum TestGroup { + + + /** + * Performance related tests that may take a considerable time to run. + */ + PERFORMANCE; + + + /** + * Parse the specified comma separates string of groups. + * @param value the comma separated string of groups + * @return a set of groups + */ + public static Set parse(String value) { + if (value == null || "".equals(value)) { + return Collections.emptySet(); + } + if("ALL".equalsIgnoreCase(value)) { + return EnumSet.allOf(TestGroup.class); + } + Set groups = new HashSet(); + for (String group : value.split(",")) { + try { + groups.add(valueOf(group.trim().toUpperCase())); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Unable to find test group '" + group.trim() + + "' when parsing '" + value + "'"); + } + } + return groups; + } +} diff --git a/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java b/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java new file mode 100644 index 0000000000..1600d4ca19 --- /dev/null +++ b/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.build.junit; + +import static org.hamcrest.Matchers.startsWith; +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Tests for {@link JavaVersion}. + * + * @author Phillip Webb + */ +public class JavaVersionTest { + + @Test + public void runningVersion() { + assertNotNull(JavaVersion.runningVersion()); + assertThat(System.getProperty("java.version"), startsWith(JavaVersion.runningVersion().toString())); + } + + @Test + public void isAtLeast() throws Exception { + assertTrue(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_15)); + assertTrue(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_16)); + assertFalse(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_17)); + } +} diff --git a/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java b/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java new file mode 100644 index 0000000000..2b30f29931 --- /dev/null +++ b/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.build.junit; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.Collections; +import java.util.EnumSet; +import java.util.Set; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * Tests for {@link TestGroup}. + * + * @author Phillip Webb + */ +public class TestGroupTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void parseNull() throws Exception { + assertThat(TestGroup.parse(null), is(Collections. emptySet())); + } + + @Test + public void parseEmptyString() throws Exception { + assertThat(TestGroup.parse(""), is(Collections. emptySet())); + } + + @Test + public void parseWithSpaces() throws Exception { + assertThat(TestGroup.parse("PERFORMANCE, PERFORMANCE"), + is((Set) EnumSet.of(TestGroup.PERFORMANCE))); + } + + @Test + public void parseInMixedCase() throws Exception { + assertThat(TestGroup.parse("performance, PERFormaNCE"), + is((Set) EnumSet.of(TestGroup.PERFORMANCE))); + } + + @Test + public void parseMissing() throws Exception { + thrown.expect(IllegalArgumentException.class); + thrown.expectMessage("Unable to find test group 'missing' when parsing 'performance, missing'"); + TestGroup.parse("performance, missing"); + } + + @Test + public void parseAll() throws Exception { + assertThat(TestGroup.parse("all"), is((Set)EnumSet.allOf(TestGroup.class))); + } +} diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java index eb02a84e2a..fa28b2913c 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java @@ -49,27 +49,33 @@ public class EhCacheCache implements Cache { } + @Override public String getName() { return this.cache.getName(); } + @Override public Ehcache getNativeCache() { return this.cache; } + @Override public ValueWrapper get(Object key) { Element element = this.cache.get(key); return (element != null ? new SimpleValueWrapper(element.getObjectValue()) : null); } + @Override public void put(Object key, Object value) { this.cache.put(new Element(key, value)); } + @Override public void evict(Object key) { this.cache.remove(key); } + @Override public void clear() { this.cache.removeAll(); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java index 2527180e03..4088855bd3 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java @@ -112,7 +112,7 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, /** * Set a CacheManager from which to retrieve a named Cache instance. - * By default, CacheManager.getInstance() will be called. + * By default, {@code CacheManager.getInstance()} will be called. *

      Note that in particular for persistent caches, it is advisable to * properly handle the shutdown of the CacheManager: Set up a separate * EhCacheManagerFactoryBean and pass a reference to this bean property. @@ -296,11 +296,13 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, this.disabled = disabled; } + @Override public void setBeanName(String name) { this.beanName = name; } + @Override public void afterPropertiesSet() throws CacheException, IOException { // If no CacheManager given, fetch the default. if (this.cacheManager == null) { @@ -393,6 +395,7 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, } + @Override public Ehcache getObject() { return this.cache; } @@ -402,6 +405,7 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, * {@link #getObject()} based on logic in {@link #createCache()} and * {@link #decorateCache(Ehcache)} as orchestrated by {@link #afterPropertiesSet()}. */ + @Override public Class getObjectType() { if (this.cache != null) { return this.cache.getClass(); @@ -420,6 +424,7 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, return Cache.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java index 8ae68321dc..b055160dc3 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -96,6 +96,7 @@ public class EhCacheManagerFactoryBean implements FactoryBean, Ini } + @Override public void afterPropertiesSet() throws IOException, CacheException { logger.info("Initializing EHCache CacheManager"); if (this.configLocation != null) { @@ -116,19 +117,23 @@ public class EhCacheManagerFactoryBean implements FactoryBean, Ini } + @Override public CacheManager getObject() { return this.cacheManager; } + @Override public Class getObjectType() { return (this.cacheManager != null ? this.cacheManager.getClass() : CacheManager.class); } + @Override public boolean isSingleton() { return true; } + @Override public void destroy() { logger.info("Shutting down EHCache CacheManager"); this.cacheManager.shutdown(); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java index 0e66d5ebe4..8b0a731c4e 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java @@ -64,10 +64,12 @@ public class JCacheCache implements Cache { } + @Override public String getName() { return this.cache.getName(); } + @Override public javax.cache.Cache getNativeCache() { return this.cache; } @@ -76,22 +78,26 @@ public class JCacheCache implements Cache { return this.allowNullValues; } + @Override @SuppressWarnings("unchecked") public ValueWrapper get(Object key) { Object value = this.cache.get(key); return (value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null); } + @Override @SuppressWarnings("unchecked") public void put(Object key, Object value) { this.cache.put(key, toStoreValue(value)); } + @Override @SuppressWarnings("unchecked") public void evict(Object key) { this.cache.remove(key); } + @Override public void clear() { this.cache.removeAll(); } @@ -99,7 +105,7 @@ public class JCacheCache implements Cache { /** * Convert the given value from the internal store to a user value - * returned from the get method (adapting null). + * returned from the get method (adapting {@code null}). * @param storeValue the store value * @return the value to return to the user */ @@ -112,7 +118,7 @@ public class JCacheCache implements Cache { /** * Convert the given user value, as passed into the put method, - * to a value in the internal store (adapting null). + * to a value in the internal store (adapting {@code null}). * @param userValue the given user value * @return the value to store */ diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheManagerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheManagerFactoryBean.java index b43c1d75b8..0bf1c5cb6c 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheManagerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheManagerFactoryBean.java @@ -53,10 +53,12 @@ public class JCacheManagerFactoryBean this.cacheManagerName = cacheManagerName; } + @Override public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } + @Override public void afterPropertiesSet() { this.cacheManager = (this.beanClassLoader != null ? Caching.getCacheManager(this.beanClassLoader, this.cacheManagerName) : @@ -64,19 +66,23 @@ public class JCacheManagerFactoryBean } + @Override public CacheManager getObject() { return this.cacheManager; } + @Override public Class getObjectType() { return (this.cacheManager != null ? this.cacheManager.getClass() : CacheManager.class); } + @Override public boolean isSingleton() { return true; } + @Override public void destroy() { this.cacheManager.shutdown(); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java index 7b7ac52f97..abda2b7caf 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java +++ b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java @@ -47,18 +47,22 @@ public class TransactionAwareCacheDecorator implements Cache { } + @Override public String getName() { return this.targetCache.getName(); } + @Override public Object getNativeCache() { return this.targetCache.getNativeCache(); } + @Override public ValueWrapper get(Object key) { return this.targetCache.get(key); } + @Override public void put(final Object key, final Object value) { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @@ -73,6 +77,7 @@ public class TransactionAwareCacheDecorator implements Cache { } } + @Override public void evict(final Object key) { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @@ -87,6 +92,7 @@ public class TransactionAwareCacheDecorator implements Cache { } } + @Override public void clear() { this.targetCache.clear(); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheManagerProxy.java b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheManagerProxy.java index efcfd8f54c..2813c0d334 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheManagerProxy.java +++ b/spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheManagerProxy.java @@ -65,6 +65,7 @@ public class TransactionAwareCacheManagerProxy implements CacheManager, Initiali this.targetCacheManager = targetCacheManager; } + @Override public void afterPropertiesSet() { if (this.targetCacheManager == null) { throw new IllegalStateException("'targetCacheManager' is required"); @@ -72,10 +73,12 @@ public class TransactionAwareCacheManagerProxy implements CacheManager, Initiali } + @Override public Cache getCache(String name) { return new TransactionAwareCacheDecorator(this.targetCacheManager.getCache(name)); } + @Override public Collection getCacheNames() { return this.targetCacheManager.getCacheNames(); } diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailAuthenticationException.java b/spring-context-support/src/main/java/org/springframework/mail/MailAuthenticationException.java index 6a54761ebc..d4eb9cc604 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailAuthenticationException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailAuthenticationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ package org.springframework.mail; * @author Dmitriy Kopylenko * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class MailAuthenticationException extends MailException { /** diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailException.java b/spring-context-support/src/main/java/org/springframework/mail/MailException.java index 407a42a838..b254dc9073 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.core.NestedRuntimeException; * * @author Dmitriy Kopylenko */ +@SuppressWarnings("serial") public abstract class MailException extends NestedRuntimeException { /** diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailParseException.java b/spring-context-support/src/main/java/org/springframework/mail/MailParseException.java index b09676e22c..b6b47f1613 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailParseException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailParseException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ package org.springframework.mail; * @author Dmitriy Kopylenko * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class MailParseException extends MailException { /** diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailPreparationException.java b/spring-context-support/src/main/java/org/springframework/mail/MailPreparationException.java index 7068c0f94c..b1e99b5591 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailPreparationException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailPreparationException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ package org.springframework.mail; * @see org.springframework.ui.velocity.VelocityEngineUtils#mergeTemplateIntoString * @see org.springframework.ui.freemarker.FreeMarkerTemplateUtils#processTemplateIntoString */ +@SuppressWarnings("serial") public class MailPreparationException extends MailException { /** diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java index faefe64982..4820c270a2 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.util.ObjectUtils; * @author Dmitriy Kopylenko * @author Juergen Hoeller */ +@SuppressWarnings("serial") public class MailSendException extends MailException { private transient final Map failedMessages; diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailSender.java b/spring-context-support/src/main/java/org/springframework/mail/MailSender.java index 390b950871..6b87d7bb99 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailSender.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailSender.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,7 @@ package org.springframework.mail; * @see org.springframework.mail.javamail.JavaMailSender */ public interface MailSender { - + /** * Send the given simple mail message. * @param simpleMessage the message to send diff --git a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java index e5e5fe73b8..65dc4d08ee 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java +++ b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.util.Assert; /** * Models a simple mail message, including data such as the from, to, cc, subject, and text fields. * - *

      Consider JavaMailSender and JavaMail MimeMessages for creating + *

      Consider {@code JavaMailSender} and JavaMail {@code MimeMessages} for creating * more sophisticated messages, for example messages with attachments, special * character encodings, or personal names that accompany mail addresses. * @@ -39,6 +39,7 @@ import org.springframework.util.Assert; * @see org.springframework.mail.javamail.MimeMessageHelper * @see org.springframework.mail.javamail.MimeMailMessage */ +@SuppressWarnings("serial") public class SimpleMailMessage implements MailMessage, Serializable { private String from; @@ -59,15 +60,15 @@ public class SimpleMailMessage implements MailMessage, Serializable { /** - * Create a new SimpleMailMessage. + * Create a new {@code SimpleMailMessage}. */ public SimpleMailMessage() { } /** - * Copy constructor for creating a new SimpleMailMessage from the state - * of an existing SimpleMailMessage instance. - * @throws IllegalArgumentException if the supplied message is null + * Copy constructor for creating a new {@code SimpleMailMessage} from the state + * of an existing {@code SimpleMailMessage} instance. + * @throws IllegalArgumentException if the supplied message is {@code null} */ public SimpleMailMessage(SimpleMailMessage original) { Assert.notNull(original, "The 'original' message argument cannot be null"); @@ -88,6 +89,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { } + @Override public void setFrom(String from) { this.from = from; } @@ -96,6 +98,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { return this.from; } + @Override public void setReplyTo(String replyTo) { this.replyTo = replyTo; } @@ -104,10 +107,12 @@ public class SimpleMailMessage implements MailMessage, Serializable { return replyTo; } + @Override public void setTo(String to) { this.to = new String[] {to}; } + @Override public void setTo(String[] to) { this.to = to; } @@ -116,10 +121,12 @@ public class SimpleMailMessage implements MailMessage, Serializable { return this.to; } + @Override public void setCc(String cc) { this.cc = new String[] {cc}; } + @Override public void setCc(String[] cc) { this.cc = cc; } @@ -128,10 +135,12 @@ public class SimpleMailMessage implements MailMessage, Serializable { return cc; } + @Override public void setBcc(String bcc) { this.bcc = new String[] {bcc}; } + @Override public void setBcc(String[] bcc) { this.bcc = bcc; } @@ -140,6 +149,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { return bcc; } + @Override public void setSentDate(Date sentDate) { this.sentDate = sentDate; } @@ -148,6 +158,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { return sentDate; } + @Override public void setSubject(String subject) { this.subject = subject; } @@ -156,6 +167,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { return this.subject; } + @Override public void setText(String text) { this.text = text; } @@ -167,8 +179,8 @@ public class SimpleMailMessage implements MailMessage, Serializable { /** * Copy the contents of this message to the given target message. - * @param target the MailMessage to copy to - * @throws IllegalArgumentException if the supplied target is null + * @param target the {@code MailMessage} to copy to + * @throws IllegalArgumentException if the supplied {@code target} is {@code null} */ public void copyTo(MailMessage target) { Assert.notNull(target, "The 'target' message argument cannot be null"); diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMap.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMap.java index e0fdfadf7e..803e1f5be1 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMap.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMap.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; /** - * Spring-configurable FileTypeMap implementation that will read + * Spring-configurable {@code FileTypeMap} implementation that will read * MIME type to file extension mappings from a standard JavaMail MIME type - * mapping file, using a standard MimetypesFileTypeMap underneath. + * mapping file, using a standard {@code MimetypesFileTypeMap} underneath. * *

      The mapping file should be in the following format, as specified by the * Java Activation Framework: @@ -38,18 +38,18 @@ import org.springframework.core.io.Resource; * # map text/html to .htm and .html files * text/html html htm HTML HTM * - * Lines starting with # are treated as comments and are ignored. All + * Lines starting with {@code #} are treated as comments and are ignored. All * other lines are treated as mappings. Each mapping line should contain the MIME * type as the first entry and then each file extension to map to that MIME type * as subsequent entries. Each entry is separated by spaces or tabs. * - *

      By default, the mappings in the mime.types file located in the + *

      By default, the mappings in the {@code mime.types} file located in the * same package as this class are used, which cover many common file extensions - * (in contrast to the out-of-the-box mappings in activation.jar). - * This can be overridden using the mappingLocation property. + * (in contrast to the out-of-the-box mappings in {@code activation.jar}). + * This can be overridden using the {@code mappingLocation} property. * - *

      Additional mappings can be added via the mappings bean property, - * as lines that follow the mime.types file format. + *

      Additional mappings can be added via the {@code mappings} bean property, + * as lines that follow the {@code mime.types} file format. * * @author Rob Harrop * @author Juergen Hoeller @@ -61,7 +61,7 @@ import org.springframework.core.io.Resource; public class ConfigurableMimeFileTypeMap extends FileTypeMap implements InitializingBean { /** - * The Resource to load the mapping file from. + * The {@code Resource} to load the mapping file from. */ private Resource mappingLocation = new ClassPathResource("mime.types", getClass()); @@ -72,16 +72,16 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali /** * The delegate FileTypeMap, compiled from the mappings in the mapping file - * and the entries in the mappings property. + * and the entries in the {@code mappings} property. */ private FileTypeMap fileTypeMap; /** - * Specify the Resource from which mappings are loaded. - *

      Needs to follow the mime.types file format, as specified + * Specify the {@code Resource} from which mappings are loaded. + *

      Needs to follow the {@code mime.types} file format, as specified * by the Java Activation Framework, containing lines such as:
      - * text/html html htm HTML HTM + * {@code text/html html htm HTML HTM} */ public void setMappingLocation(Resource mappingLocation) { this.mappingLocation = mappingLocation; @@ -89,9 +89,9 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali /** * Specify additional MIME type mappings as lines that follow the - * mime.types file format, as specified by the + * {@code mime.types} file format, as specified by the * Java Activation Framework, for example:
      - * text/html html htm HTML HTM + * {@code text/html html htm HTML HTM} */ public void setMappings(String[] mappings) { this.mappings = mappings; @@ -101,13 +101,14 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali /** * Creates the final merged mapping set. */ + @Override public void afterPropertiesSet() { getFileTypeMap(); } /** * Return the delegate FileTypeMap, compiled from the mappings in the mapping file - * and the entries in the mappings property. + * and the entries in the {@code mappings} property. * @see #setMappingLocation * @see #setMappings * @see #createFileTypeMap @@ -131,8 +132,8 @@ public class ConfigurableMimeFileTypeMap extends FileTypeMap implements Initiali *

      The default implementation creates an Activation Framework {@link MimetypesFileTypeMap}, * passing in an InputStream from the mapping resource (if any) and registering * the mapping lines programmatically. - * @param mappingLocation a mime.types mapping resource (can be null) - * @param mappings MIME type mapping lines (can be null) + * @param mappingLocation a {@code mime.types} mapping resource (can be {@code null}) + * @param mappings MIME type mapping lines (can be {@code null}) * @return the compiled FileTypeMap * @throws IOException if resource access failed * @see javax.activation.MimetypesFileTypeMap#MimetypesFileTypeMap(java.io.InputStream) diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java index 2647d76ef4..2cf0b89671 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import javax.mail.internet.InternetAddress; import org.springframework.util.StringUtils; /** - * Editor for java.mail.internet.InternetAddress, + * Editor for {@code java.mail.internet.InternetAddress}, * to directly populate an InternetAddress property. * *

      Expects the same syntax as InternetAddress's constructor with diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSender.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSender.java index ea2a0efbd0..7372f62512 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSender.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSender.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,8 +49,8 @@ import org.springframework.mail.MailSender; * {@link org.springframework.mail.MailSender} client, but still straightforward * compared to traditional JavaMail code: Just let {@link #createMimeMessage()} * return a plain {@link MimeMessage} created with a - * Session.getInstance(new Properties()) call, and check the passed-in - * messages in your mock implementations of the various send methods. + * {@code Session.getInstance(new Properties())} call, and check the passed-in + * messages in your mock implementations of the various {@code send} methods. * * @author Juergen Hoeller * @since 07.10.2003 diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java index 8c4557974c..3993d28ee0 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,8 +51,8 @@ import org.springframework.util.Assert; * specified, possibly pulled from an application server's JNDI environment. * *

      Non-default properties in this object will always override the settings - * in the JavaMail Session. Note that if overriding all values locally, - * there is no added value in setting a pre-configured Session. + * in the JavaMail {@code Session}. Note that if overriding all values locally, + * there is no added value in setting a pre-configured {@code Session}. * * @author Dmitriy Kopylenko * @author Juergen Hoeller @@ -97,7 +97,7 @@ public class JavaMailSenderImpl implements JavaMailSender { /** - * Create a new instance of the JavaMailSenderImpl class. + * Create a new instance of the {@code JavaMailSenderImpl} class. *

      Initializes the {@link #setDefaultFileTypeMap "defaultFileTypeMap"} * property with a default {@link ConfigurableMimeFileTypeMap}. */ @@ -109,8 +109,8 @@ public class JavaMailSenderImpl implements JavaMailSender { /** - * Set JavaMail properties for the Session. - *

      A new Session will be created with those properties. + * Set JavaMail properties for the {@code Session}. + *

      A new {@code Session} will be created with those properties. * Use either this method or {@link #setSession}, but not both. *

      Non-default properties in this instance will override given * JavaMail properties. @@ -133,11 +133,11 @@ public class JavaMailSenderImpl implements JavaMailSender { } /** - * Set the JavaMail Session, possibly pulled from JNDI. - *

      Default is a new Session without defaults, that is + * Set the JavaMail {@code Session}, possibly pulled from JNDI. + *

      Default is a new {@code Session} without defaults, that is * completely configured via this instance's properties. - *

      If using a pre-configured Session, non-default properties - * in this instance will override the settings in the Session. + *

      If using a pre-configured {@code Session}, non-default properties + * in this instance will override the settings in the {@code Session}. * @see #setJavaMailProperties */ public synchronized void setSession(Session session) { @@ -146,7 +146,7 @@ public class JavaMailSenderImpl implements JavaMailSender { } /** - * Return the JavaMail Session, + * Return the JavaMail {@code Session}, * lazily initializing it if hasn't been specified explicitly. */ public synchronized Session getSession() { @@ -203,11 +203,11 @@ public class JavaMailSenderImpl implements JavaMailSender { /** * Set the username for the account at the mail host, if any. - *

      Note that the underlying JavaMail Session has to be - * configured with the property "mail.smtp.auth" set to - * true, else the specified username will not be sent to the + *

      Note that the underlying JavaMail {@code Session} has to be + * configured with the property {@code "mail.smtp.auth"} set to + * {@code true}, else the specified username will not be sent to the * mail server by the JavaMail runtime. If you are not explicitly passing - * in a Session to use, simply specify this setting via + * in a {@code Session} to use, simply specify this setting via * {@link #setJavaMailProperties}. * @see #setSession * @see #setPassword @@ -225,11 +225,11 @@ public class JavaMailSenderImpl implements JavaMailSender { /** * Set the password for the account at the mail host, if any. - *

      Note that the underlying JavaMail Session has to be - * configured with the property "mail.smtp.auth" set to - * true, else the specified password will not be sent to the + *

      Note that the underlying JavaMail {@code Session} has to be + * configured with the property {@code "mail.smtp.auth"} set to + * {@code true}, else the specified password will not be sent to the * mail server by the JavaMail runtime. If you are not explicitly passing - * in a Session to use, simply specify this setting via + * in a {@code Session} to use, simply specify this setting via * {@link #setJavaMailProperties}. * @see #setSession * @see #setUsername @@ -256,7 +256,7 @@ public class JavaMailSenderImpl implements JavaMailSender { /** * Return the default encoding for {@link MimeMessage MimeMessages}, - * or null if none. + * or {@code null} if none. */ public String getDefaultEncoding() { return this.defaultEncoding; @@ -265,14 +265,14 @@ public class JavaMailSenderImpl implements JavaMailSender { /** * Set the default Java Activation {@link FileTypeMap} to use for * {@link MimeMessage MimeMessages} created by this instance. - *

      A FileTypeMap specified here will be autodetected by + *

      A {@code FileTypeMap} specified here will be autodetected by * {@link MimeMessageHelper}, avoiding the need to specify the - * FileTypeMap for each MimeMessageHelper instance. + * {@code FileTypeMap} for each {@code MimeMessageHelper} instance. *

      For example, you can specify a custom instance of Spring's * {@link ConfigurableMimeFileTypeMap} here. If not explicitly specified, - * a default ConfigurableMimeFileTypeMap will be used, containing + * a default {@code ConfigurableMimeFileTypeMap} will be used, containing * an extended set of MIME type mappings (as defined by the - * mime.types file contained in the Spring jar). + * {@code mime.types} file contained in the Spring jar). * @see MimeMessageHelper#setFileTypeMap */ public void setDefaultFileTypeMap(FileTypeMap defaultFileTypeMap) { @@ -281,7 +281,7 @@ public class JavaMailSenderImpl implements JavaMailSender { /** * Return the default Java Activation {@link FileTypeMap} for - * {@link MimeMessage MimeMessages}, or null if none. + * {@link MimeMessage MimeMessages}, or {@code null} if none. */ public FileTypeMap getDefaultFileTypeMap() { return this.defaultFileTypeMap; @@ -292,10 +292,12 @@ public class JavaMailSenderImpl implements JavaMailSender { // Implementation of MailSender //--------------------------------------------------------------------- + @Override public void send(SimpleMailMessage simpleMessage) throws MailException { send(new SimpleMailMessage[] { simpleMessage }); } + @Override public void send(SimpleMailMessage[] simpleMessages) throws MailException { List mimeMessages = new ArrayList(simpleMessages.length); for (SimpleMailMessage simpleMessage : simpleMessages) { @@ -319,10 +321,12 @@ public class JavaMailSenderImpl implements JavaMailSender { * @see #setDefaultEncoding * @see #setDefaultFileTypeMap */ + @Override public MimeMessage createMimeMessage() { return new SmartMimeMessage(getSession(), getDefaultEncoding(), getDefaultFileTypeMap()); } + @Override public MimeMessage createMimeMessage(InputStream contentStream) throws MailException { try { return new MimeMessage(getSession(), contentStream); @@ -332,18 +336,22 @@ public class JavaMailSenderImpl implements JavaMailSender { } } + @Override public void send(MimeMessage mimeMessage) throws MailException { send(new MimeMessage[] {mimeMessage}); } + @Override public void send(MimeMessage[] mimeMessages) throws MailException { doSend(mimeMessages, null); } + @Override public void send(MimeMessagePreparator mimeMessagePreparator) throws MailException { send(new MimeMessagePreparator[] { mimeMessagePreparator }); } + @Override public void send(MimeMessagePreparator[] mimeMessagePreparators) throws MailException { try { List mimeMessages = new ArrayList(mimeMessagePreparators.length); diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java index 242f0e5f27..6a483168eb 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -73,6 +73,7 @@ public class MimeMailMessage implements MailMessage { } + @Override public void setFrom(String from) throws MailParseException { try { this.helper.setFrom(from); @@ -82,6 +83,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setReplyTo(String replyTo) throws MailParseException { try { this.helper.setReplyTo(replyTo); @@ -91,6 +93,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setTo(String to) throws MailParseException { try { this.helper.setTo(to); @@ -100,6 +103,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setTo(String[] to) throws MailParseException { try { this.helper.setTo(to); @@ -109,6 +113,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setCc(String cc) throws MailParseException { try { this.helper.setCc(cc); @@ -118,6 +123,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setCc(String[] cc) throws MailParseException { try { this.helper.setCc(cc); @@ -127,6 +133,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setBcc(String bcc) throws MailParseException { try { this.helper.setBcc(bcc); @@ -136,6 +143,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setBcc(String[] bcc) throws MailParseException { try { this.helper.setBcc(bcc); @@ -145,6 +153,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setSentDate(Date sentDate) throws MailParseException { try { this.helper.setSentDate(sentDate); @@ -154,6 +163,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setSubject(String subject) throws MailParseException { try { this.helper.setSubject(subject); @@ -163,6 +173,7 @@ public class MimeMailMessage implements MailMessage { } } + @Override public void setText(String text) throws MailParseException { try { this.helper.setText(text); diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java index b4984c693d..245fb23c78 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java @@ -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"); * you may not use this file except in compliance with the License. @@ -241,7 +241,7 @@ public class MimeMessageHelper { * @see #MimeMessageHelper(javax.mail.internet.MimeMessage, int, String) */ public MimeMessageHelper(MimeMessage mimeMessage, boolean multipart, String encoding) - throws MessagingException { + throws MessagingException { this(mimeMessage, (multipart ? MULTIPART_MODE_MIXED_RELATED : MULTIPART_MODE_NO), encoding); } @@ -283,7 +283,7 @@ public class MimeMessageHelper { * @see #MULTIPART_MODE_MIXED_RELATED */ public MimeMessageHelper(MimeMessage mimeMessage, int multipartMode, String encoding) - throws MessagingException { + throws MessagingException { this.mimeMessage = mimeMessage; createMimeMultiparts(mimeMessage, multipartMode); @@ -355,7 +355,7 @@ public class MimeMessageHelper { /** * Set the given MimeMultipart objects for use by this MimeMessageHelper. * @param root the root MimeMultipart object, which attachments will be added to; - * or null to indicate no multipart at all + * or {@code null} to indicate no multipart at all * @param main the main MimeMultipart object, which text(s) and inline elements * will be added to (can be the same as the root multipart object, or an element * nested underneath the root multipart element) @@ -380,8 +380,8 @@ public class MimeMessageHelper { private void checkMultipart() throws IllegalStateException { if (!isMultipart()) { throw new IllegalStateException("Not in multipart mode - " + - "create an appropriate MimeMessageHelper via a constructor that takes a 'multipart' flag " + - "if you need to set alternative texts or add inline elements or attachments."); + "create an appropriate MimeMessageHelper via a constructor that takes a 'multipart' flag " + + "if you need to set alternative texts or add inline elements or attachments."); } } @@ -420,7 +420,7 @@ public class MimeMessageHelper { * Determine the default encoding for the given MimeMessage. * @param mimeMessage the passed-in MimeMessage * @return the default encoding associated with the MimeMessage, - * or null if none found + * or {@code null} if none found */ protected String getDefaultEncoding(MimeMessage mimeMessage) { if (mimeMessage instanceof SmartMimeMessage) { @@ -456,12 +456,12 @@ public class MimeMessageHelper { } /** - * Set the Java Activation Framework FileTypeMap to use + * Set the Java Activation Framework {@code FileTypeMap} to use * for determining the content type of inline content and attachments * that get added to the message. - *

      Default is the FileTypeMap that the underlying + *

      Default is the {@code FileTypeMap} that the underlying * MimeMessage carries, if any, or the Activation Framework's default - * FileTypeMap instance else. + * {@code FileTypeMap} instance else. * @see #addInline * @see #addAttachment * @see #getDefaultFileTypeMap(javax.mail.internet.MimeMessage) @@ -474,7 +474,7 @@ public class MimeMessageHelper { } /** - * Return the FileTypeMap used by this MimeMessageHelper. + * Return the {@code FileTypeMap} used by this MimeMessageHelper. */ public FileTypeMap getFileTypeMap() { return this.fileTypeMap; @@ -485,7 +485,7 @@ public class MimeMessageHelper { * Set whether to validate all addresses which get passed to this helper. * Default is "false". *

      Note that this is by default just available for JavaMail >= 1.3. - * You can override the default validateAddress method for + * You can override the default {@code validateAddress method} for * validation on older JavaMail versions (or for custom validation). * @see #validateAddress */ @@ -503,7 +503,7 @@ public class MimeMessageHelper { /** * Validate the given mail address. * Called by all of MimeMessageHelper's address setters and adders. - *

      Default implementation invokes InternetAddress.validate(), + *

      Default implementation invokes {@code InternetAddress.validate()}, * provided that address validation is activated for the helper instance. *

      Note that this method will just work on JavaMail >= 1.3. You can override * it for validation on older JavaMail versions or for custom validation. @@ -546,7 +546,7 @@ public class MimeMessageHelper { public void setFrom(String from, String personal) throws MessagingException, UnsupportedEncodingException { Assert.notNull(from, "From address must not be null"); setFrom(getEncoding() != null ? - new InternetAddress(from, personal, getEncoding()) : new InternetAddress(from, personal)); + new InternetAddress(from, personal, getEncoding()) : new InternetAddress(from, personal)); } public void setReplyTo(InternetAddress replyTo) throws MessagingException { @@ -608,8 +608,8 @@ public class MimeMessageHelper { public void addTo(String to, String personal) throws MessagingException, UnsupportedEncodingException { Assert.notNull(to, "To address must not be null"); addTo(getEncoding() != null ? - new InternetAddress(to, personal, getEncoding()) : - new InternetAddress(to, personal)); + new InternetAddress(to, personal, getEncoding()) : + new InternetAddress(to, personal)); } @@ -653,8 +653,8 @@ public class MimeMessageHelper { public void addCc(String cc, String personal) throws MessagingException, UnsupportedEncodingException { Assert.notNull(cc, "Cc address must not be null"); addCc(getEncoding() != null ? - new InternetAddress(cc, personal, getEncoding()) : - new InternetAddress(cc, personal)); + new InternetAddress(cc, personal, getEncoding()) : + new InternetAddress(cc, personal)); } @@ -698,8 +698,8 @@ public class MimeMessageHelper { public void addBcc(String bcc, String personal) throws MessagingException, UnsupportedEncodingException { Assert.notNull(bcc, "Bcc address must not be null"); addBcc(getEncoding() != null ? - new InternetAddress(bcc, personal, getEncoding()) : - new InternetAddress(bcc, personal)); + new InternetAddress(bcc, personal, getEncoding()) : + new InternetAddress(bcc, personal)); } private InternetAddress parseAddress(String address) throws MessagingException { @@ -730,7 +730,7 @@ public class MimeMessageHelper { /** * Set the sent-date of the message. - * @param sentDate the date to set (never null) + * @param sentDate the date to set (never {@code null}) * @throws MessagingException in case of errors */ public void setSentDate(Date sentDate) throws MessagingException { @@ -758,7 +758,7 @@ public class MimeMessageHelper { * Set the given text directly as content in non-multipart mode * or as default body part in multipart mode. * Always applies the default content type "text/plain". - *

      NOTE: Invoke {@link #addInline} after setText; + *

      NOTE: Invoke {@link #addInline} after {@code setText}; * else, mail readers might not be able to resolve inline references correctly. * @param text the text for the message * @throws MessagingException in case of errors @@ -771,7 +771,7 @@ public class MimeMessageHelper { * Set the given text directly as content in non-multipart mode * or as default body part in multipart mode. * The "html" flag determines the content type to apply. - *

      NOTE: Invoke {@link #addInline} after setText; + *

      NOTE: Invoke {@link #addInline} after {@code setText}; * else, mail readers might not be able to resolve inline references correctly. * @param text the text for the message * @param html whether to apply content type "text/html" for an @@ -798,7 +798,7 @@ public class MimeMessageHelper { /** * Set the given plain text and HTML text as alternatives, offering * both options to the email client. Requires multipart mode. - *

      NOTE: Invoke {@link #addInline} after setText; + *

      NOTE: Invoke {@link #addInline} after {@code setText}; * else, mail readers might not be able to resolve inline references correctly. * @param plainText the plain text for the message * @param htmlText the HTML text for the message @@ -860,16 +860,16 @@ public class MimeMessageHelper { /** * Add an inline element to the MimeMessage, taking the content from a - * javax.activation.DataSource. + * {@code javax.activation.DataSource}. *

      Note that the InputStream returned by the DataSource implementation * needs to be a fresh one on each call, as JavaMail will invoke - * getInputStream() multiple times. - *

      NOTE: Invoke addInline after {@link #setText}; + * {@code getInputStream()} multiple times. + *

      NOTE: Invoke {@code addInline} after {@link #setText}; * else, mail readers might not be able to resolve inline references correctly. * @param contentId the content ID to use. Will end up as "Content-ID" header * in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>". * Can be referenced in HTML source via src="cid:myId" expressions. - * @param dataSource the javax.activation.DataSource to take + * @param dataSource the {@code javax.activation.DataSource} to take * the content from, determining the InputStream and the content type * @throws MessagingException in case of errors * @see #addInline(String, java.io.File) @@ -889,11 +889,11 @@ public class MimeMessageHelper { /** * Add an inline element to the MimeMessage, taking the content from a - * java.io.File. + * {@code java.io.File}. *

      The content type will be determined by the name of the given * content file. Do not use this for temporary files with arbitrary * filenames (possibly ending in ".tmp" or the like)! - *

      NOTE: Invoke addInline after {@link #setText}; + *

      NOTE: Invoke {@code addInline} after {@link #setText}; * else, mail readers might not be able to resolve inline references correctly. * @param contentId the content ID to use. Will end up as "Content-ID" header * in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>". @@ -913,14 +913,14 @@ public class MimeMessageHelper { /** * Add an inline element to the MimeMessage, taking the content from a - * org.springframework.core.io.Resource. + * {@code org.springframework.core.io.Resource}. *

      The content type will be determined by the name of the given * content file. Do not use this for temporary files with arbitrary * filenames (possibly ending in ".tmp" or the like)! *

      Note that the InputStream returned by the Resource implementation * needs to be a fresh one on each call, as JavaMail will invoke - * getInputStream() multiple times. - *

      NOTE: Invoke addInline after {@link #setText}; + * {@code getInputStream()} multiple times. + *

      NOTE: Invoke {@code addInline} after {@link #setText}; * else, mail readers might not be able to resolve inline references correctly. * @param contentId the content ID to use. Will end up as "Content-ID" header * in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>". @@ -939,14 +939,14 @@ public class MimeMessageHelper { /** * Add an inline element to the MimeMessage, taking the content from an - * org.springframework.core.InputStreamResource, and + * {@code org.springframework.core.InputStreamResource}, and * specifying the content type explicitly. *

      You can determine the content type for any given filename via a Java * Activation Framework's FileTypeMap, for example the one held by this helper. *

      Note that the InputStream returned by the InputStreamSource implementation * needs to be a fresh one on each call, as JavaMail will invoke - * getInputStream() multiple times. - *

      NOTE: Invoke addInline after setText; + * {@code getInputStream()} multiple times. + *

      NOTE: Invoke {@code addInline} after {@code setText}; * else, mail readers might not be able to resolve inline references correctly. * @param contentId the content ID to use. Will end up as "Content-ID" header * in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>". @@ -960,7 +960,7 @@ public class MimeMessageHelper { * @see #addInline(String, javax.activation.DataSource) */ public void addInline(String contentId, InputStreamSource inputStreamSource, String contentType) - throws MessagingException { + throws MessagingException { Assert.notNull(inputStreamSource, "InputStreamSource must not be null"); if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) { @@ -974,13 +974,13 @@ public class MimeMessageHelper { /** * Add an attachment to the MimeMessage, taking the content from a - * javax.activation.DataSource. + * {@code javax.activation.DataSource}. *

      Note that the InputStream returned by the DataSource implementation * needs to be a fresh one on each call, as JavaMail will invoke - * getInputStream() multiple times. + * {@code getInputStream()} multiple times. * @param attachmentFilename the name of the attachment as it will * appear in the mail (the content type will be determined by this) - * @param dataSource the javax.activation.DataSource to take + * @param dataSource the {@code javax.activation.DataSource} to take * the content from, determining the InputStream and the content type * @throws MessagingException in case of errors * @see #addAttachment(String, org.springframework.core.io.InputStreamSource) @@ -998,7 +998,7 @@ public class MimeMessageHelper { /** * Add an attachment to the MimeMessage, taking the content from a - * java.io.File. + * {@code java.io.File}. *

      The content type will be determined by the name of the given * content file. Do not use this for temporary files with arbitrary * filenames (possibly ending in ".tmp" or the like)! @@ -1018,13 +1018,13 @@ public class MimeMessageHelper { /** * Add an attachment to the MimeMessage, taking the content from an - * org.springframework.core.io.InputStreamResource. + * {@code org.springframework.core.io.InputStreamResource}. *

      The content type will be determined by the given filename for * the attachment. Thus, any content source will be fine, including * temporary files with arbitrary filenames. *

      Note that the InputStream returned by the InputStreamSource * implementation needs to be a fresh one on each call, as - * JavaMail will invoke getInputStream() multiple times. + * JavaMail will invoke {@code getInputStream()} multiple times. * @param attachmentFilename the name of the attachment as it will * appear in the mail * @param inputStreamSource the resource to take the content from @@ -1035,7 +1035,7 @@ public class MimeMessageHelper { * @see org.springframework.core.io.Resource */ public void addAttachment(String attachmentFilename, InputStreamSource inputStreamSource) - throws MessagingException { + throws MessagingException { String contentType = getFileTypeMap().getContentType(attachmentFilename); addAttachment(attachmentFilename, inputStreamSource, contentType); @@ -1043,10 +1043,10 @@ public class MimeMessageHelper { /** * Add an attachment to the MimeMessage, taking the content from an - * org.springframework.core.io.InputStreamResource. + * {@code org.springframework.core.io.InputStreamResource}. *

      Note that the InputStream returned by the InputStreamSource * implementation needs to be a fresh one on each call, as - * JavaMail will invoke getInputStream() multiple times. + * JavaMail will invoke {@code getInputStream()} multiple times. * @param attachmentFilename the name of the attachment as it will * appear in the mail * @param inputStreamSource the resource to take the content from @@ -1059,7 +1059,7 @@ public class MimeMessageHelper { */ public void addAttachment( String attachmentFilename, InputStreamSource inputStreamSource, String contentType) - throws MessagingException { + throws MessagingException { Assert.notNull(inputStreamSource, "InputStreamSource must not be null"); if (inputStreamSource instanceof Resource && ((Resource) inputStreamSource).isOpen()) { @@ -1079,18 +1079,22 @@ public class MimeMessageHelper { * @return the Activation Framework DataSource */ protected DataSource createDataSource( - final InputStreamSource inputStreamSource, final String contentType, final String name) { + final InputStreamSource inputStreamSource, final String contentType, final String name) { return new DataSource() { + @Override public InputStream getInputStream() throws IOException { return inputStreamSource.getInputStream(); } + @Override public OutputStream getOutputStream() { throw new UnsupportedOperationException("Read-only javax.activation.DataSource"); } + @Override public String getContentType() { return contentType; } + @Override public String getName() { return name; } diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessagePreparator.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessagePreparator.java index 8ac0e8be2e..9b0f49fc34 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessagePreparator.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessagePreparator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import javax.mail.internet.MimeMessage; /** * Callback interface for the preparation of JavaMail MIME messages. * - *

      The corresponding send methods of {@link JavaMailSender} + *

      The corresponding {@code send} methods of {@link JavaMailSender} * will take care of the actual creation of a {@link MimeMessage} instance, * and of proper exception conversion. * diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/SmartMimeMessage.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/SmartMimeMessage.java index 6a3bcd4957..35b3ace313 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/SmartMimeMessage.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/SmartMimeMessage.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ class SmartMimeMessage extends MimeMessage { /** * Create a new SmartMimeMessage. * @param session the JavaMail Session to create the message for - * @param defaultEncoding the default encoding, or null if none - * @param defaultFileTypeMap the default FileTypeMap, or null if none + * @param defaultEncoding the default encoding, or {@code null} if none + * @param defaultFileTypeMap the default FileTypeMap, or {@code null} if none */ public SmartMimeMessage(Session session, String defaultEncoding, FileTypeMap defaultFileTypeMap) { super(session); @@ -56,14 +56,14 @@ class SmartMimeMessage extends MimeMessage { /** - * Return the default encoding of this message, or null if none. + * Return the default encoding of this message, or {@code null} if none. */ public final String getDefaultEncoding() { return this.defaultEncoding; } /** - * Return the default FileTypeMap of this message, or null if none. + * Return the default FileTypeMap of this message, or {@code null} if none. */ public final FileTypeMap getDefaultFileTypeMap() { return this.defaultFileTypeMap; diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingTimerListener.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingTimerListener.java index 853ea465f2..5d0e444715 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingTimerListener.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingTimerListener.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ public class DelegatingTimerListener implements TimerListener { /** * Delegates execution to the underlying Runnable. */ + @Override public void timerExpired(Timer timer) { this.runnable.run(); } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingWork.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingWork.java index 6566dc7892..d748203698 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingWork.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/DelegatingWork.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,6 +57,7 @@ public class DelegatingWork implements Work { /** * Delegates execution to the underlying Runnable. */ + @Override public void run() { this.delegate.run(); } @@ -66,6 +67,7 @@ public class DelegatingWork implements Work { * {@link org.springframework.scheduling.SchedulingAwareRunnable#isLongLived()}, * if available. */ + @Override public boolean isDaemon() { return (this.delegate instanceof SchedulingAwareRunnable && ((SchedulingAwareRunnable) this.delegate).isLongLived()); @@ -75,6 +77,7 @@ public class DelegatingWork implements Work { * This implementation is empty, since we expect the Runnable * to terminate based on some specific shutdown signal. */ + @Override public void release() { } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/ScheduledTimerListener.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/ScheduledTimerListener.java index 34a61b8f17..c3e603882d 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/ScheduledTimerListener.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/ScheduledTimerListener.java @@ -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"); * you may not use this file except in compliance with the License. @@ -179,7 +179,7 @@ public class ScheduledTimerListener { *

      Note: A period of 0 (for example as fixed delay) is * supported, because the CommonJ specification defines this as a legal value. * Hence a value of 0 will result in immediate re-execution after a job has - * finished (not in one-time execution like with java.util.Timer). + * finished (not in one-time execution like with {@code java.util.Timer}). * @see #setFixedRate * @see #isOneTimeTask() * @see commonj.timers.TimerManager#schedule(commonj.timers.TimerListener, long, long) @@ -197,7 +197,7 @@ public class ScheduledTimerListener { /** * Is this task only ever going to execute once? - * @return true if this task is only ever going to execute once + * @return {@code true} if this task is only ever going to execute once * @see #getPeriod() */ public boolean isOneTimeTask() { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerAccessor.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerAccessor.java index 46db6ee2c0..728350db8e 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerAccessor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -74,8 +74,8 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport *

      Default is "false", i.e. managing an independent TimerManager instance. * This is what the CommonJ specification suggests that application servers * are supposed to offer via JNDI lookups, typically declared as a - * resource-ref of type commonj.timers.TimerManager - * in web.xml, with res-sharing-scope set to 'Unshareable'. + * {@code resource-ref} of type {@code commonj.timers.TimerManager} + * in {@code web.xml}, with {@code res-sharing-scope} set to 'Unshareable'. *

      Switch this flag to "true" if you are obtaining a shared TimerManager, * typically through specifying the JNDI location of a TimerManager that * has been explicitly declared as 'Shareable'. Note that WebLogic's @@ -95,6 +95,7 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport } + @Override public void afterPropertiesSet() throws NamingException { if (this.timerManager == null) { if (this.timerManagerName == null) { @@ -117,6 +118,7 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport * Resumes the underlying TimerManager (if not shared). * @see commonj.timers.TimerManager#resume() */ + @Override public void start() { if (!this.shared) { this.timerManager.resume(); @@ -127,6 +129,7 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport * Suspends the underlying TimerManager (if not shared). * @see commonj.timers.TimerManager#suspend() */ + @Override public void stop() { if (!this.shared) { this.timerManager.suspend(); @@ -139,6 +142,7 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport * @see commonj.timers.TimerManager#isSuspending() * @see commonj.timers.TimerManager#isStopping() */ + @Override public boolean isRunning() { return (!this.timerManager.isSuspending() && !this.timerManager.isStopping()); } @@ -152,6 +156,7 @@ public abstract class TimerManagerAccessor extends JndiLocatorSupport * Stops the underlying TimerManager (if not shared). * @see commonj.timers.TimerManager#stop() */ + @Override public void destroy() { // Stop the entire TimerManager, if necessary. if (!this.shared) { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java index e46cbdba70..3b67a93f95 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -76,6 +76,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor // Implementation of InitializingBean interface //--------------------------------------------------------------------- + @Override public void afterPropertiesSet() throws NamingException { super.afterPropertiesSet(); if (this.scheduledTimerListeners != null) { @@ -105,15 +106,18 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor // Implementation of FactoryBean interface //--------------------------------------------------------------------- + @Override public TimerManager getObject() { return getTimerManager(); } + @Override public Class getObjectType() { TimerManager timerManager = getTimerManager(); return (timerManager != null ? timerManager.getClass() : TimerManager.class); } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java index 76714ce5f2..3801e703c0 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerTaskScheduler.java @@ -52,10 +52,12 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T } + @Override public ScheduledFuture schedule(Runnable task, Trigger trigger) { return new ReschedulingTimerListener(errorHandlingTask(task, true), trigger).schedule(); } + @Override public ScheduledFuture schedule(Runnable task, Date startTime) { TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, false)); Timer timer = getTimerManager().schedule(futureTask, startTime); @@ -63,6 +65,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T return futureTask; } + @Override public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) { TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true)); Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, startTime, period); @@ -70,6 +73,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T return futureTask; } + @Override public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) { TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true)); Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, 0, period); @@ -77,6 +81,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T return futureTask; } + @Override public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) { TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true)); Timer timer = getTimerManager().schedule(futureTask, startTime, delay); @@ -84,6 +89,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T return futureTask; } + @Override public ScheduledFuture scheduleWithFixedDelay(Runnable task, long delay) { TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true)); Timer timer = getTimerManager().schedule(futureTask, 0, delay); @@ -113,6 +119,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T this.timer = timer; } + @Override public void timerExpired(Timer timer) { runAndReset(); } @@ -125,10 +132,12 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T return result; } + @Override public long getDelay(TimeUnit unit) { return unit.convert(System.currentTimeMillis() - this.timer.getScheduledExecutionTime(), TimeUnit.MILLISECONDS); } + @Override public int compareTo(Delayed other) { if (this == other) { return 0; diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java index 4d1518dfa9..2c9ce17a49 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java @@ -109,6 +109,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport this.workListener = workListener; } + @Override public void afterPropertiesSet() throws NamingException { if (this.workManager == null) { if (this.workManagerName == null) { @@ -123,6 +124,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport // Implementation of the Spring SchedulingTaskExecutor interface //------------------------------------------------------------------------- + @Override public void execute(Runnable task) { Assert.state(this.workManager != null, "No WorkManager specified"); Work work = new DelegatingWork(task); @@ -142,16 +144,19 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport } } + @Override public void execute(Runnable task, long startTimeout) { execute(task); } + @Override public Future submit(Runnable task) { FutureTask future = new FutureTask(task, null); execute(future); return future; } + @Override public Future submit(Callable task) { FutureTask future = new FutureTask(task); execute(future); @@ -161,6 +166,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport /** * This task executor prefers short-lived work units. */ + @Override public boolean prefersShortLivedTasks() { return true; } @@ -170,24 +176,28 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport // Implementation of the CommonJ WorkManager interface //------------------------------------------------------------------------- + @Override public WorkItem schedule(Work work) throws WorkException, IllegalArgumentException { return this.workManager.schedule(work); } + @Override public WorkItem schedule(Work work, WorkListener workListener) throws WorkException, IllegalArgumentException { return this.workManager.schedule(work, workListener); } + @Override public boolean waitForAll(Collection workItems, long timeout) throws InterruptedException, IllegalArgumentException { return this.workManager.waitForAll(workItems, timeout); } + @Override public Collection waitForAny(Collection workItems, long timeout) throws InterruptedException, IllegalArgumentException { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java index aa40358ca9..ba8a6d0c7a 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/AdaptableJobFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ public class AdaptableJobFactory implements JobFactory { /** * Quartz 1.x version of newJob: contains actual implementation code. */ + @Override public Job newJob(TriggerFiredBundle bundle) throws SchedulerException { try { Object jobObject = createJobInstance(bundle); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java index cee2683dce..00988a7749 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.util.Assert; * Convenience subclass of Quartz's {@link org.quartz.CronTrigger} class, * making bean-style usage easier. * - *

      CronTrigger itself is already a JavaBean but lacks sensible defaults. + *

      {@code CronTrigger} itself is already a JavaBean but lacks sensible defaults. * This class uses the Spring bean name as job name, the Quartz default group * ("DEFAULT") as job group, the current time as start time, and indefinite * repetition, if not specified. @@ -44,7 +44,7 @@ import org.springframework.util.Assert; * instead of registering the JobDetail separately. * *

      NOTE: This convenience subclass does not work against Quartz 2.0. - * Use Quartz 2.0's native JobDetailImpl class or the new Quartz 2.0 + * Use Quartz 2.0's native {@code JobDetailImpl} class or the new Quartz 2.0 * builder API instead. Alternatively, switch to Spring's {@link CronTriggerFactoryBean} * which largely is a drop-in replacement for this class and its properties and * consistently works against Quartz 1.x as well as Quartz 2.0/2.1. @@ -61,6 +61,7 @@ import org.springframework.util.Assert; * @see SchedulerFactoryBean#setJobDetails * @see SimpleTriggerBean */ +@SuppressWarnings("serial") public class CronTriggerBean extends CronTrigger implements JobDetailAwareTrigger, BeanNameAware, InitializingBean { @@ -90,7 +91,7 @@ public class CronTriggerBean extends CronTrigger /** * Set the misfire instruction via the name of the corresponding * constant in the {@link org.quartz.CronTrigger} class. - * Default is MISFIRE_INSTRUCTION_SMART_POLICY. + * Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}. * @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW * @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING * @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY @@ -138,15 +139,18 @@ public class CronTriggerBean extends CronTrigger this.jobDetail = jobDetail; } + @Override public JobDetail getJobDetail() { return this.jobDetail; } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void afterPropertiesSet() throws Exception { if (this.startDelay > 0) { setStartTime(new Date(System.currentTimeMillis() + this.startDelay)); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java index b205e6d73a..66741456fd 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java @@ -40,7 +40,7 @@ import org.springframework.util.ReflectionUtils; * A Spring {@link FactoryBean} for creating a Quartz {@link org.quartz.CronTrigger} * instance, supporting bean-style usage for trigger configuration. * - *

      CronTrigger(Impl) itself is already a JavaBean but lacks sensible defaults. + *

      {@code CronTrigger(Impl)} itself is already a JavaBean but lacks sensible defaults. * This class uses the Spring bean name as job name, the Quartz default group ("DEFAULT") * as job group, the current time as start time, and indefinite repetition, if not specified. * @@ -58,9 +58,9 @@ import org.springframework.util.ReflectionUtils; * @see #setGroup * @see #setStartDelay * @see #setJobDetail - * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers - * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails - * @see org.springframework.scheduling.quartz.SimpleTriggerBean + * @see SchedulerFactoryBean#setTriggers + * @see SchedulerFactoryBean#setJobDetails + * @see SimpleTriggerBean */ public class CronTriggerFactoryBean implements FactoryBean, BeanNameAware, InitializingBean { @@ -182,7 +182,7 @@ public class CronTriggerFactoryBean implements FactoryBean, BeanNam /** * Set the misfire instruction via the name of the corresponding * constant in the {@link org.quartz.CronTrigger} class. - * Default is MISFIRE_INSTRUCTION_SMART_POLICY. + * Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}. * @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW * @see org.quartz.CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING * @see org.quartz.Trigger#MISFIRE_INSTRUCTION_SMART_POLICY @@ -191,11 +191,13 @@ public class CronTriggerFactoryBean implements FactoryBean, BeanNam this.misfireInstruction = constants.asNumber(constantName).intValue(); } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; @@ -265,14 +267,17 @@ public class CronTriggerFactoryBean implements FactoryBean, BeanNam } + @Override public CronTrigger getObject() { return this.cronTrigger; } + @Override public Class getObjectType() { return CronTrigger.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/DelegatingJob.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/DelegatingJob.java index bcec0e566a..7536e0aa3a 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/DelegatingJob.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/DelegatingJob.java @@ -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"); * you may not use this file except in compliance with the License. @@ -60,6 +60,7 @@ public class DelegatingJob implements Job { /** * Delegates execution to the underlying Runnable. */ + @Override public void execute(JobExecutionContext context) throws JobExecutionException { this.delegate.run(); } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailAwareTrigger.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailAwareTrigger.java index dcbfdc12dc..3edec2aacb 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailAwareTrigger.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailAwareTrigger.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public interface JobDetailAwareTrigger { /** * Return the JobDetail that this Trigger is associated with. - * @return the associated JobDetail, or null if none + * @return the associated JobDetail, or {@code null} if none */ JobDetail getJobDetail(); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java index 34c8395c93..43998ffcdb 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,12 +31,12 @@ import org.springframework.context.ApplicationContextAware; * Convenience subclass of Quartz's {@link org.quartz.JobDetail} class, * making bean-style usage easier. * - *

      JobDetail itself is already a JavaBean but lacks + *

      {@code JobDetail} itself is already a JavaBean but lacks * sensible defaults. This class uses the Spring bean name as job name, * and the Quartz default group ("DEFAULT") as job group if not specified. * *

      NOTE: This convenience subclass does not work against Quartz 2.0. - * Use Quartz 2.0's native JobDetailImpl class or the new Quartz 2.0 + * Use Quartz 2.0's native {@code JobDetailImpl} class or the new Quartz 2.0 * builder API instead. Alternatively, switch to Spring's {@link JobDetailFactoryBean} * which largely is a drop-in replacement for this class and its properties and * consistently works against Quartz 1.x as well as Quartz 2.0/2.1. @@ -48,6 +48,7 @@ import org.springframework.context.ApplicationContextAware; * @see org.springframework.beans.factory.BeanNameAware * @see org.quartz.Scheduler#DEFAULT_GROUP */ +@SuppressWarnings("serial") public class JobDetailBean extends JobDetail implements BeanNameAware, ApplicationContextAware, InitializingBean { @@ -114,10 +115,12 @@ public class JobDetailBean extends JobDetail } } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @@ -143,6 +146,7 @@ public class JobDetailBean extends JobDetail } + @Override public void afterPropertiesSet() { if (getName() == null) { setName(this.beanName); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailFactoryBean.java index 921a5e03d4..8f177da433 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailFactoryBean.java @@ -35,7 +35,7 @@ import org.springframework.context.ApplicationContextAware; * A Spring {@link FactoryBean} for creating a Quartz {@link org.quartz.JobDetail} * instance, supporting bean-style usage for JobDetail configuration. * - *

      JobDetail(Impl) itself is already a JavaBean but lacks + *

      {@code JobDetail(Impl)} itself is already a JavaBean but lacks * sensible defaults. This class uses the Spring bean name as job name, * and the Quartz default group ("DEFAULT") as job group if not specified. * @@ -139,10 +139,12 @@ public class JobDetailFactoryBean this.description = description; } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @@ -168,6 +170,7 @@ public class JobDetailFactoryBean } + @Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; @@ -215,14 +218,17 @@ public class JobDetailFactoryBean } + @Override public JobDetail getObject() { return this.jobDetail; } + @Override public Class getObjectType() { return JobDetail.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobMethodInvocationFailedException.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobMethodInvocationFailedException.java index 2b04f76d8d..d79bd3f69d 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobMethodInvocationFailedException.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobMethodInvocationFailedException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.util.MethodInvoker; * @since 2.5.3 * @see MethodInvokingJobDetailFactoryBean */ +@SuppressWarnings("serial") public class JobMethodInvocationFailedException extends NestedRuntimeException { /** diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java index 139febeb7d..1c0939a006 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java @@ -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"); * you may not use this file except in compliance with the License. @@ -83,14 +83,14 @@ public class LocalDataSourceJobStore extends JobStoreCMT { @Override public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) - throws SchedulerConfigException { + throws SchedulerConfigException { // Absolutely needs thread-bound DataSource to initialize. this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource(); if (this.dataSource == null) { throw new SchedulerConfigException( - "No local DataSource found for configuration - " + - "'dataSource' property must be set on SchedulerFactoryBean"); + "No local DataSource found for configuration - " + + "'dataSource' property must be set on SchedulerFactoryBean"); } // Configure transactional connection settings for Quartz. @@ -101,10 +101,12 @@ public class LocalDataSourceJobStore extends JobStoreCMT { DBConnectionManager.getInstance().addConnectionProvider( TX_DATA_SOURCE_PREFIX + getInstanceName(), new ConnectionProvider() { + @Override public Connection getConnection() throws SQLException { // Return a transactional Connection, if any. return DataSourceUtils.doGetConnection(dataSource); } + @Override public void shutdown() { // Do nothing - a Spring-managed DataSource has its own lifecycle. } @@ -124,10 +126,12 @@ public class LocalDataSourceJobStore extends JobStoreCMT { DBConnectionManager.getInstance().addConnectionProvider( NON_TX_DATA_SOURCE_PREFIX + getInstanceName(), new ConnectionProvider() { + @Override public Connection getConnection() throws SQLException { // Always return a non-transactional Connection. return nonTxDataSourceToUse.getConnection(); } + @Override public void shutdown() { // Do nothing - a Spring-managed DataSource has its own lifecycle. } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java index 8738e21a51..9614f1d1a4 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalTaskExecutorThreadPool.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,24 +47,28 @@ public class LocalTaskExecutorThreadPool implements ThreadPool { } + @Override public void initialize() throws SchedulerConfigException { // Absolutely needs thread-bound TaskExecutor to initialize. this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor(); if (this.taskExecutor == null) { throw new SchedulerConfigException( - "No local TaskExecutor found for configuration - " + - "'taskExecutor' property must be set on SchedulerFactoryBean"); + "No local TaskExecutor found for configuration - " + + "'taskExecutor' property must be set on SchedulerFactoryBean"); } } + @Override public void shutdown(boolean waitForJobsToComplete) { } + @Override public int getPoolSize() { return -1; } + @Override public boolean runInThread(Runnable runnable) { if (runnable == null) { return false; @@ -79,12 +83,13 @@ public class LocalTaskExecutorThreadPool implements ThreadPool { } } + @Override public int blockForAvailableThreads() { // The present implementation always returns 1, making Quartz (1.6) // always schedule any tasks that it feels like scheduling. // This could be made smarter for specific TaskExecutors, - // for example calling getMaximumPoolSize() - getActiveCount() - // on a java.util.concurrent.ThreadPoolExecutor. + // for example calling {@code getMaximumPoolSize() - getActiveCount()} + // on a {@code java.util.concurrent.ThreadPoolExecutor}. return 1; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java index 80ce225457..5d6a8a867d 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java @@ -176,14 +176,17 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod this.jobListenerNames = names; } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void setBeanClassLoader(ClassLoader classLoader) { this.beanClassLoader = classLoader; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -194,6 +197,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod } + @Override public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodException { prepare(); @@ -272,14 +276,17 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod } + @Override public JobDetail getObject() { return this.jobDetail; } + @Override public Class getObjectType() { return (this.jobDetail != null ? this.jobDetail.getClass() : JobDetail.class); } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/QuartzJobBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/QuartzJobBean.java index 6b193b43d5..bdeb1e749a 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/QuartzJobBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/QuartzJobBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -92,9 +92,10 @@ public abstract class QuartzJobBean implements Job { /** * This implementation applies the passed-in job data map as bean property - * values, and delegates to executeInternal afterwards. + * values, and delegates to {@code executeInternal} afterwards. * @see #executeInternal */ + @Override public final void execute(JobExecutionContext context) throws JobExecutionException { try { // Reflectively adapting to differences between Quartz 1.x and Quartz 2.0... diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java index c77a1480a5..54dd55760b 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/ResourceLoaderClassLoadHelper.java @@ -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"); * you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper { } + @Override public void initialize() { if (this.resourceLoader == null) { this.resourceLoader = SchedulerFactoryBean.getConfigTimeResourceLoader(); @@ -71,15 +72,17 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper { } } + @Override public Class loadClass(String name) throws ClassNotFoundException { return this.resourceLoader.getClassLoader().loadClass(name); } @SuppressWarnings("unchecked") public Class loadClass(String name, Class clazz) throws ClassNotFoundException { - return loadClass(name); - } + return loadClass(name); + } + @Override public URL getResource(String name) { Resource resource = this.resourceLoader.getResource(name); try { @@ -94,6 +97,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper { } } + @Override public InputStream getResourceAsStream(String name) { Resource resource = this.resourceLoader.getResource(name); try { @@ -108,6 +112,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper { } } + @Override public ClassLoader getClassLoader() { return this.resourceLoader.getClassLoader(); } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java index 07e85c514c..020c3f141c 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java @@ -238,6 +238,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { this.transactionManager = transactionManager; } + @Override public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } @@ -333,8 +334,8 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { * Add the given job to the Scheduler, if it doesn't already exist. * Overwrites the job in any case if "overwriteExistingJobs" is set. * @param jobDetail the job to add - * @return true if the job was actually added, - * false if it already existed before + * @return {@code true} if the job was actually added, + * {@code false} if it already existed before * @see #setOverwriteExistingJobs */ private boolean addJobToScheduler(JobDetail jobDetail) throws SchedulerException { @@ -351,8 +352,8 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { * Add the given trigger to the Scheduler, if it doesn't already exist. * Overwrites the trigger in any case if "overwriteExistingJobs" is set. * @param trigger the trigger to add - * @return true if the trigger was actually added, - * false if it already existed before + * @return {@code true} if the trigger was actually added, + * {@code false} if it already existed before * @see #setOverwriteExistingJobs */ private boolean addTriggerToScheduler(Trigger trigger) throws SchedulerException { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java index 9c69a47c00..edf2941060 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessorBean.java @@ -73,11 +73,13 @@ public class SchedulerAccessorBean extends SchedulerAccessor implements BeanFact return this.scheduler; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } + @Override public void afterPropertiesSet() throws SchedulerException { if (this.scheduler == null) { if (this.schedulerName != null) { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java index 966ad09b74..cb266ad6a3 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ import org.springframework.util.CollectionUtils; * *

      For dynamic registration of jobs at runtime, use a bean reference to * this SchedulerFactoryBean to get direct access to the Quartz Scheduler - * (org.quartz.Scheduler). This allows you to create new jobs + * ({@code org.quartz.Scheduler}). This allows you to create new jobs * and triggers, and also to control and monitor the entire Scheduler. * *

      Note that Quartz instantiates a new Job for each execution, in @@ -201,7 +201,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe /** * Set the Quartz SchedulerFactory implementation to use. *

      Default is StdSchedulerFactory, reading in the standard - * quartz.properties from quartz.jar. + * {@code quartz.properties} from {@code quartz.jar}. * To use custom Quartz properties, specify the "configLocation" * or "quartzProperties" bean property on this FactoryBean. * @see org.quartz.impl.StdSchedulerFactory @@ -369,6 +369,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe * the scheduler will start after the context is refreshed and after the * start delay, if any. */ + @Override public boolean isAutoStartup() { return this.autoStartup; } @@ -387,6 +388,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe /** * Return the phase in which this scheduler will be started and stopped. */ + @Override public int getPhase() { return this.phase; } @@ -426,12 +428,14 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe } + @Override public void setBeanName(String name) { if (this.schedulerName == null) { this.schedulerName = name; } } + @Override public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @@ -441,6 +445,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe // Implementation of InitializingBean interface //--------------------------------------------------------------------- + @Override public void afterPropertiesSet() throws Exception { if (this.dataSource == null && this.nonTransactionalDataSource != null) { this.dataSource = this.nonTransactionalDataSource; @@ -571,7 +576,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe /** * Create the Scheduler instance for the given factory and scheduler name. * Called by {@link #afterPropertiesSet}. - *

      The default implementation invokes SchedulerFactory's getScheduler + *

      The default implementation invokes SchedulerFactory's {@code getScheduler} * method. Can be overridden for custom Scheduler creation. * @param schedulerFactory the factory to create the Scheduler with * @param schedulerName the name of the scheduler to create @@ -689,14 +694,17 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe return this.scheduler; } + @Override public Scheduler getObject() { return this.scheduler; } + @Override public Class getObjectType() { return (this.scheduler != null) ? this.scheduler.getClass() : Scheduler.class; } + @Override public boolean isSingleton() { return true; } @@ -706,6 +714,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe // Implementation of Lifecycle interface //--------------------------------------------------------------------- + @Override public void start() throws SchedulingException { if (this.scheduler != null) { try { @@ -717,6 +726,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe } } + @Override public void stop() throws SchedulingException { if (this.scheduler != null) { try { @@ -728,11 +738,13 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe } } + @Override public void stop(Runnable callback) throws SchedulingException { stop(); callback.run(); } + @Override public boolean isRunning() throws SchedulingException { if (this.scheduler != null) { try { @@ -754,6 +766,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe * Shut down the Quartz scheduler on bean factory shutdown, * stopping all scheduled jobs. */ + @Override public void destroy() throws SchedulerException { logger.info("Shutting down Quartz Scheduler"); this.scheduler.shutdown(this.waitForJobsToCompleteOnShutdown); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java index de51892481..6f5374ab21 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,11 +59,13 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool this.waitForJobsToCompleteOnShutdown = waitForJobsToCompleteOnShutdown; } + @Override public void afterPropertiesSet() throws SchedulerConfigException { initialize(); } + @Override public void execute(Runnable task) { Assert.notNull(task, "Runnable must not be null"); if (!runInThread(task)) { @@ -71,16 +73,19 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool } } + @Override public void execute(Runnable task, long startTimeout) { execute(task); } + @Override public Future submit(Runnable task) { FutureTask future = new FutureTask(task, null); execute(future); return future; } + @Override public Future submit(Callable task) { FutureTask future = new FutureTask(task); execute(future); @@ -90,11 +95,13 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool /** * This task executor prefers short-lived work units. */ + @Override public boolean prefersShortLivedTasks() { return true; } + @Override public void destroy() { shutdown(this.waitForJobsToCompleteOnShutdown); } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerBean.java index ca9d44c658..37f480e3e4 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import org.springframework.core.Constants; * Convenience subclass of Quartz's {@link org.quartz.SimpleTrigger} class, * making bean-style usage easier. * - *

      SimpleTrigger itself is already a JavaBean but lacks sensible defaults. + *

      {@code SimpleTrigger} itself is already a JavaBean but lacks sensible defaults. * This class uses the Spring bean name as job name, the Quartz default group * ("DEFAULT") as job group, the current time as start time, and indefinite * repetition, if not specified. @@ -43,7 +43,7 @@ import org.springframework.core.Constants; * instead of registering the JobDetail separately. * *

      NOTE: This convenience subclass does not work against Quartz 2.0. - * Use Quartz 2.0's native JobDetailImpl class or the new Quartz 2.0 + * Use Quartz 2.0's native {@code JobDetailImpl} class or the new Quartz 2.0 * builder API instead. Alternatively, switch to Spring's {@link SimpleTriggerFactoryBean} * which largely is a drop-in replacement for this class and its properties and * consistently works against Quartz 1.x as well as Quartz 2.0/2.1. @@ -60,6 +60,7 @@ import org.springframework.core.Constants; * @see SchedulerFactoryBean#setJobDetails * @see CronTriggerBean */ +@SuppressWarnings("serial") public class SimpleTriggerBean extends SimpleTrigger implements JobDetailAwareTrigger, BeanNameAware, InitializingBean { @@ -93,7 +94,7 @@ public class SimpleTriggerBean extends SimpleTrigger /** * Set the misfire instruction via the name of the corresponding * constant in the {@link org.quartz.SimpleTrigger} class. - * Default is MISFIRE_INSTRUCTION_SMART_POLICY. + * Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}. * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_FIRE_NOW * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT @@ -143,15 +144,18 @@ public class SimpleTriggerBean extends SimpleTrigger this.jobDetail = jobDetail; } + @Override public JobDetail getJobDetail() { return this.jobDetail; } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void afterPropertiesSet() throws ParseException { if (getName() == null) { setName(this.beanName); diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java index 5baffd047d..31896c7ff4 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java @@ -40,7 +40,7 @@ import org.springframework.util.ReflectionUtils; * A Spring {@link FactoryBean} for creating a Quartz {@link org.quartz.SimpleTrigger} * instance, supporting bean-style usage for trigger configuration. * - *

      SimpleTrigger(Impl) itself is already a JavaBean but lacks sensible defaults. + *

      {@code SimpleTrigger(Impl)} itself is already a JavaBean but lacks sensible defaults. * This class uses the Spring bean name as job name, the Quartz default group ("DEFAULT") * as job group, the current time as start time, and indefinite repetition, if not specified. * @@ -58,9 +58,9 @@ import org.springframework.util.ReflectionUtils; * @see #setGroup * @see #setStartDelay * @see #setJobDetail - * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers - * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails - * @see org.springframework.scheduling.quartz.CronTriggerBean + * @see SchedulerFactoryBean#setTriggers + * @see SchedulerFactoryBean#setJobDetails + * @see CronTriggerBean */ public class SimpleTriggerFactoryBean implements FactoryBean, BeanNameAware, InitializingBean { @@ -183,7 +183,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea /** * Set the misfire instruction via the name of the corresponding * constant in the {@link org.quartz.SimpleTrigger} class. - * Default is MISFIRE_INSTRUCTION_SMART_POLICY. + * Default is {@code MISFIRE_INSTRUCTION_SMART_POLICY}. * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_FIRE_NOW * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT * @see org.quartz.SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT @@ -195,11 +195,13 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea this.misfireInstruction = constants.asNumber(constantName).intValue(); } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } + @Override public void afterPropertiesSet() throws ParseException { if (this.name == null) { this.name = this.beanName; @@ -266,14 +268,17 @@ public class SimpleTriggerFactoryBean implements FactoryBean, Bea } + @Override public SimpleTrigger getObject() { return this.simpleTrigger; } + @Override public Class getObjectType() { return SimpleTrigger.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java index 5e555e2d04..6ffed1af47 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SpringBeanJobFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul /** * Specify the unknown properties (not found in the bean) that should be ignored. - *

      Default is null, indicating that all unknown properties + *

      Default is {@code null}, indicating that all unknown properties * should be ignored. Specify an empty array to throw an exception in case * of any unknown properties, or a list of property names that should be * ignored if there is no corresponding property found on the particular @@ -63,6 +63,7 @@ public class SpringBeanJobFactory extends AdaptableJobFactory implements Schedul this.ignoredUnknownProperties = ignoredUnknownProperties; } + @Override public void setSchedulerContext(SchedulerContext schedulerContext) { this.schedulerContext = schedulerContext; } diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java index 2abf6296e2..574c7695e7 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -47,12 +47,12 @@ import org.springframework.util.CollectionUtils; *

      The optional "configLocation" property sets the location of a FreeMarker * properties file, within the current application. FreeMarker properties can be * overridden via "freemarkerSettings". All of these properties will be set by - * calling FreeMarker's Configuration.setSettings() method and are + * calling FreeMarker's {@code Configuration.setSettings()} method and are * subject to constraints set by FreeMarker. * *

      The "freemarkerVariables" property can be used to specify a Map of * shared variables that will be applied to the Configuration via the - * setAllSharedVariables() method. Like setSettings(), + * {@code setAllSharedVariables()} method. Like {@code setSettings()}, * these entries are subject to FreeMarker constraints. * *

      The simplest way to use this class is to specify a "templateLoaderPath"; @@ -109,7 +109,7 @@ public class FreeMarkerConfigurationFactory { /** * Set properties that contain well-known FreeMarker keys which will be - * passed to FreeMarker's Configuration.setSettings method. + * passed to FreeMarker's {@code Configuration.setSettings} method. * @see freemarker.template.Configuration#setSettings */ public void setFreemarkerSettings(Properties settings) { @@ -118,7 +118,7 @@ public class FreeMarkerConfigurationFactory { /** * Set a Map that contains well-known FreeMarker objects which will be passed - * to FreeMarker's Configuration.setAllSharedVariables() method. + * to FreeMarker's {@code Configuration.setAllSharedVariables()} method. * @see freemarker.template.Configuration#setAllSharedVariables */ public void setFreemarkerVariables(Map variables) { @@ -138,7 +138,7 @@ public class FreeMarkerConfigurationFactory { } /** - * Set a List of TemplateLoaders that will be used to search + * Set a List of {@code TemplateLoader}s that will be used to search * for templates. For example, one or more custom loaders such as database * loaders could be configured and injected here. * @deprecated as of Spring 2.0.1, in favor of the "preTemplateLoaders" @@ -154,7 +154,7 @@ public class FreeMarkerConfigurationFactory { } /** - * Set a List of TemplateLoaders that will be used to search + * Set a List of {@code TemplateLoader}s that will be used to search * for templates. For example, one or more custom loaders such as database * loaders could be configured and injected here. *

      The {@link TemplateLoader TemplateLoaders} specified here will be @@ -169,7 +169,7 @@ public class FreeMarkerConfigurationFactory { } /** - * Set a List of TemplateLoaders that will be used to search + * Set a List of {@code TemplateLoader}s that will be used to search * for templates. For example, one or more custom loaders such as database * loaders can be configured. *

      The {@link TemplateLoader TemplateLoaders} specified here will be @@ -198,13 +198,13 @@ public class FreeMarkerConfigurationFactory { * pseudo URLs are supported, as understood by ResourceEditor. Allows for * relative paths when running in an ApplicationContext. *

      Will define a path for the default FreeMarker template loader. - * If a specified resource cannot be resolved to a java.io.File, + * If a specified resource cannot be resolved to a {@code java.io.File}, * a generic SpringTemplateLoader will be used, without modification detection. *

      To enforce the use of SpringTemplateLoader, i.e. to not resolve a path * as file system resource in any case, turn off the "preferFileSystemAccess" * flag. See the latter's javadoc for details. *

      If you wish to specify your own list of TemplateLoaders, do not set this - * property and instead use setTemplateLoaders(List templateLoaders) + * property and instead use {@code setTemplateLoaders(List templateLoaders)} * @see org.springframework.core.io.ResourceEditor * @see org.springframework.context.ApplicationContext#getResource * @see freemarker.template.Configuration#setDirectoryForTemplateLoading @@ -323,7 +323,7 @@ public class FreeMarkerConfigurationFactory { /** * Return a new Configuration object. Subclasses can override this for * custom initialization, or for using a mock object for testing. - *

      Called by createConfiguration(). + *

      Called by {@code createConfiguration()}. * @return the Configuration object * @throws IOException if a config file wasn't found * @throws TemplateException on FreeMarker initialization failure @@ -374,7 +374,7 @@ public class FreeMarkerConfigurationFactory { * To be overridden by subclasses that want to to register custom * TemplateLoader instances after this factory created its default * template loaders. - *

      Called by createConfiguration(). Note that specified + *

      Called by {@code createConfiguration()}. Note that specified * "postTemplateLoaders" will be registered after any loaders * registered by this callback; as a consequence, they are are not * included in the given List. @@ -411,7 +411,7 @@ public class FreeMarkerConfigurationFactory { * To be overridden by subclasses that want to to perform custom * post-processing of the Configuration object after this factory * performed its default initialization. - *

      Called by createConfiguration(). + *

      Called by {@code createConfiguration()}. * @param config the current Configuration object * @throws IOException if a config file wasn't found * @throws TemplateException on FreeMarker initialization failure diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java index cf1652b5b6..4e295bbb53 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -56,19 +56,23 @@ public class FreeMarkerConfigurationFactoryBean extends FreeMarkerConfigurationF private Configuration configuration; + @Override public void afterPropertiesSet() throws IOException, TemplateException { this.configuration = createConfiguration(); } + @Override public Configuration getObject() { return this.configuration; } + @Override public Class getObjectType() { return Configuration.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java index f4ba067752..b2e7a85214 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java index 7ed965ddb5..6f1c22a62d 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -63,6 +63,7 @@ public class SpringTemplateLoader implements TemplateLoader { } } + @Override public Object findTemplateSource(String name) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Looking for FreeMarker template with name [" + name + "]"); @@ -71,6 +72,7 @@ public class SpringTemplateLoader implements TemplateLoader { return (resource.exists() ? resource : null); } + @Override public Reader getReader(Object templateSource, String encoding) throws IOException { Resource resource = (Resource) templateSource; try { @@ -85,6 +87,7 @@ public class SpringTemplateLoader implements TemplateLoader { } + @Override public long getLastModified(Object templateSource) { Resource resource = (Resource) templateSource; try { @@ -99,6 +102,7 @@ public class SpringTemplateLoader implements TemplateLoader { } } + @Override public void closeTemplateSource(Object templateSource) throws IOException { } diff --git a/spring-context-support/src/main/java/org/springframework/ui/jasperreports/JasperReportsUtils.java b/spring-context-support/src/main/java/org/springframework/ui/jasperreports/JasperReportsUtils.java index a4da611b26..b74611a4b0 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/jasperreports/JasperReportsUtils.java +++ b/spring-context-support/src/main/java/org/springframework/ui/jasperreports/JasperReportsUtils.java @@ -46,13 +46,13 @@ import net.sf.jasperreports.engine.export.JRXlsExporter; public abstract class JasperReportsUtils { /** - * Convert the given report data value to a JRDataSource. - *

      In the default implementation, a JRDataSource, - * java.util.Collection or object array is detected. - * The latter are converted to JRBeanCollectionDataSource - * or JRBeanArrayDataSource, respectively. + * Convert the given report data value to a {@code JRDataSource}. + *

      In the default implementation, a {@code JRDataSource}, + * {@code java.util.Collection} or object array is detected. + * The latter are converted to {@code JRBeanCollectionDataSource} + * or {@code JRBeanArrayDataSource}, respectively. * @param value the report data value to convert - * @return the JRDataSource (never null) + * @return the JRDataSource (never {@code null}) * @throws IllegalArgumentException if the value could not be converted * @see net.sf.jasperreports.engine.JRDataSource * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource @@ -74,14 +74,14 @@ public abstract class JasperReportsUtils { } /** - * Render the supplied JasperPrint instance using the - * supplied JRAbstractExporter instance and write the results - * to the supplied Writer. - *

      Make sure that the JRAbstractExporter implementation - * you supply is capable of writing to a Writer. - * @param exporter the JRAbstractExporter to use to render the report - * @param print the JasperPrint instance to render - * @param writer the Writer to write the result to + * Render the supplied {@code JasperPrint} instance using the + * supplied {@code JRAbstractExporter} instance and write the results + * to the supplied {@code Writer}. + *

      Make sure that the {@code JRAbstractExporter} implementation + * you supply is capable of writing to a {@code Writer}. + * @param exporter the {@code JRAbstractExporter} to use to render the report + * @param print the {@code JasperPrint} instance to render + * @param writer the {@code Writer} to write the result to * @throws JRException if rendering failed */ public static void render(JRExporter exporter, JasperPrint print, Writer writer) @@ -93,14 +93,14 @@ public abstract class JasperReportsUtils { } /** - * Render the supplied JasperPrint instance using the - * supplied JRAbstractExporter instance and write the results - * to the supplied OutputStream. - *

      Make sure that the JRAbstractExporter implementation you - * supply is capable of writing to a OutputStream. - * @param exporter the JRAbstractExporter to use to render the report - * @param print the JasperPrint instance to render - * @param outputStream the OutputStream to write the result to + * Render the supplied {@code JasperPrint} instance using the + * supplied {@code JRAbstractExporter} instance and write the results + * to the supplied {@code OutputStream}. + *

      Make sure that the {@code JRAbstractExporter} implementation you + * supply is capable of writing to a {@code OutputStream}. + * @param exporter the {@code JRAbstractExporter} to use to render the report + * @param print the {@code JasperPrint} instance to render + * @param outputStream the {@code OutputStream} to write the result to * @throws JRException if rendering failed */ public static void render(JRExporter exporter, JasperPrint print, OutputStream outputStream) @@ -113,11 +113,11 @@ public abstract class JasperReportsUtils { /** * Render a report in CSV format using the supplied report data. - * Writes the results to the supplied Writer. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code Writer}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param writer the Writer to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param writer the {@code Writer} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @throws JRException if rendering failed * @see #convertReportData @@ -131,11 +131,11 @@ public abstract class JasperReportsUtils { /** * Render a report in CSV format using the supplied report data. - * Writes the results to the supplied Writer. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code Writer}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param writer the Writer to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param writer the {@code Writer} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @param exporterParameters a {@link Map} of {@link JRExporterParameter exporter parameters} * @throws JRException if rendering failed @@ -152,11 +152,11 @@ public abstract class JasperReportsUtils { /** * Render a report in HTML format using the supplied report data. - * Writes the results to the supplied Writer. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code Writer}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param writer the Writer to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param writer the {@code Writer} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @throws JRException if rendering failed * @see #convertReportData @@ -170,11 +170,11 @@ public abstract class JasperReportsUtils { /** * Render a report in HTML format using the supplied report data. - * Writes the results to the supplied Writer. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code Writer}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param writer the Writer to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param writer the {@code Writer} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @param exporterParameters a {@link Map} of {@link JRExporterParameter exporter parameters} * @throws JRException if rendering failed @@ -191,11 +191,11 @@ public abstract class JasperReportsUtils { /** * Render a report in PDF format using the supplied report data. - * Writes the results to the supplied OutputStream. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code OutputStream}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param stream the OutputStream to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param stream the {@code OutputStream} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @throws JRException if rendering failed * @see #convertReportData @@ -209,11 +209,11 @@ public abstract class JasperReportsUtils { /** * Render a report in PDF format using the supplied report data. - * Writes the results to the supplied OutputStream. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code OutputStream}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param stream the OutputStream to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param stream the {@code OutputStream} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @param exporterParameters a {@link Map} of {@link JRExporterParameter exporter parameters} * @throws JRException if rendering failed @@ -230,11 +230,11 @@ public abstract class JasperReportsUtils { /** * Render a report in XLS format using the supplied report data. - * Writes the results to the supplied OutputStream. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code OutputStream}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param stream the OutputStream to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param stream the {@code OutputStream} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @throws JRException if rendering failed * @see #convertReportData @@ -248,11 +248,11 @@ public abstract class JasperReportsUtils { /** * Render a report in XLS format using the supplied report data. - * Writes the results to the supplied OutputStream. - * @param report the JasperReport instance to render + * Writes the results to the supplied {@code OutputStream}. + * @param report the {@code JasperReport} instance to render * @param parameters the parameters to use for rendering - * @param stream the OutputStream to write the rendered report to - * @param reportData a JRDataSource, java.util.Collection or object array + * @param stream the {@code OutputStream} to write the rendered report to + * @param reportData a {@code JRDataSource}, {@code java.util.Collection} or object array * (converted accordingly), representing the report data to read fields from * @param exporterParameters a {@link Map} of {@link JRExporterParameter exporter parameters} * @throws JRException if rendering failed diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java index b845d6c6ae..454ef1adbb 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java +++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java @@ -26,23 +26,25 @@ import org.apache.velocity.runtime.log.LogSystem; * Velocity LogSystem implementation for Jakarta Commons Logging. * Used by VelocityConfigurer to redirect log output. * - *

      NOTE: To be replaced by Velocity 1.5's LogChute mechanism - * and Velocity 1.6's CommonsLogLogChute implementation once we + *

      NOTE: To be replaced by Velocity 1.5's {@code LogChute} mechanism + * and Velocity 1.6's {@code CommonsLogLogChute} implementation once we * upgrade to Velocity 1.6+ (likely Velocity 1.7+) in a future version of Spring. * * @author Juergen Hoeller * @since 07.08.2003 * @see VelocityEngineFactoryBean - * @deprecated as of Spring 3.2, in favor of Velocity 1.6's CommonsLogLogChute + * @deprecated as of Spring 3.2, in favor of Velocity 1.6's {@code CommonsLogLogChute} */ @Deprecated public class CommonsLoggingLogSystem implements LogSystem { private static final Log logger = LogFactory.getLog(VelocityEngine.class); + @Override public void init(RuntimeServices runtimeServices) { } + @Override public void logVelocityMessage(int type, String msg) { switch (type) { case ERROR_ID: diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java index e93ed15530..f03a8e6190 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java +++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java @@ -32,15 +32,15 @@ import org.springframework.util.StringUtils; /** * Velocity ResourceLoader adapter that loads via a Spring ResourceLoader. * Used by VelocityEngineFactory for any resource loader path that cannot - * be resolved to a java.io.File. + * be resolved to a {@code java.io.File}. * *

      Note that this loader does not allow for modification detection: - * Use Velocity's default FileResourceLoader for java.io.File + * Use Velocity's default FileResourceLoader for {@code java.io.File} * resources. * *

      Expects "spring.resource.loader" and "spring.resource.loader.path" * application attributes in the Velocity runtime: the former of type - * org.springframework.core.io.ResourceLoader, the latter a String. + * {@code org.springframework.core.io.ResourceLoader}, the latter a String. * * @author Juergen Hoeller * @since 14.03.2004 diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java index 302f989f7b..2e81188968 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java +++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactory.java @@ -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"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public class VelocityEngineFactory { * pseudo URLs are supported, as understood by ResourceLoader. Allows for * relative paths when running in an ApplicationContext. *

      Will define a path for the default Velocity resource loader with the name - * "file". If the specified resource cannot be resolved to a java.io.File, + * "file". If the specified resource cannot be resolved to a {@code java.io.File}, * a generic SpringResourceLoader will be used under the name "spring", without * modification detection. *

      Note that resource caching will be enabled in any case. With the file @@ -270,7 +270,7 @@ public class VelocityEngineFactory { /** * Return a new VelocityEngine. Subclasses can override this for * custom initialization, or for using a mock object for testing. - *

      Called by createVelocityEngine(). + *

      Called by {@code createVelocityEngine()}. * @return the VelocityEngine instance * @throws IOException if a config file wasn't found * @throws VelocityException on Velocity initialization failure @@ -283,7 +283,7 @@ public class VelocityEngineFactory { /** * Initialize a Velocity resource loader for the given VelocityEngine: * either a standard Velocity FileResourceLoader or a SpringResourceLoader. - *

      Called by createVelocityEngine(). + *

      Called by {@code createVelocityEngine()}. * @param velocityEngine the VelocityEngine to configure * @param resourceLoaderPath the path to load Velocity resources from * @see org.apache.velocity.runtime.resource.loader.FileResourceLoader @@ -334,7 +334,7 @@ public class VelocityEngineFactory { /** * Initialize a SpringResourceLoader for the given VelocityEngine. - *

      Called by initVelocityResourceLoader. + *

      Called by {@code initVelocityResourceLoader}. * @param velocityEngine the VelocityEngine to configure * @param resourceLoaderPath the path to load Velocity resources from * @see SpringResourceLoader @@ -357,7 +357,7 @@ public class VelocityEngineFactory { * To be implemented by subclasses that want to to perform custom * post-processing of the VelocityEngine after this FactoryBean * performed its default configuration (but before VelocityEngine.init). - *

      Called by createVelocityEngine(). + *

      Called by {@code createVelocityEngine()}. * @param velocityEngine the current VelocityEngine * @throws IOException if a config file wasn't found * @throws VelocityException on Velocity initialization failure diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java index 8d25492aa6..7c45782625 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -53,19 +53,23 @@ public class VelocityEngineFactoryBean extends VelocityEngineFactory private VelocityEngine velocityEngine; + @Override public void afterPropertiesSet() throws IOException, VelocityException { this.velocityEngine = createVelocityEngine(); } + @Override public VelocityEngine getObject() { return this.velocityEngine; } + @Override public Class getObjectType() { return VelocityEngine.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context-support/src/test/java/org/springframework/beans/Colour.java b/spring-context-support/src/test/java/org/springframework/beans/Colour.java index 60dc333e0b..a992a2ebfc 100644 --- a/spring-context-support/src/test/java/org/springframework/beans/Colour.java +++ b/spring-context-support/src/test/java/org/springframework/beans/Colour.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum; /** * @author Rob Harrop */ +@SuppressWarnings("serial") public class Colour extends ShortCodedLabeledEnum { public static final Colour RED = new Colour(0, "RED"); @@ -32,4 +33,4 @@ public class Colour extends ShortCodedLabeledEnum { super(code, label); } -} \ No newline at end of file +} diff --git a/spring-context-support/src/test/java/org/springframework/beans/INestedTestBean.java b/spring-context-support/src/test/java/org/springframework/beans/INestedTestBean.java index 7d87547b5f..e0ae5f20a3 100644 --- a/spring-context-support/src/test/java/org/springframework/beans/INestedTestBean.java +++ b/spring-context-support/src/test/java/org/springframework/beans/INestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-context-support/src/test/java/org/springframework/beans/IOther.java b/spring-context-support/src/test/java/org/springframework/beans/IOther.java index 797486ec44..d7fb346185 100644 --- a/spring-context-support/src/test/java/org/springframework/beans/IOther.java +++ b/spring-context-support/src/test/java/org/springframework/beans/IOther.java @@ -1,13 +1,13 @@ /* - * 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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-context-support/src/test/java/org/springframework/beans/NestedTestBean.java b/spring-context-support/src/test/java/org/springframework/beans/NestedTestBean.java index a06e15d150..412891c439 100644 --- a/spring-context-support/src/test/java/org/springframework/beans/NestedTestBean.java +++ b/spring-context-support/src/test/java/org/springframework/beans/NestedTestBean.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean { this.company = (company != null ? company : ""); } + @Override public String getCompany() { return company; } diff --git a/spring-context-support/src/test/java/org/springframework/beans/TestBean.java b/spring-context-support/src/test/java/org/springframework/beans/TestBean.java index 7842bbfeac..6d71de7576 100644 --- a/spring-context-support/src/test/java/org/springframework/beans/TestBean.java +++ b/spring-context-support/src/test/java/org/springframework/beans/TestBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -137,6 +137,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt } + @Override public void setBeanName(String beanName) { this.beanName = beanName; } @@ -145,6 +146,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return beanName; } + @Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } @@ -161,10 +163,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return postProcessed; } + @Override public String getName() { return name; } + @Override public void setName(String name) { this.name = name; } @@ -180,10 +184,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt } } + @Override public int getAge() { return age; } + @Override public void setAge(int age) { this.age = age; } @@ -196,14 +202,17 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.jedi = jedi; } + @Override public ITestBean getSpouse() { return (spouses != null ? spouses[0] : null); } + @Override public void setSpouse(ITestBean spouse) { this.spouses = new ITestBean[] {spouse}; } + @Override public ITestBean[] getSpouses() { return spouses; } @@ -230,10 +239,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.country = country; } + @Override public String[] getStringArray() { return stringArray; } + @Override public void setStringArray(String[] stringArray) { this.stringArray = stringArray; } @@ -302,6 +313,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.someProperties = someProperties; } + @Override public INestedTestBean getDoctor() { return doctor; } @@ -310,6 +322,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.doctor = doctor; } + @Override public INestedTestBean getLawyer() { return lawyer; } @@ -342,6 +355,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt this.someBoolean = someBoolean; } + @Override public IndexedTestBean getNestedIndexedBean() { return nestedIndexedBean; } @@ -370,18 +384,21 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt /** * @see org.springframework.beans.ITestBean#exceptional(Throwable) */ + @Override public void exceptional(Throwable t) throws Throwable { if (t != null) { throw t; } } + @Override public void unreliableFileOperation() throws IOException { throw new IOException(); } /** * @see org.springframework.beans.ITestBean#returnsThis() */ + @Override public Object returnsThis() { return this; } @@ -389,9 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt /** * @see org.springframework.beans.IOther#absquatulate() */ + @Override public void absquatulate() { } + @Override public int haveBirthday() { return age++; } @@ -421,6 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt return this.age; } + @Override public int compareTo(Object other) { if (this.name != null && other instanceof TestBean) { return this.name.compareTo(((TestBean) other).getName()); diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java index 8ea783e17c..646a679717 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java @@ -188,6 +188,7 @@ public class EhCacheSupportTests extends TestCase { cacheFb.setCacheManager(cm); cacheFb.setCacheName("myCache1"); cacheFb.setCacheEntryFactory(new CacheEntryFactory() { + @Override public Object createEntry(Object key) throws Exception { return key; } @@ -212,9 +213,11 @@ public class EhCacheSupportTests extends TestCase { cacheFb.setCacheManager(cm); cacheFb.setCacheName("myCache1"); cacheFb.setCacheEntryFactory(new UpdatingCacheEntryFactory() { + @Override public Object createEntry(Object key) throws Exception { return key; } + @Override public void updateEntryValue(Object key, Object value) throws Exception { } }); diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java index 3233099bac..4b397425a5 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/InternetAddressEditorTests.java @@ -1,5 +1,5 @@ /* - * 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"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ public class InternetAddressEditorTests extends TestCase { private InternetAddressEditor editor; + @Override protected void setUp() { editor = new InternetAddressEditor(); } diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java index b0deb96a6a..51eab98cd6 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -170,6 +170,7 @@ public class JavaMailSenderTests extends TestCase { final List messages = new ArrayList(); MimeMessagePreparator preparator = new MimeMessagePreparator() { + @Override public void prepare(MimeMessage mimeMessage) throws MessagingException { mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org")); messages.add(mimeMessage); @@ -194,12 +195,14 @@ public class JavaMailSenderTests extends TestCase { final List messages = new ArrayList(); MimeMessagePreparator preparator1 = new MimeMessagePreparator() { + @Override public void prepare(MimeMessage mimeMessage) throws MessagingException { mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org")); messages.add(mimeMessage); } }; MimeMessagePreparator preparator2 = new MimeMessagePreparator() { + @Override public void prepare(MimeMessage mimeMessage) throws MessagingException { mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org")); messages.add(mimeMessage); @@ -300,6 +303,7 @@ public class JavaMailSenderTests extends TestCase { public void testJavaMailSenderWithParseExceptionOnMimeMessagePreparator() { MockJavaMailSender sender = new MockJavaMailSender(); MimeMessagePreparator preparator = new MimeMessagePreparator() { + @Override public void prepare(MimeMessage mimeMessage) throws MessagingException { mimeMessage.setFrom(new InternetAddress("")); } diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/CronTriggerBeanTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/CronTriggerBeanTests.java index fcd1a2f7c5..8ccc9c5b69 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/CronTriggerBeanTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/CronTriggerBeanTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public class CronTriggerBeanTests { @Test public void testStartTime() throws Exception { - CronTriggerBean bean = createTriggerBean(); + CronTriggerBean bean = createTriggerBean(); Date startTime = new Date(System.currentTimeMillis() + 1234L); bean.setStartTime(startTime); bean.afterPropertiesSet(); diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index e1bd9a8c63..af4042c2c9 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import java.util.Arrays; import java.util.Date; @@ -30,7 +33,6 @@ import java.util.Map; import javax.sql.DataSource; -import org.easymock.MockControl; import org.junit.Test; import org.quartz.CronTrigger; import org.quartz.Job; @@ -118,7 +120,7 @@ public class QuartzSupportTests { } mijdfb.setTargetMethod("doSomething"); mijdfb.afterPropertiesSet(); - JobDetail jobDetail1 = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail1 = mijdfb.getObject(); SimpleTriggerBean trigger1 = new SimpleTriggerBean(); trigger1.setBeanName("myTrigger1"); @@ -127,33 +129,13 @@ public class QuartzSupportTests { trigger1.setRepeatInterval(20); trigger1.afterPropertiesSet(); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); - scheduler.getContext(); - schedulerControl.setReturnValue(new SchedulerContext()); - scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getJobDetail("myJob1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.addJob(jobDetail0, true); - schedulerControl.setVoidCallable(); - scheduler.scheduleJob(trigger0); - schedulerControl.setReturnValue(new Date()); - scheduler.addJob(jobDetail1, true); - schedulerControl.setVoidCallable(); - scheduler.scheduleJob(trigger1); - schedulerControl.setReturnValue(new Date()); - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); + final Scheduler scheduler = mock(Scheduler.class); + given(scheduler.getContext()).willReturn(new SchedulerContext()); + given(scheduler.scheduleJob(trigger0)).willReturn(new Date()); + given(scheduler.scheduleJob(trigger1)).willReturn(new Date()); SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -174,7 +156,14 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getJobDetail("myJob1", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); + verify(scheduler).addJob(jobDetail0, true); + verify(scheduler).addJob(jobDetail1, true); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } @Test @@ -210,7 +199,7 @@ public class QuartzSupportTests { mijdfb.setTargetObject(task1); mijdfb.setTargetMethod("doSomething"); mijdfb.afterPropertiesSet(); - JobDetail jobDetail1 = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail1 = mijdfb.getObject(); SimpleTriggerBean trigger1 = new SimpleTriggerBean(); trigger1.setBeanName("myTrigger1"); @@ -219,35 +208,14 @@ public class QuartzSupportTests { trigger1.setRepeatInterval(20); trigger1.afterPropertiesSet(); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); - scheduler.getContext(); - schedulerControl.setReturnValue(new SchedulerContext()); - scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(new SimpleTrigger()); - if (overwrite) { - scheduler.addJob(jobDetail1, true); - schedulerControl.setVoidCallable(); - scheduler.rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1); - schedulerControl.setReturnValue(new Date()); - } - else { - scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - } - scheduler.addJob(jobDetail0, true); - schedulerControl.setVoidCallable(); - scheduler.scheduleJob(trigger0); - schedulerControl.setReturnValue(new Date()); - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); + final Scheduler scheduler = mock(Scheduler.class); + given(scheduler.getContext()).willReturn(new SchedulerContext()); + given(scheduler.rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1)).willReturn(new Date()); + given(scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP)).willReturn(new SimpleTrigger()); + given(scheduler.scheduleJob(trigger0)).willReturn(new Date()); SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -268,7 +236,18 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); + if (overwrite) { + verify(scheduler).addJob(jobDetail1, true); + verify(scheduler).rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1); + } + else { + verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); + } + verify(scheduler).addJob(jobDetail0, true); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } @Test @@ -304,7 +283,7 @@ public class QuartzSupportTests { mijdfb.setTargetObject(task1); mijdfb.setTargetMethod("doSomething"); mijdfb.afterPropertiesSet(); - JobDetail jobDetail1 = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail1 = mijdfb.getObject(); SimpleTriggerBean trigger1 = new SimpleTriggerBean(); trigger1.setBeanName("myTrigger1"); @@ -313,39 +292,19 @@ public class QuartzSupportTests { trigger1.setRepeatInterval(20); trigger1.afterPropertiesSet(); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); - scheduler.getContext(); - schedulerControl.setReturnValue(new SchedulerContext()); - scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(new SimpleTrigger()); + final Scheduler scheduler = mock(Scheduler.class); + given(scheduler.getContext()).willReturn(new SchedulerContext()); + given(scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP)).willReturn(new SimpleTrigger()); if (overwrite) { - scheduler.addJob(jobDetail1, true); - schedulerControl.setVoidCallable(); - scheduler.rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1); - schedulerControl.setReturnValue(new Date()); + given(scheduler.rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1)).willReturn(new Date()); } - else { - scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - } - scheduler.addJob(jobDetail0, true); - schedulerControl.setVoidCallable(); - scheduler.scheduleJob(trigger0); - schedulerControl.setThrowable(new ObjectAlreadyExistsException("")); + given(scheduler.scheduleJob(trigger0)).willThrow(new ObjectAlreadyExistsException("")); if (overwrite) { - scheduler.rescheduleJob("myTrigger0", Scheduler.DEFAULT_GROUP, trigger0); - schedulerControl.setReturnValue(new Date()); + given(scheduler.rescheduleJob("myTrigger0", Scheduler.DEFAULT_GROUP, trigger0)).willReturn(new Date()); } - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -366,15 +325,25 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); + if (overwrite) { + verify(scheduler).addJob(jobDetail1, true); + verify(scheduler).rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1); + } + else { + verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); + } + verify(scheduler).addJob(jobDetail0, true); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } @Test public void testSchedulerFactoryBeanWithListeners() throws Exception { JobFactory jobFactory = new AdaptableJobFactory(); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); + final Scheduler scheduler = mock(Scheduler.class); SchedulerListener schedulerListener = new TestSchedulerListener(); JobListener globalJobListener = new TestJobListener(); @@ -382,25 +351,8 @@ public class QuartzSupportTests { TriggerListener globalTriggerListener = new TestTriggerListener(); TriggerListener triggerListener = new TestTriggerListener(); - scheduler.setJobFactory(jobFactory); - schedulerControl.setVoidCallable(); - scheduler.addSchedulerListener(schedulerListener); - schedulerControl.setVoidCallable(); - scheduler.addGlobalJobListener(globalJobListener); - schedulerControl.setVoidCallable(); - scheduler.addJobListener(jobListener); - schedulerControl.setVoidCallable(); - scheduler.addGlobalTriggerListener(globalTriggerListener); - schedulerControl.setVoidCallable(); - scheduler.addTriggerListener(triggerListener); - schedulerControl.setVoidCallable(); - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); - SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -419,7 +371,14 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).setJobFactory(jobFactory); + verify(scheduler).addSchedulerListener(schedulerListener); + verify(scheduler).addGlobalJobListener(globalJobListener); + verify(scheduler).addJobListener(jobListener); + verify(scheduler).addGlobalTriggerListener(globalTriggerListener); + verify(scheduler).addTriggerListener(triggerListener); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } /*public void testMethodInvocationWithConcurrency() throws Exception { @@ -446,7 +405,7 @@ public class QuartzSupportTests { mijdfb.setTargetObject(task1); mijdfb.setTargetMethod("doWait"); mijdfb.afterPropertiesSet(); - JobDetail jobDetail1 = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail1 = mijdfb.getObject(); SimpleTriggerBean trigger0 = new SimpleTriggerBean(); trigger0.setBeanName("myTrigger1"); @@ -532,7 +491,7 @@ public class QuartzSupportTests { mijdfb.setTargetObject(task1); mijdfb.setTargetMethod("doSomething"); mijdfb.afterPropertiesSet(); - JobDetail jobDetail1 = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail1 = mijdfb.getObject(); SimpleTrigger trigger1 = new SimpleTrigger(); trigger1.setName("myTrigger1"); @@ -543,33 +502,12 @@ public class QuartzSupportTests { trigger1.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY); trigger1.setRepeatInterval(20); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); - scheduler.setJobFactory(jobFactory); - schedulerControl.setVoidCallable(); - scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getJobDetail("myJob1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); - schedulerControl.setReturnValue(null); - scheduler.addJob(jobDetail0, true); - schedulerControl.setVoidCallable(); - scheduler.addJob(jobDetail1, true); - schedulerControl.setVoidCallable(); - scheduler.scheduleJob(trigger0); - schedulerControl.setReturnValue(new Date()); - scheduler.scheduleJob(trigger1); - schedulerControl.setReturnValue(new Date()); - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); + final Scheduler scheduler = mock(Scheduler.class); + given(scheduler.scheduleJob(trigger0)).willReturn(new Date()); + given(scheduler.scheduleJob(trigger1)).willReturn(new Date()); SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -585,7 +523,17 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).setJobFactory(jobFactory); + verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getJobDetail("myJob1", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP); + verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP); + verify(scheduler).addJob(jobDetail0, true); + verify(scheduler).addJob(jobDetail1, true); + verify(scheduler).scheduleJob(trigger0); + verify(scheduler).scheduleJob(trigger1); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } @Test @@ -593,18 +541,12 @@ public class QuartzSupportTests { TestBean tb = new TestBean("tb", 99); StaticApplicationContext ac = new StaticApplicationContext(); - MockControl schedulerControl = MockControl.createControl(Scheduler.class); - final Scheduler scheduler = (Scheduler) schedulerControl.getMock(); + final Scheduler scheduler = mock(Scheduler.class); SchedulerContext schedulerContext = new SchedulerContext(); - scheduler.getContext(); - schedulerControl.setReturnValue(schedulerContext, 4); - scheduler.start(); - schedulerControl.setVoidCallable(); - scheduler.shutdown(false); - schedulerControl.setVoidCallable(); - schedulerControl.replay(); + given(scheduler.getContext()).willReturn(schedulerContext); SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() { + @Override protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) { return scheduler; } @@ -618,7 +560,7 @@ public class QuartzSupportTests { try { schedulerFactoryBean.afterPropertiesSet(); schedulerFactoryBean.start(); - Scheduler returnedScheduler = (Scheduler) schedulerFactoryBean.getObject(); + Scheduler returnedScheduler = schedulerFactoryBean.getObject(); assertEquals(tb, returnedScheduler.getContext().get("testBean")); assertEquals(ac, returnedScheduler.getContext().get("appCtx")); } @@ -626,7 +568,8 @@ public class QuartzSupportTests { schedulerFactoryBean.destroy(); } - schedulerControl.verify(); + verify(scheduler).start(); + verify(scheduler).shutdown(false); } @Test @@ -659,7 +602,7 @@ public class QuartzSupportTests { mijdfb.setTargetMethod("doSomething"); mijdfb.setJobListenerNames(names); mijdfb.afterPropertiesSet(); - JobDetail jobDetail = (JobDetail) mijdfb.getObject(); + JobDetail jobDetail = mijdfb.getObject(); List result = Arrays.asList(jobDetail.getJobListenerNames()); assertEquals(Arrays.asList(names), result); } @@ -1040,30 +983,39 @@ public class QuartzSupportTests { private static class TestSchedulerListener implements SchedulerListener { + @Override public void jobScheduled(Trigger trigger) { } + @Override public void jobUnscheduled(String triggerName, String triggerGroup) { } + @Override public void triggerFinalized(Trigger trigger) { } + @Override public void triggersPaused(String triggerName, String triggerGroup) { } + @Override public void triggersResumed(String triggerName, String triggerGroup) { } + @Override public void jobsPaused(String jobName, String jobGroup) { } + @Override public void jobsResumed(String jobName, String jobGroup) { } + @Override public void schedulerError(String msg, SchedulerException cause) { } + @Override public void schedulerShutdown() { } } @@ -1071,16 +1023,20 @@ public class QuartzSupportTests { private static class TestJobListener implements JobListener { + @Override public String getName() { return null; } + @Override public void jobToBeExecuted(JobExecutionContext context) { } + @Override public void jobExecutionVetoed(JobExecutionContext context) { } + @Override public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { } } @@ -1088,20 +1044,25 @@ public class QuartzSupportTests { private static class TestTriggerListener implements TriggerListener { + @Override public String getName() { return null; } + @Override public void triggerFired(Trigger trigger, JobExecutionContext context) { } + @Override public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) { return false; } + @Override public void triggerMisfired(Trigger trigger) { } + @Override public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode) { } } @@ -1111,6 +1072,7 @@ public class QuartzSupportTests { private int count; + @Override public void execute(Runnable task) { this.count++; task.run(); @@ -1131,6 +1093,7 @@ public class QuartzSupportTests { param = value; } + @Override public synchronized void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { count++; } @@ -1150,6 +1113,7 @@ public class QuartzSupportTests { param = value; } + @Override protected synchronized void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { count++; } @@ -1169,6 +1133,7 @@ public class QuartzSupportTests { param = value; } + @Override public void run() { count++; } diff --git a/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java b/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java index 7e22fe88f7..4f8cc86fca 100644 --- a/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java +++ b/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java @@ -236,6 +236,7 @@ public class JasperReportsUtilsTests extends TestCase { private boolean invoked = false; + @Override public void afterPageExport() { this.invoked = true; } diff --git a/spring-context/src/main/java/org/springframework/cache/Cache.java b/spring-context/src/main/java/org/springframework/cache/Cache.java index 32cedfe6de..dbfa1cba84 100644 --- a/spring-context/src/main/java/org/springframework/cache/Cache.java +++ b/spring-context/src/main/java/org/springframework/cache/Cache.java @@ -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"); * you may not use this file except in compliance with the License. @@ -40,10 +40,10 @@ public interface Cache { /** * Return the value to which this cache maps the specified key. Returns - * null if the cache contains no mapping for this key. + * {@code null} if the cache contains no mapping for this key. * @param key key whose associated value is to be returned. * @return the value to which this cache maps the specified key, - * or null if the cache contains no mapping for this key + * or {@code null} if the cache contains no mapping for this key */ ValueWrapper get(Object key); diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java b/spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java index 4937eeb5e3..222d3308f4 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java @@ -50,6 +50,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware { @Autowired(required=false) private Collection cachingConfigurers; + @Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableCaching = AnnotationAttributes.fromMap( importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false)); diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java b/spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java index 3e6e49d760..6017ca6df2 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java @@ -38,7 +38,7 @@ public @interface CacheEvict { /** * Qualifier value for the specified cached operation. - *

      May be used to determine the target cache (or caches), matching the qualifier + *

      May be used to determine the target cache (or caches), matching the qualifier * value (or the bean name(s)) of (a) specific bean definition. */ String[] value(); @@ -50,7 +50,7 @@ public @interface CacheEvict { String key() default ""; /** - * Spring Expression Language (SpEL) attribute used for conditioning the method caching. + * Spring Expression Language (SpEL) attribute used for conditioning the method caching. *

      Default is "", meaning the method is always cached. */ String condition() default ""; diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java b/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java index 447ce62b4f..716b840ad0 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java @@ -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"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public @interface Cacheable { String key() default ""; /** - * Spring Expression Language (SpEL) attribute used for conditioning the method caching. + * Spring Expression Language (SpEL) attribute used for conditioning the method caching. *

      Default is "", meaning the method is always cached. */ String condition() default ""; diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index 33c4a120a7..b4fb7e5c83 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -39,6 +39,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector parseCacheAnnotations(AnnotatedElement ae) { Collection ops = null; diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java index 0da4c6850b..7780357153 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java @@ -73,7 +73,7 @@ public class ConcurrentMapCache implements Cache { * given internal ConcurrentMap to use. * @param name the name of the cache * @param store the ConcurrentMap to use as an internal store - * @param allowNullValues whether to allow null values + * @param allowNullValues whether to allow {@code null} values * (adapting them to an internal null holder value) */ public ConcurrentMapCache(String name, ConcurrentMap store, boolean allowNullValues) { @@ -83,10 +83,12 @@ public class ConcurrentMapCache implements Cache { } + @Override public String getName() { return this.name; } + @Override public ConcurrentMap getNativeCache() { return this.store; } @@ -95,19 +97,23 @@ public class ConcurrentMapCache implements Cache { return this.allowNullValues; } + @Override public ValueWrapper get(Object key) { Object value = this.store.get(key); return (value != null ? new SimpleValueWrapper(fromStoreValue(value)) : null); } + @Override public void put(Object key, Object value) { this.store.put(key, toStoreValue(value)); } + @Override public void evict(Object key) { this.store.remove(key); } + @Override public void clear() { this.store.clear(); } @@ -115,7 +121,7 @@ public class ConcurrentMapCache implements Cache { /** * Convert the given value from the internal store to a user value - * returned from the get method (adapting null). + * returned from the get method (adapting {@code null}). * @param storeValue the store value * @return the value to return to the user */ @@ -128,7 +134,7 @@ public class ConcurrentMapCache implements Cache { /** * Convert the given user value, as passed into the put method, - * to a value in the internal store (adapting null). + * to a value in the internal store (adapting {@code null}). * @param userValue the given user value * @return the value to store */ @@ -140,6 +146,7 @@ public class ConcurrentMapCache implements Cache { } + @SuppressWarnings("serial") private static class NullHolder implements Serializable { } diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheFactoryBean.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheFactoryBean.java index 26b242310b..0e0b5a8adf 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -74,26 +74,31 @@ public class ConcurrentMapCacheFactoryBean this.allowNullValues = allowNullValues; } + @Override public void setBeanName(String beanName) { if (!StringUtils.hasLength(this.name)) { setName(beanName); } } + @Override public void afterPropertiesSet() { this.cache = (this.store != null ? new ConcurrentMapCache(this.name, this.store, this.allowNullValues) : new ConcurrentMapCache(this.name, this.allowNullValues)); } + @Override public ConcurrentMapCache getObject() { return this.cache; } + @Override public Class getObjectType() { return ConcurrentMapCache.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java index 7a0067a329..35371d92d4 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java @@ -71,10 +71,12 @@ public class ConcurrentMapCacheManager implements CacheManager { } } + @Override public Collection getCacheNames() { return Collections.unmodifiableSet(this.cacheMap.keySet()); } + @Override public Cache getCache(String name) { Cache cache = this.cacheMap.get(name); if (cache == null && this.dynamic) { diff --git a/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java index 5cae8fdff4..1488d62bd8 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/cache/config/AnnotationDrivenCacheBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser * {@link AopNamespaceUtils#registerAutoProxyCreatorIfNecessary * register an AutoProxyCreator} with the container as necessary. */ + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { String mode = element.getAttribute("mode"); if ("aspectj".equals(mode)) { diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java b/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java index 40100245f3..238a3d2805 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java +++ b/spring-context/src/main/java/org/springframework/cache/config/CacheNamespaceHandler.java @@ -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"); * you may not use this file except in compliance with the License. @@ -51,6 +51,7 @@ public class CacheNamespaceHandler extends NamespaceHandlerSupport { return def; } + @Override public void init() { registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenCacheBeanDefinitionParser()); registerBeanDefinitionParser("advice", new CacheAdviceParser()); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java index 978dbd8c36..11dc537f03 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java @@ -84,6 +84,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera * @return {@link CacheOperation} for this method, or {@code null} if the method * is not cacheable */ + @Override public Collection getCacheOperations(Method method, Class targetClass) { // First, see if we have a cached value. Object cacheKey = getCacheKey(method, targetClass); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java b/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java index a8d4a51e7b..55a746f44f 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java @@ -57,6 +57,7 @@ public class BeanFactoryCacheOperationSourceAdvisor extends AbstractBeanFactoryP this.pointcut.setClassFilter(classFilter); } + @Override public Pointcut getPointcut() { return this.pointcut; } diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index 1a600193b9..3ebe8e0606 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -128,6 +128,7 @@ public abstract class CacheAspectSupport implements InitializingBean { return this.keyGenerator; } + @Override public void afterPropertiesSet() { if (this.cacheManager == null) { throw new IllegalStateException("'cacheManager' is required"); @@ -223,7 +224,7 @@ public abstract class CacheAspectSupport implements InitializingBean { return invoker.invoke(); } - + private void inspectBeforeCacheEvicts(Collection evictions) { inspectCacheEvicts(evictions, true); } @@ -326,7 +327,7 @@ public abstract class CacheAspectSupport implements InitializingBean { } } } - + // return a status only if at least on cacheable matched if (atLeastOnePassed) { return new CacheStatus(cUpdates, updateRequire, retVal); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheInterceptor.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheInterceptor.java index 9358a5b07c..ad4ab9721b 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheInterceptor.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -49,10 +49,12 @@ public class CacheInterceptor extends CacheAspectSupport implements MethodInterc } } + @Override public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); Invoker aopAllianceInvoker = new Invoker() { + @Override public Object invoke() { try { return invocation.proceed(); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java index 8210297a23..58548bb799 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationSourcePointcut.java @@ -33,6 +33,7 @@ import org.springframework.util.ObjectUtils; @SuppressWarnings("serial") abstract class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable { + @Override public boolean matches(Method method, Class targetClass) { CacheOperationSource cas = getCacheOperationSource(); return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass))); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java index a604ba266a..8c01c66417 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri return this.cacheOperationSources; } + @Override public Collection getCacheOperations(Method method, Class targetClass) { Collection ops = null; diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/DefaultKeyGenerator.java b/spring-context/src/main/java/org/springframework/cache/interceptor/DefaultKeyGenerator.java index cb0dcc95d8..a37218804a 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/DefaultKeyGenerator.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/DefaultKeyGenerator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ public class DefaultKeyGenerator implements KeyGenerator { public static final int NO_PARAM_KEY = 0; public static final int NULL_PARAM_KEY = 53; + @Override public Object generate(Object target, Method method, Object... params) { if (params.length == 1) { return (params[0] == null ? NULL_PARAM_KEY : params[0]); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java index 69f22ec49f..c1cbdc0e9b 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 the original author or authors. + * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,6 +71,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri this.nameMap.put(methodName, ops); } + @Override public Collection getCacheOperations(Method method, Class targetClass) { // look for direct name match String methodName = method.getName(); diff --git a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java index 5d301d85f4..8d0f00bbf1 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java @@ -43,6 +43,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing private Set cacheNames = new LinkedHashSet(16); + @Override public void afterPropertiesSet() { Collection caches = loadCaches(); Assert.notEmpty(caches, "loadCaches must not return an empty Collection"); @@ -71,10 +72,12 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing } + @Override public Cache getCache(String name) { return this.cacheMap.get(name); } + @Override public Collection getCacheNames() { return Collections.unmodifiableSet(this.cacheNames); } diff --git a/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java index ab5b96d867..3d64b770e0 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java @@ -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"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager { this.fallbackToNoOpCache = fallbackToNoOpCache; } + @Override public void afterPropertiesSet() { if (this.fallbackToNoOpCache) { this.cacheManagers.add(new NoOpCacheManager()); @@ -66,6 +67,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager { } + @Override public Cache getCache(String name) { for (CacheManager cacheManager : this.cacheManagers) { Cache cache = cacheManager.getCache(name); @@ -76,6 +78,7 @@ public class CompositeCacheManager implements InitializingBean, CacheManager { return null; } + @Override public Collection getCacheNames() { List names = new ArrayList(); for (CacheManager manager : this.cacheManagers) { diff --git a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java index dc3203e6cf..f8ffe0e729 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java @@ -48,6 +48,7 @@ public class NoOpCacheManager implements CacheManager { * This implementation always returns a {@link Cache} implementation that will not store items. * Additionally, the request cache will be remembered by the manager for consistency. */ + @Override public Cache getCache(String name) { Cache cache = this.caches.get(name); if (cache == null) { @@ -63,6 +64,7 @@ public class NoOpCacheManager implements CacheManager { /** * This implementation returns the name of the caches previously requested. */ + @Override public Collection getCacheNames() { synchronized (this.cacheNames) { return Collections.unmodifiableSet(this.cacheNames); @@ -78,24 +80,30 @@ public class NoOpCacheManager implements CacheManager { this.name = name; } + @Override public void clear() { } + @Override public void evict(Object key) { } + @Override public ValueWrapper get(Object key) { return null; } + @Override public String getName() { return this.name; } + @Override public Object getNativeCache() { return null; } + @Override public void put(Object key, Object value) { } } diff --git a/spring-context/src/main/java/org/springframework/cache/support/SimpleValueWrapper.java b/spring-context/src/main/java/org/springframework/cache/support/SimpleValueWrapper.java index 8f2fb39166..b248902038 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/SimpleValueWrapper.java +++ b/spring-context/src/main/java/org/springframework/cache/support/SimpleValueWrapper.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public class SimpleValueWrapper implements ValueWrapper { /** * Create a new SimpleValueWrapper instance for exposing the given value. - * @param value the value to expose (may be null) + * @param value the value to expose (may be {@code null}) */ public SimpleValueWrapper(Object value) { this.value = value; @@ -42,6 +42,7 @@ public class SimpleValueWrapper implements ValueWrapper { /** * Simply returns the value as given at construction time. */ + @Override public Object get() { return this.value; } diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationContext.java b/spring-context/src/main/java/org/springframework/context/ApplicationContext.java index 85336bc43a..776e9f492b 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.core.env.EnvironmentCapable; import org.springframework.core.io.support.ResourcePatternResolver; -/** +/** * Central interface to provide configuration for an application. * This is read-only while the application is running, but may be * reloaded if the implementation supports this. @@ -59,7 +59,7 @@ public interface ApplicationContext extends EnvironmentCapable, ListableBeanFact /** * Return the unique id of this application context. - * @return the unique id of the context, or null if none + * @return the unique id of the context, or {@code null} if none */ String getId(); @@ -71,8 +71,8 @@ public interface ApplicationContext extends EnvironmentCapable, ListableBeanFact /** * Return a friendly name for this context. - * @return a display name for this context (never null) - */ + * @return a display name for this context (never {@code null}) + */ String getDisplayName(); /** @@ -82,9 +82,9 @@ public interface ApplicationContext extends EnvironmentCapable, ListableBeanFact long getStartupDate(); /** - * Return the parent context, or null if there is no parent + * Return the parent context, or {@code null} if there is no parent * and this is the root of the context hierarchy. - * @return the parent context, or null if there is no parent + * @return the parent context, or {@code null} if there is no parent */ ApplicationContext getParent(); @@ -101,7 +101,7 @@ public interface ApplicationContext extends EnvironmentCapable, ListableBeanFact * @return the AutowireCapableBeanFactory for this context * @throws IllegalStateException if the context does not support * the AutowireCapableBeanFactory interface or does not hold an autowire-capable - * bean factory yet (usually if refresh() has never been called) + * bean factory yet (usually if {@code refresh()} has never been called) * @see ConfigurableApplicationContext#refresh() * @see ConfigurableApplicationContext#getBeanFactory() */ diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationContextAware.java b/spring-context/src/main/java/org/springframework/context/ApplicationContextAware.java index 07a7f7f3ec..c8a20ef17e 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationContextAware.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationContextAware.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.beans.factory.Aware; * for bean lookup purposes. * *

      This interface can also be implemented if an object needs access to file - * resources, i.e. wants to call getResource, wants to publish + * resources, i.e. wants to call {@code getResource}, wants to publish * an application event, or requires access to the MessageSource. However, * it is preferable to implement the more specific {@link ResourceLoaderAware}, * {@link ApplicationEventPublisherAware} or {@link MessageSourceAware} interface @@ -57,8 +57,8 @@ import org.springframework.beans.factory.Aware; * @see org.springframework.beans.factory.BeanFactoryAware */ public interface ApplicationContextAware extends Aware { - - /** + + /** * Set the ApplicationContext that this object runs in. * Normally this call will be used to initialize the object. *

      Invoked after population of normal bean properties but before an init callback such diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationContextException.java b/spring-context/src/main/java/org/springframework/context/ApplicationContextException.java index 9c9f4066a4..2a53416c09 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationContextException.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationContextException.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ import org.springframework.beans.FatalBeanException; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class ApplicationContextException extends FatalBeanException { /** - * Create a new ApplicationContextException + * Create a new {@code ApplicationContextException} * with the specified detail message and no root cause. * @param msg the detail message */ @@ -35,7 +36,7 @@ public class ApplicationContextException extends FatalBeanException { } /** - * Create a new ApplicationContextException + * Create a new {@code ApplicationContextException} * with the specified detail message and the given root cause. * @param msg the detail message * @param cause the root cause diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java b/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java index 66bddfcfd2..e20d12cd85 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public abstract class ApplicationEvent extends EventObject { /** * Create a new ApplicationEvent. - * @param source the component that published the event (never null) + * @param source the component that published the event (never {@code null}) */ public ApplicationEvent(Object source) { super(source); diff --git a/spring-context/src/main/java/org/springframework/context/ApplicationListener.java b/spring-context/src/main/java/org/springframework/context/ApplicationListener.java index fc40e50222..a7eea9b5f9 100644 --- a/spring-context/src/main/java/org/springframework/context/ApplicationListener.java +++ b/spring-context/src/main/java/org/springframework/context/ApplicationListener.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.util.EventListener; /** * Interface to be implemented by application event listeners. - * Based on the standard java.util.EventListener interface + * Based on the standard {@code java.util.EventListener} interface * for the Observer design pattern. * *

      As of Spring 3.0, an ApplicationListener can generically declare the event type diff --git a/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java b/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java index 264d9b569e..09048cbe1f 100644 --- a/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/ConfigurableApplicationContext.java @@ -100,6 +100,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life /** * Return the Environment for this application context in configurable form. */ + @Override ConfigurableEnvironment getEnvironment(); /** @@ -153,11 +154,12 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life /** * Close this application context, releasing all resources and locks that the * implementation might hold. This includes destroying all cached singleton beans. - *

      Note: Does not invoke close on a parent context; + *

      Note: Does not invoke {@code close} on a parent context; * parent contexts have their own, independent lifecycle. *

      This method can be called multiple times without side effects: Subsequent - * close calls on an already closed context will be ignored. + * {@code close} calls on an already closed context will be ignored. */ + @Override void close(); /** diff --git a/spring-context/src/main/java/org/springframework/context/HierarchicalMessageSource.java b/spring-context/src/main/java/org/springframework/context/HierarchicalMessageSource.java index 45ef4243c7..d03b98774d 100644 --- a/spring-context/src/main/java/org/springframework/context/HierarchicalMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/HierarchicalMessageSource.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,18 +24,18 @@ package org.springframework.context; * @author Juergen Hoeller */ public interface HierarchicalMessageSource extends MessageSource { - - /** + + /** * Set the parent that will be used to try to resolve messages * that this object can't resolve. * @param parent the parent MessageSource that will be used to * resolve messages that this object can't resolve. - * May be null, in which case no further resolution is possible. + * May be {@code null}, in which case no further resolution is possible. */ void setParentMessageSource(MessageSource parent); /** - * Return the parent of this MessageSource, or null if none. + * Return the parent of this MessageSource, or {@code null} if none. */ MessageSource getParentMessageSource(); diff --git a/spring-context/src/main/java/org/springframework/context/Lifecycle.java b/spring-context/src/main/java/org/springframework/context/Lifecycle.java index 748bb35041..cfc101e39b 100644 --- a/spring-context/src/main/java/org/springframework/context/Lifecycle.java +++ b/spring-context/src/main/java/org/springframework/context/Lifecycle.java @@ -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"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public interface Lifecycle { /** * Check whether this component is currently running. - *

      In the case of a container, this will return true + *

      In the case of a container, this will return {@code true} * only if all components that apply are currently running. * @return whether the component is currently running */ diff --git a/spring-context/src/main/java/org/springframework/context/MessageSource.java b/spring-context/src/main/java/org/springframework/context/MessageSource.java index b83ec2a014..13f1530b31 100644 --- a/spring-context/src/main/java/org/springframework/context/MessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/MessageSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public interface MessageSource { * qualified class name, thus avoiding conflict and ensuring maximum clarity. * @param args array of arguments that will be filled in for params within * the message (params look like "{0}", "{1,date}", "{2,time}" within a message), - * or null if none. + * or {@code null} if none. * @param defaultMessage String to return if the lookup fails * @param locale the Locale in which to do the lookup * @return the resolved message if the lookup was successful; @@ -58,7 +58,7 @@ public interface MessageSource { * @param code the code to lookup up, such as 'calculator.noRateSet' * @param args Array of arguments that will be filled in for params within * the message (params look like "{0}", "{1,date}", "{2,time}" within a message), - * or null if none. + * or {@code null} if none. * @param locale the Locale in which to do the lookup * @return the resolved message * @throws NoSuchMessageException if the message wasn't found @@ -68,10 +68,10 @@ public interface MessageSource { /** * Try to resolve the message using all the attributes contained within the - * MessageSourceResolvable argument that was passed in. - *

      NOTE: We must throw a NoSuchMessageException on this method + * {@code MessageSourceResolvable} argument that was passed in. + *

      NOTE: We must throw a {@code NoSuchMessageException} on this method * since at the time of calling this method we aren't able to determine if the - * defaultMessage property of the resolvable is null or not. + * {@code defaultMessage} property of the resolvable is null or not. * @param resolvable value object storing attributes required to properly resolve a message * @param locale the Locale in which to do the lookup * @return the resolved message diff --git a/spring-context/src/main/java/org/springframework/context/MessageSourceResolvable.java b/spring-context/src/main/java/org/springframework/context/MessageSourceResolvable.java index b6441e59d7..965a44bbe7 100644 --- a/spring-context/src/main/java/org/springframework/context/MessageSourceResolvable.java +++ b/spring-context/src/main/java/org/springframework/context/MessageSourceResolvable.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.context; /** * Interface for objects that are suitable for message resolution in a * {@link MessageSource}. - * + * *

      Spring's own validation error classes implement this interface. * * @author Juergen Hoeller @@ -46,7 +46,7 @@ public interface MessageSourceResolvable { /** * Return the default message to be used to resolve this message. - * @return the default message, or null if no default + * @return the default message, or {@code null} if no default */ String getDefaultMessage(); diff --git a/spring-context/src/main/java/org/springframework/context/NoSuchMessageException.java b/spring-context/src/main/java/org/springframework/context/NoSuchMessageException.java index b2ab999a3f..777bd389b7 100644 --- a/spring-context/src/main/java/org/springframework/context/NoSuchMessageException.java +++ b/spring-context/src/main/java/org/springframework/context/NoSuchMessageException.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,6 +23,7 @@ import java.util.Locale; * * @author Rod Johnson */ +@SuppressWarnings("serial") public class NoSuchMessageException extends RuntimeException { /** diff --git a/spring-context/src/main/java/org/springframework/context/Phased.java b/spring-context/src/main/java/org/springframework/context/Phased.java index 3d262233b9..e815988e96 100644 --- a/spring-context/src/main/java/org/springframework/context/Phased.java +++ b/spring-context/src/main/java/org/springframework/context/Phased.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.context; /** * Interface for objects that may participate in a phased * process such as lifecycle management. - * + * * @author Mark Fisher * @since 3.0 * @see SmartLifecycle diff --git a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java index 3491cd047b..cf9edd7101 100644 --- a/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java +++ b/spring-context/src/main/java/org/springframework/context/ResourceLoaderAware.java @@ -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"); * you may not use this file except in compliance with the License. @@ -41,12 +41,12 @@ import org.springframework.core.io.ResourceLoader; * to resolve resource patterns into arrays of Resource objects. This will always * work when running in an ApplicationContext (the context interface extends * ResourcePatternResolver). Use a PathMatchingResourcePatternResolver as default. - * See also the ResourcePatternUtils.getResourcePatternResolver method. + * See also the {@code ResourcePatternUtils.getResourcePatternResolver} method. * *

      As alternative to a ResourcePatternResolver dependency, consider exposing * bean properties of type Resource array, populated via pattern Strings with * automatic type conversion by the bean factory. - * + * * @author Juergen Hoeller * @author Chris Beams * @since 10.03.2004 @@ -64,11 +64,11 @@ public interface ResourceLoaderAware extends Aware { /** * Set the ResourceLoader that this object runs in. *

      This might be a ResourcePatternResolver, which can be checked - * through instanceof ResourcePatternResolver. See also the - * ResourcePatternUtils.getResourcePatternResolver method. + * through {@code instanceof ResourcePatternResolver}. See also the + * {@code ResourcePatternUtils.getResourcePatternResolver} method. *

      Invoked after population of normal bean properties but before an init callback - * like InitializingBean's afterPropertiesSet or a custom init-method. - * Invoked before ApplicationContextAware's setApplicationContext. + * like InitializingBean's {@code afterPropertiesSet} or a custom init-method. + * Invoked before ApplicationContextAware's {@code setApplicationContext}. * @param resourceLoader ResourceLoader object to be used by this object * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver diff --git a/spring-context/src/main/java/org/springframework/context/access/ContextBeanFactoryReference.java b/spring-context/src/main/java/org/springframework/context/access/ContextBeanFactoryReference.java index fe56c165ae..f978a3db42 100644 --- a/spring-context/src/main/java/org/springframework/context/access/ContextBeanFactoryReference.java +++ b/spring-context/src/main/java/org/springframework/context/access/ContextBeanFactoryReference.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,9 +25,9 @@ import org.springframework.context.ConfigurableApplicationContext; * ApplicationContext-specific implementation of BeanFactoryReference, * wrapping a newly created ApplicationContext, closing it on release. * - *

      As per BeanFactoryReference contract, release may be called + *

      As per BeanFactoryReference contract, {@code release} may be called * more than once, with subsequent calls not doing anything. However, calling - * getFactory after a release call will cause an exception. + * {@code getFactory} after a {@code release} call will cause an exception. * * @author Juergen Hoeller * @author Colin Sampaleanu @@ -48,6 +48,7 @@ public class ContextBeanFactoryReference implements BeanFactoryReference { } + @Override public BeanFactory getFactory() { if (this.applicationContext == null) { throw new IllegalStateException( @@ -56,10 +57,11 @@ public class ContextBeanFactoryReference implements BeanFactoryReference { return this.applicationContext; } + @Override public void release() { if (this.applicationContext != null) { ApplicationContext savedCtx; - + // We don't actually guarantee thread-safety, but it's not a lot of extra work. synchronized (this) { savedCtx = this.applicationContext; diff --git a/spring-context/src/main/java/org/springframework/context/access/ContextJndiBeanFactoryLocator.java b/spring-context/src/main/java/org/springframework/context/access/ContextJndiBeanFactoryLocator.java index 9996b9473b..fe9493824b 100644 --- a/spring-context/src/main/java/org/springframework/context/access/ContextJndiBeanFactoryLocator.java +++ b/spring-context/src/main/java/org/springframework/context/access/ContextJndiBeanFactoryLocator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -50,13 +50,14 @@ public class ContextJndiBeanFactoryLocator extends JndiLocatorSupport implements /** * Load/use a bean factory, as specified by a factory key which is a JNDI - * address, of the form java:comp/env/ejb/BeanFactoryPath. The + * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The * contents of this JNDI location must be a string containing one or more - * classpath resource names (separated by any of the delimiters ',; \t\n' + * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}' * if there is more than one. The resulting BeanFactory (or ApplicationContext) * will be created from the combined resources. * @see #createBeanFactory */ + @Override public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException { try { String beanFactoryPath = lookup(factoryKey, String.class); @@ -77,7 +78,7 @@ public class ContextJndiBeanFactoryLocator extends JndiLocatorSupport implements * Create the BeanFactory instance, given an array of class path resource Strings * which should be combined. This is split out as a separate method so that * subclasses can override the actual BeanFactory implementation class. - *

      Delegates to createApplicationContext by default, + *

      Delegates to {@code createApplicationContext} by default, * wrapping the result in a ContextBeanFactoryReference. * @param resources an array of Strings representing classpath resource names * @return the created BeanFactory, wrapped in a BeanFactoryReference diff --git a/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java b/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java index cc250cafdd..57df5694c8 100644 --- a/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java +++ b/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class ContextSingletonBeanFactoryLocator extends SingletonBeanFactoryLoca /** * Returns an instance which uses the default "classpath*:beanRefContext.xml", as * the name of the definition file(s). All resources returned by the current - * thread's context class loader's getResources method with this + * thread's context class loader's {@code getResources} method with this * name will be combined to create a definition, which is just a BeanFactory. * @return the corresponding BeanFactoryLocator instance * @throws BeansException in case of factory loading failure @@ -73,7 +73,7 @@ public class ContextSingletonBeanFactoryLocator extends SingletonBeanFactoryLoca * Returns an instance which uses the the specified selector, as the name of the * definition file(s). In the case of a name with a Spring "classpath*:" prefix, * or with no prefix, which is treated the same, the current thread's context class - * loader's getResources method will be called with this value to get + * loader's {@code getResources} method will be called with this value to get * all resources having that name. These resources will then be combined to form a * definition. In the case where the name uses a Spring "classpath:" prefix, or * a standard URL prefix, then only one resource file will be loaded as the diff --git a/spring-context/src/main/java/org/springframework/context/access/DefaultLocatorFactory.java b/spring-context/src/main/java/org/springframework/context/access/DefaultLocatorFactory.java index 66e88b6bfc..1ac558f538 100644 --- a/spring-context/src/main/java/org/springframework/context/access/DefaultLocatorFactory.java +++ b/spring-context/src/main/java/org/springframework/context/access/DefaultLocatorFactory.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spring-context/src/main/java/org/springframework/context/access/package-info.java b/spring-context/src/main/java/org/springframework/context/access/package-info.java index eeceb70a9f..bcf7238ac6 100644 --- a/spring-context/src/main/java/org/springframework/context/access/package-info.java +++ b/spring-context/src/main/java/org/springframework/context/access/package-info.java @@ -2,7 +2,7 @@ /** * * Helper infrastructure to locate and access shared application contexts. - * + * *

      Note: This package is only relevant for special sharing of application * contexts, for example behind EJB facades. It is not used in a typical * web application or standalone application. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java b/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java index eae51ec251..826214448b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AdviceModeImportSelector.java @@ -65,6 +65,7 @@ public abstract class AdviceModeImportSelector implements * on the importing {@code @Configuration} class or if {@link #selectImports(AdviceMode)} * returns {@code null} */ + @Override public final String[] selectImports(AnnotationMetadata importingClassMetadata) { Class annoType = GenericTypeResolver.resolveTypeArgument(this.getClass(), AdviceModeImportSelector.class); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java index 60a05635aa..00d2f9810d 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationBeanNameGenerator.java @@ -37,7 +37,7 @@ import org.springframework.util.StringUtils; * {@link org.springframework.stereotype.Component @Component} as a * meta-annotation. For example, Spring's stereotype annotations (such as * {@link org.springframework.stereotype.Repository @Repository}) are - * themselves annotated with + * themselves annotated with * {@link org.springframework.stereotype.Component @Component}. * *

      Also supports Java EE 6's {@link javax.annotation.ManagedBean} and @@ -64,6 +64,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator { private static final String COMPONENT_ANNOTATION_CLASSNAME = "org.springframework.stereotype.Component"; + @Override public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) { if (definition instanceof AnnotatedBeanDefinition) { String beanName = determineBeanNameFromAnnotation((AnnotatedBeanDefinition) definition); @@ -79,7 +80,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator { /** * Derive a bean name from one of the annotations on the class. * @param annotatedDef the annotation-aware bean definition - * @return the bean name, or null if none is found + * @return the bean name, or {@code null} if none is found */ protected String determineBeanNameFromAnnotation(AnnotatedBeanDefinition annotatedDef) { AnnotationMetadata amd = annotatedDef.getMetadata(); @@ -103,7 +104,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator { /** * Check whether the given annotation is a stereotype that is allowed - * to suggest a component name through its annotation value(). + * to suggest a component name through its annotation {@code value()}. * @param annotationType the name of the annotation class to check * @param metaAnnotationTypes the names of meta-annotations on the given annotation * @param attributes the map of attributes for the given annotation @@ -124,7 +125,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator { *

      The default implementation delegates to {@link #buildDefaultBeanName(BeanDefinition)}. * @param definition the bean definition to build a bean name for * @param registry the registry that the given bean definition is being registered with - * @return the default bean name (never null) + * @return the default bean name (never {@code null}) */ protected String buildDefaultBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) { return buildDefaultBeanName(definition); @@ -138,7 +139,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator { * "outerClassName.innerClassName", which because of the period in the * name may be an issue if you are autowiring by name. * @param definition the bean definition to build a bean name for - * @return the default bean name (never null) + * @return the default bean name (never {@code null}) */ protected String buildDefaultBeanName(BeanDefinition definition) { String shortClassName = ClassUtils.getShortName(definition.getBeanClassName()); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigBeanDefinitionParser.java index c25b536f93..de52f2e6d3 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import org.springframework.beans.factory.xml.ParserContext; */ public class AnnotationConfigBeanDefinitionParser implements BeanDefinitionParser { + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { Object source = parserContext.extractSource(element); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java index 793ba314b4..f283bb6d2c 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java @@ -170,7 +170,7 @@ public class AnnotationConfigUtils { * Register all relevant annotation post processors in the given registry. * @param registry the registry to operate on * @param source the configuration source element (already extracted) - * that this registration was triggered from. May be null. + * that this registration was triggered from. May be {@code null}. * @return a Set of BeanDefinitionHolders, containing all bean definitions * that have actually been registered by this call */ diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java index 493745bd82..79556e6aff 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java @@ -44,7 +44,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { private final ScopedProxyMode defaultProxyMode; /** - * Create a new instance of the AnnotationScopeMetadataResolver class. + * Create a new instance of the {@code AnnotationScopeMetadataResolver} class. * @see #AnnotationScopeMetadataResolver(ScopedProxyMode) * @see ScopedProxyMode#NO */ @@ -53,7 +53,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { } /** - * Create a new instance of the AnnotationScopeMetadataResolver class. + * Create a new instance of the {@code AnnotationScopeMetadataResolver} class. * @param defaultProxyMode the desired scoped-proxy mode */ public AnnotationScopeMetadataResolver(ScopedProxyMode defaultProxyMode) { @@ -73,6 +73,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { } + @Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); if (definition instanceof AnnotatedBeanDefinition) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AspectJAutoProxyRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/AspectJAutoProxyRegistrar.java index aedbbbe28e..5b3c522d8f 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AspectJAutoProxyRegistrar.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AspectJAutoProxyRegistrar.java @@ -39,6 +39,7 @@ class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar { * of the @{@link EnableAspectJAutoProxy#proxyTargetClass()} attribute on the importing * {@code @Configuration} class. */ + @Override public void registerBeanDefinitions( AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java index 804dbca526..e0fde7df8f 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java @@ -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"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.context.annotation; import static org.springframework.context.annotation.MetadataUtils.attributesFor; -import java.util.Map; import java.util.Set; import org.apache.commons.logging.Log; @@ -57,6 +56,7 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar { * {@code proxyTargetClass} attributes, the APC can be registered and configured all * the same. */ + @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { boolean candidateFound = false; Set annoTypes = importingClassMetadata.getAnnotationTypes(); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java index 900584037d..a0c8ab1159 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java @@ -78,7 +78,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; * classes. In this case, bean methods may reference other {@code @Bean} methods * in the same class by calling them directly. This ensures that references between * beans are strongly typed and navigable. Such so-called 'inter-bean references' are - * guaranteed to respect scoping and AOP semantics, just like getBean() lookups + * guaranteed to respect scoping and AOP semantics, just like {@code getBean()} lookups * would. These are the semantics known from the original 'Spring JavaConfig' project * which require CGLIB subclassing of each such configuration class at runtime. As a * consequence, {@code @Configuration} classes and their factory methods must not be @@ -118,7 +118,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; * the invocation via a CGLIB proxy. This is analogous to inter-{@code @Transactional} * method calls where in proxy mode, Spring does not intercept the invocation — * Spring does so only in AspectJ mode. - * + * *

      For example: * *

      diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java
      index a06bd3d770..b3f9450f98 100644
      --- a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java
      +++ b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java
      @@ -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");
        * you may not use this file except in compliance with the License.
      @@ -256,7 +256,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
       					beanDefinitions.add(definitionHolder);
       					registerBeanDefinition(definitionHolder, this.registry);
       				}
      -			}						
      +			}
       		}
       		return beanDefinitions;
       	}
      @@ -291,8 +291,8 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
       	 * bean definition needs to be registered or conflicts with an existing definition.
       	 * @param beanName the suggested name for the bean
       	 * @param beanDefinition the corresponding bean definition
      -	 * @return true if the bean can be registered as-is;
      -	 * false if it should be skipped because there is an
      +	 * @return {@code true} if the bean can be registered as-is;
      +	 * {@code false} if it should be skipped because there is an
       	 * existing, compatible bean definition for the specified name
       	 * @throws ConflictingBeanDefinitionException if an existing, incompatible
       	 * bean definition has been found for the specified name
      diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
      index 6dacb49d60..5e1dd4b18a 100644
      --- a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
      +++ b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
      @@ -117,6 +117,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
       	 * @see org.springframework.core.io.support.ResourcePatternResolver
       	 * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
       	 */
      +	@Override
       	public void setResourceLoader(ResourceLoader resourceLoader) {
       		this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
       		this.metadataReaderFactory = new CachingMetadataReaderFactory(resourceLoader);
      @@ -157,6 +158,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
       		this.environment = environment;
       	}
       
      +	@Override
       	public final Environment getEnvironment() {
       		return this.environment;
       	}
      diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
      index 295ebb500f..e381c9ce71 100644
      --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
      +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
      @@ -69,7 +69,7 @@ import org.springframework.util.StringUtils;
       /**
        * {@link org.springframework.beans.factory.config.BeanPostProcessor} implementation
        * that supports common Java annotations out of the box, in particular the JSR-250
      - * annotations in the javax.annotation package. These common Java
      + * annotations in the {@code javax.annotation} package. These common Java
        * annotations are supported in many Java EE 5 technologies (e.g. JSF 1.2),
        * as well as in Java 6's JAX-WS.
        *
      @@ -80,9 +80,9 @@ import org.springframework.util.StringUtils;
        *
        * 

      The central element is the {@link javax.annotation.Resource} annotation * for annotation-driven injection of named beans, by default from the containing - * Spring BeanFactory, with only mappedName references resolved in JNDI. + * Spring BeanFactory, with only {@code mappedName} references resolved in JNDI. * The {@link #setAlwaysUseJndiLookup "alwaysUseJndiLookup" flag} enforces JNDI lookups - * equivalent to standard Java EE 5 resource injection for name references + * equivalent to standard Java EE 5 resource injection for {@code name} references * and default names as well. The target beans can be simple POJOs, with no special * requirements other than the type having to match. * @@ -116,9 +116,9 @@ import org.springframework.util.StringUtils; * <property name="alwaysUseJndiLookup" value="true"/> * </bean>

      * - * mappedName references will always be resolved in JNDI, + * {@code mappedName} references will always be resolved in JNDI, * allowing for global JNDI names (including "java:" prefix) as well. The - * "alwaysUseJndiLookup" flag just affects name references and + * "alwaysUseJndiLookup" flag just affects {@code name} references and * default names (inferred from the field name / property name). * *

      NOTE: A default CommonAnnotationBeanPostProcessor will be registered @@ -127,7 +127,7 @@ import org.springframework.util.StringUtils; * to specify a custom CommonAnnotationBeanPostProcessor bean definition! *

      NOTE: Annotation injection will be performed before XML injection; thus * the latter configuration will override the former for properties wired through - * both approaches. + * both approaches. * * @author Juergen Hoeller * @since 2.5 @@ -196,9 +196,9 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean /** - * Ignore the given resource type when resolving @Resource + * Ignore the given resource type when resolving {@code @Resource} * annotations. - *

      By default, the javax.xml.ws.WebServiceContext interface + *

      By default, the {@code javax.xml.ws.WebServiceContext} interface * will be ignored, since it will be resolved by the JAX-WS runtime. * @param resourceType the resource type to ignore */ @@ -223,11 +223,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean /** * Set whether to always use JNDI lookups equivalent to standard Java EE 5 resource - * injection, even for name attributes and default names. + * injection, even for {@code name} attributes and default names. *

      Default is "false": Resource names are used for Spring bean lookups in the - * containing BeanFactory; only mappedName attributes point directly + * containing BeanFactory; only {@code mappedName} attributes point directly * into JNDI. Switch this flag to "true" for enforcing Java EE style JNDI lookups - * in any case, even for name attributes and default names. + * in any case, even for {@code name} attributes and default names. * @see #setJndiFactory * @see #setResourceFactory */ @@ -236,11 +236,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } /** - * Specify the factory for objects to be injected into @Resource / - * @WebServiceRef / @EJB annotated fields and setter methods, - * for mappedName attributes that point directly into JNDI. + * Specify the factory for objects to be injected into {@code @Resource} / + * {@code @WebServiceRef} / {@code @EJB} annotated fields and setter methods, + * for {@code mappedName} attributes that point directly into JNDI. * This factory will also be used if "alwaysUseJndiLookup" is set to "true" in order - * to enforce JNDI lookups even for name attributes and default names. + * to enforce JNDI lookups even for {@code name} attributes and default names. *

      The default is a {@link org.springframework.jndi.support.SimpleJndiBeanFactory} * for JNDI lookup behavior equivalent to standard Java EE 5 resource injection. * @see #setResourceFactory @@ -252,15 +252,15 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } /** - * Specify the factory for objects to be injected into @Resource / - * @WebServiceRef / @EJB annotated fields and setter methods, - * for name attributes and default names. + * Specify the factory for objects to be injected into {@code @Resource} / + * {@code @WebServiceRef} / {@code @EJB} annotated fields and setter methods, + * for {@code name} attributes and default names. *

      The default is the BeanFactory that this post-processor is defined in, * if any, looking up resource names as Spring bean names. Specify the resource * factory explicitly for programmatic usage of this post-processor. *

      Specifying Spring's {@link org.springframework.jndi.support.SimpleJndiBeanFactory} * leads to JNDI lookup behavior equivalent to standard Java EE 5 resource injection, - * even for name attributes and default names. This is the same behavior + * even for {@code name} attributes and default names. This is the same behavior * that the "alwaysUseJndiLookup" flag enables. * @see #setAlwaysUseJndiLookup */ @@ -269,6 +269,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean this.resourceFactory = resourceFactory; } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { Assert.notNull(beanFactory, "BeanFactory must not be null"); this.beanFactory = beanFactory; @@ -287,14 +288,17 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } } + @Override public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { return null; } + @Override public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { return true; } + @Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { @@ -399,7 +403,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean * Obtain the resource object for the given name and type. * @param element the descriptor for the annotated field/method * @param requestingBeanName the name of the requesting bean - * @return the resource object (never null) + * @return the resource object (never {@code null}) * @throws BeansException if we failed to obtain the target resource */ protected Object getResource(LookupElement element, String requestingBeanName) throws BeansException { @@ -422,7 +426,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean * @param factory the factory to autowire against * @param element the descriptor for the annotated field/method * @param requestingBeanName the name of the requesting bean - * @return the resource object (never null) + * @return the resource object (never {@code null}) * @throws BeansException if we failed to obtain the target resource */ protected Object autowireResource(BeanFactory factory, LookupElement element, String requestingBeanName) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java index f7b5677635..2ef0ad17af 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -75,6 +75,7 @@ public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser { private static final String FILTER_EXPRESSION_ATTRIBUTE = "expression"; + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute(BASE_PACKAGE_ATTRIBUTE), ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java index 5268e633aa..a25fdcf4ce 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java @@ -178,7 +178,7 @@ final class ConfigurationClass { int newCount = currentCount != null ? currentCount + 1 : 1; methodNameCounts.put(fqMethodName, newCount); } - + for (String methodName : methodNameCounts.keySet()) { int count = methodNameCounts.get(methodName); if (count > 1) { @@ -186,7 +186,7 @@ final class ConfigurationClass { problemReporter.error(new BeanMethodOverloadingProblem(shortMethodName, count)); } } - + // A configuration class may not be final (CGLIB limitation) if (getMetadata().isAnnotated(Configuration.class.getName())) { if (getMetadata().isFinal()) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java index e7fa93a246..b30a04694e 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java @@ -318,6 +318,7 @@ class ConfigurationClassBeanDefinitionReader { this.annotationMetadata = original.annotationMetadata; } + @Override public AnnotationMetadata getMetadata() { return this.annotationMetadata; } @@ -333,7 +334,7 @@ class ConfigurationClassBeanDefinitionReader { } } - + /** * Configuration classes must be annotated with {@link Configuration @Configuration} or * declare at least one {@link Bean @Bean} method. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index 99678159d3..f75157fc16 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -56,6 +56,7 @@ class ConfigurationClassEnhancer { DisposableBeanMethodInterceptor.class, NoOp.class }; private static final CallbackFilter CALLBACK_FILTER = new CallbackFilter() { + @Override public int accept(Method candidateMethod) { // Set up the callback filter to return the index of the BeanMethodInterceptor when // handling a @Bean-annotated method; otherwise, return index of the NoOp callback. @@ -168,6 +169,7 @@ class ConfigurationClassEnhancer { this.beanName = beanName; } + @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { return beanFactory.getBean(beanName); } @@ -183,6 +185,7 @@ class ConfigurationClassEnhancer { */ private static class DisposableBeanMethodInterceptor implements MethodInterceptor { + @Override public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { Enhancer.registerStaticCallbacks(obj.getClass(), null); // does the actual (non-CGLIB) superclass actually implement DisposableBean? @@ -213,6 +216,7 @@ class ConfigurationClassEnhancer { GetObjectMethodInterceptor.class, NoOp.class }; private static final CallbackFilter CALLBACK_FITLER = new CallbackFilter() { + @Override public int accept(Method method) { return method.getName().equals("getObject") ? 0 : 1; } @@ -234,6 +238,7 @@ class ConfigurationClassEnhancer { * invoking the super implementation of the proxied method i.e., the actual * {@code @Bean} method. */ + @Override public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object[] beanMethodArgs, MethodProxy cglibMethodProxy) throws Throwable { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index 2901e5cea0..7bb0e7f1f3 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -413,6 +413,7 @@ class ConfigurationClassParser { this.imports.put(importedClass, importingClass); } + @Override public String getImportingClassFor(String importedClass) { return this.imports.get(importedClass); } @@ -426,6 +427,7 @@ class ConfigurationClassParser { public boolean contains(Object elem) { ConfigurationClass configClass = (ConfigurationClass) elem; Comparator comparator = new Comparator() { + @Override public int compare(ConfigurationClass first, ConfigurationClass second) { return first.getMetadata().getClassName().equals(second.getMetadata().getClassName()) ? 0 : 1; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java index f2fa6273e6..ab10dfda19 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java @@ -79,7 +79,7 @@ import static org.springframework.context.annotation.AnnotationConfigUtils.*; * that any {@link Bean} methods declared in Configuration classes have their * respective bean definitions registered before any other BeanFactoryPostProcessor * executes. - * + * * @author Chris Beams * @author Juergen Hoeller * @since 3.0 @@ -183,16 +183,19 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo this.importBeanNameGenerator = beanNameGenerator; } + @Override public void setEnvironment(Environment environment) { Assert.notNull(environment, "Environment must not be null"); this.environment = environment; } + @Override public void setResourceLoader(ResourceLoader resourceLoader) { Assert.notNull(resourceLoader, "ResourceLoader must not be null"); this.resourceLoader = resourceLoader; } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; if (!this.setMetadataReaderFactoryCalled) { @@ -204,6 +207,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo /** * Derive further bean definitions from the configuration classes in the registry. */ + @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { RootBeanDefinition iabpp = new RootBeanDefinition(ImportAwareBeanPostProcessor.class); iabpp.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); @@ -227,6 +231,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo * Prepare the Configuration classes for servicing bean requests at runtime * by replacing them with CGLIB-enhanced subclasses. */ + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { int factoryId = System.identityHashCode(beanFactory); if (this.factoriesPostProcessed.contains(factoryId)) { @@ -373,10 +378,12 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo private BeanFactory beanFactory; + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ImportAware) { ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class); @@ -399,10 +406,12 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; } + @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/DependsOn.java b/spring-context/src/main/java/org/springframework/context/annotation/DependsOn.java index 4b05e14b28..88d06dc6c0 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/DependsOn.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/DependsOn.java @@ -20,7 +20,6 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Inherited; import java.lang.annotation.Documented; /** diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java b/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java index 8549d97f8e..47b6395fbd 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -81,6 +81,7 @@ public class Jsr330ScopeMetadataResolver implements ScopeMetadataResolver { } + @Override public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) { ScopeMetadata metadata = new ScopeMetadata(); metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java index d81821b703..efc2a0e30e 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfiguration.java @@ -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"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade private ClassLoader beanClassLoader; + @Override public void setImportMetadata(AnnotationMetadata importMetadata) { this.enableLTW = MetadataUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class); Assert.notNull(this.enableLTW, @@ -59,6 +60,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade importMetadata.getClassName()); } + @Override public void setBeanClassLoader(ClassLoader beanClassLoader) { this.beanClassLoader = beanClassLoader; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java index f9d38ecefd..d2f0bb2b5b 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java @@ -56,6 +56,7 @@ public class MBeanExportConfiguration implements ImportAware, BeanFactoryAware { private BeanFactory beanFactory; + @Override public void setImportMetadata(AnnotationMetadata importMetadata) { Map map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName()); this.attributes = AnnotationAttributes.fromMap(map); @@ -63,6 +64,7 @@ public class MBeanExportConfiguration implements ImportAware, BeanFactoryAware { "importing class " + importMetadata.getClassName()); } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ScannedGenericBeanDefinition.java b/spring-context/src/main/java/org/springframework/context/annotation/ScannedGenericBeanDefinition.java index b5afe9f6de..7ed9bed6fe 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ScannedGenericBeanDefinition.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ScannedGenericBeanDefinition.java @@ -61,6 +61,7 @@ public class ScannedGenericBeanDefinition extends GenericBeanDefinition implemen } + @Override public final AnnotationMetadata getMetadata() { return this.metadata; } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Scope.java b/spring-context/src/main/java/org/springframework/context/annotation/Scope.java index b62c3ca6ec..2e556f5187 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Scope.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Scope.java @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.stereotype.Component; * When used as a type-level annotation in conjunction with the {@link Component} * annotation, indicates the name of a scope to use for instances of the annotated * type. - * + * *

      When used as a method-level annotation in conjunction with the * {@link Bean} annotation, indicates the name of a scope to use for * the instance returned from the method. diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java b/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java index 07b41d1000..a13dfdd193 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadata.java @@ -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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.springframework.util.Assert; public class ScopeMetadata { private String scopeName = BeanDefinition.SCOPE_SINGLETON; - + private ScopedProxyMode scopedProxyMode = ScopedProxyMode.NO; diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadataResolver.java b/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadataResolver.java index e9cbcb25f7..04fda90705 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadataResolver.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ScopeMetadataResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.BeanDefinition; /** * Strategy interface for resolving the scope of bean definitions. - * + * * @author Mark Fisher * @since 2.5 * @see org.springframework.context.annotation.Scope @@ -29,16 +29,16 @@ public interface ScopeMetadataResolver { /** * Resolve the {@link ScopeMetadata} appropriate to the supplied - * bean definition. + * bean {@code definition}. *

      Implementations can of course use any strategy they like to * determine the scope metadata, but some implementations that spring * immediately to mind might be to use source level annotations * present on {@link BeanDefinition#getBeanClassName() the class} of the - * supplied definition, or to use metadata present in the - * {@link BeanDefinition#attributeNames()} of the supplied definition. + * supplied {@code definition}, or to use metadata present in the + * {@link BeanDefinition#attributeNames()} of the supplied {@code definition}. * @param definition the target bean definition - * @return the relevant scope metadata; never null + * @return the relevant scope metadata; never {@code null} */ ScopeMetadata resolveScopeMetadata(BeanDefinition definition); - + } diff --git a/spring-context/src/main/java/org/springframework/context/config/ContextNamespaceHandler.java b/spring-context/src/main/java/org/springframework/context/config/ContextNamespaceHandler.java index 62f83a8f0d..f85d09d0ab 100644 --- a/spring-context/src/main/java/org/springframework/context/config/ContextNamespaceHandler.java +++ b/spring-context/src/main/java/org/springframework/context/config/ContextNamespaceHandler.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.context.annotation.ComponentScanBeanDefinitionParser; /** * {@link org.springframework.beans.factory.xml.NamespaceHandler} - * for the 'context' namespace. + * for the '{@code context}' namespace. * * @author Mark Fisher * @author Juergen Hoeller @@ -30,6 +30,7 @@ import org.springframework.context.annotation.ComponentScanBeanDefinitionParser; */ public class ContextNamespaceHandler extends NamespaceHandlerSupport { + @Override public void init() { registerBeanDefinitionParser("property-placeholder", new PropertyPlaceholderBeanDefinitionParser()); registerBeanDefinitionParser("property-override", new PropertyOverrideBeanDefinitionParser()); diff --git a/spring-context/src/main/java/org/springframework/context/config/PropertyOverrideBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/context/config/PropertyOverrideBeanDefinitionParser.java index d48ad706b8..c7ad16ac50 100644 --- a/spring-context/src/main/java/org/springframework/context/config/PropertyOverrideBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/context/config/PropertyOverrideBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ class PropertyOverrideBeanDefinitionParser extends AbstractPropertyLoadingBeanDe protected Class getBeanClass(Element element) { return PropertyOverrideConfigurer.class; } - + @Override protected void doParse(Element element, BeanDefinitionBuilder builder) { diff --git a/spring-context/src/main/java/org/springframework/context/config/SpringConfiguredBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/context/config/SpringConfiguredBeanDefinitionParser.java index 98e3c3a025..3d61447fc3 100644 --- a/spring-context/src/main/java/org/springframework/context/config/SpringConfiguredBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/context/config/SpringConfiguredBeanDefinitionParser.java @@ -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"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser { "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"; + @Override public BeanDefinition parse(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) { RootBeanDefinition def = new RootBeanDefinition(); diff --git a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java index 055b5e59db..35a3ed3288 100644 --- a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java @@ -58,6 +58,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application private BeanFactory beanFactory; + @Override public void addApplicationListener(ApplicationListener listener) { synchronized (this.defaultRetriever) { this.defaultRetriever.applicationListeners.add(listener); @@ -65,6 +66,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application } } + @Override public void addApplicationListenerBean(String listenerBeanName) { synchronized (this.defaultRetriever) { this.defaultRetriever.applicationListenerBeans.add(listenerBeanName); @@ -72,6 +74,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application } } + @Override public void removeApplicationListener(ApplicationListener listener) { synchronized (this.defaultRetriever) { this.defaultRetriever.applicationListeners.remove(listener); @@ -79,6 +82,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application } } + @Override public void removeApplicationListenerBean(String listenerBeanName) { synchronized (this.defaultRetriever) { this.defaultRetriever.applicationListenerBeans.remove(listenerBeanName); @@ -86,6 +90,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application } } + @Override public void removeAllListeners() { synchronized (this.defaultRetriever) { this.defaultRetriever.applicationListeners.clear(); @@ -94,6 +99,7 @@ public abstract class AbstractApplicationEventMulticaster implements Application } } + @Override public final void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; } diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationContextEvent.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationContextEvent.java index bc9dbb3d5f..fa84458568 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationContextEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationContextEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -20,24 +20,25 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; /** - * Base class for events raised for an ApplicationContext. + * Base class for events raised for an {@code ApplicationContext}. * * @author Juergen Hoeller * @since 2.5 */ +@SuppressWarnings("serial") public abstract class ApplicationContextEvent extends ApplicationEvent { /** * Create a new ContextStartedEvent. - * @param source the ApplicationContext that the event is raised for - * (must not be null) + * @param source the {@code ApplicationContext} that the event is raised for + * (must not be {@code null}) */ public ApplicationContextEvent(ApplicationContext source) { super(source); } /** - * Get the ApplicationContext that the event was raised for. + * Get the {@code ApplicationContext} that the event was raised for. */ public final ApplicationContext getApplicationContext() { return (ApplicationContext) getSource(); diff --git a/spring-context/src/main/java/org/springframework/context/event/ContextClosedEvent.java b/spring-context/src/main/java/org/springframework/context/event/ContextClosedEvent.java index e53df33896..8db8dc4dc7 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ContextClosedEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ContextClosedEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,18 +19,19 @@ package org.springframework.context.event; import org.springframework.context.ApplicationContext; /** - * Event raised when an ApplicationContext gets closed. + * Event raised when an {@code ApplicationContext} gets closed. * * @author Juergen Hoeller * @since 12.08.2003 * @see ContextRefreshedEvent */ +@SuppressWarnings("serial") public class ContextClosedEvent extends ApplicationContextEvent { /** * Creates a new ContextClosedEvent. - * @param source the ApplicationContext that has been closed - * (must not be null) + * @param source the {@code ApplicationContext} that has been closed + * (must not be {@code null}) */ public ContextClosedEvent(ApplicationContext source) { super(source); diff --git a/spring-context/src/main/java/org/springframework/context/event/ContextRefreshedEvent.java b/spring-context/src/main/java/org/springframework/context/event/ContextRefreshedEvent.java index 9b448cb3b4..d18b3970d2 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ContextRefreshedEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ContextRefreshedEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,18 +19,19 @@ package org.springframework.context.event; import org.springframework.context.ApplicationContext; /** - * Event raised when an ApplicationContext gets initialized or refreshed. + * Event raised when an {@code ApplicationContext} gets initialized or refreshed. * * @author Juergen Hoeller * @since 04.03.2003 * @see ContextClosedEvent */ +@SuppressWarnings("serial") public class ContextRefreshedEvent extends ApplicationContextEvent { /** * Create a new ContextRefreshedEvent. - * @param source the ApplicationContext that has been initialized - * or refreshed (must not be null) + * @param source the {@code ApplicationContext} that has been initialized + * or refreshed (must not be {@code null}) */ public ContextRefreshedEvent(ApplicationContext source) { super(source); diff --git a/spring-context/src/main/java/org/springframework/context/event/ContextStartedEvent.java b/spring-context/src/main/java/org/springframework/context/event/ContextStartedEvent.java index bc3e7163c1..5033d7dbb7 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ContextStartedEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ContextStartedEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,19 +19,20 @@ package org.springframework.context.event; import org.springframework.context.ApplicationContext; /** - * Event raised when an ApplicationContext gets started. + * Event raised when an {@code ApplicationContext} gets started. * * @author Mark Fisher * @author Juergen Hoeller * @since 2.5 * @see ContextStoppedEvent */ +@SuppressWarnings("serial") public class ContextStartedEvent extends ApplicationContextEvent { /** * Create a new ContextStartedEvent. - * @param source the ApplicationContext that has been started - * (must not be null) + * @param source the {@code ApplicationContext} that has been started + * (must not be {@code null}) */ public ContextStartedEvent(ApplicationContext source) { super(source); diff --git a/spring-context/src/main/java/org/springframework/context/event/ContextStoppedEvent.java b/spring-context/src/main/java/org/springframework/context/event/ContextStoppedEvent.java index a00f82baea..98d95a8cef 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ContextStoppedEvent.java +++ b/spring-context/src/main/java/org/springframework/context/event/ContextStoppedEvent.java @@ -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"); * you may not use this file except in compliance with the License. @@ -19,19 +19,20 @@ package org.springframework.context.event; import org.springframework.context.ApplicationContext; /** - * Event raised when an ApplicationContext gets stopped. + * Event raised when an {@code ApplicationContext} gets stopped. * * @author Mark Fisher * @author Juergen Hoeller * @since 2.5 * @see ContextStartedEvent */ +@SuppressWarnings("serial") public class ContextStoppedEvent extends ApplicationContextEvent { /** * Create a new ContextStoppedEvent. - * @param source the ApplicationContext that has been stopped - * (must not be null) + * @param source the {@code ApplicationContext} that has been stopped + * (must not be {@code null}) */ public ContextStoppedEvent(ApplicationContext source) { super(source); diff --git a/spring-context/src/main/java/org/springframework/context/event/EventPublicationInterceptor.java b/spring-context/src/main/java/org/springframework/context/event/EventPublicationInterceptor.java index 98d08dbcf3..0ff440e34c 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventPublicationInterceptor.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventPublicationInterceptor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,8 +28,8 @@ import org.springframework.context.ApplicationEventPublisherAware; /** * {@link MethodInterceptor Interceptor} that publishes an - * ApplicationEvent to all ApplicationListeners - * registered with an ApplicationEventPublisher after each + * {@code ApplicationEvent} to all {@code ApplicationListeners} + * registered with an {@code ApplicationEventPublisher} after each * successful method invocation. * *

      Note that this interceptor is only capable of publishing stateless @@ -56,11 +56,11 @@ public class EventPublicationInterceptor /** * Set the application event class to publish. *

      The event class must have a constructor with a single - * Object argument for the event source. The interceptor + * {@code Object} argument for the event source. The interceptor * will pass in the invoked object. - * @throws IllegalArgumentException if the supplied Class is - * null or if it is not an ApplicationEvent subclass or - * if it does not expose a constructor that takes a single Object argument + * @throws IllegalArgumentException if the supplied {@code Class} is + * {@code null} or if it is not an {@code ApplicationEvent} subclass or + * if it does not expose a constructor that takes a single {@code Object} argument */ public void setApplicationEventClass(Class applicationEventClass) { if (ApplicationEvent.class.equals(applicationEventClass) || @@ -77,10 +77,12 @@ public class EventPublicationInterceptor } } + @Override public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { this.applicationEventPublisher = applicationEventPublisher; } + @Override public void afterPropertiesSet() throws Exception { if (this.applicationEventClassConstructor == null) { throw new IllegalArgumentException("applicationEventClass is required"); @@ -88,6 +90,7 @@ public class EventPublicationInterceptor } + @Override public Object invoke(MethodInvocation invocation) throws Throwable { Object retVal = invocation.proceed(); diff --git a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java index 5866212e87..8c7f6e6d57 100644 --- a/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/GenericApplicationListenerAdapter.java @@ -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"); * you may not use this file except in compliance with the License. @@ -46,11 +46,13 @@ public class GenericApplicationListenerAdapter implements SmartApplicationListen } + @Override @SuppressWarnings("unchecked") public void onApplicationEvent(ApplicationEvent event) { this.delegate.onApplicationEvent(event); } + @Override public boolean supportsEventType(Class eventType) { Class typeArg = GenericTypeResolver.resolveTypeArgument(this.delegate.getClass(), ApplicationListener.class); if (typeArg == null || typeArg.equals(ApplicationEvent.class)) { @@ -62,10 +64,12 @@ public class GenericApplicationListenerAdapter implements SmartApplicationListen return (typeArg == null || typeArg.isAssignableFrom(eventType)); } + @Override public boolean supportsSourceType(Class sourceType) { return true; } + @Override public int getOrder() { return (this.delegate instanceof Ordered ? ((Ordered) this.delegate).getOrder() : Ordered.LOWEST_PRECEDENCE); } diff --git a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java index d84d0d17b0..ebbdae71dc 100644 --- a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.context.ApplicationListener; * *

      Multicasts all events to all registered listeners, leaving it up to * the listeners to ignore events that they are not interested in. - * Listeners will usually perform corresponding instanceof + * Listeners will usually perform corresponding {@code instanceof} * checks on the passed-in event object. * *

      By default, all listeners are invoked in the calling thread. @@ -81,12 +81,14 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM } + @Override @SuppressWarnings("unchecked") public void multicastEvent(final ApplicationEvent event) { for (final ApplicationListener listener : getApplicationListeners(event)) { Executor executor = getTaskExecutor(); if (executor != null) { executor.execute(new Runnable() { + @Override @SuppressWarnings("unchecked") public void run() { listener.onApplicationEvent(event); diff --git a/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java b/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java index a9326c5b16..ff1f4bb2d1 100644 --- a/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java +++ b/spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java @@ -63,20 +63,24 @@ public class SourceFilteringListener implements SmartApplicationListener { } + @Override public void onApplicationEvent(ApplicationEvent event) { if (event.getSource() == this.source) { onApplicationEventInternal(event); } } + @Override public boolean supportsEventType(Class eventType) { return (this.delegate == null || this.delegate.supportsEventType(eventType)); } + @Override public boolean supportsSourceType(Class sourceType) { return sourceType.isInstance(this.source); } + @Override public int getOrder() { return (this.delegate != null ? this.delegate.getOrder() : Ordered.LOWEST_PRECEDENCE); } diff --git a/spring-context/src/main/java/org/springframework/context/expression/BeanExpressionContextAccessor.java b/spring-context/src/main/java/org/springframework/context/expression/BeanExpressionContextAccessor.java index e81c929e81..0f1a161948 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/BeanExpressionContextAccessor.java +++ b/spring-context/src/main/java/org/springframework/context/expression/BeanExpressionContextAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,22 +32,27 @@ import org.springframework.expression.TypedValue; */ public class BeanExpressionContextAccessor implements PropertyAccessor { + @Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { return ((BeanExpressionContext) target).containsObject(name); } + @Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { return new TypedValue(((BeanExpressionContext) target).getObject(name)); } + @Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { return false; } + @Override public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); } + @Override public Class[] getSpecificTargetClasses() { return new Class[] {BeanExpressionContext.class}; } diff --git a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryAccessor.java b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryAccessor.java index 486ded925f..15d3d7a622 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryAccessor.java +++ b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -32,22 +32,27 @@ import org.springframework.expression.TypedValue; */ public class BeanFactoryAccessor implements PropertyAccessor { + @Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { return (((BeanFactory) target).containsBean(name)); } + @Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { return new TypedValue(((BeanFactory) target).getBean(name)); } + @Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { return false; } + @Override public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); } + @Override public Class[] getSpecificTargetClasses() { return new Class[] {BeanFactory.class}; } diff --git a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java index ff4aaaa78d..94ecbe74a0 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java +++ b/spring-context/src/main/java/org/springframework/context/expression/BeanFactoryResolver.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ public class BeanFactoryResolver implements BeanResolver { this.beanFactory = beanFactory; } + @Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { try { return this.beanFactory.getBean(beanName); diff --git a/spring-context/src/main/java/org/springframework/context/expression/EnvironmentAccessor.java b/spring-context/src/main/java/org/springframework/context/expression/EnvironmentAccessor.java index d041610a5e..86893f3daa 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/EnvironmentAccessor.java +++ b/spring-context/src/main/java/org/springframework/context/expression/EnvironmentAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.expression.TypedValue; */ public class EnvironmentAccessor implements PropertyAccessor { + @Override public Class[] getSpecificTargetClasses() { return new Class[] { Environment.class }; } @@ -39,6 +40,7 @@ public class EnvironmentAccessor implements PropertyAccessor { * Can read any {@link Environment}, thus always returns true. * @return true */ + @Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { return true; } @@ -47,6 +49,7 @@ public class EnvironmentAccessor implements PropertyAccessor { * Access the given target object by resolving the given property name against the given target * environment. */ + @Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { return new TypedValue(((Environment)target).getProperty(name)); } @@ -55,6 +58,7 @@ public class EnvironmentAccessor implements PropertyAccessor { * Read only. * @return false */ + @Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { return false; } @@ -62,6 +66,7 @@ public class EnvironmentAccessor implements PropertyAccessor { /** * Read only. No-op. */ + @Override public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { } diff --git a/spring-context/src/main/java/org/springframework/context/expression/MapAccessor.java b/spring-context/src/main/java/org/springframework/context/expression/MapAccessor.java index 53ed9ce911..7f4de09daf 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/MapAccessor.java +++ b/spring-context/src/main/java/org/springframework/context/expression/MapAccessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -33,11 +33,13 @@ import org.springframework.expression.TypedValue; */ public class MapAccessor implements PropertyAccessor { + @Override public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException { Map map = (Map) target; return map.containsKey(name); } + @Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { Map map = (Map) target; Object value = map.get(name); @@ -47,25 +49,29 @@ public class MapAccessor implements PropertyAccessor { return new TypedValue(value); } + @Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { return true; } + @Override @SuppressWarnings("unchecked") public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { Map map = (Map) target; map.put(name, newValue); } + @Override public Class[] getSpecificTargetClasses() { return new Class[] {Map.class}; } /** - * Exception thrown from read in order to reset a cached + * Exception thrown from {@code read} in order to reset a cached * PropertyAccessor, allowing other accessors to have a try. */ + @SuppressWarnings("serial") private static class MapAccessException extends AccessException { private final String key; diff --git a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java index 8537e05087..b2cecd883e 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java +++ b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java @@ -38,7 +38,7 @@ import org.springframework.util.StringUtils; * Standard implementation of the * {@link org.springframework.beans.factory.config.BeanExpressionResolver} * interface, parsing and evaluating Spring EL using Spring's expression module. - * + * * @author Juergen Hoeller * @since 3.0 * @see org.springframework.expression.ExpressionParser @@ -66,12 +66,15 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver { new ConcurrentHashMap(8); private final ParserContext beanExpressionParserContext = new ParserContext() { + @Override public boolean isTemplate() { return true; } + @Override public String getExpressionPrefix() { return expressionPrefix; } + @Override public String getExpressionSuffix() { return expressionSuffix; } @@ -109,6 +112,7 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver { } + @Override public Object evaluate(String value, BeanExpressionContext evalContext) throws BeansException { if (!StringUtils.hasLength(value)) { return value; diff --git a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java index 5f3cabedf4..2ca6ea2f85 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.core.NamedThreadLocal; * Simple holder class that associates a LocaleContext instance * with the current thread. The LocaleContext will be inherited * by any child threads spawned by the current thread if the - * inheritable flag is set to true. + * {@code inheritable} flag is set to {@code true}. * *

      Used as a central holder for the current Locale in Spring, * wherever necessary: for example, in MessageSourceAccessor. @@ -68,9 +68,9 @@ public abstract class LocaleContextHolder { /** * Associate the given LocaleContext with the current thread. * @param localeContext the current LocaleContext, - * or null to reset the thread-bound context + * or {@code null} to reset the thread-bound context * @param inheritable whether to expose the LocaleContext as inheritable - * for child threads (using an {@link java.lang.InheritableThreadLocal}) + * for child threads (using an {@link InheritableThreadLocal}) */ public static void setLocaleContext(LocaleContext localeContext, boolean inheritable) { if (localeContext == null) { @@ -90,7 +90,7 @@ public abstract class LocaleContextHolder { /** * Return the LocaleContext associated with the current thread, if any. - * @return the current LocaleContext, or null if none + * @return the current LocaleContext, or {@code null} if none */ public static LocaleContext getLocaleContext() { LocaleContext localeContext = localeContextHolder.get(); @@ -104,7 +104,7 @@ public abstract class LocaleContextHolder { * Associate the given Locale with the current thread. *

      Will implicitly create a LocaleContext for the given Locale, * not exposing it as inheritable for child threads. - * @param locale the current Locale, or null to reset + * @param locale the current Locale, or {@code null} to reset * the thread-bound context * @see SimpleLocaleContext#SimpleLocaleContext(java.util.Locale) */ @@ -115,10 +115,10 @@ public abstract class LocaleContextHolder { /** * Associate the given Locale with the current thread. *

      Will implicitly create a LocaleContext for the given Locale. - * @param locale the current Locale, or null to reset + * @param locale the current Locale, or {@code null} to reset * the thread-bound context * @param inheritable whether to expose the LocaleContext as inheritable - * for child threads (using an {@link java.lang.InheritableThreadLocal}) + * for child threads (using an {@link InheritableThreadLocal}) * @see SimpleLocaleContext#SimpleLocaleContext(java.util.Locale) */ public static void setLocale(Locale locale, boolean inheritable) { diff --git a/spring-context/src/main/java/org/springframework/context/i18n/SimpleLocaleContext.java b/spring-context/src/main/java/org/springframework/context/i18n/SimpleLocaleContext.java index c55773f320..de1246bf0b 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/SimpleLocaleContext.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/SimpleLocaleContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.util.Assert; /** * Simple implementation of the {@link LocaleContext} interface, - * always returning a specified Locale. + * always returning a specified {@code Locale}. * * @author Juergen Hoeller * @since 1.2 @@ -34,7 +34,7 @@ public class SimpleLocaleContext implements LocaleContext { /** * Create a new SimpleLocaleContext that exposes the specified Locale. - * Every getLocale() will return this Locale. + * Every {@code getLocale()} will return this Locale. * @param locale the Locale to expose */ public SimpleLocaleContext(Locale locale) { @@ -42,6 +42,7 @@ public class SimpleLocaleContext implements LocaleContext { this.locale = locale; } + @Override public Locale getLocale() { return this.locale; } diff --git a/spring-context/src/main/java/org/springframework/context/package-info.java b/spring-context/src/main/java/org/springframework/context/package-info.java index c7ae35d00e..3a09bc5a58 100644 --- a/spring-context/src/main/java/org/springframework/context/package-info.java +++ b/spring-context/src/main/java/org/springframework/context/package-info.java @@ -5,7 +5,7 @@ * message sources and for the Observer design pattern, and the * ability for application objects to obtain resources using a * consistent API. - * + * *

      There is no necessity for Spring applications to depend * on ApplicationContext or even BeanFactory functionality * explicitly. One of the strengths of the Spring architecture diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index b1e7726ed6..8a9001cb00 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -240,14 +240,17 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * of the context bean if the context is itself defined as a bean. * @param id the unique id of the context */ + @Override public void setId(String id) { this.id = id; } + @Override public String getId() { return this.id; } + @Override public String getApplicationName() { return ""; } @@ -264,16 +267,18 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Return a friendly name for this context. - * @return a display name for this context (never null) + * @return a display name for this context (never {@code null}) */ + @Override public String getDisplayName() { return this.displayName; } /** - * Return the parent context, or null if there is no parent + * Return the parent context, or {@code null} if there is no parent * (that is, this context is the root of the context hierarchy). */ + @Override public ApplicationContext getParent() { return this.parent; } @@ -283,6 +288,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader *

      If {@code null}, a new environment will be initialized via * {@link #createEnvironment()}. */ + @Override public ConfigurableEnvironment getEnvironment() { if (this.environment == null) { this.environment = createEnvironment(); @@ -298,6 +304,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * should be performed before {@link #refresh()}. * @see org.springframework.context.support.AbstractApplicationContext#createEnvironment */ + @Override public void setEnvironment(ConfigurableEnvironment environment) { this.environment = environment; } @@ -307,6 +314,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * if already available. * @see #getBeanFactory() */ + @Override public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException { return getBeanFactory(); } @@ -314,6 +322,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Return the timestamp (ms) when this context was first loaded. */ + @Override public long getStartupDate() { return this.startupDate; } @@ -326,6 +335,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * @param event the event to publish (may be application-specific or a * standard framework event) */ + @Override public void publishEvent(ApplicationEvent event) { Assert.notNull(event, "Event must not be null"); if (logger.isTraceEnabled()) { @@ -339,7 +349,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Return the internal ApplicationEventMulticaster used by the context. - * @return the internal ApplicationEventMulticaster (never null) + * @return the internal ApplicationEventMulticaster (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ private ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException { @@ -352,7 +362,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Return the internal LifecycleProcessor used by the context. - * @return the internal LifecycleProcessor (never null) + * @return the internal LifecycleProcessor (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ private LifecycleProcessor getLifecycleProcessor() { @@ -371,7 +381,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader *

      Can be overridden in subclasses, for extended resolution strategies, * for example in a web environment. *

      Do not call this when needing to resolve a location pattern. - * Call the context's getResources method instead, which + * Call the context's {@code getResources} method instead, which * will delegate to the ResourcePatternResolver. * @return the ResourcePatternResolver for this context * @see #getResources @@ -394,6 +404,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * its environment is an instance of {@link ConfigurableEnvironment}. * @see ConfigurableEnvironment#merge(ConfigurableEnvironment) */ + @Override public void setParent(ApplicationContext parent) { this.parent = parent; if (parent != null) { @@ -404,6 +415,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader } } + @Override public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor beanFactoryPostProcessor) { this.beanFactoryPostProcessors.add(beanFactoryPostProcessor); } @@ -417,6 +429,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader return this.beanFactoryPostProcessors; } + @Override public void addApplicationListener(ApplicationListener listener) { if (this.applicationEventMulticaster != null) { this.applicationEventMulticaster.addApplicationListener(listener); @@ -442,6 +455,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader return new StandardEnvironment(); } + @Override public void refresh() throws BeansException, IllegalStateException { synchronized (this.startupShutdownMonitor) { // Prepare this context for refreshing. @@ -952,7 +966,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader } /** - * Cancel this context's refresh attempt, resetting the active flag + * Cancel this context's refresh attempt, resetting the {@code active} flag * after an exception got thrown. * @param ex the exception that led to the cancellation */ @@ -966,11 +980,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Register a shutdown hook with the JVM runtime, closing this context * on JVM shutdown unless it has already been closed at that time. - *

      Delegates to doClose() for the actual closing procedure. - * @see java.lang.Runtime#addShutdownHook + *

      Delegates to {@code doClose()} for the actual closing procedure. + * @see Runtime#addShutdownHook * @see #close() * @see #doClose() */ + @Override public void registerShutdownHook() { if (this.shutdownHook == null) { // No shutdown hook registered yet. @@ -989,22 +1004,24 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader * Only called when the ApplicationContext itself is running * as a bean in another BeanFactory or ApplicationContext, * which is rather unusual. - *

      The close method is the native way to + *

      The {@code close} method is the native way to * shut down an ApplicationContext. * @see #close() * @see org.springframework.beans.factory.access.SingletonBeanFactoryLocator */ + @Override public void destroy() { close(); } /** * Close this application context, destroying all beans in its bean factory. - *

      Delegates to doClose() for the actual closing procedure. + *

      Delegates to {@code doClose()} for the actual closing procedure. * Also removes a JVM shutdown hook, if registered, as it's not needed anymore. * @see #doClose() * @see #registerShutdownHook() */ + @Override public void close() { synchronized (this.startupShutdownMonitor) { doClose(); @@ -1024,7 +1041,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Actually performs context closing: publishes a ContextClosedEvent and * destroys the singletons in the bean factory of this application context. - *

      Called by both close() and a JVM shutdown hook, if any. + *

      Called by both {@code close()} and a JVM shutdown hook, if any. * @see org.springframework.context.event.ContextClosedEvent * @see #destroyBeans() * @see #close() @@ -1078,7 +1095,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** * Template method for destroying all beans that this context manages. * The default implementation destroy all cached singletons in this context, - * invoking DisposableBean.destroy() and/or the specified + * invoking {@code DisposableBean.destroy()} and/or the specified * "destroy-method". *

      Can be overridden to add context-specific bean destruction steps * right before or right after standard singleton destruction, @@ -1102,6 +1119,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // For subclasses: do nothing by default. } + @Override public boolean isActive() { synchronized (this.activeMonitor) { return this.active; @@ -1113,42 +1131,52 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of BeanFactory interface //--------------------------------------------------------------------- + @Override public Object getBean(String name) throws BeansException { return getBeanFactory().getBean(name); } + @Override public T getBean(String name, Class requiredType) throws BeansException { return getBeanFactory().getBean(name, requiredType); } + @Override public T getBean(Class requiredType) throws BeansException { return getBeanFactory().getBean(requiredType); } + @Override public Object getBean(String name, Object... args) throws BeansException { return getBeanFactory().getBean(name, args); } + @Override public boolean containsBean(String name) { return getBeanFactory().containsBean(name); } + @Override public boolean isSingleton(String name) throws NoSuchBeanDefinitionException { return getBeanFactory().isSingleton(name); } + @Override public boolean isPrototype(String name) throws NoSuchBeanDefinitionException { return getBeanFactory().isPrototype(name); } + @Override public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException { return getBeanFactory().isTypeMatch(name, targetType); } + @Override public Class getType(String name) throws NoSuchBeanDefinitionException { return getBeanFactory().getType(name); } + @Override public String[] getAliases(String name) { return getBeanFactory().getAliases(name); } @@ -1158,42 +1186,51 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of ListableBeanFactory interface //--------------------------------------------------------------------- + @Override public boolean containsBeanDefinition(String beanName) { return getBeanFactory().containsBeanDefinition(beanName); } + @Override public int getBeanDefinitionCount() { return getBeanFactory().getBeanDefinitionCount(); } + @Override public String[] getBeanDefinitionNames() { return getBeanFactory().getBeanDefinitionNames(); } + @Override public String[] getBeanNamesForType(Class type) { return getBeanFactory().getBeanNamesForType(type); } + @Override public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) { return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit); } + @Override public Map getBeansOfType(Class type) throws BeansException { return getBeanFactory().getBeansOfType(type); } + @Override public Map getBeansOfType(Class type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException { return getBeanFactory().getBeansOfType(type, includeNonSingletons, allowEagerInit); } + @Override public Map getBeansWithAnnotation(Class annotationType) throws BeansException { return getBeanFactory().getBeansWithAnnotation(annotationType); } + @Override public A findAnnotationOnBean(String beanName, Class annotationType) { return getBeanFactory().findAnnotationOnBean(beanName, annotationType); } @@ -1203,10 +1240,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of HierarchicalBeanFactory interface //--------------------------------------------------------------------- + @Override public BeanFactory getParentBeanFactory() { return getParent(); } + @Override public boolean containsLocalBean(String name) { return getBeanFactory().containsLocalBean(name); } @@ -1226,21 +1265,24 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of MessageSource interface //--------------------------------------------------------------------- + @Override public String getMessage(String code, Object args[], String defaultMessage, Locale locale) { return getMessageSource().getMessage(code, args, defaultMessage, locale); } + @Override public String getMessage(String code, Object args[], Locale locale) throws NoSuchMessageException { return getMessageSource().getMessage(code, args, locale); } + @Override public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { return getMessageSource().getMessage(resolvable, locale); } /** * Return the internal MessageSource used by the context. - * @return the internal MessageSource (never null) + * @return the internal MessageSource (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ private MessageSource getMessageSource() throws IllegalStateException { @@ -1257,7 +1299,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader */ protected MessageSource getInternalParentMessageSource() { return (getParent() instanceof AbstractApplicationContext) ? - ((AbstractApplicationContext) getParent()).messageSource : getParent(); + ((AbstractApplicationContext) getParent()).messageSource : getParent(); } @@ -1265,6 +1307,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of ResourcePatternResolver interface //--------------------------------------------------------------------- + @Override public Resource[] getResources(String locationPattern) throws IOException { return this.resourcePatternResolver.getResources(locationPattern); } @@ -1274,16 +1317,19 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Implementation of Lifecycle interface //--------------------------------------------------------------------- + @Override public void start() { getLifecycleProcessor().start(); publishEvent(new ContextStartedEvent(this)); } + @Override public void stop() { getLifecycleProcessor().stop(); publishEvent(new ContextStoppedEvent(this)); } + @Override public boolean isRunning() { return getLifecycleProcessor().isRunning(); } @@ -1318,13 +1364,14 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader *

      Note: Subclasses should check whether the context is still active before * returning the internal bean factory. The internal factory should generally be * considered unavailable once the context has been closed. - * @return this application context's internal bean factory (never null) + * @return this application context's internal bean factory (never {@code null}) * @throws IllegalStateException if the context does not hold an internal bean factory yet * (usually if {@link #refresh()} has never been called) or if the context has been * closed already * @see #refreshBeanFactory() * @see #closeBeanFactory() */ + @Override public abstract ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException; @@ -1363,10 +1410,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader this.beanPostProcessorTargetCount = beanPostProcessorTargetCount; } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean != null && !(bean instanceof BeanPostProcessor) && this.beanFactory.getBeanPostProcessorCount() < this.beanPostProcessorTargetCount) { @@ -1389,16 +1438,19 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader private final Map singletonNames = new ConcurrentHashMap(64); + @Override public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) { if (beanDefinition.isSingleton()) { this.singletonNames.put(beanName, Boolean.TRUE); } } + @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { return bean; } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof ApplicationListener) { // potentially not detected as a listener by getBeanNamesForType retrieval diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java index 3d9231a0fc..87209ec95a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -67,10 +67,12 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme private boolean useCodeAsDefaultMessage = false; + @Override public void setParentMessageSource(MessageSource parent) { this.parentMessageSource = parent; } + @Override public MessageSource getParentMessageSource() { return this.parentMessageSource; } @@ -109,6 +111,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme } + @Override public final String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { String msg = getMessageInternal(code, args, locale); if (msg != null) { @@ -123,6 +126,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme return renderDefaultMessage(defaultMessage, args, locale); } + @Override public final String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { String msg = getMessageInternal(code, args, locale); if (msg != null) { @@ -135,6 +139,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme throw new NoSuchMessageException(code, locale); } + @Override public final String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { @@ -164,13 +169,13 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme /** * Resolve the given code and arguments as message in the given Locale, - * returning null if not found. Does not fall back to - * the code as default message. Invoked by getMessage methods. + * returning {@code null} if not found. Does not fall back to + * the code as default message. Invoked by {@code getMessage} methods. * @param code the code to lookup up, such as 'calculator.noRateSet' * @param args array of arguments that will be filled in for params * within the message * @param locale the Locale in which to do the lookup - * @return the resolved message, or null if not found + * @return the resolved message, or {@code null} if not found * @see #getMessage(String, Object[], String, Locale) * @see #getMessage(String, Object[], Locale) * @see #getMessage(MessageSourceResolvable, Locale) @@ -220,7 +225,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme * @param args array of arguments that will be filled in for params * within the message * @param locale the Locale in which to do the lookup - * @return the resolved message, or null if not found + * @return the resolved message, or {@code null} if not found * @see #getParentMessageSource() */ protected String getMessageFromParent(String code, Object[] args, Locale locale) { @@ -244,10 +249,10 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme * Return a fallback default message for the given code, if any. *

      Default is to return the code itself if "useCodeAsDefaultMessage" is activated, * or return no fallback else. In case of no fallback, the caller will usually - * receive a NoSuchMessageException from getMessage. + * receive a NoSuchMessageException from {@code getMessage}. * @param code the message code that we couldn't resolve * and that we didn't receive an explicit default message for - * @return the default message to use, or null if none + * @return the default message to use, or {@code null} if none * @see #setUseCodeAsDefaultMessage */ protected String getDefaultMessage(String code) { @@ -289,14 +294,14 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme *

      The default implementation does use MessageFormat, through * delegating to the {@link #resolveCode} method. Subclasses are encouraged * to replace this with optimized resolution. - *

      Unfortunately, java.text.MessageFormat is not implemented + *

      Unfortunately, {@code java.text.MessageFormat} is not implemented * in an efficient fashion. In particular, it does not detect that a message * pattern doesn't contain argument placeholders in the first place. Therefore, * it is advisable to circumvent MessageFormat for messages without arguments. * @param code the code of the message to resolve * @param locale the Locale to resolve the code for * (subclasses are encouraged to support internationalization) - * @return the message String, or null if not found + * @return the message String, or {@code null} if not found * @see #resolveCode * @see java.text.MessageFormat */ @@ -320,7 +325,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme * @param code the code of the message to resolve * @param locale the Locale to resolve the code for * (subclasses are encouraged to support internationalization) - * @return the MessageFormat for the message, or null if not found + * @return the MessageFormat for the message, or {@code null} if not found * @see #resolveCodeWithoutArguments(String, java.util.Locale) */ protected abstract MessageFormat resolveCode(String code, Locale locale); diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableApplicationContext.java index 9cbfcdddb0..44ba2589d8 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; /** * Base class for {@link org.springframework.context.ApplicationContext} diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java index 77155fb220..3004d68c22 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractRefreshableConfigApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -90,9 +90,9 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra * Return an array of resource locations, referring to the XML bean definition * files that this context should be built with. Can also include location * patterns, which will get resolved via a ResourcePatternResolver. - *

      The default implementation returns null. Subclasses can override + *

      The default implementation returns {@code null}. Subclasses can override * this to provide a set of resource locations to load bean definitions from. - * @return an array of resource locations, or null if none + * @return an array of resource locations, or {@code null} if none * @see #getResources * @see #getResourcePatternResolver */ @@ -103,7 +103,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra /** * Return the default config locations to use, for the case where no * explicit config locations have been specified. - *

      The default implementation returns null, + *

      The default implementation returns {@code null}, * requiring explicit config locations. * @return an array of default config locations, if any * @see #setConfigLocations @@ -133,6 +133,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra * Sets the id of this context to the bean name by default, * for cases where the context instance is itself defined as a bean. */ + @Override public void setBeanName(String name) { if (!this.setIdCalled) { super.setId(name); @@ -144,6 +145,7 @@ public abstract class AbstractRefreshableConfigApplicationContext extends Abstra * Triggers {@link #refresh()} if not refreshed in the concrete context's * constructor already. */ + @Override public void afterPropertiesSet() { if (!isActive()) { refresh(); diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java index 20c2734f76..1e7681aa0b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractXmlApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC /** - * Set whether to use XML validation. Default is true. + * Set whether to use XML validation. Default is {@code true}. */ public void setValidating(boolean validating) { this.validating = validating; @@ -131,9 +131,9 @@ public abstract class AbstractXmlApplicationContext extends AbstractRefreshableC /** * Return an array of Resource objects, referring to the XML bean definition * files that this context should be built with. - *

      The default implementation returns null. Subclasses can override + *

      The default implementation returns {@code null}. Subclasses can override * this to provide pre-built Resource objects rather than location Strings. - * @return an array of Resource objects, or null if none + * @return an array of Resource objects, or {@code null} if none * @see #getConfigLocations() */ protected Resource[] getConfigResources() { diff --git a/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java b/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java index 83b7aec725..2a521b3b64 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/ApplicationContextAwareProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -70,6 +70,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { } + @Override public Object postProcessBeforeInitialization(final Object bean, String beanName) throws BeansException { AccessControlContext acc = null; @@ -82,6 +83,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { if (acc != null) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { invokeAwareInterfaces(bean); return null; @@ -91,10 +93,10 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { else { invokeAwareInterfaces(bean); } - + return bean; } - + private void invokeAwareInterfaces(Object bean) { if (bean instanceof Aware) { if (bean instanceof EnvironmentAware) { @@ -119,6 +121,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { } } + @Override public Object postProcessAfterInitialization(Object bean, String beanName) { return bean; } @@ -132,6 +135,7 @@ class ApplicationContextAwareProcessor implements BeanPostProcessor { this.beanFactory = beanFactory; } + @Override public String resolveStringValue(String strVal) { return this.beanFactory.resolveEmbeddedValue(strVal); } diff --git a/spring-context/src/main/java/org/springframework/context/support/ApplicationObjectSupport.java b/spring-context/src/main/java/org/springframework/context/support/ApplicationObjectSupport.java index 0a0acb70f7..e3bb18e49c 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ApplicationObjectSupport.java +++ b/spring-context/src/main/java/org/springframework/context/support/ApplicationObjectSupport.java @@ -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"); * you may not use this file except in compliance with the License. @@ -45,10 +45,10 @@ import org.springframework.context.ApplicationContextException; * @see org.springframework.web.context.support.WebApplicationObjectSupport */ public abstract class ApplicationObjectSupport implements ApplicationContextAware { - + /** Logger that is available to subclasses */ protected final Log logger = LogFactory.getLog(getClass()); - + /** ApplicationContext this object runs in */ private ApplicationContext applicationContext; @@ -56,6 +56,7 @@ public abstract class ApplicationObjectSupport implements ApplicationContextAwar private MessageSourceAccessor messageSourceAccessor; + @Override public final void setApplicationContext(ApplicationContext context) throws BeansException { if (context == null && !isContextRequired()) { // Reset internal context state. @@ -95,7 +96,7 @@ public abstract class ApplicationObjectSupport implements ApplicationContextAwar /** * Determine the context class that any context passed to - * setApplicationContext must be an instance of. + * {@code setApplicationContext} must be an instance of. * Can be overridden in subclasses. * @see #setApplicationContext */ @@ -105,7 +106,7 @@ public abstract class ApplicationObjectSupport implements ApplicationContextAwar /** * Subclasses can override this for custom initialization behavior. - * Gets called by setApplicationContext after setting the context instance. + * Gets called by {@code setApplicationContext} after setting the context instance. *

      Note: Does not get called on reinitialization of the context * but rather just on first initialization of this object's context reference. *

      The default implementation calls the overloaded {@link #initApplicationContext()} diff --git a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java index 9570bcb0d5..9cdff9d621 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java +++ b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java @@ -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"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.springframework.util.ReflectionUtils; /** * Special variant of an overriding ClassLoader, used for temporary type * matching in {@link AbstractApplicationContext}. Redefines classes from - * a cached byte array for every loadClass call in order to + * a cached byte array for every {@code loadClass} call in order to * pick up recently loaded types in the parent ClassLoader. * * @author Juergen Hoeller @@ -63,6 +63,7 @@ class ContextTypeMatchClassLoader extends DecoratingClassLoader implements Smart return new ContextOverridingClassLoader(getParent()).loadClass(name); } + @Override public boolean isClassReloadable(Class clazz) { return (clazz.getClassLoader() instanceof ContextOverridingClassLoader); } diff --git a/spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java b/spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java index a4fb136b2b..5cf2e81746 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java @@ -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"); * you may not use this file except in compliance with the License. @@ -64,6 +64,7 @@ public class ConversionServiceFactoryBean implements FactoryBean getObjectType() { return GenericConversionService.class; } + @Override public boolean isSingleton() { return true; } diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java index 025f4cfb96..6290f869fd 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -68,6 +68,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor this.timeoutPerShutdownPhase = timeoutPerShutdownPhase; } + @Override public void setBeanFactory(BeanFactory beanFactory) { Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory); this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; @@ -85,6 +86,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor * declared as a dependency of another bean will be started before * the dependent bean regardless of the declared phase. */ + @Override public void start() { startBeans(false); this.running = true; @@ -99,21 +101,25 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor * declared as dependent on another bean will be stopped before * the dependency bean regardless of the declared phase. */ + @Override public void stop() { stopBeans(); this.running = false; } + @Override public void onRefresh() { startBeans(true); this.running = true; } + @Override public void onClose() { stopBeans(); this.running = false; } + @Override public boolean isRunning() { return this.running; } @@ -221,6 +227,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor } countDownBeanNames.add(beanName); ((SmartLifecycle) bean).stop(new Runnable() { + @Override public void run() { latch.countDown(); countDownBeanNames.remove(beanName); @@ -389,6 +396,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor this.bean = bean; } + @Override public int compareTo(LifecycleGroupMember other) { int thisOrder = getPhase(this.bean); int otherOrder = getPhase(other.bean); diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java b/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java index dab8670443..e688b5009d 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java @@ -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"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import org.springframework.util.StringUtils; * @since 13.02.2004 * @see org.springframework.context.MessageSource#getMessage(MessageSourceResolvable, java.util.Locale) */ +@SuppressWarnings("serial") public class DefaultMessageSourceResolvable implements MessageSourceResolvable, Serializable { private final String[] codes; @@ -95,6 +96,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, } + @Override public String[] getCodes() { return this.codes; } @@ -107,10 +109,12 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, return (this.codes != null && this.codes.length > 0) ? this.codes[this.codes.length - 1] : null; } + @Override public Object[] getArguments() { return this.arguments; } + @Override public String getDefaultMessage() { return this.defaultMessage; } @@ -131,7 +135,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, /** * Default implementation exposes the attributes of this MessageSourceResolvable. * To be overridden in more specific subclasses, potentially including the - * resolvable content through resolvableToString(). + * resolvable content through {@code resolvableToString()}. * @see #resolvableToString() */ @Override diff --git a/spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java index c42e38d5ea..6526cc957a 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/DelegatingMessageSource.java @@ -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"); * you may not use this file except in compliance with the License. @@ -39,15 +39,18 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie private MessageSource parentMessageSource; + @Override public void setParentMessageSource(MessageSource parent) { this.parentMessageSource = parent; } + @Override public MessageSource getParentMessageSource() { return this.parentMessageSource; } + @Override public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) { if (this.parentMessageSource != null) { return this.parentMessageSource.getMessage(code, args, defaultMessage, locale); @@ -57,6 +60,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie } } + @Override public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { if (this.parentMessageSource != null) { return this.parentMessageSource.getMessage(code, args, locale); @@ -66,6 +70,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie } } + @Override public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { if (this.parentMessageSource != null) { return this.parentMessageSource.getMessage(resolvable, locale); diff --git a/spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java index 8a5da83ddc..01f175abe3 100644 --- a/spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.ApplicationContext; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.support.ResourcePatternResolver; @@ -178,7 +177,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem /** * Set a ResourceLoader to use for this context. If set, the context will - * delegate all getResource calls to the given ResourceLoader. + * delegate all {@code getResource} calls to the given ResourceLoader. * If not set, default resource loading will apply. *

      The main reason to specify a custom ResourceLoader is to resolve * resource paths (without URL prefix) in a specific fashion. @@ -186,7 +185,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem * To resolve resource paths as file system locations, specify a * FileSystemResourceLoader here. *

      You can also pass in a full ResourcePatternResolver, which will - * be autodetected by the context and used for getResources + * be autodetected by the context and used for {@code getResources} * calls as well. Else, default resource pattern matching will apply. * @see #getResource * @see org.springframework.core.io.DefaultResourceLoader @@ -287,32 +286,39 @@ public class GenericApplicationContext extends AbstractApplicationContext implem // Implementation of BeanDefinitionRegistry //--------------------------------------------------------------------- + @Override public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException { this.beanFactory.registerBeanDefinition(beanName, beanDefinition); } + @Override public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { this.beanFactory.removeBeanDefinition(beanName); } + @Override public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException { return this.beanFactory.getBeanDefinition(beanName); } + @Override public boolean isBeanNameInUse(String beanName) { return this.beanFactory.isBeanNameInUse(beanName); } + @Override public void registerAlias(String beanName, String alias) { this.beanFactory.registerAlias(beanName, alias); } + @Override public void removeAlias(String alias) { this.beanFactory.removeAlias(alias); } + @Override public boolean isAlias(String beanName) { return this.beanFactory.isAlias(beanName); } diff --git a/spring-context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java index 00b6555849..e120f667fb 100644 --- a/spring-context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/GenericXmlApplicationContext.java @@ -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"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class GenericXmlApplicationContext extends GenericApplicationContext { } /** - * Set whether to use XML validation. Default is true. + * Set whether to use XML validation. Default is {@code true}. */ public void setValidating(boolean validating) { this.reader.setValidating(validating); diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java index 7cdfb8d492..bf20ae1017 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java +++ b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java @@ -93,6 +93,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar private ConfigurableApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) { Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext, "ApplicationContext does not implement ConfigurableApplicationContext"); @@ -105,6 +106,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar * finding all active ApplicationContexts through {@link #findApplicationContexts()}, * then delegating to {@link #generateJson(java.util.Set)}. */ + @Override public String getSnapshotAsJson() { Set contexts; if (this.applicationContext != null) { diff --git a/spring-context/src/main/java/org/springframework/context/support/MessageSourceAccessor.java b/spring-context/src/main/java/org/springframework/context/support/MessageSourceAccessor.java index 2d97735091..03fa94a525 100644 --- a/spring-context/src/main/java/org/springframework/context/support/MessageSourceAccessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/MessageSourceAccessor.java @@ -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"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -97,7 +97,7 @@ public class MessageSourceAccessor { /** * Retrieve the message for the given code and the default Locale. * @param code code of the message - * @param args arguments for the message, or null if none + * @param args arguments for the message, or {@code null} if none * @param defaultMessage String to return if the lookup fails * @return the message */ @@ -108,7 +108,7 @@ public class MessageSourceAccessor { /** * Retrieve the message for the given code and the given Locale. * @param code code of the message - * @param args arguments for the message, or null if none + * @param args arguments for the message, or {@code null} if none * @param defaultMessage String to return if the lookup fails * @param locale Locale in which to do lookup * @return the message @@ -141,7 +141,7 @@ public class MessageSourceAccessor { /** * Retrieve the message for the given code and the default Locale. * @param code code of the message - * @param args arguments for the message, or null if none + * @param args arguments for the message, or {@code null} if none * @return the message * @throws org.springframework.context.NoSuchMessageException if not found */ @@ -152,7 +152,7 @@ public class MessageSourceAccessor { /** * Retrieve the message for the given code and the given Locale. * @param code code of the message - * @param args arguments for the message, or null if none + * @param args arguments for the message, or {@code null} if none * @param locale Locale in which to do lookup * @return the message * @throws org.springframework.context.NoSuchMessageException if not found diff --git a/spring-context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java b/spring-context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java index c5fe46acf5..8dc2c1ffb3 100644 --- a/spring-context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java +++ b/spring-context/src/main/java/org/springframework/context/support/MessageSourceResourceBundle.java @@ -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"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class MessageSourceResourceBundle extends ResourceBundle { /** * This implementation resolves the code in the MessageSource. - * Returns null if the message could not be resolved. + * Returns {@code null} if the message could not be resolved. */ @Override protected Object handleGetObject(String code) { @@ -80,7 +80,7 @@ public class MessageSourceResourceBundle extends ResourceBundle { } /** - * This implementation returns null, as a MessageSource does + * This implementation returns {@code null}, as a MessageSource does * not allow for enumerating the defined message codes. */ @Override @@ -90,7 +90,7 @@ public class MessageSourceResourceBundle extends ResourceBundle { /** * This implementation exposes the specified Locale for introspection - * through the standard ResourceBundle.getLocale() method. + * through the standard {@code ResourceBundle.getLocale()} method. */ @Override public Locale getLocale() { diff --git a/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java b/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java index b7601375a7..d863add687 100644 --- a/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java +++ b/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java @@ -32,7 +32,7 @@ import org.springframework.util.ObjectUtils; * methods defined in the {@link org.springframework.context.MessageSource}. * *

      {@link AbstractMessageSource} derives from this class, providing concrete - * getMessage implementations that delegate to a central template + * {@code getMessage} implementations that delegate to a central template * method for message code resolution. * * @author Juergen Hoeller @@ -87,12 +87,12 @@ public abstract class MessageSourceSupport { * Render the given default message String. The default message is * passed in as specified by the caller and can be rendered into * a fully formatted default message shown to the user. - *

      The default implementation passes the String to formatMessage, + *

      The default implementation passes the String to {@code formatMessage}, * resolving any argument placeholders found in them. Subclasses may override * this method to plug in custom processing of default messages. * @param defaultMessage the passed-in default message String * @param args array of arguments that will be filled in for params within - * the message, or null if none. + * the message, or {@code null} if none. * @param locale the Locale used for formatting * @return the rendered default message (with resolved arguments) * @see #formatMessage(String, Object[], java.util.Locale) @@ -107,7 +107,7 @@ public abstract class MessageSourceSupport { * any argument placeholders found in them. * @param msg the message to format * @param args array of arguments that will be filled in for params within - * the message, or null if none + * the message, or {@code null} if none * @param locale the Locale used for formatting * @return the formatted message (with resolved arguments) */ diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index c831bbb855..d39c7d3d5b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -98,6 +98,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS * @see #setPropertySources * @see #postProcessBeanFactory */ + @Override public void setEnvironment(Environment environment) { this.environment = environment; } @@ -163,6 +164,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS propertyResolver.setValueSeparator(this.valueSeparator); StringValueResolver valueResolver = new StringValueResolver() { + @Override public String resolveStringValue(String strVal) { String resolved = ignoreUnresolvablePlaceholders ? propertyResolver.resolvePlaceholders(strVal) : diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index 44d284c9a5..14b831c098 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -174,7 +174,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractMessageSource /** * Set the default charset to use for parsing properties files. * Used if no file-specific charset is specified for a file. - *

      Default is none, using the java.util.Properties + *

      Default is none, using the {@code java.util.Properties} * default encoding: ISO-8859-1. *

      Only applies to classic properties files, not to XML files. * @param defaultEncoding the default charset @@ -205,7 +205,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractMessageSource * fallback will be the default file (e.g. "messages.properties" for * basename "messages"). *

      Falling back to the system Locale is the default behavior of - * java.util.ResourceBundle. However, this is often not desirable + * {@code java.util.ResourceBundle}. However, this is often not desirable * in an application server environment, where the system Locale is not relevant * to the application at all: Set this flag to "false" in such a scenario. */ @@ -217,7 +217,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractMessageSource * Set the number of seconds to cache loaded properties files. *