Package org.springframework.aop.support
Class DefaultIntroductionAdvisor
- java.lang.Object
- org.springframework.aop.support.DefaultIntroductionAdvisor
- All Implemented Interfaces:
Serializable,Advisor,ClassFilter,IntroductionAdvisor,IntroductionInfo,Ordered
public class DefaultIntroductionAdvisor extends Object implements IntroductionAdvisor, ClassFilter, Ordered, Serializable
SimpleIntroductionAdvisorimplementation that by default applies to any class.- Since:
- 11.11.2003
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- Serialized Form
Field Summary
Fields inherited from interface org.springframework.aop.ClassFilter
TRUE
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor Summary
Constructors Constructor Description DefaultIntroductionAdvisor(Advice advice)Create a DefaultIntroductionAdvisor for the given advice.DefaultIntroductionAdvisor(Advice advice, IntroductionInfo introductionInfo)Create a DefaultIntroductionAdvisor for the given advice.DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> ifc)Create a DefaultIntroductionAdvisor for the given advice.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInterface(Class<?> ifc)Add the specified interface to the list of interfaces to introduce.booleanequals(Object other)AdvicegetAdvice()Return the advice part of this aspect.ClassFiltergetClassFilter()Return the filter determining which target classes this introduction should apply to.Class<?>[]getInterfaces()Return the additional interfaces introduced by this Advisor or Advice.intgetOrder()Get the order value of this object.inthashCode()booleanisPerInstance()Return whether this advice is associated with a particular instance (for example, creating a mixin) or shared with all instances of the advised class obtained from the same Spring bean factory.booleanmatches(Class<?> clazz)Should the pointcut apply to the given interface or target class?voidsetOrder(int order)StringtoString()voidvalidateInterfaces()Can the advised interfaces be implemented by the introduction advice? Invoked before adding an IntroductionAdvisor.
Constructor Detail
DefaultIntroductionAdvisor
public DefaultIntroductionAdvisor(Advice advice)
Create a DefaultIntroductionAdvisor for the given advice.- Parameters:
advice- the Advice to apply (may implement theIntroductionInfointerface)- See Also:
addInterface(java.lang.Class<?>)
DefaultIntroductionAdvisor
public DefaultIntroductionAdvisor(Advice advice, IntroductionInfo introductionInfo)
Create a DefaultIntroductionAdvisor for the given advice.- Parameters:
advice- the Advice to applyintroductionInfo- the IntroductionInfo that describes the interface to introduce (may benull)
DefaultIntroductionAdvisor
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> ifc)
Create a DefaultIntroductionAdvisor for the given advice.- Parameters:
advice- the Advice to applyifc- the interface to introduce
Method Detail
addInterface
public void addInterface(Class<?> ifc)
Add the specified interface to the list of interfaces to introduce.- Parameters:
ifc- the interface to introduce
getInterfaces
public Class<?>[] getInterfaces()
Description copied from interface:IntroductionInfoReturn the additional interfaces introduced by this Advisor or Advice.- Specified by:
getInterfacesin interfaceIntroductionInfo- Returns:
- the introduced interfaces
validateInterfaces
public void validateInterfaces() throws IllegalArgumentException
Description copied from interface:IntroductionAdvisorCan the advised interfaces be implemented by the introduction advice? Invoked before adding an IntroductionAdvisor.- Specified by:
validateInterfacesin interfaceIntroductionAdvisor- Throws:
IllegalArgumentException- if the advised interfaces can't be implemented by the introduction advice
setOrder
public void setOrder(int order)
getOrder
public int getOrder()
Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrderin interfaceOrdered- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE,Ordered.LOWEST_PRECEDENCE
getAdvice
public Advice getAdvice()
Description copied from interface:AdvisorReturn the advice part of this aspect. An advice may be an interceptor, a before advice, a throws advice, etc.- Specified by:
getAdvicein interfaceAdvisor- Returns:
- the advice that should apply if the pointcut matches
- See Also:
MethodInterceptor,BeforeAdvice,ThrowsAdvice,AfterReturningAdvice
isPerInstance
public boolean isPerInstance()
Description copied from interface:AdvisorReturn whether this advice is associated with a particular instance (for example, creating a mixin) or shared with all instances of the advised class obtained from the same Spring bean factory.Note that this method is not currently used by the framework. Typical Advisor implementations always return
true. Use singleton/prototype bean definitions or appropriate programmatic proxy creation to ensure that Advisors have the correct lifecycle model.- Specified by:
isPerInstancein interfaceAdvisor- Returns:
- whether this advice is associated with a particular target instance
getClassFilter
public ClassFilter getClassFilter()
Description copied from interface:IntroductionAdvisorReturn the filter determining which target classes this introduction should apply to.This represents the class part of a pointcut. Note that method matching doesn't make sense to introductions.
- Specified by:
getClassFilterin interfaceIntroductionAdvisor- Returns:
- the class filter
matches
public boolean matches(Class<?> clazz)
Description copied from interface:ClassFilterShould the pointcut apply to the given interface or target class?- Specified by:
matchesin interfaceClassFilter- Parameters:
clazz- the candidate target class- Returns:
- whether the advice should apply to the given target class