diff --git a/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java b/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java index 6ba69a833da..9f68b074248 100644 --- a/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java +++ b/spring-aop/src/main/java/org/springframework/aop/IntroductionInfo.java @@ -34,6 +34,6 @@ public interface IntroductionInfo { * Return the additional interfaces introduced by this Advisor or Advice. * @return the introduced interfaces */ - Class[] getInterfaces(); + Class[] getInterfaces(); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java index 27618c9b466..b437755ec1c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/DeclareParentsAdvisor.java @@ -34,7 +34,7 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor; */ public class DeclareParentsAdvisor implements IntroductionAdvisor { - private final Class introducedInterface; + private final Class introducedInterface; private final ClassFilter typePatternClassFilter; @@ -47,7 +47,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param typePattern type pattern the introduction is restricted to * @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, new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); } @@ -58,7 +58,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param typePattern type pattern the introduction is restricted to * @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(), new DelegatingIntroductionInterceptor(delegateRef)); } @@ -71,13 +71,13 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { * @param implementationClass implementation class * @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; ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern); // Excludes methods implemented. ClassFilter exclusion = new ClassFilter() { - public boolean matches(Class clazz) { + public boolean matches(Class clazz) { return !(introducedInterface.isAssignableFrom(clazz)); } }; @@ -103,8 +103,8 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor { return this.advice; } - public Class[] getInterfaces() { - return new Class[] {this.introducedInterface}; + public Class[] getInterfaces() { + return new Class[] {this.introducedInterface}; } } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java index fdd985191e9..ac4a4ecad9c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.aop.support; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -215,7 +215,7 @@ public abstract class AopUtils { introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher; } - Set classes = new HashSet(ClassUtils.getAllInterfacesForClassAsSet(targetClass)); + Set classes = new LinkedHashSet(ClassUtils.getAllInterfacesForClassAsSet(targetClass)); classes.add(targetClass); for (Class clazz : classes) { Method[] methods = clazz.getMethods(); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java index e1aad6a1701..d1af2ec4a7a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.springframework.aop.support; import java.io.Serializable; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.aopalliance.aop.Advice; @@ -43,7 +43,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil private final Advice advice; - private final Set interfaces = new HashSet(); + private final Set interfaces = new LinkedHashSet(); private int order = Integer.MAX_VALUE; @@ -68,11 +68,11 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil Assert.notNull(advice, "Advice must not be null"); this.advice = advice; if (introductionInfo != null) { - Class[] introducedInterfaces = introductionInfo.getInterfaces(); + Class[] introducedInterfaces = introductionInfo.getInterfaces(); if (introducedInterfaces.length == 0) { throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces"); } - for (Class ifc : introducedInterfaces) { + for (Class ifc : introducedInterfaces) { addInterface(ifc); } } @@ -83,7 +83,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil * @param advice the Advice to apply * @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"); this.advice = advice; addInterface(intf); @@ -94,7 +94,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil * Add the specified interface to the list of interfaces 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"); if (!intf.isInterface()) { throw new IllegalArgumentException("Specified class [" + intf.getName() + "] must be an interface"); @@ -102,12 +102,13 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil this.interfaces.add(intf); } - public Class[] getInterfaces() { - return this.interfaces.toArray(new Class[this.interfaces.size()]); + public Class[] getInterfaces() { + return this.interfaces.toArray(new Class[this.interfaces.size()]); } + @Override public void validateInterfaces() throws IllegalArgumentException { - for (Class ifc : this.interfaces) { + for (Class ifc : this.interfaces) { if (this.advice instanceof DynamicIntroductionAdvice && !((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) { throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " + @@ -138,7 +139,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil return this; } - public boolean matches(Class clazz) { + public boolean matches(Class clazz) { return true; } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java index c8807f76393..73adc67b166 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; import java.lang.reflect.Method; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -43,7 +43,7 @@ import org.springframework.util.ClassUtils; @SuppressWarnings("serial") public class IntroductionInfoSupport implements IntroductionInfo, Serializable { - protected final Set publishedInterfaces = new HashSet(); + protected final Set publishedInterfaces = new LinkedHashSet(); private transient Map rememberedMethods = new ConcurrentHashMap(32); @@ -55,12 +55,12 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable { *

Does nothing if the interface is not implemented by the delegate. * @param intf the interface to suppress */ - public void suppressInterface(Class intf) { + public void suppressInterface(Class intf) { this.publishedInterfaces.remove(intf); } - public Class[] getInterfaces() { - return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]); + public Class[] getInterfaces() { + return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]); } /** @@ -68,8 +68,8 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable { * @param ifc the interface to check * @return whether the interface is part of this introduction */ - public boolean implementsInterface(Class ifc) { - for (Class pubIfc : this.publishedInterfaces) { + public boolean implementsInterface(Class ifc) { + for (Class pubIfc : this.publishedInterfaces) { if (ifc.isInterface() && ifc.isAssignableFrom(pubIfc)) { return true; }