org.springframework.aop.framework
Interface Advised

All Known Implementing Classes:
AdvisedSupport

public interface Advised

Interface to be implemented by classes that hold the configuration of a factory of AOP proxies. This configuration includes the Interceptors and Advisors, and the proxied interfaces.

Any AOP proxy obtained from Spring can be cast to this interface to allow manipulation of its AOP advice.

Author:
Rod Johnson
Version: $Id: Advised.java,v 1.8 2004/01/25 19:44:26 johnsonr Exp $
Since: 13-Mar-2003
See Also: AdvisedSupport

Method Summary
 voidaddAdvisor(Advisor advisor)
          Add an Advisor at the end of the advisor chain.
 voidaddAdvisor(int pos, Advisor advisor)
          Add an Advisor at the specified position in the chain
 voidaddInterceptor(Interceptor interceptor)
          Add the given interceptor to the tail of the advice (interceptor) chain.
 voidaddInterceptor(int pos, Interceptor interceptor)
          Add an interceptor at the specified position in the interceptor chain.
 Advisor[]getAdvisors()
          Return the Advisors applying to this proxy.
 booleangetExposeProxy()
          Get whether the factory should expose the proxy as a ThreadLocal.
 Class[]getProxiedInterfaces()
          Return the interfaces proxied by the AOP proxy.
 booleangetProxyTargetClass()
          Should we proxy the target class as well as any interfaces? Can use this to force CGLIB proxying.
 TargetSourcegetTargetSource()
          Return the TargetSource used by this Advised object
 intindexOf(Advisor advisor)
          Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.
 booleanisInterfaceProxied(Class intf)
          Return whether this interface is proxied
 booleanremoveAdvisor(Advisor advisor)
          Remove the given advisor
 voidremoveAdvisor(int index)
          Remove the advisor at the given index
 booleanreplaceAdvisor(Advisor a, Advisor b)
          Replace the given advisor.
 StringtoProxyConfigString()
          As toString() will normally pass to the target, this returns the equivalent for the AOP proxy

Method Detail

addAdvisor

public void addAdvisor(Advisor advisor)
Add an Advisor at the end of the advisor chain. The Advisor may be an IntroductionAdvisor, in which new interfaces will be available when a proxy is next obtained from the relevant factory.
Parameters:
advisor - Advisor to add to the end of the chain

addAdvisor

public void addAdvisor(int pos, Advisor advisor)
Add an Advisor at the specified position in the chain
Parameters:
advisor - advisor to add at the specified position in the chain
pos - position in chain (0 is head). Must be valid.

addInterceptor

public void addInterceptor(Interceptor interceptor)
Add the given interceptor to the tail of the advice (interceptor) chain. This will be wrapped in a DefaultInterceptionAroundAdvisor with a pointcut that always applies, and returned from the getAdvisors() method in this wrapped form.
Parameters:
interceptor - to add to the tail of the chain
See Also:
addInterceptor(int,Interceptor)

addInterceptor

public void addInterceptor(int pos, Interceptor interceptor)
Add an interceptor at the specified position in the interceptor chain.
Parameters:
pos - index from 0 (head)
interceptor - interceptor to add at the specified position in the interceptor chain

getAdvisors

public Advisor[] getAdvisors()
Return the Advisors applying to this proxy.
Returns: a list of Advisors applying to this proxy. Cannot return null, but may return the empty array.

getExposeProxy

public boolean getExposeProxy()
Get whether the factory should expose the proxy as a ThreadLocal. This can be necessary if a target object needs to invoke a method on itself benefitting from advice. (If it invokes a method on this no advice will apply.) Getting the proxy is analogous to an EJB calling getEJBObject().
Returns: whether the factory should expose the proxy as a ThreadLocal
See Also:
AopContext

getProxiedInterfaces

public Class[] getProxiedInterfaces()
Return the interfaces proxied by the AOP proxy. Will not include the target class, which may also be proxied.
Returns: the interfaces proxied by the AOP proxy

getProxyTargetClass

public boolean getProxyTargetClass()
Should we proxy the target class as well as any interfaces? Can use this to force CGLIB proxying.
Returns: whether we proxy the target class as well as any interfaces

getTargetSource

public TargetSource getTargetSource()
Return the TargetSource used by this Advised object
Returns: the TargetSource used by this advised object

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.

isInterfaceProxied

public boolean isInterfaceProxied(Class intf)
Return whether this interface is proxied
Parameters:
intf - interface to test
Returns: whether the interface is proxied

removeAdvisor

public boolean removeAdvisor(Advisor advisor)
Remove the given advisor
Parameters:
advisor - advisor to remove
Returns: true if the advisor was removed; false if the advisor was not found and hence could not be removed

removeAdvisor

public void removeAdvisor(int index)
throws AopConfigException
Remove the advisor at the given index
Parameters:
index - index of advisor to remove
Throws:
AopConfigException - if the index is invalid

replaceAdvisor

public 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.

toProxyConfigString

public String toProxyConfigString()
As toString() will normally pass to the target, this returns the equivalent for the AOP proxy
Returns: a string description of the proxy configuration