public interface

Advised

implements TargetClassAware
org.springframework.aop.framework.Advised
Known Indirect Subclasses

Class Overview

Interface to be implemented by classes that hold the configuration of a factory of AOP proxies. This configuration includes the Interceptors and other advice, 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.

See Also

Summary

Public Methods
abstract void addAdvice(int pos, Advice advice)
Add the given AOP Alliance Advice at the specified position in the advice chain.
abstract void addAdvice(Advice advice)
Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.
abstract void addAdvisor(Advisor advisor)
Add an advisor at the end of the advisor chain.
abstract void addAdvisor(int pos, Advisor advisor)
Add an Advisor at the specified position in the chain.
abstract Advisor[] getAdvisors()
Return the advisors applying to this proxy.
abstract Class[] getProxiedInterfaces()
Return the interfaces proxied by the AOP proxy.
abstract TargetSource getTargetSource()
Return the TargetSource used by this Advised object.
abstract int indexOf(Advisor advisor)
Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.
abstract int indexOf(Advice advice)
Return the index (from 0) of the given AOP Alliance Advice, or -1 if no such advice is an advice for this proxy.
abstract boolean isExposeProxy()
Return whether the factory should expose the proxy as a ThreadLocal.
abstract boolean isFrozen()
Return whether the Advised configuration is frozen, in which case no advice changes can be made.
abstract boolean isInterfaceProxied(Class intf)
Determine whether the given interface is proxied.
abstract boolean isPreFiltered()
Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).
abstract boolean isProxyTargetClass()
Are we proxying the full target class instead of specified interfaces?
abstract boolean removeAdvice(Advice advice)
Remove the Advisor containing the given advice.
abstract void removeAdvisor(int index)
Remove the advisor at the given index.
abstract boolean removeAdvisor(Advisor advisor)
Remove the given advisor.
abstract boolean replaceAdvisor(Advisor a, Advisor b)
Replace the given advisor.
abstract void setExposeProxy(boolean exposeProxy)
Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class.
abstract void setPreFiltered(boolean preFiltered)
Set whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).
abstract void setTargetSource(TargetSource targetSource)
Change the TargetSource used by this Advised object.
abstract String toProxyConfigString()
As toString() will normally be delegated to the target, this returns the equivalent for the AOP proxy.
[Expand]
Inherited Methods
From interface org.springframework.aop.TargetClassAware

Public Methods

public abstract void addAdvice (int pos, Advice advice)

Add the given AOP Alliance Advice at the specified position in the advice chain.

This will be wrapped in a DefaultPointcutAdvisor with a pointcut that always applies, and returned from the getAdvisors() method in this wrapped form.

Note: The given advice will apply to all invocations on the proxy, even to the toString() method! Use appropriate advice implementations or specify appropriate pointcuts to apply to a narrower set of methods.

Parameters
pos index from 0 (head)
advice advice to add at the specified position in the advice chain
Throws
AopConfigException in case of invalid advice

public abstract void addAdvice (Advice advice)

Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.

This will be wrapped in a DefaultPointcutAdvisor with a pointcut that always applies, and returned from the getAdvisors() method in this wrapped form.

Note that the given advice will apply to all invocations on the proxy, even to the toString() method! Use appropriate advice implementations or specify appropriate pointcuts to apply to a narrower set of methods.

Parameters
advice advice to add to the tail of the chain
Throws
AopConfigException in case of invalid advice

public abstract 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 the advisor to add to the end of the chain
Throws
AopConfigException in case of invalid advice

public abstract void addAdvisor (int pos, Advisor advisor)

Add an Advisor at the specified position in the chain.

Parameters
pos position in chain (0 is head). Must be valid.
advisor the advisor to add at the specified position in the chain
Throws
AopConfigException in case of invalid advice

public abstract Advisor[] getAdvisors ()

Return the advisors applying to this proxy.

Returns
  • a list of Advisors applying to this proxy (never null)

public abstract Class[] getProxiedInterfaces ()

Return the interfaces proxied by the AOP proxy. Will not include the target class, which may also be proxied.

public abstract TargetSource getTargetSource ()

Return the TargetSource used by this Advised object.

public abstract 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 the advisor to search for
Returns
  • index from 0 of this advisor, or -1 if there's no such advisor

public abstract int indexOf (Advice advice)

Return the index (from 0) of the given AOP Alliance Advice, or -1 if no such advice is an advice for this proxy.

The return value of this method can be used to index into the advisors array.

Parameters
advice AOP Alliance advice to search for
Returns
  • index from 0 of this advice, or -1 if there's no such advice

public abstract boolean isExposeProxy ()

Return 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().

See Also

public abstract boolean isFrozen ()

Return whether the Advised configuration is frozen, in which case no advice changes can be made.

public abstract boolean isInterfaceProxied (Class intf)

Determine whether the given interface is proxied.

Parameters
intf the interface to check

public abstract boolean isPreFiltered ()

Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).

public abstract boolean isProxyTargetClass ()

Are we proxying the full target class instead of specified interfaces?

public abstract boolean removeAdvice (Advice advice)

Remove the Advisor containing the given advice.

Parameters
advice the advice to remove
Returns
  • true of the advice was found and removed; false if there was no such advice

public abstract void removeAdvisor (int index)

Remove the advisor at the given index.

Parameters
index index of advisor to remove
Throws
AopConfigException if the index is invalid

public abstract boolean removeAdvisor (Advisor advisor)

Remove the given advisor.

Parameters
advisor the advisor to remove
Returns
  • true if the advisor was removed; false if the advisor was not found and hence could not be removed

public abstract boolean replaceAdvisor (Advisor a, Advisor b)

Replace the given advisor.

Note: 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 the advisor to replace
b the 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.
Throws
AopConfigException in case of invalid advice

public abstract void setExposeProxy (boolean exposeProxy)

Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class. This is useful if an advised object needs to call another advised method on itself. (If it uses this, the invocation will not be advised).

Default is "false", for optimal performance.

public abstract void setPreFiltered (boolean preFiltered)

Set whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).

Default is "false". Set this to "true" if the advisors have been pre-filtered already, meaning that the ClassFilter check can be skipped when building the actual advisor chain for proxy invocations.

See Also

public abstract void setTargetSource (TargetSource targetSource)

Change the TargetSource used by this Advised object. Only works if the configuration isn't frozen.

Parameters
targetSource new TargetSource to use

public abstract String toProxyConfigString ()

As toString() will normally be delegated to the target, this returns the equivalent for the AOP proxy.

Returns
  • a string description of the proxy configuration