|
|
|
@ -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"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -17,7 +17,7 @@ |
|
|
|
package org.springframework.aop.support; |
|
|
|
package org.springframework.aop.support; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
import java.io.Serializable; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import org.aopalliance.aop.Advice; |
|
|
|
import org.aopalliance.aop.Advice; |
|
|
|
@ -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 LinkedHashSet<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"); |
|
|
|
@ -102,12 +102,13 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil |
|
|
|
this.interfaces.add(intf); |
|
|
|
this.interfaces.add(intf); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
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 + "] " + |
|
|
|
@ -138,7 +139,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean matches(Class clazz) { |
|
|
|
public boolean matches(Class<?> clazz) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|