Top Description Methods
org.springframework.aop.framework

public Interface Advised

extends TargetClassAware
Known Direct Implementers
org.springframework.aop.framework.AdvisedSupport
Imports
org.aopalliance.aop.Advice, org.springframework.aop.Advisor, .TargetClassAware, .TargetSource

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

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

Authors
Rod Johnson, Juergen Hoeller
Since
13.03.2003
See Also
org.springframework.aop.framework.AdvisedSupport

Method Summary

Modifier and TypeMethod and Description
public void
addAdvice(Advice
the advice to add to the tail of the chain
advice
)

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

public void
addAdvice(int
index from 0 (head)
pos
,
Advice
the advice to add at the specified position in the advice chain
advice
)

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

public void
addAdvisor(Advisor
the advisor to add to the end of the chain
advisor
)

Add an advisor at the end of the advisor chain.

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

Add an Advisor at the specified position in the chain.

public default int
getAdvisorCount()

Return the number of advisors applying to this proxy.

public Advisor[]

Returns:

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

Return the advisors applying to this proxy.

public Class<?>[]
getProxiedInterfaces()

Return the interfaces proxied by the AOP proxy.

public TargetSource
getTargetSource()

Return the TargetSource used by this Advised object.

public int

Returns:

index from 0 of this advisor, or -1 if there's no such advisor
indexOf
(Advisor
the advisor to search for
advisor
)

Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.

public int

Returns:

index from 0 of this advice, or -1 if there's no such advice
indexOf
(Advice
the AOP Alliance advice to search for
advice
)

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

public boolean
isExposeProxy()

Return whether the factory should expose the proxy as a ThreadLocal.

public boolean
isFrozen()

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

public boolean
isInterfaceProxied(Class<?>
the interface to check
intf
)

Determine whether the given interface is proxied.

public boolean
isPreFiltered()

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

public boolean
isProxyTargetClass()

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

public boolean

Returns:

true of the advice was found and removed; false if there was no such advice
removeAdvice
(Advice
the advice to remove
advice
)

Remove the Advisor containing the given advice.

public boolean

Returns:

true if the advisor was removed; false if the advisor was not found and hence could not be removed
removeAdvisor
(Advisor
the advisor to remove
advisor
)

Remove the given advisor.

public void
removeAdvisor(int
the index of advisor to remove
index
)

Remove the advisor at the given index.

public boolean

Returns:

whether it was replaced. If the advisor wasn't found in the list of advisors, this method returns false and does nothing.
replaceAdvisor
(Advisor
the advisor to replace
a
,
Advisor
the advisor to replace it with
b
)

Replace the given advisor.

public void
setExposeProxy(boolean exposeProxy)

Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class.

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

public void
setTargetSource(TargetSource
new TargetSource to use
targetSource
)

Change the TargetSource used by this Advised object.

public String

Returns:

a string description of the proxy configuration
toProxyConfigString
()

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

Inherited from org.springframework.aop.TargetClassAware:
getTargetClass

Method Detail

addAdviceback to summary
public void addAdvice(Advice advice) throws AopConfigException

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

the advice to add to the tail of the chain

Exceptions
AopConfigException:
in case of invalid advice
See Also
addAdvice(int, Advice), org.springframework.aop.support.DefaultPointcutAdvisor
addAdviceback to summary
public void addAdvice(int pos, Advice advice) throws AopConfigException

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

This will be wrapped in a org.springframework.aop.support.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:int

index from 0 (head)

advice:Advice

the advice to add at the specified position in the advice chain

Exceptions
AopConfigException:
in case of invalid advice
addAdvisorback to summary
public void addAdvisor(Advisor advisor) throws AopConfigException

Add an advisor at the end of the advisor chain.

The Advisor may be an org.springframework.aop.IntroductionAdvisor, in which new interfaces will be available when a proxy is next obtained from the relevant factory.

Parameters
advisor:Advisor

the advisor to add to the end of the chain

Exceptions
AopConfigException:
in case of invalid advice
addAdvisorback to summary
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException

Add an Advisor at the specified position in the chain.

Parameters
pos:int

position in chain (0 is head). Must be valid.

advisor:Advisor

the advisor to add at the specified position in the chain

Exceptions
AopConfigException:
in case of invalid advice
getAdvisorCountback to summary
public default int getAdvisorCount()

Return the number of advisors applying to this proxy.

The default implementation delegates to getAdvisors().length.

Since
5.3.1
getAdvisorsback to summary
public Advisor[] getAdvisors()

Return the advisors applying to this proxy.

Returns:Advisor[]

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

getProxiedInterfacesback to summary
public Class<?>[] getProxiedInterfaces()

Return the interfaces proxied by the AOP proxy.

Will not include the target class, which may also be proxied.

getTargetSourceback to summary
public TargetSource getTargetSource()

Return the TargetSource used by this Advised object.

indexOfback to summary
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

the advisor to search for

Returns:int

index from 0 of this advisor, or -1 if there's no such advisor

indexOfback to summary
public 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:Advice

the AOP Alliance advice to search for

Returns:int

index from 0 of this advice, or -1 if there's no such advice

isExposeProxyback to summary
public boolean isExposeProxy()

Return whether the factory should expose the proxy as a ThreadLocal.

It can be necessary to expose the proxy if an advised object needs to invoke a method on itself with advice applied. Otherwise, if an advised object invokes a method on this, no advice will be applied.

Getting the proxy is analogous to an EJB calling getEJBObject().

See Also
AopContext
isFrozenback to summary
public boolean isFrozen()

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

isInterfaceProxiedback to summary
public boolean isInterfaceProxied(Class<?> intf)

Determine whether the given interface is proxied.

Parameters
intf:Class<?>

the interface to check

isPreFilteredback to summary
public boolean isPreFiltered()

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

isProxyTargetClassback to summary
public boolean isProxyTargetClass()

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

removeAdviceback to summary
public boolean removeAdvice(Advice advice)

Remove the Advisor containing the given advice.

Parameters
advice:Advice

the advice to remove

Returns:boolean

true of the advice was found and removed; false if there was no such advice

removeAdvisorback to summary
public boolean removeAdvisor(Advisor advisor)

Remove the given advisor.

Parameters
advisor:Advisor

the advisor to remove

Returns:boolean

true if the advisor was removed; false if the advisor was not found and hence could not be removed

removeAdvisorback to summary
public void removeAdvisor(int index) throws AopConfigException

Remove the advisor at the given index.

Parameters
index:int

the index of advisor to remove

Exceptions
AopConfigException:
if the index is invalid
replaceAdvisorback to summary
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException

Replace the given advisor.

Note

If the advisor is an org.springframework.aop.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

the advisor to replace

b:Advisor

the advisor to replace it with

Returns:boolean

whether it was replaced. If the advisor wasn't found in the list of advisors, this method returns false and does nothing.

Exceptions
AopConfigException:
in case of invalid advice
setExposeProxyback to summary
public void setExposeProxy(boolean exposeProxy)

Set whether the proxy should be exposed by the AOP framework as a ThreadLocal for retrieval via the AopContext class.

It can be necessary to expose the proxy if an advised object needs to invoke a method on itself with advice applied. Otherwise, if an advised object invokes a method on this, no advice will be applied.

Default is false, for optimal performance.

setPreFilteredback to summary
public 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
org.springframework.aop.ClassFilter
setTargetSourceback to summary
public void setTargetSource(TargetSource targetSource)

Change the TargetSource used by this Advised object.

Only works if the configuration isn't frozen.

Parameters
targetSource:TargetSource

new TargetSource to use

toProxyConfigStringback to summary
public String toProxyConfigString()

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

Returns:String

a string description of the proxy configuration