Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing generics or deprecated code. Also add the `-Werror` compiler option to ensure that any future warnings will fail the build. Issue: SPR-11064
This commit is contained in:
parent
4de3291dc7
commit
59002f2456
32
build.gradle
32
build.gradle
|
|
@ -26,27 +26,21 @@ configure(allprojects) { project ->
|
||||||
apply plugin: "test-source-set-dependencies"
|
apply plugin: "test-source-set-dependencies"
|
||||||
apply from: "${gradleScriptDir}/ide.gradle"
|
apply from: "${gradleScriptDir}/ide.gradle"
|
||||||
|
|
||||||
[compileJava, compileTestJava]*.options*.compilerArgs = [
|
compileJava.options*.compilerArgs = [
|
||||||
"-Xlint:serial",
|
"-Xlint:serial", "-Xlint:varargs", "-Xlint:cast", "-Xlint:classfile",
|
||||||
"-Xlint:varargs",
|
"-Xlint:dep-ann", "-Xlint:divzero", "-Xlint:empty", "-Xlint:finally",
|
||||||
"-Xlint:cast",
|
"-Xlint:overrides", "-Xlint:path", "-Xlint:processing", "-Xlint:static",
|
||||||
"-Xlint:classfile",
|
"-Xlint:try", "-Xlint:fallthrough", "-Xlint:rawtypes", "-Xlint:deprecation",
|
||||||
"-Xlint:dep-ann",
|
"-Xlint:unchecked", "-Xlint:-options", "-Werror"
|
||||||
"-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
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
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:-fallthrough", "-Xlint:-rawtypes", "-Xlint:-deprecation",
|
||||||
|
"-Xlint:-unchecked", "-Xlint:-options"]
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
sourceCompatibility=1.6
|
sourceCompatibility=1.6
|
||||||
targetCompatibility=1.6
|
targetCompatibility=1.6
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,6 @@ public interface IntroductionAwareMethodMatcher extends MethodMatcher {
|
||||||
* asking is the subject on one or more introductions; {@code false} otherwise
|
* asking is the subject on one or more introductions; {@code false} otherwise
|
||||||
* @return whether or not this method matches statically
|
* @return whether or not this method matches statically
|
||||||
*/
|
*/
|
||||||
boolean matches(Method method, Class targetClass, boolean hasIntroductions);
|
boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,6 @@ public interface IntroductionInfo {
|
||||||
* Return the additional interfaces introduced by this Advisor or Advice.
|
* Return the additional interfaces introduced by this Advisor or Advice.
|
||||||
* @return the introduced interfaces
|
* @return the introduced interfaces
|
||||||
*/
|
*/
|
||||||
Class[] getInterfaces();
|
Class<?>[] getInterfaces();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class TrueClassFilter implements ClassFilter, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,12 @@ class TrueMethodMatcher implements MethodMatcher, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
// Should never be invoked as isRuntime returns false.
|
// Should never be invoked as isRuntime returns false.
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,9 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
/** Non-null if after returning advice binds the return value */
|
/** Non-null if after returning advice binds the return value */
|
||||||
private String returningName = null;
|
private String returningName = null;
|
||||||
|
|
||||||
private Class discoveredReturningType = Object.class;
|
private Class<?> discoveredReturningType = Object.class;
|
||||||
|
|
||||||
private Class discoveredThrowingType = Object.class;
|
private Class<?> discoveredThrowingType = Object.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index for thisJoinPoint argument (currently only
|
* Index for thisJoinPoint argument (currently only
|
||||||
|
|
@ -253,7 +253,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
if (argumentNames != null) {
|
if (argumentNames != null) {
|
||||||
if (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1) {
|
if (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1) {
|
||||||
// May need to add implicit join point arg name...
|
// May need to add implicit join point arg name...
|
||||||
Class firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
|
Class<?> firstArgType = aspectJAdviceMethod.getParameterTypes()[0];
|
||||||
if (firstArgType == JoinPoint.class ||
|
if (firstArgType == JoinPoint.class ||
|
||||||
firstArgType == ProceedingJoinPoint.class ||
|
firstArgType == ProceedingJoinPoint.class ||
|
||||||
firstArgType == JoinPoint.StaticPart.class) {
|
firstArgType == JoinPoint.StaticPart.class) {
|
||||||
|
|
@ -292,7 +292,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class getDiscoveredReturningType() {
|
protected Class<?> getDiscoveredReturningType() {
|
||||||
return this.discoveredReturningType;
|
return this.discoveredReturningType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class getDiscoveredThrowingType() {
|
protected Class<?> getDiscoveredThrowingType() {
|
||||||
return this.discoveredThrowingType;
|
return this.discoveredThrowingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,7 +364,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
|
|
||||||
int numUnboundArgs = this.adviceInvocationArgumentCount;
|
int numUnboundArgs = this.adviceInvocationArgumentCount;
|
||||||
Class[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
Class<?>[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||||
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
||||||
numUnboundArgs--;
|
numUnboundArgs--;
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +380,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
this.argumentsIntrospected = true;
|
this.argumentsIntrospected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean maybeBindJoinPoint(Class candidateParameterType) {
|
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
|
||||||
if (candidateParameterType.equals(JoinPoint.class)) {
|
if (candidateParameterType.equals(JoinPoint.class)) {
|
||||||
this.joinPointArgumentIndex = 0;
|
this.joinPointArgumentIndex = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -390,7 +390,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean maybeBindProceedingJoinPoint(Class candidateParameterType) {
|
private boolean maybeBindProceedingJoinPoint(Class<?> candidateParameterType) {
|
||||||
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
|
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
|
||||||
if (!supportsProceedingJoinPoint()) {
|
if (!supportsProceedingJoinPoint()) {
|
||||||
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
|
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
|
||||||
|
|
@ -407,7 +407,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean maybeBindJoinPointStaticPart(Class candidateParameterType) {
|
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) {
|
||||||
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
|
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
|
||||||
this.joinPointStaticPartArgumentIndex = 0;
|
this.joinPointStaticPartArgumentIndex = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -509,8 +509,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
numParametersToRemove++;
|
numParametersToRemove++;
|
||||||
}
|
}
|
||||||
String[] pointcutParameterNames = new String[this.argumentNames.length - numParametersToRemove];
|
String[] pointcutParameterNames = new String[this.argumentNames.length - numParametersToRemove];
|
||||||
Class[] pointcutParameterTypes = new Class[pointcutParameterNames.length];
|
Class<?>[] pointcutParameterTypes = new Class<?>[pointcutParameterNames.length];
|
||||||
Class[] methodParameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
Class<?>[] methodParameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < this.argumentNames.length; i++) {
|
for (int i = 0; i < this.argumentNames.length; i++) {
|
||||||
|
|
@ -679,7 +679,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return !this.adviceMethod.equals(method);
|
return !this.adviceMethod.equals(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -29,7 +28,6 @@ import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.weaver.tools.PointcutParser;
|
import org.aspectj.weaver.tools.PointcutParser;
|
||||||
import org.aspectj.weaver.tools.PointcutPrimitive;
|
import org.aspectj.weaver.tools.PointcutPrimitive;
|
||||||
|
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
|
@ -142,9 +140,8 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
singleValuedAnnotationPcds.add("@withincode");
|
singleValuedAnnotationPcds.add("@withincode");
|
||||||
singleValuedAnnotationPcds.add("@annotation");
|
singleValuedAnnotationPcds.add("@annotation");
|
||||||
|
|
||||||
Set pointcutPrimitives = PointcutParser.getAllSupportedPointcutPrimitives();
|
Set<PointcutPrimitive> pointcutPrimitives = PointcutParser.getAllSupportedPointcutPrimitives();
|
||||||
for (Iterator iterator = pointcutPrimitives.iterator(); iterator.hasNext();) {
|
for (PointcutPrimitive primitive : pointcutPrimitives) {
|
||||||
PointcutPrimitive primitive = (PointcutPrimitive) iterator.next();
|
|
||||||
nonReferencePointcutTokens.add(primitive.getName());
|
nonReferencePointcutTokens.add(primitive.getName());
|
||||||
}
|
}
|
||||||
nonReferencePointcutTokens.add("&&");
|
nonReferencePointcutTokens.add("&&");
|
||||||
|
|
@ -173,7 +170,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
*/
|
*/
|
||||||
private String pointcutExpression;
|
private String pointcutExpression;
|
||||||
|
|
||||||
private Class[] argumentTypes;
|
private Class<?>[] argumentTypes;
|
||||||
|
|
||||||
private String[] parameterNameBindings;
|
private String[] parameterNameBindings;
|
||||||
|
|
||||||
|
|
@ -311,7 +308,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
* {@link #setRaiseExceptions(boolean) raiseExceptions} has been set to {@code true}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] getParameterNames(Constructor ctor) {
|
public String[] getParameterNames(Constructor<?> ctor) {
|
||||||
if (this.raiseExceptions) {
|
if (this.raiseExceptions) {
|
||||||
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
throw new UnsupportedOperationException("An advice method can never be a constructor");
|
||||||
}
|
}
|
||||||
|
|
@ -731,7 +728,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* Return {@code true} if the given argument type is a subclass
|
* Return {@code true} if the given argument type is a subclass
|
||||||
* of the given supertype.
|
* of the given supertype.
|
||||||
*/
|
*/
|
||||||
private boolean isSubtypeOf(Class supertype, int argumentNumber) {
|
private boolean isSubtypeOf(Class<?> supertype, int argumentNumber) {
|
||||||
return supertype.isAssignableFrom(this.argumentTypes[argumentNumber]);
|
return supertype.isAssignableFrom(this.argumentTypes[argumentNumber]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -759,7 +756,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||||
* Find the argument index with the given type, and bind the given
|
* Find the argument index with the given type, and bind the given
|
||||||
* {@code varName} in that position.
|
* {@code varName} in that position.
|
||||||
*/
|
*/
|
||||||
private void findAndBind(Class argumentType, String varName) {
|
private void findAndBind(Class<?> argumentType, String varName) {
|
||||||
for (int i = 0; i < this.argumentTypes.length; i++) {
|
for (int i = 0; i < this.argumentTypes.length; i++) {
|
||||||
if (isUnbound(i) && isSubtypeOf(argumentType, i)) {
|
if (isUnbound(i) && isSubtypeOf(argumentType, i)) {
|
||||||
bindParameterName(i, varName);
|
bindParameterName(i, varName);
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,7 @@ public class AspectJAfterThrowingAdvice extends AbstractAspectJAdvice implements
|
||||||
* is only invoked if the thrown exception is a subtype of the given throwing type.
|
* is only invoked if the thrown exception is a subtype of the given throwing type.
|
||||||
*/
|
*/
|
||||||
private boolean shouldInvokeOnThrowing(Throwable t) {
|
private boolean shouldInvokeOnThrowing(Throwable t) {
|
||||||
Class throwingType = getDiscoveredThrowingType();
|
return getDiscoveredThrowingType().isAssignableFrom(t.getClass());
|
||||||
return throwingType.isAssignableFrom(t.getClass());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,11 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(AspectJExpressionPointcut.class);
|
private static final Log logger = LogFactory.getLog(AspectJExpressionPointcut.class);
|
||||||
|
|
||||||
private Class pointcutDeclarationScope;
|
private Class<?> pointcutDeclarationScope;
|
||||||
|
|
||||||
private String[] pointcutParameterNames = new String[0];
|
private String[] pointcutParameterNames = new String[0];
|
||||||
|
|
||||||
private Class[] pointcutParameterTypes = new Class[0];
|
private Class<?>[] pointcutParameterTypes = new Class<?>[0];
|
||||||
|
|
||||||
private BeanFactory beanFactory;
|
private BeanFactory beanFactory;
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
* @param paramNames the parameter names for the pointcut
|
* @param paramNames the parameter names for the pointcut
|
||||||
* @param paramTypes the parameter types for the pointcut
|
* @param paramTypes the parameter types for the pointcut
|
||||||
*/
|
*/
|
||||||
public AspectJExpressionPointcut(Class declarationScope, String[] paramNames, Class[] paramTypes) {
|
public AspectJExpressionPointcut(Class<?> declarationScope, String[] paramNames, Class<?>[] paramTypes) {
|
||||||
this.pointcutDeclarationScope = declarationScope;
|
this.pointcutDeclarationScope = declarationScope;
|
||||||
if (paramNames.length != paramTypes.length) {
|
if (paramNames.length != paramTypes.length) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
|
|
@ -137,7 +137,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
/**
|
/**
|
||||||
* Set the declaration scope for the pointcut.
|
* Set the declaration scope for the pointcut.
|
||||||
*/
|
*/
|
||||||
public void setPointcutDeclarationScope(Class pointcutDeclarationScope) {
|
public void setPointcutDeclarationScope(Class<?> pointcutDeclarationScope) {
|
||||||
this.pointcutDeclarationScope = pointcutDeclarationScope;
|
this.pointcutDeclarationScope = pointcutDeclarationScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
/**
|
/**
|
||||||
* Set the parameter types for the pointcut.
|
* Set the parameter types for the pointcut.
|
||||||
*/
|
*/
|
||||||
public void setParameterTypes(Class[] types) {
|
public void setParameterTypes(Class<?>[] types) {
|
||||||
this.pointcutParameterTypes = types;
|
this.pointcutParameterTypes = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +248,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class targetClass) {
|
public boolean matches(Class<?> targetClass) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
try {
|
try {
|
||||||
return this.pointcutExpression.couldMatchJoinPointsInType(targetClass);
|
return this.pointcutExpression.couldMatchJoinPointsInType(targetClass);
|
||||||
|
|
@ -272,7 +272,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean beanHasIntroductions) {
|
public boolean matches(Method method, Class<?> targetClass, boolean beanHasIntroductions) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
Method targetMethod = AopUtils.getMostSpecificMethod(method, targetClass);
|
||||||
ShadowMatch shadowMatch = getShadowMatch(targetMethod, method);
|
ShadowMatch shadowMatch = getShadowMatch(targetMethod, method);
|
||||||
|
|
@ -293,7 +293,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return matches(method, targetClass, false);
|
return matches(method, targetClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,7 +304,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
checkReadyToMatch();
|
checkReadyToMatch();
|
||||||
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
|
ShadowMatch shadowMatch = getShadowMatch(AopUtils.getMostSpecificMethod(method, targetClass), method);
|
||||||
ShadowMatch originalShadowMatch = getShadowMatch(method, method);
|
ShadowMatch originalShadowMatch = getShadowMatch(method, method);
|
||||||
|
|
@ -377,7 +377,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
return !(getRuntimeTestWalker(shadowMatch).testsSubtypeSensitiveVars());
|
return !(getRuntimeTestWalker(shadowMatch).testsSubtypeSensitiveVars());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesTarget(ShadowMatch shadowMatch, Class targetClass) {
|
private boolean matchesTarget(ShadowMatch shadowMatch, Class<?> targetClass) {
|
||||||
return getRuntimeTestWalker(shadowMatch).testTargetInstanceOfResidue(targetClass);
|
return getRuntimeTestWalker(shadowMatch).testTargetInstanceOfResidue(targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,11 +542,15 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
@Deprecated
|
||||||
public boolean couldMatchJoinPointsInType(Class someClass) {
|
public boolean couldMatchJoinPointsInType(Class someClass) {
|
||||||
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
@Deprecated
|
||||||
public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) {
|
public boolean couldMatchJoinPointsInType(Class someClass, MatchingContext context) {
|
||||||
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
return (contextMatch(someClass) == FuzzyBoolean.YES);
|
||||||
}
|
}
|
||||||
|
|
@ -566,7 +570,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FuzzyBoolean contextMatch(Class targetType) {
|
private FuzzyBoolean contextMatch(Class<?> targetType) {
|
||||||
String advisedBeanName = getCurrentProxiedBeanName();
|
String advisedBeanName = getCurrentProxiedBeanName();
|
||||||
if (advisedBeanName == null) { // no proxy creation in progress
|
if (advisedBeanName == null) { // no proxy creation in progress
|
||||||
// abstain; can't return YES, since that will make pointcut with negation fail
|
// abstain; can't return YES, since that will make pointcut with negation fail
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class AspectJExpressionPointcutAdvisor extends AbstractGenericPointcutAdv
|
||||||
this.pointcut.setLocation(location);
|
this.pointcut.setLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParameterTypes(Class[] types) {
|
public void setParameterTypes(Class<?>[] types) {
|
||||||
this.pointcut.setParameterTypes(types);
|
this.pointcut.setParameterTypes(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||||
*/
|
*/
|
||||||
public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
|
|
||||||
private final Class introducedInterface;
|
private final Class<?> introducedInterface;
|
||||||
|
|
||||||
private final ClassFilter typePatternClassFilter;
|
private final ClassFilter typePatternClassFilter;
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
* @param typePattern type pattern the introduction is restricted to
|
* @param typePattern type pattern the introduction is restricted to
|
||||||
* @param defaultImpl the default implementation class
|
* @param defaultImpl the default implementation class
|
||||||
*/
|
*/
|
||||||
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Class defaultImpl) {
|
public DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Class<?> defaultImpl) {
|
||||||
this(interfaceType, typePattern, defaultImpl,
|
this(interfaceType, typePattern, defaultImpl,
|
||||||
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
* @param typePattern type pattern the introduction is restricted to
|
* @param typePattern type pattern the introduction is restricted to
|
||||||
* @param delegateRef the delegate implementation object
|
* @param delegateRef the delegate implementation object
|
||||||
*/
|
*/
|
||||||
public DeclareParentsAdvisor(Class interfaceType, String typePattern, Object delegateRef) {
|
public DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Object delegateRef) {
|
||||||
this(interfaceType, typePattern, delegateRef.getClass(),
|
this(interfaceType, typePattern, delegateRef.getClass(),
|
||||||
new DelegatingIntroductionInterceptor(delegateRef));
|
new DelegatingIntroductionInterceptor(delegateRef));
|
||||||
}
|
}
|
||||||
|
|
@ -71,14 +71,14 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
* @param implementationClass implementation class
|
* @param implementationClass implementation class
|
||||||
* @param advice delegation advice
|
* @param advice delegation advice
|
||||||
*/
|
*/
|
||||||
private DeclareParentsAdvisor(Class interfaceType, String typePattern, Class implementationClass, Advice advice) {
|
private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Class<?> implementationClass, Advice advice) {
|
||||||
this.introducedInterface = interfaceType;
|
this.introducedInterface = interfaceType;
|
||||||
ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);
|
ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);
|
||||||
|
|
||||||
// Excludes methods implemented.
|
// Excludes methods implemented.
|
||||||
ClassFilter exclusion = new ClassFilter() {
|
ClassFilter exclusion = new ClassFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
return !(introducedInterface.isAssignableFrom(clazz));
|
return !(introducedInterface.isAssignableFrom(clazz));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -109,8 +109,8 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class<?>[] getInterfaces() {
|
||||||
return new Class[] {this.introducedInterface};
|
return new Class<?>[] {this.introducedInterface};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getDeclaringType() {
|
public Class<?> getDeclaringType() {
|
||||||
return methodInvocation.getMethod().getDeclaringClass();
|
return methodInvocation.getMethod().getDeclaringClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getReturnType() {
|
public Class<?> getReturnType() {
|
||||||
return methodInvocation.getMethod().getReturnType();
|
return methodInvocation.getMethod().getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getParameterTypes() {
|
public Class<?>[] getParameterTypes() {
|
||||||
return methodInvocation.getMethod().getParameterTypes();
|
return methodInvocation.getMethod().getParameterTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getExceptionTypes() {
|
public Class<?>[] getExceptionTypes() {
|
||||||
return methodInvocation.getMethod().getExceptionTypes();
|
return methodInvocation.getMethod().getExceptionTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,7 +256,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
sb.append(".");
|
sb.append(".");
|
||||||
sb.append(getMethod().getName());
|
sb.append(getMethod().getName());
|
||||||
sb.append("(");
|
sb.append("(");
|
||||||
Class[] parametersTypes = getParameterTypes();
|
Class<?>[] parametersTypes = getParameterTypes();
|
||||||
appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName);
|
appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName);
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
@ -297,7 +297,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
private class SourceLocationImpl implements SourceLocation {
|
private class SourceLocationImpl implements SourceLocation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getWithinType() {
|
public Class<?> getWithinType() {
|
||||||
if (methodInvocation.getThis() == null) {
|
if (methodInvocation.getThis() == null) {
|
||||||
throw new UnsupportedOperationException("No source location joinpoint available: target is null");
|
throw new UnsupportedOperationException("No source location joinpoint available: target is null");
|
||||||
}
|
}
|
||||||
|
|
@ -315,6 +315,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public int getColumn() {
|
public int getColumn() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,12 +87,12 @@ class RuntimeTestWalker {
|
||||||
new SubtypeSensitiveVarTypeTestVisitor().testsSubtypeSensitiveVars(this.runtimeTest));
|
new SubtypeSensitiveVarTypeTestVisitor().testsSubtypeSensitiveVars(this.runtimeTest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testThisInstanceOfResidue(Class thisClass) {
|
public boolean testThisInstanceOfResidue(Class<?> thisClass) {
|
||||||
return (this.runtimeTest != null &&
|
return (this.runtimeTest != null &&
|
||||||
new ThisInstanceOfResidueTestVisitor(thisClass).thisInstanceOfMatches(this.runtimeTest));
|
new ThisInstanceOfResidueTestVisitor(thisClass).thisInstanceOfMatches(this.runtimeTest));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testTargetInstanceOfResidue(Class targetClass) {
|
public boolean testTargetInstanceOfResidue(Class<?> targetClass) {
|
||||||
return (this.runtimeTest != null &&
|
return (this.runtimeTest != null &&
|
||||||
new TargetInstanceOfResidueTestVisitor(targetClass).targetInstanceOfMatches(this.runtimeTest));
|
new TargetInstanceOfResidueTestVisitor(targetClass).targetInstanceOfMatches(this.runtimeTest));
|
||||||
}
|
}
|
||||||
|
|
@ -169,11 +169,11 @@ class RuntimeTestWalker {
|
||||||
|
|
||||||
private static abstract class InstanceOfResidueTestVisitor extends TestVisitorAdapter {
|
private static abstract class InstanceOfResidueTestVisitor extends TestVisitorAdapter {
|
||||||
|
|
||||||
private Class matchClass;
|
private Class<?> matchClass;
|
||||||
private boolean matches;
|
private boolean matches;
|
||||||
private int matchVarType;
|
private int matchVarType;
|
||||||
|
|
||||||
public InstanceOfResidueTestVisitor(Class matchClass, boolean defaultMatches, int matchVarType) {
|
public InstanceOfResidueTestVisitor(Class<?> matchClass, boolean defaultMatches, int matchVarType) {
|
||||||
this.matchClass = matchClass;
|
this.matchClass = matchClass;
|
||||||
this.matches = defaultMatches;
|
this.matches = defaultMatches;
|
||||||
this.matchVarType = matchVarType;
|
this.matchVarType = matchVarType;
|
||||||
|
|
@ -192,7 +192,7 @@ class RuntimeTestWalker {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Class typeClass = ClassUtils.forName(type.getName(), this.matchClass.getClassLoader());
|
Class<?> typeClass = ClassUtils.forName(type.getName(), this.matchClass.getClassLoader());
|
||||||
// Don't use ReflectionType.isAssignableFrom() as it won't be aware of (Spring) mixins
|
// Don't use ReflectionType.isAssignableFrom() as it won't be aware of (Spring) mixins
|
||||||
this.matches = typeClass.isAssignableFrom(this.matchClass);
|
this.matches = typeClass.isAssignableFrom(this.matchClass);
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,7 @@ class RuntimeTestWalker {
|
||||||
*/
|
*/
|
||||||
private static class TargetInstanceOfResidueTestVisitor extends InstanceOfResidueTestVisitor {
|
private static class TargetInstanceOfResidueTestVisitor extends InstanceOfResidueTestVisitor {
|
||||||
|
|
||||||
public TargetInstanceOfResidueTestVisitor(Class targetClass) {
|
public TargetInstanceOfResidueTestVisitor(Class<?> targetClass) {
|
||||||
super(targetClass, false, TARGET_VAR);
|
super(targetClass, false, TARGET_VAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,7 +223,7 @@ class RuntimeTestWalker {
|
||||||
*/
|
*/
|
||||||
private static class ThisInstanceOfResidueTestVisitor extends InstanceOfResidueTestVisitor {
|
private static class ThisInstanceOfResidueTestVisitor extends InstanceOfResidueTestVisitor {
|
||||||
|
|
||||||
public ThisInstanceOfResidueTestVisitor(Class thisClass) {
|
public ThisInstanceOfResidueTestVisitor(Class<?> thisClass) {
|
||||||
super(thisClass, true, THIS_VAR);
|
super(thisClass, true, THIS_VAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,14 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
|
|
||||||
private final Class aspectClass;
|
private final Class<?> aspectClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new SimpleAspectInstanceFactory for the given aspect class.
|
* Create a new SimpleAspectInstanceFactory for the given aspect class.
|
||||||
* @param aspectClass the aspect class
|
* @param aspectClass the aspect class
|
||||||
*/
|
*/
|
||||||
public SimpleAspectInstanceFactory(Class aspectClass) {
|
public SimpleAspectInstanceFactory(Class<?> aspectClass) {
|
||||||
Assert.notNull(aspectClass, "Aspect class must not be null");
|
Assert.notNull(aspectClass, "Aspect class must not be null");
|
||||||
this.aspectClass = aspectClass;
|
this.aspectClass = aspectClass;
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +44,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||||
/**
|
/**
|
||||||
* Return the specified aspect class (never {@code null}).
|
* Return the specified aspect class (never {@code null}).
|
||||||
*/
|
*/
|
||||||
public final Class getAspectClass() {
|
public final Class<?> getAspectClass() {
|
||||||
return this.aspectClass;
|
return this.aspectClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||||
* @throws IllegalStateException if no {@link #setTypePattern(String)} has been set
|
* @throws IllegalStateException if no {@link #setTypePattern(String)} has been set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
if (this.aspectJTypePatternMatcher == null) {
|
if (this.aspectJTypePatternMatcher == null) {
|
||||||
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
|
throw new IllegalStateException("No 'typePattern' has been set via ctor/setter.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,9 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.aspectj.lang.reflect.AjType;
|
import org.aspectj.lang.reflect.AjType;
|
||||||
import org.aspectj.lang.reflect.AjTypeSystem;
|
import org.aspectj.lang.reflect.AjTypeSystem;
|
||||||
import org.aspectj.lang.reflect.PerClauseKind;
|
import org.aspectj.lang.reflect.PerClauseKind;
|
||||||
|
|
||||||
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||||
import org.springframework.aop.framework.AopConfigException;
|
import org.springframework.aop.framework.AopConfigException;
|
||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.core.PrioritizedParameterNameDiscoverer;
|
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
|
@ -67,11 +65,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
* (there <i>should</i> only be one anyway...)
|
* (there <i>should</i> only be one anyway...)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected static AspectJAnnotation findAspectJAnnotationOnMethod(Method method) {
|
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
|
||||||
Class<? extends Annotation>[] classesToLookFor = new Class[] {
|
Class<?>[] classesToLookFor = new Class<?>[] {
|
||||||
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
|
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
|
||||||
for (Class<? extends Annotation> c : classesToLookFor) {
|
for (Class<?> c : classesToLookFor) {
|
||||||
AspectJAnnotation foundAnnotation = findAnnotation(method, c);
|
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
|
||||||
if (foundAnnotation != null) {
|
if (foundAnnotation != null) {
|
||||||
return foundAnnotation;
|
return foundAnnotation;
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +154,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
* formal parameters for the pointcut.
|
* formal parameters for the pointcut.
|
||||||
*/
|
*/
|
||||||
protected AspectJExpressionPointcut createPointcutExpression(
|
protected AspectJExpressionPointcut createPointcutExpression(
|
||||||
Method annotatedMethod, Class declarationScope, String[] pointcutParameterNames) {
|
Method annotatedMethod, Class<?> declarationScope, String[] pointcutParameterNames) {
|
||||||
|
|
||||||
Class<?> [] pointcutParameterTypes = new Class<?>[0];
|
Class<?> [] pointcutParameterTypes = new Class<?>[0];
|
||||||
if (pointcutParameterNames != null) {
|
if (pointcutParameterNames != null) {
|
||||||
|
|
@ -210,8 +208,8 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
|
|
||||||
private static final String[] EXPRESSION_PROPERTIES = new String[] {"value", "pointcut"};
|
private static final String[] EXPRESSION_PROPERTIES = new String[] {"value", "pointcut"};
|
||||||
|
|
||||||
private static Map<Class, AspectJAnnotationType> annotationTypes =
|
private static Map<Class<?>, AspectJAnnotationType> annotationTypes =
|
||||||
new HashMap<Class, AspectJAnnotationType>();
|
new HashMap<Class<?>, AspectJAnnotationType>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
annotationTypes.put(Pointcut.class,AspectJAnnotationType.AtPointcut);
|
annotationTypes.put(Pointcut.class,AspectJAnnotationType.AtPointcut);
|
||||||
|
|
@ -245,7 +243,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
}
|
}
|
||||||
|
|
||||||
private AspectJAnnotationType determineAnnotationType(A annotation) {
|
private AspectJAnnotationType determineAnnotationType(A annotation) {
|
||||||
for (Class type : annotationTypes.keySet()) {
|
for (Class<?> type : annotationTypes.keySet()) {
|
||||||
if (type.isInstance(annotation)) {
|
if (type.isInstance(annotation)) {
|
||||||
return annotationTypes.get(type);
|
return annotationTypes.get(type);
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +305,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
if (method.getParameterTypes().length == 0) {
|
if (method.getParameterTypes().length == 0) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
AspectJAnnotation annotation = findAspectJAnnotationOnMethod(method);
|
AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);
|
||||||
if (annotation == null) {
|
if (annotation == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +323,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getParameterNames(Constructor ctor) {
|
public String[] getParameterNames(Constructor<?> ctor) {
|
||||||
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
throw new UnsupportedOperationException("Spring AOP cannot handle constructor advice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isInfrastructureClass(Class beanClass) {
|
protected boolean isInfrastructureClass(Class<?> beanClass) {
|
||||||
// Previously we setProxyTargetClass(true) in the constructor, but that has too
|
// Previously we setProxyTargetClass(true) in the constructor, but that has too
|
||||||
// broad an impact. Instead we now override isInfrastructureClass to avoid proxying
|
// broad an impact. Instead we now override isInfrastructureClass to avoid proxying
|
||||||
// aspects. I'm not entirely happy with that as there is no good reason not
|
// aspects. I'm not entirely happy with that as there is no good reason not
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ import org.springframework.util.ClassUtils;
|
||||||
public class AspectJProxyFactory extends ProxyCreatorSupport {
|
public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
|
|
||||||
/** Cache for singleton aspect instances */
|
/** Cache for singleton aspect instances */
|
||||||
private static final Map<Class, Object> aspectCache = new HashMap<Class, Object>();
|
private static final Map<Class<?>, Object> aspectCache = new HashMap<Class<?>, Object>();
|
||||||
|
|
||||||
private final AspectJAdvisorFactory aspectFactory = new ReflectiveAspectJAdvisorFactory();
|
private final AspectJAdvisorFactory aspectFactory = new ReflectiveAspectJAdvisorFactory();
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
* Create a new {@code AspectJProxyFactory}.
|
* Create a new {@code AspectJProxyFactory}.
|
||||||
* No target, only interfaces. Must add interceptors.
|
* No target, only interfaces. Must add interceptors.
|
||||||
*/
|
*/
|
||||||
public AspectJProxyFactory(Class[] interfaces) {
|
public AspectJProxyFactory(Class<?>[] interfaces) {
|
||||||
setInterfaces(interfaces);
|
setInterfaces(interfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
* @param aspectInstance the AspectJ aspect instance
|
* @param aspectInstance the AspectJ aspect instance
|
||||||
*/
|
*/
|
||||||
public void addAspect(Object aspectInstance) {
|
public void addAspect(Object aspectInstance) {
|
||||||
Class aspectClass = aspectInstance.getClass();
|
Class<?> aspectClass = aspectInstance.getClass();
|
||||||
String aspectName = aspectClass.getName();
|
String aspectName = aspectClass.getName();
|
||||||
AspectMetadata am = createAspectMetadata(aspectClass, aspectName);
|
AspectMetadata am = createAspectMetadata(aspectClass, aspectName);
|
||||||
if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) {
|
if (am.getAjType().getPerClause().getKind() != PerClauseKind.SINGLETON) {
|
||||||
|
|
@ -104,7 +104,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
* Add an aspect of the supplied type to the end of the advice chain.
|
* Add an aspect of the supplied type to the end of the advice chain.
|
||||||
* @param aspectClass the AspectJ aspect class
|
* @param aspectClass the AspectJ aspect class
|
||||||
*/
|
*/
|
||||||
public void addAspect(Class aspectClass) {
|
public void addAspect(Class<?> aspectClass) {
|
||||||
String aspectName = aspectClass.getName();
|
String aspectName = aspectClass.getName();
|
||||||
AspectMetadata am = createAspectMetadata(aspectClass, aspectName);
|
AspectMetadata am = createAspectMetadata(aspectClass, aspectName);
|
||||||
MetadataAwareAspectInstanceFactory instanceFactory = createAspectInstanceFactory(am, aspectClass, aspectName);
|
MetadataAwareAspectInstanceFactory instanceFactory = createAspectInstanceFactory(am, aspectClass, aspectName);
|
||||||
|
|
@ -128,7 +128,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
/**
|
/**
|
||||||
* Create an {@link AspectMetadata} instance for the supplied aspect type.
|
* Create an {@link AspectMetadata} instance for the supplied aspect type.
|
||||||
*/
|
*/
|
||||||
private AspectMetadata createAspectMetadata(Class aspectClass, String aspectName) {
|
private AspectMetadata createAspectMetadata(Class<?> aspectClass, String aspectName) {
|
||||||
AspectMetadata am = new AspectMetadata(aspectClass, aspectName);
|
AspectMetadata am = new AspectMetadata(aspectClass, aspectName);
|
||||||
if (!am.getAjType().isAspect()) {
|
if (!am.getAjType().isAspect()) {
|
||||||
throw new IllegalArgumentException("Class [" + aspectClass.getName() + "] is not a valid aspect type");
|
throw new IllegalArgumentException("Class [" + aspectClass.getName() + "] is not a valid aspect type");
|
||||||
|
|
@ -142,7 +142,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
* a {@link PrototypeAspectInstanceFactory} is returned.
|
* a {@link PrototypeAspectInstanceFactory} is returned.
|
||||||
*/
|
*/
|
||||||
private MetadataAwareAspectInstanceFactory createAspectInstanceFactory(
|
private MetadataAwareAspectInstanceFactory createAspectInstanceFactory(
|
||||||
AspectMetadata am, Class aspectClass, String aspectName) {
|
AspectMetadata am, Class<?> aspectClass, String aspectName) {
|
||||||
|
|
||||||
MetadataAwareAspectInstanceFactory instanceFactory = null;
|
MetadataAwareAspectInstanceFactory instanceFactory = null;
|
||||||
if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
|
if (am.getAjType().getPerClause().getKind() == PerClauseKind.SINGLETON) {
|
||||||
|
|
@ -161,7 +161,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||||
* Get the singleton aspect instance for the supplied aspect type. An instance
|
* Get the singleton aspect instance for the supplied aspect type. An instance
|
||||||
* is created if one cannot be found in the instance cache.
|
* is created if one cannot be found in the instance cache.
|
||||||
*/
|
*/
|
||||||
private Object getSingletonAspectInstance(Class aspectClass) {
|
private Object getSingletonAspectInstance(Class<?> aspectClass) {
|
||||||
synchronized (aspectCache) {
|
synchronized (aspectCache) {
|
||||||
Object instance = aspectCache.get(aspectClass);
|
Object instance = aspectCache.get(aspectClass);
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class AspectMetadata {
|
||||||
/**
|
/**
|
||||||
* AspectJ reflection information (AspectJ 5 / Java 5 specific).
|
* AspectJ reflection information (AspectJ 5 / Java 5 specific).
|
||||||
*/
|
*/
|
||||||
private final AjType ajType;
|
private final AjType<?> ajType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring AOP pointcut corresponding to the per clause of the
|
* Spring AOP pointcut corresponding to the per clause of the
|
||||||
|
|
@ -71,9 +71,9 @@ public class AspectMetadata {
|
||||||
this.aspectName = aspectName;
|
this.aspectName = aspectName;
|
||||||
|
|
||||||
Class<?> currClass = aspectClass;
|
Class<?> currClass = aspectClass;
|
||||||
AjType ajType = null;
|
AjType<?> ajType = null;
|
||||||
while (!currClass.equals(Object.class)) {
|
while (!currClass.equals(Object.class)) {
|
||||||
AjType ajTypeToCheck = AjTypeSystem.getAjType(currClass);
|
AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
|
||||||
if (ajTypeToCheck.isAspect()) {
|
if (ajTypeToCheck.isAspect()) {
|
||||||
ajType = ajTypeToCheck;
|
ajType = ajTypeToCheck;
|
||||||
break;
|
break;
|
||||||
|
|
@ -124,14 +124,14 @@ public class AspectMetadata {
|
||||||
/**
|
/**
|
||||||
* Return AspectJ reflection information.
|
* Return AspectJ reflection information.
|
||||||
*/
|
*/
|
||||||
public AjType getAjType() {
|
public AjType<?> getAjType() {
|
||||||
return this.ajType;
|
return this.ajType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the aspect class.
|
* Return the aspect class.
|
||||||
*/
|
*/
|
||||||
public Class getAspectClass() {
|
public Class<?> getAspectClass() {
|
||||||
return this.ajType.getJavaClass();
|
return this.ajType.getJavaClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class BeanFactoryAspectInstanceFactory implements MetadataAwareAspectInst
|
||||||
* @param name the name of the bean
|
* @param name the name of the bean
|
||||||
* @param type the type that should be introspected by AspectJ
|
* @param type the type that should be introspected by AspectJ
|
||||||
*/
|
*/
|
||||||
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name, Class type) {
|
public BeanFactoryAspectInstanceFactory(BeanFactory beanFactory, String name, Class<?> type) {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aspectMetadata = new AspectMetadata(type, name);
|
this.aspectMetadata = new AspectMetadata(type, name);
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
|
||||||
// We must be careful not to instantiate beans eagerly as in this
|
// We must be careful not to instantiate beans eagerly as in this
|
||||||
// case they would be cached by the Spring container but would not
|
// case they would be cached by the Spring container but would not
|
||||||
// have been weaved
|
// have been weaved
|
||||||
Class beanType = this.beanFactory.getType(beanName);
|
Class<?> beanType = this.beanFactory.getType(beanName);
|
||||||
if (beanType == null) {
|
if (beanType == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +134,7 @@ public class BeanFactoryAspectJAdvisorsBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aspectNames.isEmpty()) {
|
if (aspectNames.isEmpty()) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<Advisor> advisors = new LinkedList<Advisor>();
|
List<Advisor> advisors = new LinkedList<Advisor>();
|
||||||
for (String aspectName : aspectNames) {
|
for (String aspectName : aspectNames) {
|
||||||
|
|
|
||||||
|
|
@ -249,14 +249,14 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
// We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut
|
// We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut
|
||||||
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) ||
|
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) ||
|
||||||
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
|
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
// This can match only on declared pointcut.
|
// This can match only on declared pointcut.
|
||||||
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
|
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AspectJExpressionPointcut ajexp =
|
AspectJExpressionPointcut ajexp =
|
||||||
new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class[0]);
|
new AspectJExpressionPointcut(candidateAspectClass, new String[0], new Class<?>[0]);
|
||||||
ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
|
ajexp.setExpression(aspectJAnnotation.getPointcutExpression());
|
||||||
return ajexp;
|
return ajexp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class SimpleMetadataAwareAspectInstanceFactory extends SimpleAspectInstan
|
||||||
* @param aspectClass the aspect class
|
* @param aspectClass the aspect class
|
||||||
* @param aspectName the aspect name
|
* @param aspectName the aspect name
|
||||||
*/
|
*/
|
||||||
public SimpleMetadataAwareAspectInstanceFactory(Class aspectClass, String aspectName) {
|
public SimpleMetadataAwareAspectInstanceFactory(Class<?> aspectClass, String aspectName) {
|
||||||
super(aspectClass);
|
super(aspectClass);
|
||||||
this.metadata = new AspectMetadata(aspectClass, aspectName);
|
this.metadata = new AspectMetadata(aspectClass, aspectName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import org.springframework.util.ClassUtils;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {
|
public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {
|
||||||
|
|
||||||
private static final Comparator DEFAULT_PRECEDENCE_COMPARATOR = new AspectJPrecedenceComparator();
|
private static final Comparator<Advisor> DEFAULT_PRECEDENCE_COMPARATOR = new AspectJPrecedenceComparator();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,7 +98,7 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldSkip(Class beanClass, String beanName) {
|
protected boolean shouldSkip(Class<?> beanClass, String beanName) {
|
||||||
// TODO: Consider optimization by caching the list of the aspect names
|
// TODO: Consider optimization by caching the list of the aspect names
|
||||||
List<Advisor> candidateAdvisors = findCandidateAdvisors();
|
List<Advisor> candidateAdvisors = findCandidateAdvisors();
|
||||||
for (Advisor advisor : candidateAdvisors) {
|
for (Advisor advisor : candidateAdvisors) {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ import org.springframework.util.Assert;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class AspectJPrecedenceComparator implements Comparator {
|
class AspectJPrecedenceComparator implements Comparator<Advisor> {
|
||||||
|
|
||||||
private static final int HIGHER_PRECEDENCE = -1;
|
private static final int HIGHER_PRECEDENCE = -1;
|
||||||
private static final int SAME_PRECEDENCE = 0;
|
private static final int SAME_PRECEDENCE = 0;
|
||||||
|
|
@ -76,18 +76,10 @@ class AspectJPrecedenceComparator implements Comparator {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Advisor o1, Advisor o2) {
|
||||||
if (!(o1 instanceof Advisor && o2 instanceof Advisor)) {
|
int advisorPrecedence = this.advisorComparator.compare(o1, o2);
|
||||||
throw new IllegalArgumentException(
|
if (advisorPrecedence == SAME_PRECEDENCE && declaredInSameAspect(o1, o2)) {
|
||||||
"AspectJPrecedenceComparator can only compare the order of Advisors, " +
|
advisorPrecedence = comparePrecedenceWithinAspect(o1, o2);
|
||||||
"but was passed [" + o1 + "] and [" + o2 + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
Advisor advisor1 = (Advisor) o1;
|
|
||||||
Advisor advisor2 = (Advisor) o2;
|
|
||||||
int advisorPrecedence = this.advisorComparator.compare(advisor1, advisor2);
|
|
||||||
if (advisorPrecedence == SAME_PRECEDENCE && declaredInSameAspect(advisor1, advisor2)) {
|
|
||||||
advisorPrecedence = comparePrecedenceWithinAspect(advisor1, advisor2);
|
|
||||||
}
|
}
|
||||||
return advisorPrecedence;
|
return advisorPrecedence;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public abstract class AopConfigUtils {
|
||||||
/**
|
/**
|
||||||
* Stores the auto proxy creator classes in escalation order.
|
* Stores the auto proxy creator classes in escalation order.
|
||||||
*/
|
*/
|
||||||
private static final List<Class> APC_PRIORITY_LIST = new ArrayList<Class>();
|
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the escalation list.
|
* Setup the escalation list.
|
||||||
|
|
@ -105,7 +105,7 @@ public abstract class AopConfigUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static BeanDefinition registerOrEscalateApcAsRequired(Class cls, BeanDefinitionRegistry registry, Object source) {
|
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
|
||||||
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
||||||
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
|
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
|
||||||
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
|
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
|
||||||
|
|
@ -126,13 +126,13 @@ public abstract class AopConfigUtils {
|
||||||
return beanDefinition;
|
return beanDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int findPriorityForClass(Class clazz) {
|
private static int findPriorityForClass(Class<?> clazz) {
|
||||||
return APC_PRIORITY_LIST.indexOf(clazz);
|
return APC_PRIORITY_LIST.indexOf(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int findPriorityForClass(String className) {
|
private static int findPriorityForClass(String className) {
|
||||||
for (int i = 0; i < APC_PRIORITY_LIST.size(); i++) {
|
for (int i = 0; i < APC_PRIORITY_LIST.size(); i++) {
|
||||||
Class clazz = APC_PRIORITY_LIST.get(i);
|
Class<?> clazz = APC_PRIORITY_LIST.get(i);
|
||||||
if (clazz.getName().equals(className)) {
|
if (clazz.getName().equals(className)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
/**
|
/**
|
||||||
* Gets the advice implementation class corresponding to the supplied {@link Element}.
|
* Gets the advice implementation class corresponding to the supplied {@link Element}.
|
||||||
*/
|
*/
|
||||||
private Class getAdviceClass(Element adviceElement, ParserContext parserContext) {
|
private Class<?> getAdviceClass(Element adviceElement, ParserContext parserContext) {
|
||||||
String elementName = parserContext.getDelegate().getLocalName(adviceElement);
|
String elementName = parserContext.getDelegate().getLocalName(adviceElement);
|
||||||
if (BEFORE.equals(elementName)) {
|
if (BEFORE.equals(elementName)) {
|
||||||
return AspectJMethodBeforeAdvice.class;
|
return AspectJMethodBeforeAdvice.class;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFacto
|
||||||
throw new IllegalArgumentException("Property 'methodName' is required");
|
throw new IllegalArgumentException("Property 'methodName' is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class beanClass = beanFactory.getType(this.targetBeanName);
|
Class<?> beanClass = beanFactory.getType(this.targetBeanName);
|
||||||
if (beanClass == null) {
|
if (beanClass == null) {
|
||||||
throw new IllegalArgumentException("Can't determine type of bean with name '" + this.targetBeanName + "'");
|
throw new IllegalArgumentException("Can't determine type of bean with name '" + this.targetBeanName + "'");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyConfig
|
||||||
*/
|
*/
|
||||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||||
|
|
||||||
private final Map<Class, Boolean> eligibleBeans = new ConcurrentHashMap<Class, Boolean>(64);
|
private final Map<Class<?>, Boolean> eligibleBeans = new ConcurrentHashMap<Class<?>, Boolean>(64);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ import org.springframework.util.CollectionUtils;
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @see org.springframework.aop.framework.AopProxy
|
* @see org.springframework.aop.framework.AopProxy
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class AdvisedSupport extends ProxyConfig implements Advised {
|
public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
|
|
||||||
/** use serialVersionUID from Spring 2.0 for interoperability */
|
/** use serialVersionUID from Spring 2.0 for interoperability */
|
||||||
|
|
@ -88,7 +87,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
* Interfaces to be implemented by the proxy. Held in List to keep the order
|
* Interfaces to be implemented by the proxy. Held in List to keep the order
|
||||||
* of registration, to create JDK proxy with specified order of interfaces.
|
* of registration, to create JDK proxy with specified order of interfaces.
|
||||||
*/
|
*/
|
||||||
private List<Class> interfaces = new ArrayList<Class>();
|
private List<Class<?>> interfaces = new ArrayList<Class<?>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of Advisors. If an Advice is added, it will be wrapped
|
* List of Advisors. If an Advice is added, it will be wrapped
|
||||||
|
|
@ -114,7 +113,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
* Create a AdvisedSupport instance with the given parameters.
|
* Create a AdvisedSupport instance with the given parameters.
|
||||||
* @param interfaces the proxied interfaces
|
* @param interfaces the proxied interfaces
|
||||||
*/
|
*/
|
||||||
public AdvisedSupport(Class[] interfaces) {
|
public AdvisedSupport(Class<?>[] interfaces) {
|
||||||
this();
|
this();
|
||||||
setInterfaces(interfaces);
|
setInterfaces(interfaces);
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +201,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
public void setInterfaces(Class<?>... interfaces) {
|
public void setInterfaces(Class<?>... interfaces) {
|
||||||
Assert.notNull(interfaces, "Interfaces must not be null");
|
Assert.notNull(interfaces, "Interfaces must not be null");
|
||||||
this.interfaces.clear();
|
this.interfaces.clear();
|
||||||
for (Class ifc : interfaces) {
|
for (Class<?> ifc : interfaces) {
|
||||||
addInterface(ifc);
|
addInterface(ifc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -235,12 +234,12 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?>[] getProxiedInterfaces() {
|
public Class<?>[] getProxiedInterfaces() {
|
||||||
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInterfaceProxied(Class<?> intf) {
|
public boolean isInterfaceProxied(Class<?> intf) {
|
||||||
for (Class proxyIntf : this.interfaces) {
|
for (Class<?> proxyIntf : this.interfaces) {
|
||||||
if (intf.isAssignableFrom(proxyIntf)) {
|
if (intf.isAssignableFrom(proxyIntf)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -355,8 +354,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
private void validateIntroductionAdvisor(IntroductionAdvisor advisor) {
|
private void validateIntroductionAdvisor(IntroductionAdvisor advisor) {
|
||||||
advisor.validateInterfaces();
|
advisor.validateInterfaces();
|
||||||
// If the advisor passed validation, we can make the change.
|
// If the advisor passed validation, we can make the change.
|
||||||
Class[] ifcs = advisor.getInterfaces();
|
Class<?>[] ifcs = advisor.getInterfaces();
|
||||||
for (Class ifc : ifcs) {
|
for (Class<?> ifc : ifcs) {
|
||||||
addInterface(ifc);
|
addInterface(ifc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -463,7 +462,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
* @param adviceClass the advice class to check
|
* @param adviceClass the advice class to check
|
||||||
* @return the count of the interceptors of this class or subclasses
|
* @return the count of the interceptors of this class or subclasses
|
||||||
*/
|
*/
|
||||||
public int countAdvicesOfType(Class adviceClass) {
|
public int countAdvicesOfType(Class<?> adviceClass) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (adviceClass != null) {
|
if (adviceClass != null) {
|
||||||
for (Advisor advisor : this.advisors) {
|
for (Advisor advisor : this.advisors) {
|
||||||
|
|
@ -483,7 +482,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
* @param targetClass the target class
|
* @param targetClass the target class
|
||||||
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
||||||
*/
|
*/
|
||||||
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(Method method, Class targetClass) {
|
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(Method method, Class<?> targetClass) {
|
||||||
MethodCacheKey cacheKey = new MethodCacheKey(method);
|
MethodCacheKey cacheKey = new MethodCacheKey(method);
|
||||||
List<Object> cached = this.methodCache.get(cacheKey);
|
List<Object> cached = this.methodCache.get(cacheKey);
|
||||||
if (cached == null) {
|
if (cached == null) {
|
||||||
|
|
@ -521,7 +520,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||||
copyFrom(other);
|
copyFrom(other);
|
||||||
this.targetSource = targetSource;
|
this.targetSource = targetSource;
|
||||||
this.advisorChainFactory = other.advisorChainFactory;
|
this.advisorChainFactory = other.advisorChainFactory;
|
||||||
this.interfaces = new ArrayList<Class>(other.interfaces);
|
this.interfaces = new ArrayList<Class<?>>(other.interfaces);
|
||||||
for (Advisor advisor : advisors) {
|
for (Advisor advisor : advisors) {
|
||||||
if (advisor instanceof IntroductionAdvisor) {
|
if (advisor instanceof IntroductionAdvisor) {
|
||||||
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,6 @@ public interface AdvisorChainFactory {
|
||||||
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
||||||
*/
|
*/
|
||||||
List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
||||||
Advised config, Method method, Class targetClass);
|
Advised config, Method method, Class<?> targetClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,13 +78,13 @@ public abstract class AopProxyUtils {
|
||||||
* @see Advised
|
* @see Advised
|
||||||
* @see org.springframework.aop.SpringProxy
|
* @see org.springframework.aop.SpringProxy
|
||||||
*/
|
*/
|
||||||
public static Class[] completeProxiedInterfaces(AdvisedSupport advised) {
|
public static Class<?>[] completeProxiedInterfaces(AdvisedSupport advised) {
|
||||||
Class[] specifiedInterfaces = advised.getProxiedInterfaces();
|
Class<?>[] specifiedInterfaces = advised.getProxiedInterfaces();
|
||||||
if (specifiedInterfaces.length == 0) {
|
if (specifiedInterfaces.length == 0) {
|
||||||
// No user-specified interfaces: check whether target class is an interface.
|
// No user-specified interfaces: check whether target class is an interface.
|
||||||
Class targetClass = advised.getTargetClass();
|
Class<?> targetClass = advised.getTargetClass();
|
||||||
if (targetClass != null && targetClass.isInterface()) {
|
if (targetClass != null && targetClass.isInterface()) {
|
||||||
specifiedInterfaces = new Class[] {targetClass};
|
specifiedInterfaces = new Class<?>[] {targetClass};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
|
boolean addSpringProxy = !advised.isInterfaceProxied(SpringProxy.class);
|
||||||
|
|
@ -96,7 +96,7 @@ public abstract class AopProxyUtils {
|
||||||
if (addAdvised) {
|
if (addAdvised) {
|
||||||
nonUserIfcCount++;
|
nonUserIfcCount++;
|
||||||
}
|
}
|
||||||
Class[] proxiedInterfaces = new Class[specifiedInterfaces.length + nonUserIfcCount];
|
Class<?>[] proxiedInterfaces = new Class<?>[specifiedInterfaces.length + nonUserIfcCount];
|
||||||
System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
|
System.arraycopy(specifiedInterfaces, 0, proxiedInterfaces, 0, specifiedInterfaces.length);
|
||||||
if (addSpringProxy) {
|
if (addSpringProxy) {
|
||||||
proxiedInterfaces[specifiedInterfaces.length] = SpringProxy.class;
|
proxiedInterfaces[specifiedInterfaces.length] = SpringProxy.class;
|
||||||
|
|
@ -115,8 +115,8 @@ public abstract class AopProxyUtils {
|
||||||
* in the original order (never {@code null} or empty)
|
* in the original order (never {@code null} or empty)
|
||||||
* @see Advised
|
* @see Advised
|
||||||
*/
|
*/
|
||||||
public static Class[] proxiedUserInterfaces(Object proxy) {
|
public static Class<?>[] proxiedUserInterfaces(Object proxy) {
|
||||||
Class[] proxyInterfaces = proxy.getClass().getInterfaces();
|
Class<?>[] proxyInterfaces = proxy.getClass().getInterfaces();
|
||||||
int nonUserIfcCount = 0;
|
int nonUserIfcCount = 0;
|
||||||
if (proxy instanceof SpringProxy) {
|
if (proxy instanceof SpringProxy) {
|
||||||
nonUserIfcCount++;
|
nonUserIfcCount++;
|
||||||
|
|
@ -124,7 +124,7 @@ public abstract class AopProxyUtils {
|
||||||
if (proxy instanceof Advised) {
|
if (proxy instanceof Advised) {
|
||||||
nonUserIfcCount++;
|
nonUserIfcCount++;
|
||||||
}
|
}
|
||||||
Class[] userInterfaces = new Class[proxyInterfaces.length - nonUserIfcCount];
|
Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
|
||||||
System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
|
System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
|
||||||
Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
|
Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
|
||||||
return userInterfaces;
|
return userInterfaces;
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||||
enhancer.setInterfaces(AopProxyUtils.completeProxiedInterfaces(this.advised));
|
enhancer.setInterfaces(AopProxyUtils.completeProxiedInterfaces(this.advised));
|
||||||
|
|
||||||
Callback[] callbacks = getCallbacks(rootClass);
|
Callback[] callbacks = getCallbacks(rootClass);
|
||||||
Class<?>[] types = new Class[callbacks.length];
|
Class<?>[] types = new Class<?>[callbacks.length];
|
||||||
|
|
||||||
for (int x = 0; x < types.length; x++) {
|
for (int x = 0; x < types.length; x++) {
|
||||||
types[x] = callbacks[x].getClass();
|
types[x] = callbacks[x].getClass();
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(
|
||||||
Advised config, Method method, Class targetClass) {
|
Advised config, Method method, Class<?> targetClass) {
|
||||||
|
|
||||||
// This is somewhat tricky... we have to process introductions first,
|
// This is somewhat tricky... we have to process introductions first,
|
||||||
// but we need to preserve order in the ultimate list.
|
// but we need to preserve order in the ultimate list.
|
||||||
|
|
@ -94,7 +94,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
|
||||||
/**
|
/**
|
||||||
* Determine whether the Advisors contain matching introductions.
|
* Determine whether the Advisors contain matching introductions.
|
||||||
*/
|
*/
|
||||||
private static boolean hasMatchingIntroductions(Advised config, Class targetClass) {
|
private static boolean hasMatchingIntroductions(Advised config, Class<?> targetClass) {
|
||||||
for (int i = 0; i < config.getAdvisors().length; i++) {
|
for (int i = 0; i < config.getAdvisors().length; i++) {
|
||||||
Advisor advisor = config.getAdvisors()[i];
|
Advisor advisor = config.getAdvisors()[i];
|
||||||
if (advisor instanceof IntroductionAdvisor) {
|
if (advisor instanceof IntroductionAdvisor) {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||||
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
|
if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) {
|
||||||
Class targetClass = config.getTargetClass();
|
Class<?> targetClass = config.getTargetClass();
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
throw new AopConfigException("TargetSource cannot determine target class: " +
|
throw new AopConfigException("TargetSource cannot determine target class: " +
|
||||||
"Either an interface or a target is required for proxy creation.");
|
"Either an interface or a target is required for proxy creation.");
|
||||||
|
|
@ -72,7 +72,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||||
* (or no proxy interfaces specified at all).
|
* (or no proxy interfaces specified at all).
|
||||||
*/
|
*/
|
||||||
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
|
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
|
||||||
Class[] interfaces = config.getProxiedInterfaces();
|
Class<?>[] interfaces = config.getProxiedInterfaces();
|
||||||
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
|
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
|
logger.debug("Creating JDK dynamic proxy: target source is " + this.advised.getTargetSource());
|
||||||
}
|
}
|
||||||
Class[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised);
|
Class<?>[] proxiedInterfaces = AopProxyUtils.completeProxiedInterfaces(this.advised);
|
||||||
findDefinedEqualsAndHashCodeMethods(proxiedInterfaces);
|
findDefinedEqualsAndHashCodeMethods(proxiedInterfaces);
|
||||||
return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);
|
return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);
|
||||||
}
|
}
|
||||||
|
|
@ -126,8 +126,8 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
* on the supplied set of interfaces.
|
* on the supplied set of interfaces.
|
||||||
* @param proxiedInterfaces the interfaces to introspect
|
* @param proxiedInterfaces the interfaces to introspect
|
||||||
*/
|
*/
|
||||||
private void findDefinedEqualsAndHashCodeMethods(Class[] proxiedInterfaces) {
|
private void findDefinedEqualsAndHashCodeMethods(Class<?>[] proxiedInterfaces) {
|
||||||
for (Class proxiedInterface : proxiedInterfaces) {
|
for (Class<?> proxiedInterface : proxiedInterfaces) {
|
||||||
Method[] methods = proxiedInterface.getDeclaredMethods();
|
Method[] methods = proxiedInterface.getDeclaredMethods();
|
||||||
for (Method method : methods) {
|
for (Method method : methods) {
|
||||||
if (AopUtils.isEqualsMethod(method)) {
|
if (AopUtils.isEqualsMethod(method)) {
|
||||||
|
|
@ -156,7 +156,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||||
boolean setProxyContext = false;
|
boolean setProxyContext = false;
|
||||||
|
|
||||||
TargetSource targetSource = this.advised.targetSource;
|
TargetSource targetSource = this.advised.targetSource;
|
||||||
Class targetClass = null;
|
Class<?> targetClass = null;
|
||||||
Object target = null;
|
Object target = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.springframework.objenesis.ObjenesisStd;
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
class ObjenesisCglibAopProxy extends CglibAopProxy {
|
class ObjenesisCglibAopProxy extends CglibAopProxy {
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(ObjenesisCglibAopProxy.class);
|
private static final Log logger = LogFactory.getLog(ObjenesisCglibAopProxy.class);
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* @see #setInterfaces
|
* @see #setInterfaces
|
||||||
* @see AbstractSingletonProxyFactoryBean#setProxyInterfaces
|
* @see AbstractSingletonProxyFactoryBean#setProxyInterfaces
|
||||||
*/
|
*/
|
||||||
public void setProxyInterfaces(Class[] proxyInterfaces) throws ClassNotFoundException {
|
public void setProxyInterfaces(Class<?>[] proxyInterfaces) throws ClassNotFoundException {
|
||||||
setInterfaces(proxyInterfaces);
|
setInterfaces(proxyInterfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +267,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
return this.singletonInstance.getClass();
|
return this.singletonInstance.getClass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Class[] ifcs = getProxiedInterfaces();
|
Class<?>[] ifcs = getProxiedInterfaces();
|
||||||
if (ifcs.length == 1) {
|
if (ifcs.length == 1) {
|
||||||
return ifcs[0];
|
return ifcs[0];
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +297,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* @return the merged interface as Class
|
* @return the merged interface as Class
|
||||||
* @see java.lang.reflect.Proxy#getProxyClass
|
* @see java.lang.reflect.Proxy#getProxyClass
|
||||||
*/
|
*/
|
||||||
protected Class createCompositeInterface(Class[] interfaces) {
|
protected Class<?> createCompositeInterface(Class<?>[] interfaces) {
|
||||||
return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
|
return ClassUtils.createCompositeInterface(interfaces, this.proxyClassLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,7 +311,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
this.targetSource = freshTargetSource();
|
this.targetSource = freshTargetSource();
|
||||||
if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
|
if (this.autodetectInterfaces && getProxiedInterfaces().length == 0 && !isProxyTargetClass()) {
|
||||||
// Rely on AOP infrastructure to tell us what interfaces to proxy.
|
// Rely on AOP infrastructure to tell us what interfaces to proxy.
|
||||||
Class targetClass = getTargetClass();
|
Class<?> targetClass = getTargetClass();
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
|
throw new FactoryBeanNotInitializedException("Cannot determine target class for proxy");
|
||||||
}
|
}
|
||||||
|
|
@ -401,7 +401,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||||
* @return {@code true} if it's an Advisor or Advice
|
* @return {@code true} if it's an Advisor or Advice
|
||||||
*/
|
*/
|
||||||
private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) {
|
private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) {
|
||||||
Class namedBeanClass = this.beanFactory.getType(beanName);
|
Class<?> namedBeanClass = this.beanFactory.getType(beanName);
|
||||||
if (namedBeanClass != null) {
|
if (namedBeanClass != null) {
|
||||||
return (Advisor.class.isAssignableFrom(namedBeanClass) || Advice.class.isAssignableFrom(namedBeanClass));
|
return (Advisor.class.isAssignableFrom(namedBeanClass) || Advice.class.isAssignableFrom(namedBeanClass));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
|
|
||||||
protected Object[] arguments;
|
protected Object[] arguments;
|
||||||
|
|
||||||
private final Class targetClass;
|
private final Class<?> targetClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazily initialized map of user-specific attributes for this invocation.
|
* Lazily initialized map of user-specific attributes for this invocation.
|
||||||
|
|
@ -79,7 +79,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
* List of MethodInterceptor and InterceptorAndDynamicMethodMatcher
|
* List of MethodInterceptor and InterceptorAndDynamicMethodMatcher
|
||||||
* that need dynamic checks.
|
* that need dynamic checks.
|
||||||
*/
|
*/
|
||||||
protected final List interceptorsAndDynamicMethodMatchers;
|
protected final List<?> interceptorsAndDynamicMethodMatchers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index from 0 of the current interceptor we're invoking.
|
* Index from 0 of the current interceptor we're invoking.
|
||||||
|
|
@ -103,7 +103,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
*/
|
*/
|
||||||
protected ReflectiveMethodInvocation(
|
protected ReflectiveMethodInvocation(
|
||||||
Object proxy, Object target, Method method, Object[] arguments,
|
Object proxy, Object target, Method method, Object[] arguments,
|
||||||
Class targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
|
Class<?> targetClass, List<Object> interceptorsAndDynamicMethodMatchers) {
|
||||||
|
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
private final Object throwsAdvice;
|
private final Object throwsAdvice;
|
||||||
|
|
||||||
/** Methods on throws advice, keyed by exception class */
|
/** Methods on throws advice, keyed by exception class */
|
||||||
private final Map<Class, Method> exceptionHandlerMap = new HashMap<Class, Method>();
|
private final Map<Class<?>, Method> exceptionHandlerMap = new HashMap<Class<?>, Method>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -104,7 +104,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||||
* @return a handler for the given exception type
|
* @return a handler for the given exception type
|
||||||
*/
|
*/
|
||||||
private Method getExceptionHandler(Throwable exception) {
|
private Method getExceptionHandler(Throwable exception) {
|
||||||
Class exceptionClass = exception.getClass();
|
Class<?> exceptionClass = exception.getClass();
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
|
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource) {
|
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) {
|
||||||
List advisors = findEligibleAdvisors(beanClass, beanName);
|
List<Advisor> advisors = findEligibleAdvisors(beanClass, beanName);
|
||||||
if (advisors.isEmpty()) {
|
if (advisors.isEmpty()) {
|
||||||
return DO_NOT_PROXY;
|
return DO_NOT_PROXY;
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
|
||||||
* @see #sortAdvisors
|
* @see #sortAdvisors
|
||||||
* @see #extendAdvisors
|
* @see #extendAdvisors
|
||||||
*/
|
*/
|
||||||
protected List<Advisor> findEligibleAdvisors(Class beanClass, String beanName) {
|
protected List<Advisor> findEligibleAdvisors(Class<?> beanClass, String beanName) {
|
||||||
List<Advisor> candidateAdvisors = findCandidateAdvisors();
|
List<Advisor> candidateAdvisors = findCandidateAdvisors();
|
||||||
List<Advisor> eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
|
List<Advisor> eligibleAdvisors = findAdvisorsThatCanApply(candidateAdvisors, beanClass, beanName);
|
||||||
extendAdvisors(eligibleAdvisors);
|
extendAdvisors(eligibleAdvisors);
|
||||||
|
|
@ -111,7 +111,7 @@ public abstract class AbstractAdvisorAutoProxyCreator extends AbstractAutoProxyC
|
||||||
* @see ProxyCreationContext#getCurrentProxiedBeanName()
|
* @see ProxyCreationContext#getCurrentProxiedBeanName()
|
||||||
*/
|
*/
|
||||||
protected List<Advisor> findAdvisorsThatCanApply(
|
protected List<Advisor> findAdvisorsThatCanApply(
|
||||||
List<Advisor> candidateAdvisors, Class beanClass, String beanName) {
|
List<Advisor> candidateAdvisors, Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
ProxyCreationContext.setCurrentProxiedBeanName(beanName);
|
ProxyCreationContext.setCurrentProxiedBeanName(beanName);
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||||
* Identify as bean to proxy if the bean name is in the configured list of names.
|
* Identify as bean to proxy if the bean name is in the configured list of names.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource targetSource) {
|
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource targetSource) {
|
||||||
if (this.beanNames != null) {
|
if (this.beanNames != null) {
|
||||||
for (String mappedName : this.beanNames) {
|
for (String mappedName : this.beanNames) {
|
||||||
if (FactoryBean.class.isAssignableFrom(beanClass)) {
|
if (FactoryBean.class.isAssignableFrom(beanClass)) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
Class beanClass, String beanName) {
|
Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
||||||
BeanDefinition definition =
|
BeanDefinition definition =
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class QuickTargetSourceCreator extends AbstractBeanFactoryBasedTargetSour
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
protected final AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
Class beanClass, String beanName) {
|
Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
if (beanName.startsWith(PREFIX_COMMONS_POOL)) {
|
if (beanName.startsWith(PREFIX_COMMONS_POOL)) {
|
||||||
CommonsPoolTargetSource cpts = new CommonsPoolTargetSource();
|
CommonsPoolTargetSource cpts = new CommonsPoolTargetSource();
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public abstract class AbstractMonitoringInterceptor extends AbstractTraceInterce
|
||||||
protected String createInvocationTraceName(MethodInvocation invocation) {
|
protected String createInvocationTraceName(MethodInvocation invocation) {
|
||||||
StringBuilder sb = new StringBuilder(getPrefix());
|
StringBuilder sb = new StringBuilder(getPrefix());
|
||||||
Method method = invocation.getMethod();
|
Method method = invocation.getMethod();
|
||||||
Class clazz = method.getDeclaringClass();
|
Class<?> clazz = method.getDeclaringClass();
|
||||||
if (this.logTargetClassInvocation && clazz.isInstance(invocation.getThis())) {
|
if (this.logTargetClassInvocation && clazz.isInstance(invocation.getThis())) {
|
||||||
clazz = invocation.getThis().getClass();
|
clazz = invocation.getThis().getClass();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||||
* @return the target class for the given object
|
* @return the target class for the given object
|
||||||
* @see #setHideProxyClassNames
|
* @see #setHideProxyClassNames
|
||||||
*/
|
*/
|
||||||
protected Class getClassForLogging(Object target) {
|
protected Class<?> getClassForLogging(Object target) {
|
||||||
return (this.hideProxyClassNames ? AopUtils.getTargetClass(target) : target.getClass());
|
return (this.hideProxyClassNames ? AopUtils.getTargetClass(target) : target.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||||
/**
|
/**
|
||||||
* The {@code Set} of allowed placeholders.
|
* The {@code Set} of allowed placeholders.
|
||||||
*/
|
*/
|
||||||
private static final Set ALLOWED_PLACEHOLDERS =
|
private static final Set<Object> ALLOWED_PLACEHOLDERS =
|
||||||
new Constants(CustomizableTraceInterceptor.class).getValues("PLACEHOLDER_");
|
new Constants(CustomizableTraceInterceptor.class).getValues("PLACEHOLDER_");
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -395,7 +395,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||||
* @param output the {@code StringBuffer} containing the output
|
* @param output the {@code StringBuffer} containing the output
|
||||||
*/
|
*/
|
||||||
private void appendArgumentTypes(MethodInvocation methodInvocation, Matcher matcher, StringBuffer output) {
|
private void appendArgumentTypes(MethodInvocation methodInvocation, Matcher matcher, StringBuffer output) {
|
||||||
Class[] argumentTypes = methodInvocation.getMethod().getParameterTypes();
|
Class<?>[] argumentTypes = methodInvocation.getMethod().getParameterTypes();
|
||||||
String[] argumentTypeShortNames = new String[argumentTypes.length];
|
String[] argumentTypeShortNames = new String[argumentTypes.length];
|
||||||
for (int i = 0; i < argumentTypeShortNames.length; i++) {
|
for (int i = 0; i < argumentTypeShortNames.length; i++) {
|
||||||
argumentTypeShortNames[i] = ClassUtils.getShortName(argumentTypes[i]);
|
argumentTypeShortNames[i] = ClassUtils.getShortName(argumentTypes[i]);
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<O
|
||||||
pf.copyFrom(this);
|
pf.copyFrom(this);
|
||||||
pf.setTargetSource(this.scopedTargetSource);
|
pf.setTargetSource(this.scopedTargetSource);
|
||||||
|
|
||||||
Class beanType = beanFactory.getType(this.targetBeanName);
|
Class<?> beanType = beanFactory.getType(this.targetBeanName);
|
||||||
if (beanType == null) {
|
if (beanType == null) {
|
||||||
throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
|
throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
|
||||||
"': Target type could not be determined at the time of proxy creation.");
|
"': Target type could not be determined at the time of proxy creation.");
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
|
||||||
* plus the name of the method.
|
* plus the name of the method.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
|
return ((targetClass != null && matchesPattern(targetClass.getName() + "." + method.getName())) ||
|
||||||
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
|
matchesPattern(method.getDeclaringClass().getName() + "." + method.getName()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ public abstract class AopUtils {
|
||||||
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
|
introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Class> classes = new HashSet<Class>(ClassUtils.getAllInterfacesForClassAsSet(targetClass));
|
Set<Class<?>> classes = new HashSet<Class<?>>(ClassUtils.getAllInterfacesForClassAsSet(targetClass));
|
||||||
classes.add(targetClass);
|
classes.add(targetClass);
|
||||||
for (Class<?> clazz : classes) {
|
for (Class<?> clazz : classes) {
|
||||||
Method[] methods = clazz.getMethods();
|
Method[] methods = clazz.getMethods();
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public abstract class ClassFilters {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
for (int i = 0; i < this.filters.length; i++) {
|
for (int i = 0; i < this.filters.length; i++) {
|
||||||
if (this.filters[i].matches(clazz)) {
|
if (this.filters[i].matches(clazz)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -132,7 +132,7 @@ public abstract class ClassFilters {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
for (int i = 0; i < this.filters.length; i++) {
|
for (int i = 0; i < this.filters.length; i++) {
|
||||||
if (!this.filters[i].matches(clazz)) {
|
if (!this.filters[i].matches(clazz)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
|
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
|
||||||
|
|
||||||
private Class clazz;
|
private Class<?> clazz;
|
||||||
|
|
||||||
private String methodName;
|
private String methodName;
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
* Construct a new pointcut that matches all control flows below that class.
|
* Construct a new pointcut that matches all control flows below that class.
|
||||||
* @param clazz the clazz
|
* @param clazz the clazz
|
||||||
*/
|
*/
|
||||||
public ControlFlowPointcut(Class clazz) {
|
public ControlFlowPointcut(Class<?> clazz) {
|
||||||
this(clazz, null);
|
this(clazz, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
* @param clazz the clazz
|
* @param clazz the clazz
|
||||||
* @param methodName the name of the method
|
* @param methodName the name of the method
|
||||||
*/
|
*/
|
||||||
public ControlFlowPointcut(Class clazz, String methodName) {
|
public ControlFlowPointcut(Class<?> clazz, String methodName) {
|
||||||
Assert.notNull(clazz, "Class must not be null");
|
Assert.notNull(clazz, "Class must not be null");
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.methodName = methodName;
|
this.methodName = methodName;
|
||||||
|
|
@ -72,7 +72,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
* Subclasses can override this for greater filtering (and performance).
|
* Subclasses can override this for greater filtering (and performance).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
* some candidate classes.
|
* some candidate classes.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
++this.evaluations;
|
++this.evaluations;
|
||||||
ControlFlow cflow = ControlFlowFactory.createControlFlow();
|
ControlFlow cflow = ControlFlowFactory.createControlFlow();
|
||||||
return (this.methodName != null) ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz);
|
return (this.methodName != null) ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
|
|
||||||
private final Advice advice;
|
private final Advice advice;
|
||||||
|
|
||||||
private final Set<Class> interfaces = new HashSet<Class>();
|
private final Set<Class<?>> interfaces = new HashSet<Class<?>>();
|
||||||
|
|
||||||
private int order = Integer.MAX_VALUE;
|
private int order = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
|
@ -68,11 +68,11 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
Assert.notNull(advice, "Advice must not be null");
|
Assert.notNull(advice, "Advice must not be null");
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
if (introductionInfo != null) {
|
if (introductionInfo != null) {
|
||||||
Class[] introducedInterfaces = introductionInfo.getInterfaces();
|
Class<?>[] introducedInterfaces = introductionInfo.getInterfaces();
|
||||||
if (introducedInterfaces.length == 0) {
|
if (introducedInterfaces.length == 0) {
|
||||||
throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces");
|
throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces");
|
||||||
}
|
}
|
||||||
for (Class ifc : introducedInterfaces) {
|
for (Class<?> ifc : introducedInterfaces) {
|
||||||
addInterface(ifc);
|
addInterface(ifc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
* @param advice the Advice to apply
|
* @param advice the Advice to apply
|
||||||
* @param intf the interface to introduce
|
* @param intf the interface to introduce
|
||||||
*/
|
*/
|
||||||
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class intf) {
|
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
|
||||||
Assert.notNull(advice, "Advice must not be null");
|
Assert.notNull(advice, "Advice must not be null");
|
||||||
this.advice = advice;
|
this.advice = advice;
|
||||||
addInterface(intf);
|
addInterface(intf);
|
||||||
|
|
@ -94,7 +94,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
* Add the specified interface to the list of interfaces to introduce.
|
* Add the specified interface to the list of interfaces to introduce.
|
||||||
* @param intf the interface to introduce
|
* @param intf the interface to introduce
|
||||||
*/
|
*/
|
||||||
public void addInterface(Class intf) {
|
public void addInterface(Class<?> intf) {
|
||||||
Assert.notNull(intf, "Interface must not be null");
|
Assert.notNull(intf, "Interface must not be null");
|
||||||
if (!intf.isInterface()) {
|
if (!intf.isInterface()) {
|
||||||
throw new IllegalArgumentException("Specified class [" + intf.getName() + "] must be an interface");
|
throw new IllegalArgumentException("Specified class [" + intf.getName() + "] must be an interface");
|
||||||
|
|
@ -103,13 +103,13 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class<?>[] getInterfaces() {
|
||||||
return this.interfaces.toArray(new Class[this.interfaces.size()]);
|
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateInterfaces() throws IllegalArgumentException {
|
public void validateInterfaces() throws IllegalArgumentException {
|
||||||
for (Class ifc : this.interfaces) {
|
for (Class<?> ifc : this.interfaces) {
|
||||||
if (this.advice instanceof DynamicIntroductionAdvice &&
|
if (this.advice instanceof DynamicIntroductionAdvice &&
|
||||||
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
|
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
|
||||||
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
|
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
|
||||||
|
|
@ -145,7 +145,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,12 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
|
||||||
*/
|
*/
|
||||||
private final Map<Object, Object> delegateMap = new WeakHashMap<Object, Object>();
|
private final Map<Object, Object> delegateMap = new WeakHashMap<Object, Object>();
|
||||||
|
|
||||||
private Class defaultImplType;
|
private Class<?> defaultImplType;
|
||||||
|
|
||||||
private Class interfaceType;
|
private Class<?> interfaceType;
|
||||||
|
|
||||||
|
|
||||||
public DelegatePerTargetObjectIntroductionInterceptor(Class defaultImplType, Class interfaceType) {
|
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
|
||||||
this.defaultImplType = defaultImplType;
|
this.defaultImplType = defaultImplType;
|
||||||
this.interfaceType = interfaceType;
|
this.interfaceType = interfaceType;
|
||||||
// cCeate a new delegate now (but don't store it in the map).
|
// cCeate a new delegate now (but don't store it in the map).
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import org.springframework.util.ClassUtils;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||||
|
|
||||||
protected final Set<Class> publishedInterfaces = new HashSet<Class>();
|
protected final Set<Class<?>> publishedInterfaces = new HashSet<Class<?>>();
|
||||||
|
|
||||||
private transient Map<Method, Boolean> rememberedMethods = new ConcurrentHashMap<Method, Boolean>(32);
|
private transient Map<Method, Boolean> rememberedMethods = new ConcurrentHashMap<Method, Boolean>(32);
|
||||||
|
|
||||||
|
|
@ -55,13 +55,13 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||||
* <p>Does nothing if the interface is not implemented by the delegate.
|
* <p>Does nothing if the interface is not implemented by the delegate.
|
||||||
* @param intf the interface to suppress
|
* @param intf the interface to suppress
|
||||||
*/
|
*/
|
||||||
public void suppressInterface(Class intf) {
|
public void suppressInterface(Class<?> intf) {
|
||||||
this.publishedInterfaces.remove(intf);
|
this.publishedInterfaces.remove(intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class[] getInterfaces() {
|
public Class<?>[] getInterfaces() {
|
||||||
return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]);
|
return this.publishedInterfaces.toArray(new Class<?>[this.publishedInterfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,8 +69,8 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||||
* @param ifc the interface to check
|
* @param ifc the interface to check
|
||||||
* @return whether the interface is part of this introduction
|
* @return whether the interface is part of this introduction
|
||||||
*/
|
*/
|
||||||
public boolean implementsInterface(Class ifc) {
|
public boolean implementsInterface(Class<?> ifc) {
|
||||||
for (Class pubIfc : this.publishedInterfaces) {
|
for (Class<?> pubIfc : this.publishedInterfaces) {
|
||||||
if (ifc.isInterface() && ifc.isAssignableFrom(pubIfc)) {
|
if (ifc.isInterface() && ifc.isAssignableFrom(pubIfc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public abstract class MethodMatchers {
|
||||||
* asking is the subject on one or more introductions; {@code false} otherwise
|
* asking is the subject on one or more introductions; {@code false} otherwise
|
||||||
* @return whether or not this method matches statically
|
* @return whether or not this method matches statically
|
||||||
*/
|
*/
|
||||||
public static boolean matches(MethodMatcher mm, Method method, Class targetClass, boolean hasIntroductions) {
|
public static boolean matches(MethodMatcher mm, Method method, Class<?> targetClass, boolean hasIntroductions) {
|
||||||
Assert.notNull(mm, "MethodMatcher must not be null");
|
Assert.notNull(mm, "MethodMatcher must not be null");
|
||||||
return ((mm instanceof IntroductionAwareMethodMatcher &&
|
return ((mm instanceof IntroductionAwareMethodMatcher &&
|
||||||
((IntroductionAwareMethodMatcher) mm).matches(method, targetClass, hasIntroductions)) ||
|
((IntroductionAwareMethodMatcher) mm).matches(method, targetClass, hasIntroductions)) ||
|
||||||
|
|
@ -114,22 +114,22 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) {
|
||||||
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
|
return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) ||
|
||||||
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
|
(matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
|
return (matchesClass1(targetClass) && this.mm1.matches(method, targetClass)) ||
|
||||||
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
|
(matchesClass2(targetClass) && this.mm2.matches(method, targetClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean matchesClass1(Class targetClass) {
|
protected boolean matchesClass1(Class<?> targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean matchesClass2(Class targetClass) {
|
protected boolean matchesClass2(Class<?> targetClass) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
|
return this.mm1.matches(method, targetClass, args) || this.mm2.matches(method, targetClass, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,12 +183,12 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesClass1(Class targetClass) {
|
protected boolean matchesClass1(Class<?> targetClass) {
|
||||||
return this.cf1.matches(targetClass);
|
return this.cf1.matches(targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean matchesClass2(Class targetClass) {
|
protected boolean matchesClass2(Class<?> targetClass) {
|
||||||
return this.cf2.matches(targetClass);
|
return this.cf2.matches(targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,13 +230,13 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, boolean hasIntroductions) {
|
public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) {
|
||||||
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
return MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions) &&
|
||||||
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
|
MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
|
return this.mm1.matches(method, targetClass) && this.mm2.matches(method, targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ public abstract class MethodMatchers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass, Object[] args) {
|
public boolean matches(Method method, Class<?> targetClass, Object[] args) {
|
||||||
// Because a dynamic intersection may be composed of a static and dynamic part,
|
// 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
|
// we must avoid calling the 3-arg matches method on a dynamic matcher, as
|
||||||
// it will probably be an unsupported operation.
|
// it will probably be an unsupported operation.
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
for (String mappedName : this.mappedNames) {
|
for (String mappedName : this.mappedNames) {
|
||||||
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
|
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public abstract class Pointcuts {
|
||||||
* @param args arguments to the method
|
* @param args arguments to the method
|
||||||
* @return whether there's a runtime match
|
* @return whether there's a runtime match
|
||||||
*/
|
*/
|
||||||
public static boolean matches(Pointcut pointcut, Method method, Class targetClass, Object[] args) {
|
public static boolean matches(Pointcut pointcut, Method method, Class<?> targetClass, Object[] args) {
|
||||||
Assert.notNull(pointcut, "Pointcut must not be null");
|
Assert.notNull(pointcut, "Pointcut must not be null");
|
||||||
if (pointcut == Pointcut.TRUE) {
|
if (pointcut == Pointcut.TRUE) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -97,7 +97,7 @@ public abstract class Pointcuts {
|
||||||
public static SetterPointcut INSTANCE = new SetterPointcut();
|
public static SetterPointcut INSTANCE = new SetterPointcut();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return method.getName().startsWith("set") &&
|
return method.getName().startsWith("set") &&
|
||||||
method.getParameterTypes().length == 1 &&
|
method.getParameterTypes().length == 1 &&
|
||||||
method.getReturnType() == Void.TYPE;
|
method.getReturnType() == Void.TYPE;
|
||||||
|
|
@ -118,7 +118,7 @@ public abstract class Pointcuts {
|
||||||
public static GetterPointcut INSTANCE = new GetterPointcut();
|
public static GetterPointcut INSTANCE = new GetterPointcut();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
return method.getName().startsWith("get") &&
|
return method.getName().startsWith("get") &&
|
||||||
method.getParameterTypes().length == 0;
|
method.getParameterTypes().length == 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,16 +27,16 @@ import org.springframework.aop.ClassFilter;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class RootClassFilter implements ClassFilter, Serializable {
|
public class RootClassFilter implements ClassFilter, Serializable {
|
||||||
|
|
||||||
private Class clazz;
|
private Class<?> clazz;
|
||||||
|
|
||||||
// TODO inheritance
|
|
||||||
|
|
||||||
public RootClassFilter(Class clazz) {
|
public RootClassFilter(Class<?> clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class candidate) {
|
public boolean matches(Class<?> candidate) {
|
||||||
return clazz.isAssignableFrom(candidate);
|
return clazz.isAssignableFrom(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class AnnotationClassFilter implements ClassFilter {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Class clazz) {
|
public boolean matches(Class<?> clazz) {
|
||||||
return (this.checkInherited ?
|
return (this.checkInherited ?
|
||||||
(AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) :
|
(AnnotationUtils.findAnnotation(clazz, this.annotationType) != null) :
|
||||||
clazz.isAnnotationPresent(this.annotationType));
|
clazz.isAnnotationPresent(this.annotationType));
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Method method, Class targetClass) {
|
public boolean matches(Method method, Class<?> targetClass) {
|
||||||
if (method.isAnnotationPresent(this.annotationType)) {
|
if (method.isAnnotationPresent(this.annotationType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
||||||
* <p>Default is to detect the type automatically, through a {@code getType}
|
* <p>Default is to detect the type automatically, through a {@code getType}
|
||||||
* call on the BeanFactory (or even a full {@code getBean} call as fallback).
|
* call on the BeanFactory (or even a full {@code getBean} call as fallback).
|
||||||
*/
|
*/
|
||||||
public void setTargetClass(Class targetClass) {
|
public void setTargetClass(Class<?> targetClass) {
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ import org.springframework.beans.factory.DisposableBean;
|
||||||
public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBasedTargetSource
|
public abstract class AbstractPoolingTargetSource extends AbstractPrototypeBasedTargetSource
|
||||||
implements PoolingConfig, DisposableBean {
|
implements PoolingConfig, DisposableBean {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
/** The maximum size of the pool */
|
/** The maximum size of the pool */
|
||||||
private int maxSize = -1;
|
private int maxSize = -1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFactoryBasedTargetSource {
|
public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFactoryBasedTargetSource {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||||
super.setBeanFactory(beanFactory);
|
super.setBeanFactory(beanFactory);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
|
||||||
* @param targetClass the target Class (may be {@code null})
|
* @param targetClass the target Class (may be {@code null})
|
||||||
* @see #getTargetClass()
|
* @see #getTargetClass()
|
||||||
*/
|
*/
|
||||||
public static EmptyTargetSource forClass(Class targetClass) {
|
public static EmptyTargetSource forClass(Class<?> targetClass) {
|
||||||
return forClass(targetClass, true);
|
return forClass(targetClass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
|
||||||
* @param isStatic whether the TargetSource should be marked as static
|
* @param isStatic whether the TargetSource should be marked as static
|
||||||
* @see #getTargetClass()
|
* @see #getTargetClass()
|
||||||
*/
|
*/
|
||||||
public static EmptyTargetSource forClass(Class targetClass, boolean isStatic) {
|
public static EmptyTargetSource forClass(Class<?> targetClass, boolean isStatic) {
|
||||||
return (targetClass == null && isStatic ? INSTANCE : new EmptyTargetSource(targetClass, isStatic));
|
return (targetClass == null && isStatic ? INSTANCE : new EmptyTargetSource(targetClass, isStatic));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
|
||||||
// Instance implementation
|
// Instance implementation
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
private final Class targetClass;
|
private final Class<?> targetClass;
|
||||||
|
|
||||||
private final boolean isStatic;
|
private final boolean isStatic;
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class EmptyTargetSource implements TargetSource, Serializable {
|
||||||
* @param targetClass the target class to expose (may be {@code null})
|
* @param targetClass the target class to expose (may be {@code null})
|
||||||
* @param isStatic whether the TargetSource is marked as static
|
* @param isStatic whether the TargetSource is marked as static
|
||||||
*/
|
*/
|
||||||
private EmptyTargetSource(Class targetClass, boolean isStatic) {
|
private EmptyTargetSource(Class<?> targetClass, boolean isStatic) {
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
this.isStatic = isStatic;
|
this.isStatic = isStatic;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,11 @@ public class NopInterceptor implements MethodInterceptor {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (!(other instanceof NopInterceptor)) {
|
if (!(other instanceof NopInterceptor)) {
|
||||||
|
|
@ -57,4 +62,5 @@ public class NopInterceptor implements MethodInterceptor {
|
||||||
return this.count == ((NopInterceptor) other).count;
|
return this.count == ((NopInterceptor) other).count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,11 @@ import org.springframework.util.ObjectUtils;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SerializablePerson implements Person, Serializable {
|
public class SerializablePerson implements Person, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private int age;
|
private int age;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -59,6 +63,11 @@ public class SerializablePerson implements Person, Serializable {
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (!(other instanceof SerializablePerson)) {
|
if (!(other instanceof SerializablePerson)) {
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl
|
||||||
|
|
||||||
// Redefined with public visibility.
|
// Redefined with public visibility.
|
||||||
@Override
|
@Override
|
||||||
public Class getPropertyType(String propertyPath) {
|
public Class<?> getPropertyType(String propertyPath) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ package org.springframework.beans;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class BeanInstantiationException extends FatalBeanException {
|
public class BeanInstantiationException extends FatalBeanException {
|
||||||
|
|
||||||
private Class beanClass;
|
private Class<?> beanClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,7 +34,7 @@ public class BeanInstantiationException extends FatalBeanException {
|
||||||
* @param beanClass the offending bean class
|
* @param beanClass the offending bean class
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public BeanInstantiationException(Class beanClass, String msg) {
|
public BeanInstantiationException(Class<?> beanClass, String msg) {
|
||||||
this(beanClass, msg, null);
|
this(beanClass, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class BeanInstantiationException extends FatalBeanException {
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
* @param cause the root cause
|
* @param cause the root cause
|
||||||
*/
|
*/
|
||||||
public BeanInstantiationException(Class beanClass, String msg, Throwable cause) {
|
public BeanInstantiationException(Class<?> beanClass, String msg, Throwable cause) {
|
||||||
super("Could not instantiate bean class [" + beanClass.getName() + "]: " + msg, cause);
|
super("Could not instantiate bean class [" + beanClass.getName() + "]: " + msg, cause);
|
||||||
this.beanClass = beanClass;
|
this.beanClass = beanClass;
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ public class BeanInstantiationException extends FatalBeanException {
|
||||||
/**
|
/**
|
||||||
* Return the offending bean class.
|
* Return the offending bean class.
|
||||||
*/
|
*/
|
||||||
public Class getBeanClass() {
|
public Class<?> getBeanClass() {
|
||||||
return beanClass;
|
return beanClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ public abstract class BeanUtils {
|
||||||
String methodName = signature.substring(0, firstParen);
|
String methodName = signature.substring(0, firstParen);
|
||||||
String[] parameterTypeNames =
|
String[] parameterTypeNames =
|
||||||
StringUtils.commaDelimitedListToStringArray(signature.substring(firstParen + 1, lastParen));
|
StringUtils.commaDelimitedListToStringArray(signature.substring(firstParen + 1, lastParen));
|
||||||
Class<?>[] parameterTypes = new Class[parameterTypeNames.length];
|
Class<?>[] parameterTypes = new Class<?>[parameterTypeNames.length];
|
||||||
for (int i = 0; i < parameterTypeNames.length; i++) {
|
for (int i = 0; i < parameterTypeNames.length; i++) {
|
||||||
String parameterTypeName = parameterTypeNames[i].trim();
|
String parameterTypeName = parameterTypeNames[i].trim();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
|
||||||
* @return the type of the wrapped bean instance,
|
* @return the type of the wrapped bean instance,
|
||||||
* or {@code null} if no wrapped object has been set
|
* or {@code null} if no wrapped object has been set
|
||||||
*/
|
*/
|
||||||
Class getWrappedClass();
|
Class<?> getWrappedClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the PropertyDescriptors for the wrapped object
|
* Obtain the PropertyDescriptors for the wrapped object
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.CollectionFactory;
|
import org.springframework.core.CollectionFactory;
|
||||||
import org.springframework.core.GenericCollectionTypeResolver;
|
import org.springframework.core.GenericCollectionTypeResolver;
|
||||||
import org.springframework.core.convert.ConversionException;
|
import org.springframework.core.convert.ConversionException;
|
||||||
|
|
@ -225,7 +224,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Class getWrappedClass() {
|
public final Class<?> getWrappedClass() {
|
||||||
return (this.object != null ? this.object.getClass() : null);
|
return (this.object != null ? this.object.getClass() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +247,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
* Return the class of the root object at the top of the path of this BeanWrapper.
|
* Return the class of the root object at the top of the path of this BeanWrapper.
|
||||||
* @see #getNestedPath
|
* @see #getNestedPath
|
||||||
*/
|
*/
|
||||||
public final Class getRootClass() {
|
public final Class<?> getRootClass() {
|
||||||
return (this.rootObject != null ? this.rootObject.getClass() : null);
|
return (this.rootObject != null ? this.rootObject.getClass() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,7 +309,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
* Needs to be called when the target object changes.
|
* Needs to be called when the target object changes.
|
||||||
* @param clazz the class to introspect
|
* @param clazz the class to introspect
|
||||||
*/
|
*/
|
||||||
protected void setIntrospectionClass(Class clazz) {
|
protected void setIntrospectionClass(Class<?> clazz) {
|
||||||
if (this.cachedIntrospectionResults != null &&
|
if (this.cachedIntrospectionResults != null &&
|
||||||
!clazz.equals(this.cachedIntrospectionResults.getBeanClass())) {
|
!clazz.equals(this.cachedIntrospectionResults.getBeanClass())) {
|
||||||
this.cachedIntrospectionResults = null;
|
this.cachedIntrospectionResults = null;
|
||||||
|
|
@ -360,7 +359,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getPropertyType(String propertyName) throws BeansException {
|
public Class<?> getPropertyType(String propertyName) throws BeansException {
|
||||||
try {
|
try {
|
||||||
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
|
PropertyDescriptor pd = getPropertyDescriptorInternal(propertyName);
|
||||||
if (pd != null) {
|
if (pd != null) {
|
||||||
|
|
@ -374,7 +373,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
// Check to see if there is a custom editor,
|
// Check to see if there is a custom editor,
|
||||||
// which might give an indication on the desired target type.
|
// which might give an indication on the desired target type.
|
||||||
Class editorType = guessPropertyTypeFromEditors(propertyName);
|
Class<?> editorType = guessPropertyTypeFromEditors(propertyName);
|
||||||
if (editorType != null) {
|
if (editorType != null) {
|
||||||
return editorType;
|
return editorType;
|
||||||
}
|
}
|
||||||
|
|
@ -710,7 +709,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
return nestedBw.getPropertyValue(tokens);
|
return nestedBw.getPropertyValue(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getPropertyValue(PropertyTokenHolder tokens) throws BeansException {
|
@SuppressWarnings("unchecked")
|
||||||
|
private Object getPropertyValue(PropertyTokenHolder tokens) throws BeansException {
|
||||||
String propertyName = tokens.canonicalName;
|
String propertyName = tokens.canonicalName;
|
||||||
String actualName = tokens.actualName;
|
String actualName = tokens.actualName;
|
||||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
||||||
|
|
@ -779,20 +779,20 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
else if (value instanceof List) {
|
else if (value instanceof List) {
|
||||||
int index = Integer.parseInt(key);
|
int index = Integer.parseInt(key);
|
||||||
List list = (List) value;
|
List<Object> list = (List<Object>) value;
|
||||||
growCollectionIfNecessary(list, index, indexedPropertyName, pd, i + 1);
|
growCollectionIfNecessary(list, index, indexedPropertyName, pd, i + 1);
|
||||||
value = list.get(index);
|
value = list.get(index);
|
||||||
}
|
}
|
||||||
else if (value instanceof Set) {
|
else if (value instanceof Set) {
|
||||||
// Apply index to Iterator in case of a Set.
|
// Apply index to Iterator in case of a Set.
|
||||||
Set set = (Set) value;
|
Set<Object> set = (Set<Object>) value;
|
||||||
int index = Integer.parseInt(key);
|
int index = Integer.parseInt(key);
|
||||||
if (index < 0 || index >= set.size()) {
|
if (index < 0 || index >= set.size()) {
|
||||||
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
|
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
|
||||||
"Cannot get element with index " + index + " from Set of size " +
|
"Cannot get element with index " + index + " from Set of size " +
|
||||||
set.size() + ", accessed using property path '" + propertyName + "'");
|
set.size() + ", accessed using property path '" + propertyName + "'");
|
||||||
}
|
}
|
||||||
Iterator it = set.iterator();
|
Iterator<Object> it = set.iterator();
|
||||||
for (int j = 0; it.hasNext(); j++) {
|
for (int j = 0; it.hasNext(); j++) {
|
||||||
Object elem = it.next();
|
Object elem = it.next();
|
||||||
if (j == index) {
|
if (j == index) {
|
||||||
|
|
@ -802,7 +802,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value instanceof Map) {
|
else if (value instanceof Map) {
|
||||||
Map map = (Map) value;
|
Map<Object, Object> map = (Map<Object, Object>) value;
|
||||||
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(pd.getReadMethod(), i + 1);
|
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(pd.getReadMethod(), i + 1);
|
||||||
// IMPORTANT: Do not pass full property name in here - property editors
|
// IMPORTANT: Do not pass full property name in here - property editors
|
||||||
// must not kick in for map keys but rather only for map values.
|
// must not kick in for map keys but rather only for map values.
|
||||||
|
|
@ -863,16 +863,14 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private void growCollectionIfNecessary(Collection<Object> collection, int index,
|
||||||
private void growCollectionIfNecessary(
|
String name, PropertyDescriptor pd, int nestingLevel) {
|
||||||
Collection collection, int index, String name, PropertyDescriptor pd, int nestingLevel) {
|
|
||||||
|
|
||||||
if (!this.autoGrowNestedPaths) {
|
if (!this.autoGrowNestedPaths) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int size = collection.size();
|
int size = collection.size();
|
||||||
if (index >= size && index < this.autoGrowCollectionLimit) {
|
if (index >= size && index < this.autoGrowCollectionLimit) {
|
||||||
Class elementType = GenericCollectionTypeResolver.getCollectionReturnType(pd.getReadMethod(), nestingLevel);
|
Class<?> elementType = GenericCollectionTypeResolver.getCollectionReturnType(pd.getReadMethod(), nestingLevel);
|
||||||
if (elementType != null) {
|
if (elementType != null) {
|
||||||
for (int i = collection.size(); i < index + 1; i++) {
|
for (int i = collection.size(); i < index + 1; i++) {
|
||||||
collection.add(newValue(elementType, name));
|
collection.add(newValue(elementType, name));
|
||||||
|
|
@ -958,7 +956,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
if (propValue.getClass().isArray()) {
|
if (propValue.getClass().isArray()) {
|
||||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
||||||
Class requiredType = propValue.getClass().getComponentType();
|
Class<?> requiredType = propValue.getClass().getComponentType();
|
||||||
int arrayIndex = Integer.parseInt(key);
|
int arrayIndex = Integer.parseInt(key);
|
||||||
Object oldValue = null;
|
Object oldValue = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -976,9 +974,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
else if (propValue instanceof List) {
|
else if (propValue instanceof List) {
|
||||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
||||||
Class requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
|
Class<?> requiredType = GenericCollectionTypeResolver.getCollectionReturnType(
|
||||||
pd.getReadMethod(), tokens.keys.length);
|
pd.getReadMethod(), tokens.keys.length);
|
||||||
List list = (List) propValue;
|
List<Object> list = (List<Object>) propValue;
|
||||||
int index = Integer.parseInt(key);
|
int index = Integer.parseInt(key);
|
||||||
Object oldValue = null;
|
Object oldValue = null;
|
||||||
if (isExtractOldValueForEditor() && index < list.size()) {
|
if (isExtractOldValueForEditor() && index < list.size()) {
|
||||||
|
|
@ -1013,11 +1011,11 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||||
}
|
}
|
||||||
else if (propValue instanceof Map) {
|
else if (propValue instanceof Map) {
|
||||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
||||||
Class mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(
|
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(
|
||||||
pd.getReadMethod(), tokens.keys.length);
|
pd.getReadMethod(), tokens.keys.length);
|
||||||
Class mapValueType = GenericCollectionTypeResolver.getMapValueReturnType(
|
Class<?> mapValueType = GenericCollectionTypeResolver.getMapValueReturnType(
|
||||||
pd.getReadMethod(), tokens.keys.length);
|
pd.getReadMethod(), tokens.keys.length);
|
||||||
Map map = (Map) propValue;
|
Map<Object, Object> map = (Map<Object, Object>) propValue;
|
||||||
// IMPORTANT: Do not pass full property name in here - property editors
|
// IMPORTANT: Do not pass full property name in here - property editors
|
||||||
// must not kick in for map keys but rather only for map values.
|
// must not kick in for map keys but rather only for map values.
|
||||||
TypeDescriptor typeDescriptor = (mapKeyType != null ?
|
TypeDescriptor typeDescriptor = (mapKeyType != null ?
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
@ -76,7 +75,7 @@ public class CachedIntrospectionResults {
|
||||||
* Needs to be a WeakHashMap with WeakReferences as values to allow
|
* Needs to be a WeakHashMap with WeakReferences as values to allow
|
||||||
* for proper garbage collection in case of multiple class loaders.
|
* for proper garbage collection in case of multiple class loaders.
|
||||||
*/
|
*/
|
||||||
static final Map<Class, Object> classCache = new WeakHashMap<Class, Object>();
|
static final Map<Class<?>, Object> classCache = new WeakHashMap<Class<?>, Object>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -107,7 +106,7 @@ public class CachedIntrospectionResults {
|
||||||
*/
|
*/
|
||||||
public static void clearClassLoader(ClassLoader classLoader) {
|
public static void clearClassLoader(ClassLoader classLoader) {
|
||||||
synchronized (classCache) {
|
synchronized (classCache) {
|
||||||
for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) {
|
for (Iterator<Class<?>> it = classCache.keySet().iterator(); it.hasNext();) {
|
||||||
Class<?> beanClass = it.next();
|
Class<?> beanClass = it.next();
|
||||||
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
|
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
|
@ -130,6 +129,7 @@ public class CachedIntrospectionResults {
|
||||||
* @return the corresponding CachedIntrospectionResults
|
* @return the corresponding CachedIntrospectionResults
|
||||||
* @throws BeansException in case of introspection failure
|
* @throws BeansException in case of introspection failure
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
|
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
|
||||||
CachedIntrospectionResults results;
|
CachedIntrospectionResults results;
|
||||||
Object value;
|
Object value;
|
||||||
|
|
@ -137,8 +137,8 @@ public class CachedIntrospectionResults {
|
||||||
value = classCache.get(beanClass);
|
value = classCache.get(beanClass);
|
||||||
}
|
}
|
||||||
if (value instanceof Reference) {
|
if (value instanceof Reference) {
|
||||||
Reference ref = (Reference) value;
|
Reference<CachedIntrospectionResults> ref = (Reference<CachedIntrospectionResults>) value;
|
||||||
results = (CachedIntrospectionResults) ref.get();
|
results = ref.get();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
results = (CachedIntrospectionResults) value;
|
results = (CachedIntrospectionResults) value;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ public class ConversionNotSupportedException extends TypeMismatchException {
|
||||||
* @param requiredType the required target type (or {@code null} if not known)
|
* @param requiredType the required target type (or {@code null} if not known)
|
||||||
* @param cause the root cause (may be {@code null})
|
* @param cause the root cause (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) {
|
public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent,
|
||||||
|
Class<?> requiredType, Throwable cause) {
|
||||||
super(propertyChangeEvent, requiredType, cause);
|
super(propertyChangeEvent, requiredType, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +45,7 @@ public class ConversionNotSupportedException extends TypeMismatchException {
|
||||||
* @param requiredType the required target type (or {@code null} if not known)
|
* @param requiredType the required target type (or {@code null} if not known)
|
||||||
* @param cause the root cause (may be {@code null})
|
* @param cause the root cause (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public ConversionNotSupportedException(Object value, Class requiredType, Throwable cause) {
|
public ConversionNotSupportedException(Object value, Class<?> requiredType, Throwable cause) {
|
||||||
super(value, requiredType, cause);
|
super(value, requiredType, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ package org.springframework.beans;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class InvalidPropertyException extends FatalBeanException {
|
public class InvalidPropertyException extends FatalBeanException {
|
||||||
|
|
||||||
private Class beanClass;
|
private Class<?> beanClass;
|
||||||
|
|
||||||
private String propertyName;
|
private String propertyName;
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class InvalidPropertyException extends FatalBeanException {
|
||||||
* @param propertyName the offending property
|
* @param propertyName the offending property
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public InvalidPropertyException(Class beanClass, String propertyName, String msg) {
|
public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg) {
|
||||||
this(beanClass, propertyName, msg, null);
|
this(beanClass, propertyName, msg, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class InvalidPropertyException extends FatalBeanException {
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
* @param cause the root cause
|
* @param cause the root cause
|
||||||
*/
|
*/
|
||||||
public InvalidPropertyException(Class beanClass, String propertyName, String msg, Throwable cause) {
|
public InvalidPropertyException(Class<?> beanClass, String propertyName, String msg, Throwable cause) {
|
||||||
super("Invalid property '" + propertyName + "' of bean class [" + beanClass.getName() + "]: " + msg, cause);
|
super("Invalid property '" + propertyName + "' of bean class [" + beanClass.getName() + "]: " + msg, cause);
|
||||||
this.beanClass = beanClass;
|
this.beanClass = beanClass;
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
|
|
@ -57,7 +57,7 @@ public class InvalidPropertyException extends FatalBeanException {
|
||||||
/**
|
/**
|
||||||
* Return the offending bean class.
|
* Return the offending bean class.
|
||||||
*/
|
*/
|
||||||
public Class getBeanClass() {
|
public Class<?> getBeanClass() {
|
||||||
return beanClass;
|
return beanClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||||
// There is no replacement of existing property values.
|
// There is no replacement of existing property values.
|
||||||
if (original != null) {
|
if (original != null) {
|
||||||
this.propertyValueList = new ArrayList<PropertyValue>(original.size());
|
this.propertyValueList = new ArrayList<PropertyValue>(original.size());
|
||||||
for (Map.Entry entry : original.entrySet()) {
|
for (Map.Entry<?, ?> entry : original.entrySet()) {
|
||||||
this.propertyValueList.add(new PropertyValue(entry.getKey().toString(), entry.getValue()));
|
this.propertyValueList.add(new PropertyValue(entry.getKey().toString(), entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class NotReadablePropertyException extends InvalidPropertyException {
|
||||||
* @param beanClass the offending bean class
|
* @param beanClass the offending bean class
|
||||||
* @param propertyName the offending property
|
* @param propertyName the offending property
|
||||||
*/
|
*/
|
||||||
public NotReadablePropertyException(Class beanClass, String propertyName) {
|
public NotReadablePropertyException(Class<?> beanClass, String propertyName) {
|
||||||
super(beanClass, propertyName,
|
super(beanClass, propertyName,
|
||||||
"Bean property '" + propertyName + "' is not readable or has an invalid getter method: " +
|
"Bean property '" + propertyName + "' is not readable or has an invalid getter method: " +
|
||||||
"Does the return type of the getter match the parameter type of the setter?");
|
"Does the return type of the getter match the parameter type of the setter?");
|
||||||
|
|
@ -43,7 +43,7 @@ public class NotReadablePropertyException extends InvalidPropertyException {
|
||||||
* @param propertyName the offending property
|
* @param propertyName the offending property
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public NotReadablePropertyException(Class beanClass, String propertyName, String msg) {
|
public NotReadablePropertyException(Class<?> beanClass, String propertyName, String msg) {
|
||||||
super(beanClass, propertyName, msg);
|
super(beanClass, propertyName, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
|
||||||
* @param beanClass the offending bean class
|
* @param beanClass the offending bean class
|
||||||
* @param propertyName the offending property name
|
* @param propertyName the offending property name
|
||||||
*/
|
*/
|
||||||
public NotWritablePropertyException(Class beanClass, String propertyName) {
|
public NotWritablePropertyException(Class<?> beanClass, String propertyName) {
|
||||||
super(beanClass, propertyName,
|
super(beanClass, propertyName,
|
||||||
"Bean property '" + propertyName + "' is not writable or has an invalid setter method: " +
|
"Bean property '" + propertyName + "' is not writable or has an invalid setter method: " +
|
||||||
"Does the return type of the getter match the parameter type of the setter?");
|
"Does the return type of the getter match the parameter type of the setter?");
|
||||||
|
|
@ -47,7 +47,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
|
||||||
* @param propertyName the offending property name
|
* @param propertyName the offending property name
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public NotWritablePropertyException(Class beanClass, String propertyName, String msg) {
|
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg) {
|
||||||
super(beanClass, propertyName, msg);
|
super(beanClass, propertyName, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
* @param cause the root cause
|
* @param cause the root cause
|
||||||
*/
|
*/
|
||||||
public NotWritablePropertyException(Class beanClass, String propertyName, String msg, Throwable cause) {
|
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg, Throwable cause) {
|
||||||
super(beanClass, propertyName, msg, cause);
|
super(beanClass, propertyName, msg, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
|
||||||
* @param possibleMatches suggestions for actual bean property names
|
* @param possibleMatches suggestions for actual bean property names
|
||||||
* that closely match the invalid property name
|
* that closely match the invalid property name
|
||||||
*/
|
*/
|
||||||
public NotWritablePropertyException(Class beanClass, String propertyName, String msg, String[] possibleMatches) {
|
public NotWritablePropertyException(Class<?> beanClass, String propertyName, String msg, String[] possibleMatches) {
|
||||||
super(beanClass, propertyName, msg);
|
super(beanClass, propertyName, msg);
|
||||||
this.possibleMatches = possibleMatches;
|
this.possibleMatches = possibleMatches;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class NullValueInNestedPathException extends InvalidPropertyException {
|
||||||
* @param beanClass the offending bean class
|
* @param beanClass the offending bean class
|
||||||
* @param propertyName the offending property
|
* @param propertyName the offending property
|
||||||
*/
|
*/
|
||||||
public NullValueInNestedPathException(Class beanClass, String propertyName) {
|
public NullValueInNestedPathException(Class<?> beanClass, String propertyName) {
|
||||||
super(beanClass, propertyName, "Value of nested property '" + propertyName + "' is null");
|
super(beanClass, propertyName, "Value of nested property '" + propertyName + "' is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class NullValueInNestedPathException extends InvalidPropertyException {
|
||||||
* @param propertyName the offending property
|
* @param propertyName the offending property
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public NullValueInNestedPathException(Class beanClass, String propertyName, String msg) {
|
public NullValueInNestedPathException(Class<?> beanClass, String propertyName, String msg) {
|
||||||
super(beanClass, propertyName, msg);
|
super(beanClass, propertyName, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ public interface PropertyAccessor {
|
||||||
* @throws PropertyAccessException if the property was valid but the
|
* @throws PropertyAccessException if the property was valid but the
|
||||||
* accessor method failed
|
* accessor method failed
|
||||||
*/
|
*/
|
||||||
Class getPropertyType(String propertyName) throws BeansException;
|
Class<?> getPropertyType(String propertyName) throws BeansException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a type descriptor for the specified property:
|
* Return a type descriptor for the specified property:
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ public class PropertyBatchUpdateException extends BeansException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Class exType) {
|
public boolean contains(Class<?> exType) {
|
||||||
if (exType == null) {
|
if (exType == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ final class PropertyMatches {
|
||||||
* @param propertyName the name of the property to find possible matches for
|
* @param propertyName the name of the property to find possible matches for
|
||||||
* @param beanClass the bean class to search for matches
|
* @param beanClass the bean class to search for matches
|
||||||
*/
|
*/
|
||||||
public static PropertyMatches forProperty(String propertyName, Class beanClass) {
|
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass) {
|
||||||
return forProperty(propertyName, beanClass, DEFAULT_MAX_DISTANCE);
|
return forProperty(propertyName, beanClass, DEFAULT_MAX_DISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ final class PropertyMatches {
|
||||||
* @param beanClass the bean class to search for matches
|
* @param beanClass the bean class to search for matches
|
||||||
* @param maxDistance the maximum property distance allowed for matches
|
* @param maxDistance the maximum property distance allowed for matches
|
||||||
*/
|
*/
|
||||||
public static PropertyMatches forProperty(String propertyName, Class beanClass, int maxDistance) {
|
public static PropertyMatches forProperty(String propertyName, Class<?> beanClass, int maxDistance) {
|
||||||
return new PropertyMatches(propertyName, beanClass, maxDistance);
|
return new PropertyMatches(propertyName, beanClass, maxDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ final class PropertyMatches {
|
||||||
/**
|
/**
|
||||||
* Create a new PropertyMatches instance for the given property.
|
* Create a new PropertyMatches instance for the given property.
|
||||||
*/
|
*/
|
||||||
private PropertyMatches(String propertyName, Class beanClass, int maxDistance) {
|
private PropertyMatches(String propertyName, Class<?> beanClass, int maxDistance) {
|
||||||
this.propertyName = propertyName;
|
this.propertyName = propertyName;
|
||||||
this.possibleMatches = calculateMatches(BeanUtils.getPropertyDescriptors(beanClass), maxDistance);
|
this.possibleMatches = calculateMatches(BeanUtils.getPropertyDescriptors(beanClass), maxDistance);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,13 +200,13 @@ class TypeConverterDelegate {
|
||||||
else if (convertedValue instanceof Collection) {
|
else if (convertedValue instanceof Collection) {
|
||||||
// Convert elements to target type, if determined.
|
// Convert elements to target type, if determined.
|
||||||
convertedValue = convertToTypedCollection(
|
convertedValue = convertToTypedCollection(
|
||||||
(Collection) convertedValue, propertyName, requiredType, typeDescriptor);
|
(Collection<?>) convertedValue, propertyName, requiredType, typeDescriptor);
|
||||||
standardConversion = true;
|
standardConversion = true;
|
||||||
}
|
}
|
||||||
else if (convertedValue instanceof Map) {
|
else if (convertedValue instanceof Map) {
|
||||||
// Convert keys and values to respective target type, if determined.
|
// Convert keys and values to respective target type, if determined.
|
||||||
convertedValue = convertToTypedMap(
|
convertedValue = convertToTypedMap(
|
||||||
(Map) convertedValue, propertyName, requiredType, typeDescriptor);
|
(Map<?, ?>) convertedValue, propertyName, requiredType, typeDescriptor);
|
||||||
standardConversion = true;
|
standardConversion = true;
|
||||||
}
|
}
|
||||||
if (convertedValue.getClass().isArray() && Array.getLength(convertedValue) == 1) {
|
if (convertedValue.getClass().isArray() && Array.getLength(convertedValue) == 1) {
|
||||||
|
|
@ -220,8 +220,8 @@ class TypeConverterDelegate {
|
||||||
else if (convertedValue instanceof String && !requiredType.isInstance(convertedValue)) {
|
else if (convertedValue instanceof String && !requiredType.isInstance(convertedValue)) {
|
||||||
if (firstAttemptEx == null && !requiredType.isInterface() && !requiredType.isEnum()) {
|
if (firstAttemptEx == null && !requiredType.isInterface() && !requiredType.isEnum()) {
|
||||||
try {
|
try {
|
||||||
Constructor strCtor = requiredType.getConstructor(String.class);
|
Constructor<T> strCtor = requiredType.getConstructor(String.class);
|
||||||
return (T) BeanUtils.instantiateClass(strCtor, convertedValue);
|
return BeanUtils.instantiateClass(strCtor, convertedValue);
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException ex) {
|
catch (NoSuchMethodException ex) {
|
||||||
// proceed with field lookup
|
// proceed with field lookup
|
||||||
|
|
@ -331,7 +331,7 @@ class TypeConverterDelegate {
|
||||||
* @param requiredType the type to find an editor for
|
* @param requiredType the type to find an editor for
|
||||||
* @return the corresponding editor, or {@code null} if none
|
* @return the corresponding editor, or {@code null} if none
|
||||||
*/
|
*/
|
||||||
private PropertyEditor findDefaultEditor(Class requiredType) {
|
private PropertyEditor findDefaultEditor(Class<?> requiredType) {
|
||||||
PropertyEditor editor = null;
|
PropertyEditor editor = null;
|
||||||
if (requiredType != null) {
|
if (requiredType != null) {
|
||||||
// No custom editor -> check BeanWrapperImpl's default editors.
|
// No custom editor -> check BeanWrapperImpl's default editors.
|
||||||
|
|
@ -434,10 +434,10 @@ class TypeConverterDelegate {
|
||||||
private Object convertToTypedArray(Object input, String propertyName, Class<?> componentType) {
|
private Object convertToTypedArray(Object input, String propertyName, Class<?> componentType) {
|
||||||
if (input instanceof Collection) {
|
if (input instanceof Collection) {
|
||||||
// Convert Collection elements to array elements.
|
// Convert Collection elements to array elements.
|
||||||
Collection coll = (Collection) input;
|
Collection<?> coll = (Collection<?>) input;
|
||||||
Object result = Array.newInstance(componentType, coll.size());
|
Object result = Array.newInstance(componentType, coll.size());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Iterator it = coll.iterator(); it.hasNext(); i++) {
|
for (Iterator<?> it = coll.iterator(); it.hasNext(); i++) {
|
||||||
Object value = convertIfNecessary(
|
Object value = convertIfNecessary(
|
||||||
buildIndexedPropertyName(propertyName, i), null, it.next(), componentType);
|
buildIndexedPropertyName(propertyName, i), null, it.next(), componentType);
|
||||||
Array.set(result, i, value);
|
Array.set(result, i, value);
|
||||||
|
|
@ -470,8 +470,8 @@ class TypeConverterDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Collection convertToTypedCollection(
|
private Collection<?> convertToTypedCollection(
|
||||||
Collection original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) {
|
Collection<?> original, String propertyName, Class<?> requiredType, TypeDescriptor typeDescriptor) {
|
||||||
|
|
||||||
if (!Collection.class.isAssignableFrom(requiredType)) {
|
if (!Collection.class.isAssignableFrom(requiredType)) {
|
||||||
return original;
|
return original;
|
||||||
|
|
@ -494,7 +494,7 @@ class TypeConverterDelegate {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator it;
|
Iterator<?> it;
|
||||||
try {
|
try {
|
||||||
it = original.iterator();
|
it = original.iterator();
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
|
|
@ -513,13 +513,13 @@ class TypeConverterDelegate {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection convertedCopy;
|
Collection<Object> convertedCopy;
|
||||||
try {
|
try {
|
||||||
if (approximable) {
|
if (approximable) {
|
||||||
convertedCopy = CollectionFactory.createApproximateCollection(original, original.size());
|
convertedCopy = CollectionFactory.createApproximateCollection(original, original.size());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
convertedCopy = (Collection) requiredType.newInstance();
|
convertedCopy = (Collection<Object>) requiredType.newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
|
|
@ -552,8 +552,8 @@ class TypeConverterDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map convertToTypedMap(
|
private Map<?, ?> convertToTypedMap(
|
||||||
Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) {
|
Map<?, ?> original, String propertyName, Class<?> requiredType, TypeDescriptor typeDescriptor) {
|
||||||
|
|
||||||
if (!Map.class.isAssignableFrom(requiredType)) {
|
if (!Map.class.isAssignableFrom(requiredType)) {
|
||||||
return original;
|
return original;
|
||||||
|
|
@ -577,7 +577,7 @@ class TypeConverterDelegate {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator it;
|
Iterator<?> it;
|
||||||
try {
|
try {
|
||||||
it = original.entrySet().iterator();
|
it = original.entrySet().iterator();
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
|
|
@ -596,13 +596,13 @@ class TypeConverterDelegate {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map convertedCopy;
|
Map<Object, Object> convertedCopy;
|
||||||
try {
|
try {
|
||||||
if (approximable) {
|
if (approximable) {
|
||||||
convertedCopy = CollectionFactory.createApproximateMap(original, original.size());
|
convertedCopy = CollectionFactory.createApproximateMap(original, original.size());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
convertedCopy = (Map) requiredType.newInstance();
|
convertedCopy = (Map<Object, Object>) requiredType.newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
|
|
@ -614,7 +614,7 @@ class TypeConverterDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry entry = (Map.Entry) it.next();
|
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
|
||||||
Object key = entry.getKey();
|
Object key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
String keyedPropertyName = buildKeyedPropertyName(propertyName, key);
|
String keyedPropertyName = buildKeyedPropertyName(propertyName, key);
|
||||||
|
|
@ -649,7 +649,7 @@ class TypeConverterDelegate {
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canCreateCopy(Class requiredType) {
|
private boolean canCreateCopy(Class<?> requiredType) {
|
||||||
return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) &&
|
return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) &&
|
||||||
Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType));
|
Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
|
|
||||||
private transient Object value;
|
private transient Object value;
|
||||||
|
|
||||||
private Class requiredType;
|
private Class<?> requiredType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,7 +45,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
* @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem
|
* @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem
|
||||||
* @param requiredType the required target type
|
* @param requiredType the required target type
|
||||||
*/
|
*/
|
||||||
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType) {
|
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType) {
|
||||||
this(propertyChangeEvent, requiredType, null);
|
this(propertyChangeEvent, requiredType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
* @param requiredType the required target type (or {@code null} if not known)
|
* @param requiredType the required target type (or {@code null} if not known)
|
||||||
* @param cause the root cause (may be {@code null})
|
* @param cause the root cause (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class requiredType, Throwable cause) {
|
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause) {
|
||||||
super(propertyChangeEvent,
|
super(propertyChangeEvent,
|
||||||
"Failed to convert property value of type '" +
|
"Failed to convert property value of type '" +
|
||||||
ClassUtils.getDescriptiveType(propertyChangeEvent.getNewValue()) + "'" +
|
ClassUtils.getDescriptiveType(propertyChangeEvent.getNewValue()) + "'" +
|
||||||
|
|
@ -73,7 +73,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
* @param value the offending value that couldn't be converted (may be {@code 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 requiredType the required target type (or {@code null} if not known)
|
||||||
*/
|
*/
|
||||||
public TypeMismatchException(Object value, Class requiredType) {
|
public TypeMismatchException(Object value, Class<?> requiredType) {
|
||||||
this(value, requiredType, null);
|
this(value, requiredType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
* @param requiredType the required target type (or {@code null} if not known)
|
* @param requiredType the required target type (or {@code null} if not known)
|
||||||
* @param cause the root cause (may be {@code null})
|
* @param cause the root cause (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public TypeMismatchException(Object value, Class requiredType, Throwable cause) {
|
public TypeMismatchException(Object value, Class<?> requiredType, Throwable cause) {
|
||||||
super("Failed to convert value of type '" + ClassUtils.getDescriptiveType(value) + "'" +
|
super("Failed to convert value of type '" + ClassUtils.getDescriptiveType(value) + "'" +
|
||||||
(requiredType != null ? " to required type '" + ClassUtils.getQualifiedName(requiredType) + "'" : ""),
|
(requiredType != null ? " to required type '" + ClassUtils.getQualifiedName(requiredType) + "'" : ""),
|
||||||
cause);
|
cause);
|
||||||
|
|
@ -103,7 +103,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||||
/**
|
/**
|
||||||
* Return the required target type, if any.
|
* Return the required target type, if any.
|
||||||
*/
|
*/
|
||||||
public Class getRequiredType() {
|
public Class<?> getRequiredType() {
|
||||||
return this.requiredType;
|
return this.requiredType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Class exClass) {
|
public boolean contains(Class<?> exClass) {
|
||||||
if (super.contains(exClass)) {
|
if (super.contains(exClass)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class BeanIsNotAFactoryException extends BeanNotOfRequiredTypeException {
|
||||||
* @param actualType the actual type returned, which did not match
|
* @param actualType the actual type returned, which did not match
|
||||||
* the expected type
|
* the expected type
|
||||||
*/
|
*/
|
||||||
public BeanIsNotAFactoryException(String name, Class actualType) {
|
public BeanIsNotAFactoryException(String name, Class<?> actualType) {
|
||||||
super(name, FactoryBean.class, actualType);
|
super(name, FactoryBean.class, actualType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ public class BeanNotOfRequiredTypeException extends BeansException {
|
||||||
private String beanName;
|
private String beanName;
|
||||||
|
|
||||||
/** The required type */
|
/** The required type */
|
||||||
private Class requiredType;
|
private Class<?> requiredType;
|
||||||
|
|
||||||
/** The offending type */
|
/** The offending type */
|
||||||
private Class actualType;
|
private Class<?> actualType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +44,7 @@ public class BeanNotOfRequiredTypeException extends BeansException {
|
||||||
* @param actualType the actual type returned, which did not match
|
* @param actualType the actual type returned, which did not match
|
||||||
* the expected type
|
* the expected type
|
||||||
*/
|
*/
|
||||||
public BeanNotOfRequiredTypeException(String beanName, Class requiredType, Class actualType) {
|
public BeanNotOfRequiredTypeException(String beanName, Class<?> requiredType, Class<?> actualType) {
|
||||||
super("Bean named '" + beanName + "' must be of type [" + requiredType.getName() +
|
super("Bean named '" + beanName + "' must be of type [" + requiredType.getName() +
|
||||||
"], but was actually of type [" + actualType.getName() + "]");
|
"], but was actually of type [" + actualType.getName() + "]");
|
||||||
this.beanName = beanName;
|
this.beanName = beanName;
|
||||||
|
|
@ -63,14 +63,14 @@ public class BeanNotOfRequiredTypeException extends BeansException {
|
||||||
/**
|
/**
|
||||||
* Return the expected type for the bean.
|
* Return the expected type for the bean.
|
||||||
*/
|
*/
|
||||||
public Class getRequiredType() {
|
public Class<?> getRequiredType() {
|
||||||
return this.requiredType;
|
return this.requiredType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the actual type of the instance found.
|
* Return the actual type of the instance found.
|
||||||
*/
|
*/
|
||||||
public Class getActualType() {
|
public Class<?> getActualType() {
|
||||||
return this.actualType;
|
return this.actualType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
* @param msg the detail message
|
* @param msg the detail message
|
||||||
*/
|
*/
|
||||||
public UnsatisfiedDependencyException(
|
public UnsatisfiedDependencyException(
|
||||||
String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, String msg) {
|
String resourceDescription, String beanName, int ctorArgIndex, Class<?> ctorArgType, String msg) {
|
||||||
|
|
||||||
super(resourceDescription, beanName,
|
super(resourceDescription, beanName,
|
||||||
"Unsatisfied dependency expressed through constructor argument with index " +
|
"Unsatisfied dependency expressed through constructor argument with index " +
|
||||||
|
|
@ -86,7 +86,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
* @param ex the bean creation exception that indicated the unsatisfied dependency
|
* @param ex the bean creation exception that indicated the unsatisfied dependency
|
||||||
*/
|
*/
|
||||||
public UnsatisfiedDependencyException(
|
public UnsatisfiedDependencyException(
|
||||||
String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, BeansException ex) {
|
String resourceDescription, String beanName, int ctorArgIndex, Class<?> ctorArgType, BeansException ex) {
|
||||||
|
|
||||||
this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ": " + ex.getMessage() : ""));
|
this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ": " + ex.getMessage() : ""));
|
||||||
initCause(ex);
|
initCause(ex);
|
||||||
|
|
|
||||||
|
|
@ -268,10 +268,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
if (requiredConstructor == null && defaultConstructor != null) {
|
if (requiredConstructor == null && defaultConstructor != null) {
|
||||||
candidates.add(defaultConstructor);
|
candidates.add(defaultConstructor);
|
||||||
}
|
}
|
||||||
candidateConstructors = candidates.toArray(new Constructor[candidates.size()]);
|
candidateConstructors = candidates.toArray(new Constructor<?>[candidates.size()]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
candidateConstructors = new Constructor[0];
|
candidateConstructors = new Constructor<?>[0];
|
||||||
}
|
}
|
||||||
this.candidateConstructorsCache.put(beanClass, candidateConstructors);
|
this.candidateConstructorsCache.put(beanClass, candidateConstructors);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||||
|
|
||||||
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
|
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
|
||||||
|
|
||||||
private Set customQualifierTypes;
|
private Set<?> customQualifierTypes;
|
||||||
|
|
||||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||||
* does not require explicit registration.
|
* does not require explicit registration.
|
||||||
* @param customQualifierTypes the custom types to register
|
* @param customQualifierTypes the custom types to register
|
||||||
*/
|
*/
|
||||||
public void setCustomQualifierTypes(Set customQualifierTypes) {
|
public void setCustomQualifierTypes(Set<?> customQualifierTypes) {
|
||||||
this.customQualifierTypes = customQualifierTypes;
|
this.customQualifierTypes = customQualifierTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,13 +99,13 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||||
QualifierAnnotationAutowireCandidateResolver resolver =
|
QualifierAnnotationAutowireCandidateResolver resolver =
|
||||||
(QualifierAnnotationAutowireCandidateResolver) dlbf.getAutowireCandidateResolver();
|
(QualifierAnnotationAutowireCandidateResolver) dlbf.getAutowireCandidateResolver();
|
||||||
for (Object value : this.customQualifierTypes) {
|
for (Object value : this.customQualifierTypes) {
|
||||||
Class customType = null;
|
Class<? extends Annotation> customType = null;
|
||||||
if (value instanceof Class) {
|
if (value instanceof Class) {
|
||||||
customType = (Class) value;
|
customType = (Class<? extends Annotation>) value;
|
||||||
}
|
}
|
||||||
else if (value instanceof String) {
|
else if (value instanceof String) {
|
||||||
String className = (String) value;
|
String className = (String) value;
|
||||||
customType = ClassUtils.resolveClassName(className, this.beanClassLoader);
|
customType = (Class<? extends Annotation>) ClassUtils.resolveClassName(className, this.beanClassLoader);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
*/
|
*/
|
||||||
private class LifecycleMetadata {
|
private class LifecycleMetadata {
|
||||||
|
|
||||||
private final Class targetClass;
|
private final Class<?> targetClass;
|
||||||
|
|
||||||
private final Collection<LifecycleElement> initMethods;
|
private final Collection<LifecycleElement> initMethods;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ public abstract class AbstractFactoryBean<T>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private T getEarlySingletonInstance() throws Exception {
|
private T getEarlySingletonInstance() throws Exception {
|
||||||
Class[] ifcs = getEarlySingletonInterfaces();
|
Class<?>[] ifcs = getEarlySingletonInterfaces();
|
||||||
if (ifcs == null) {
|
if (ifcs == null) {
|
||||||
throw new FactoryBeanNotInitializedException(
|
throw new FactoryBeanNotInitializedException(
|
||||||
getClass().getName() + " does not support circular references");
|
getClass().getName() + " does not support circular references");
|
||||||
|
|
@ -225,9 +225,9 @@ public abstract class AbstractFactoryBean<T>
|
||||||
* or {@code null} to indicate a FactoryBeanNotInitializedException
|
* or {@code null} to indicate a FactoryBeanNotInitializedException
|
||||||
* @see org.springframework.beans.factory.FactoryBeanNotInitializedException
|
* @see org.springframework.beans.factory.FactoryBeanNotInitializedException
|
||||||
*/
|
*/
|
||||||
protected Class[] getEarlySingletonInterfaces() {
|
protected Class<?>[] getEarlySingletonInterfaces() {
|
||||||
Class type = getObjectType();
|
Class<?> type = getObjectType();
|
||||||
return (type != null && type.isInterface() ? new Class[] {type} : null);
|
return (type != null && type.isInterface() ? new Class<?>[] {type} : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import org.springframework.beans.factory.SmartFactoryBean;
|
||||||
* (which support placeholder parsing since Spring 2.5)
|
* (which support placeholder parsing since Spring 2.5)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAware {
|
public class BeanReferenceFactoryBean implements SmartFactoryBean<Object>, BeanFactoryAware {
|
||||||
|
|
||||||
private String targetBeanName;
|
private String targetBeanName;
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class BeanReferenceFactoryBean implements SmartFactoryBean, BeanFactoryAw
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
if (this.beanFactory == null) {
|
if (this.beanFactory == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,6 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
if (this.propertyEditorRegistrars != null) {
|
if (this.propertyEditorRegistrars != null) {
|
||||||
for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
|
for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
|
||||||
|
|
@ -149,7 +148,7 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
|
||||||
}
|
}
|
||||||
if (this.customEditors != null) {
|
if (this.customEditors != null) {
|
||||||
for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
|
for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : this.customEditors.entrySet()) {
|
||||||
Class requiredType = entry.getKey();
|
Class<?> requiredType = entry.getKey();
|
||||||
Class<? extends PropertyEditor> propertyEditorClass = entry.getValue();
|
Class<? extends PropertyEditor> propertyEditorClass = entry.getValue();
|
||||||
beanFactory.registerCustomEditor(requiredType, propertyEditorClass);
|
beanFactory.registerCustomEditor(requiredType, propertyEditorClass);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
if (this.scopes != null) {
|
if (this.scopes != null) {
|
||||||
for (Map.Entry<String, Object> entry : this.scopes.entrySet()) {
|
for (Map.Entry<String, Object> entry : this.scopes.entrySet()) {
|
||||||
|
|
@ -87,12 +86,12 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas
|
||||||
beanFactory.registerScope(scopeKey, (Scope) value);
|
beanFactory.registerScope(scopeKey, (Scope) value);
|
||||||
}
|
}
|
||||||
else if (value instanceof Class) {
|
else if (value instanceof Class) {
|
||||||
Class scopeClass = (Class) value;
|
Class<?> scopeClass = (Class<?>) value;
|
||||||
Assert.isAssignable(Scope.class, scopeClass);
|
Assert.isAssignable(Scope.class, scopeClass);
|
||||||
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
|
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
|
||||||
}
|
}
|
||||||
else if (value instanceof String) {
|
else if (value instanceof String) {
|
||||||
Class scopeClass = ClassUtils.resolveClassName((String) value, this.beanClassLoader);
|
Class<?> scopeClass = ClassUtils.resolveClassName((String) value, this.beanClassLoader);
|
||||||
Assert.isAssignable(Scope.class, scopeClass);
|
Assert.isAssignable(Scope.class, scopeClass);
|
||||||
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
|
beanFactory.registerScope(scopeKey, (Scope) BeanUtils.instantiateClass(scopeClass));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class DependencyDescriptor implements Serializable {
|
||||||
|
|
||||||
private String methodName;
|
private String methodName;
|
||||||
|
|
||||||
private Class[] parameterTypes;
|
private Class<?>[] parameterTypes;
|
||||||
|
|
||||||
private int parameterIndex;
|
private int parameterIndex;
|
||||||
|
|
||||||
|
|
@ -267,12 +267,12 @@ public class DependencyDescriptor implements Serializable {
|
||||||
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
|
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
|
||||||
Type arg = args[args.length - 1];
|
Type arg = args[args.length - 1];
|
||||||
if (arg instanceof Class) {
|
if (arg instanceof Class) {
|
||||||
return (Class) arg;
|
return (Class<?>) arg;
|
||||||
}
|
}
|
||||||
else if (arg instanceof ParameterizedType) {
|
else if (arg instanceof ParameterizedType) {
|
||||||
arg = ((ParameterizedType) arg).getRawType();
|
arg = ((ParameterizedType) arg).getRawType();
|
||||||
if (arg instanceof Class) {
|
if (arg instanceof Class) {
|
||||||
return (Class) arg;
|
return (Class<?>) arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
|
||||||
public class FieldRetrievingFactoryBean
|
public class FieldRetrievingFactoryBean
|
||||||
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, InitializingBean {
|
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, InitializingBean {
|
||||||
|
|
||||||
private Class targetClass;
|
private Class<?> targetClass;
|
||||||
|
|
||||||
private Object targetObject;
|
private Object targetObject;
|
||||||
|
|
||||||
|
|
@ -78,14 +78,14 @@ public class FieldRetrievingFactoryBean
|
||||||
* @see #setTargetObject
|
* @see #setTargetObject
|
||||||
* @see #setTargetField
|
* @see #setTargetField
|
||||||
*/
|
*/
|
||||||
public void setTargetClass(Class targetClass) {
|
public void setTargetClass(Class<?> targetClass) {
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the target class on which the field is defined.
|
* Return the target class on which the field is defined.
|
||||||
*/
|
*/
|
||||||
public Class getTargetClass() {
|
public Class<?> getTargetClass() {
|
||||||
return targetClass;
|
return targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,7 +189,7 @@ public class FieldRetrievingFactoryBean
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get the exact method first.
|
// Try to get the exact method first.
|
||||||
Class targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass;
|
Class<?> targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass;
|
||||||
this.fieldObject = targetClass.getField(this.targetField);
|
this.fieldObject = targetClass.getField(this.targetField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,18 @@ import org.springframework.core.GenericCollectionTypeResolver;
|
||||||
* @see SetFactoryBean
|
* @see SetFactoryBean
|
||||||
* @see MapFactoryBean
|
* @see MapFactoryBean
|
||||||
*/
|
*/
|
||||||
public class ListFactoryBean extends AbstractFactoryBean<List> {
|
public class ListFactoryBean extends AbstractFactoryBean<List<Object>> {
|
||||||
|
|
||||||
private List sourceList;
|
private List<?> sourceList;
|
||||||
|
|
||||||
private Class targetListClass;
|
@SuppressWarnings("rawtypes")
|
||||||
|
private Class<? extends List> targetListClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the source List, typically populated via XML "list" elements.
|
* Set the source List, typically populated via XML "list" elements.
|
||||||
*/
|
*/
|
||||||
public void setSourceList(List sourceList) {
|
public void setSourceList(List<?> sourceList) {
|
||||||
this.sourceList = sourceList;
|
this.sourceList = sourceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,7 +53,8 @@ public class ListFactoryBean extends AbstractFactoryBean<List> {
|
||||||
* <p>Default is a {@code java.util.ArrayList}.
|
* <p>Default is a {@code java.util.ArrayList}.
|
||||||
* @see java.util.ArrayList
|
* @see java.util.ArrayList
|
||||||
*/
|
*/
|
||||||
public void setTargetListClass(Class targetListClass) {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void setTargetListClass(Class<? extends List> targetListClass) {
|
||||||
if (targetListClass == null) {
|
if (targetListClass == null) {
|
||||||
throw new IllegalArgumentException("'targetListClass' must not be null");
|
throw new IllegalArgumentException("'targetListClass' must not be null");
|
||||||
}
|
}
|
||||||
|
|
@ -64,24 +66,25 @@ public class ListFactoryBean extends AbstractFactoryBean<List> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public Class<List> getObjectType() {
|
public Class<List> getObjectType() {
|
||||||
return List.class;
|
return List.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected List createInstance() {
|
protected List<Object> createInstance() {
|
||||||
if (this.sourceList == null) {
|
if (this.sourceList == null) {
|
||||||
throw new IllegalArgumentException("'sourceList' is required");
|
throw new IllegalArgumentException("'sourceList' is required");
|
||||||
}
|
}
|
||||||
List result = null;
|
List<Object> result = null;
|
||||||
if (this.targetListClass != null) {
|
if (this.targetListClass != null) {
|
||||||
result = (List) BeanUtils.instantiateClass(this.targetListClass);
|
result = BeanUtils.instantiateClass(this.targetListClass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = new ArrayList(this.sourceList.size());
|
result = new ArrayList<Object>(this.sourceList.size());
|
||||||
}
|
}
|
||||||
Class valueType = null;
|
Class<?> valueType = null;
|
||||||
if (this.targetListClass != null) {
|
if (this.targetListClass != null) {
|
||||||
valueType = GenericCollectionTypeResolver.getCollectionType(this.targetListClass);
|
valueType = GenericCollectionTypeResolver.getCollectionType(this.targetListClass);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,17 +32,18 @@ import org.springframework.core.GenericCollectionTypeResolver;
|
||||||
* @see SetFactoryBean
|
* @see SetFactoryBean
|
||||||
* @see ListFactoryBean
|
* @see ListFactoryBean
|
||||||
*/
|
*/
|
||||||
public class MapFactoryBean extends AbstractFactoryBean<Map> {
|
public class MapFactoryBean extends AbstractFactoryBean<Map<Object, Object>> {
|
||||||
|
|
||||||
private Map<?, ?> sourceMap;
|
private Map<?, ?> sourceMap;
|
||||||
|
|
||||||
private Class targetMapClass;
|
@SuppressWarnings("rawtypes")
|
||||||
|
private Class<? extends Map> targetMapClass;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the source Map, typically populated via XML "map" elements.
|
* Set the source Map, typically populated via XML "map" elements.
|
||||||
*/
|
*/
|
||||||
public void setSourceMap(Map sourceMap) {
|
public void setSourceMap(Map<?, ?> sourceMap) {
|
||||||
this.sourceMap = sourceMap;
|
this.sourceMap = sourceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,7 +53,8 @@ public class MapFactoryBean extends AbstractFactoryBean<Map> {
|
||||||
* <p>Default is a linked HashMap, keeping the registration order.
|
* <p>Default is a linked HashMap, keeping the registration order.
|
||||||
* @see java.util.LinkedHashMap
|
* @see java.util.LinkedHashMap
|
||||||
*/
|
*/
|
||||||
public void setTargetMapClass(Class targetMapClass) {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public void setTargetMapClass(Class<? extends Map> targetMapClass) {
|
||||||
if (targetMapClass == null) {
|
if (targetMapClass == null) {
|
||||||
throw new IllegalArgumentException("'targetMapClass' must not be null");
|
throw new IllegalArgumentException("'targetMapClass' must not be null");
|
||||||
}
|
}
|
||||||
|
|
@ -64,32 +66,33 @@ public class MapFactoryBean extends AbstractFactoryBean<Map> {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public Class<Map> getObjectType() {
|
public Class<Map> getObjectType() {
|
||||||
return Map.class;
|
return Map.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected Map createInstance() {
|
protected Map<Object, Object> createInstance() {
|
||||||
if (this.sourceMap == null) {
|
if (this.sourceMap == null) {
|
||||||
throw new IllegalArgumentException("'sourceMap' is required");
|
throw new IllegalArgumentException("'sourceMap' is required");
|
||||||
}
|
}
|
||||||
Map result = null;
|
Map<Object, Object> result = null;
|
||||||
if (this.targetMapClass != null) {
|
if (this.targetMapClass != null) {
|
||||||
result = (Map) BeanUtils.instantiateClass(this.targetMapClass);
|
result = BeanUtils.instantiateClass(this.targetMapClass);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = new LinkedHashMap(this.sourceMap.size());
|
result = new LinkedHashMap<Object, Object>(this.sourceMap.size());
|
||||||
}
|
}
|
||||||
Class keyType = null;
|
Class<?> keyType = null;
|
||||||
Class valueType = null;
|
Class<?> valueType = null;
|
||||||
if (this.targetMapClass != null) {
|
if (this.targetMapClass != null) {
|
||||||
keyType = GenericCollectionTypeResolver.getMapKeyType(this.targetMapClass);
|
keyType = GenericCollectionTypeResolver.getMapKeyType(this.targetMapClass);
|
||||||
valueType = GenericCollectionTypeResolver.getMapValueType(this.targetMapClass);
|
valueType = GenericCollectionTypeResolver.getMapValueType(this.targetMapClass);
|
||||||
}
|
}
|
||||||
if (keyType != null || valueType != null) {
|
if (keyType != null || valueType != null) {
|
||||||
TypeConverter converter = getBeanTypeConverter();
|
TypeConverter converter = getBeanTypeConverter();
|
||||||
for (Map.Entry entry : this.sourceMap.entrySet()) {
|
for (Map.Entry<?, ?> entry : this.sourceMap.entrySet()) {
|
||||||
Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType);
|
Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType);
|
||||||
Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType);
|
Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType);
|
||||||
result.put(convertedKey, convertedValue);
|
result.put(convertedKey, convertedValue);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue