org.springframework.aop.framework
Class AdvisedSupport

org.springframework.aop.framework.ProxyConfig
  |
  +--org.springframework.aop.framework.AdvisedSupport
Direct Known Subclasses:
ProxyFactory, ProxyFactoryBean

public class AdvisedSupport
extends ProxyConfig
implements Advised

Superclass for AOP Proxy configuration managers. These are not themselves AOP proxies, but subclasses of this class are normally factories from which AOP proxy instances are obtained directly.

This class frees subclasses of the housekeeping of Interceptors and Advisors, but doesn't actually implement proxy creation methods, which are provided by subclasses.

Author:
Rod Johnson
Version: $Id: AdvisedSupport.java,v 1.23 2004/01/25 19:44:25 johnsonr Exp $
See Also: AopProxy

Field Summary
 static TargetSourceEMPTY_TARGET_SOURCE
          Canonical TargetSource when there's no target, and behaviour is supplied by the advisors.

Constructor Summary
AdvisedSupport()
          No arg constructor to allow use as a Java bean.
AdvisedSupport(Class[] interfaces)
          Create a DefaultProxyConfig with the given parameters.

Method Summary
 voidaddAdvisor(int pos, IntroductionAdvisor advisor)
           
 voidaddAdvisor(int pos, Advisor advisor)
           
 voidaddAdvisor(Advisor advice)
           
 voidaddBeforeAdvice(MethodBeforeAdvice ba)
           
 voidaddInterceptor(Interceptor interceptor)
           
 voidaddInterceptor(int pos, Interceptor interceptor)
          Cannot add IntroductionInterceptors this way.
 voidaddInterface(Class newInterface)
          Add a new proxied interface.
 voidaddListener(AdvisedSupportListener l)
           
 voidaddThrowsAdvice(ThrowsAdvice throwsAdvice)
           
 final intcountInterceptorsOfType(Class interceptorClass)
          Count interceptors of the given class
 final AdvisorChainFactorygetAdvisorChainFactory()
          Return the AdvisorChainFactory associated with this ProxyConfig.
 final Advisor[]getAdvisors()
           
 final MethodInvocationFactorygetMethodInvocationFactory()
           
 final Class[]getProxiedInterfaces()
           
 final TargetSourcegetTargetSource()
           
 intindexOf(Interceptor interceptor)
          Return the index (from 0) of the given AOP Alliance interceptor, or -1 if no such interceptor is an advice for this proxy.
 intindexOf(Advisor advisor)
          Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.
 final booleaninterceptorIncluded(Interceptor mi)
          Is this interceptor included in any advisor?
 booleanisInterfaceProxied(Class intf)
           
 final booleanremoveAdvisor(Advisor advisor)
           
 voidremoveAdvisor(int index)
           
 final booleanremoveInterceptor(Interceptor interceptor)
          Convenience method to remove an interceptor
 booleanremoveInterface(Class intf)
          Remove a proxied interface.
 voidremoveListener(AdvisedSupportListener l)
           
 final booleanreplaceAdvisor(Advisor a, Advisor b)
          Replace the given advisor.
 voidsetAdvisorChainFactory(AdvisorChainFactory advisorChainFactory)
           
 voidsetInterfaces(Class[] interfaces)
          Set the interfaces to be proxied.
 voidsetMethodInvocationFactory(MethodInvocationFactory methodInvocationFactory)
           
 voidsetTarget(Object target)
           
 voidsetTargetSource(TargetSource ts)
           
 StringtoProxyConfigString()
           
 StringtoString()
          For debugging/diagnostic use.

Methods inherited from class org.springframework.aop.framework.ProxyConfig
copyFrom, getExposeProxy, getOptimize, getProxyTargetClass, setExposeProxy, setOptimize, setProxyTargetClass

Field Detail

EMPTY_TARGET_SOURCE

public static TargetSource EMPTY_TARGET_SOURCE
Canonical TargetSource when there's no target, and behaviour is supplied by the advisors.
Constructor Detail

AdvisedSupport

public AdvisedSupport()
No arg constructor to allow use as a Java bean.

AdvisedSupport

public AdvisedSupport(Class[] interfaces)
Create a DefaultProxyConfig with the given parameters.
Parameters:
interfaces - the proxied interfaces
Method Detail

addAdvisor

public void addAdvisor(int pos, IntroductionAdvisor advisor)
throws AopConfigException

addAdvisor

public void addAdvisor(int pos, Advisor advisor)

addAdvisor

public void addAdvisor(Advisor advice)

addBeforeAdvice

public void addBeforeAdvice(MethodBeforeAdvice ba)

addInterceptor

public void addInterceptor(Interceptor interceptor)

addInterceptor

public void addInterceptor(int pos, Interceptor interceptor)
Cannot add IntroductionInterceptors this way.

addInterface

public void addInterface(Class newInterface)
Add a new proxied interface.
Parameters:
newInterface - additional interface to proxy

addListener

public void addListener(AdvisedSupportListener l)

addThrowsAdvice

public void addThrowsAdvice(ThrowsAdvice throwsAdvice)

countInterceptorsOfType

public final int countInterceptorsOfType(Class interceptorClass)
Count interceptors of the given class
Parameters:
interceptorClass - class of the interceptor to check
Returns: the count of the interceptors of this class or subclasses

getAdvisorChainFactory

public final AdvisorChainFactory getAdvisorChainFactory()
Return the AdvisorChainFactory associated with this ProxyConfig.

getAdvisors

public final Advisor[] getAdvisors()

getMethodInvocationFactory

public final MethodInvocationFactory getMethodInvocationFactory()
Returns: Returns the methodInvocationFactory.

getProxiedInterfaces

public final Class[] getProxiedInterfaces()

getTargetSource

public final TargetSource getTargetSource()
Returns: the TargetSource. Never returns null

indexOf

public int indexOf(Interceptor interceptor)
Return the index (from 0) of the given AOP Alliance interceptor, or -1 if no such interceptor is an advice for this proxy. The return value of this method can be used to index into the Advisors array.
Parameters:
interceptor - AOP Alliance interceptor to search for
Returns: index from 0 of this interceptor, or -1 if there's no such advice.

indexOf

public int indexOf(Advisor advisor)
Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy. The return value of this method can be used to index into the Advisors array.
Parameters:
advisor - advisor to search for
Returns: index from 0 of this advisor, or -1 if there's no such advisor.

interceptorIncluded

public final boolean interceptorIncluded(Interceptor mi)
Is this interceptor included in any advisor?
Parameters:
mi - interceptor to check inclusion of
Returns: whether this interceptor instance could be run in an invocation

isInterfaceProxied

public boolean isInterfaceProxied(Class intf)

removeAdvisor

public final boolean removeAdvisor(Advisor advisor)

removeAdvisor

public void removeAdvisor(int index)
throws AopConfigException

removeInterceptor

public final boolean removeInterceptor(Interceptor interceptor)
Convenience method to remove an interceptor

removeInterface

public boolean removeInterface(Class intf)
Remove a proxied interface. Does nothing if it isn't proxied.

removeListener

public void removeListener(AdvisedSupportListener l)

replaceAdvisor

public final boolean replaceAdvisor(Advisor a, Advisor b)
Replace the given advisor. NB:If the advisor is an IntroductionAdvisor and the replacement is not or implements different interfaces, the proxy will need to be re-obtained or the old interfaces won't be supported and the new interface won't be implemented.
Parameters:
a - advisor to replace
b - advisor to replace it with
Returns: whether it was replaced. If the advisor wasn't found in the list of advisors, this method returns false and does nothing.

setAdvisorChainFactory

public void setAdvisorChainFactory(AdvisorChainFactory advisorChainFactory)

setInterfaces

public void setInterfaces(Class[] interfaces)
Set the interfaces to be proxied.
Parameters:
interfaces - the interfaces to set

setMethodInvocationFactory

public void setMethodInvocationFactory(MethodInvocationFactory methodInvocationFactory)
Parameters:
methodInvocationFactory - The methodInvocationFactory to set.

setTarget

public void setTarget(Object target)

setTargetSource

public void setTargetSource(TargetSource ts)

toProxyConfigString

public String toProxyConfigString()

toString

public String toString()
For debugging/diagnostic use.

Association Links

to Class org.springframework.aop.TargetSource

Canonical TargetSource when there's no target, and behaviour is supplied by the advisors.

to Class java.util.List

List of Advice. If an Interceptor is added, it will be wrapped in an Advice before being added to this List.

to Class org.springframework.aop.Advisor

Array updated on changes to the advisors list, which is easier to manipulate internally

to Class java.util.Set

Interfaces to be implemented by the proxy

to Class org.springframework.aop.TargetSource

to Class org.springframework.aop.framework.MethodInvocationFactory

to Class java.util.LinkedList

List of AdvisedSupportListener

to Class org.springframework.aop.framework.AdvisorChainFactory