public interface Advised extends TargetClassAware
Any AOP proxy obtained from Spring can be cast to this interface to allow manipulation of its AOP advice.
AdvisedSupport
Modifier and Type | Method and Description |
---|---|
void |
addAdvice(Advice advice)
Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.
|
void |
addAdvice(int pos,
Advice advice)
Add the given AOP Alliance Advice at the specified position in the advice chain.
|
void |
addAdvisor(Advisor advisor)
Add an advisor at the end of the advisor chain.
|
void |
addAdvisor(int pos,
Advisor advisor)
Add an Advisor at the specified position in the chain.
|
Advisor[] |
getAdvisors()
Return the advisors applying to this proxy.
|
java.lang.Class<?>[] |
getProxiedInterfaces()
Return the interfaces proxied by the AOP proxy.
|
TargetSource |
getTargetSource()
Return the TargetSource used by this Advised object.
|
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.
|
int |
indexOf(Advisor advisor)
Return the index (from 0) of the given advisor,
or -1 if no such advisor applies to this proxy.
|
boolean |
isExposeProxy()
Return whether the factory should expose the proxy as a ThreadLocal.
|
boolean |
isFrozen()
Return whether the Advised configuration is frozen,
in which case no advice changes can be made.
|
boolean |
isInterfaceProxied(java.lang.Class<?> intf)
Determine whether the given interface is proxied.
|
boolean |
isPreFiltered()
Return whether this proxy configuration is pre-filtered so that it only
contains applicable advisors (matching this proxy's target class).
|
boolean |
isProxyTargetClass()
Are we proxying the full target class instead of specified interfaces?
|
boolean |
removeAdvice(Advice advice)
Remove the Advisor containing the given advice.
|
boolean |
removeAdvisor(Advisor advisor)
Remove the given advisor.
|
void |
removeAdvisor(int index)
Remove the advisor at the given index.
|
boolean |
replaceAdvisor(Advisor a,
Advisor b)
Replace the given advisor.
|
void |
setExposeProxy(boolean exposeProxy)
Set whether the proxy should be exposed by the AOP framework as a
ThreadLocal for retrieval via the AopContext class.
|
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).
|
void |
setTargetSource(TargetSource targetSource)
Change the TargetSource used by this Advised object.
|
java.lang.String |
toProxyConfigString()
As
toString() will normally be delegated to the target,
this returns the equivalent for the AOP proxy. |
getTargetClass
boolean isFrozen()
boolean isProxyTargetClass()
java.lang.Class<?>[] getProxiedInterfaces()
boolean isInterfaceProxied(java.lang.Class<?> intf)
intf
- the interface to checkvoid setTargetSource(TargetSource targetSource)
targetSource
- new TargetSource to useTargetSource getTargetSource()
void setExposeProxy(boolean exposeProxy)
this
, the invocation will not be advised).
Default is "false", for optimal performance.
boolean isExposeProxy()
this
no advice
will apply.) Getting the proxy is analogous to an EJB calling getEJBObject().AopContext
void setPreFiltered(boolean preFiltered)
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.
ClassFilter
boolean isPreFiltered()
Advisor[] getAdvisors()
null
)void addAdvisor(Advisor advisor) throws AopConfigException
The Advisor may be an IntroductionAdvisor
,
in which new interfaces will be available when a proxy is next obtained
from the relevant factory.
advisor
- the advisor to add to the end of the chainAopConfigException
- in case of invalid advicevoid addAdvisor(int pos, Advisor advisor) throws AopConfigException
advisor
- the advisor to add at the specified position in the chainpos
- position in chain (0 is head). Must be valid.AopConfigException
- in case of invalid adviceboolean removeAdvisor(Advisor advisor)
advisor
- the advisor to removetrue
if the advisor was removed; false
if the advisor was not found and hence could not be removedvoid removeAdvisor(int index) throws AopConfigException
index
- index of advisor to removeAopConfigException
- if the index is invalidint indexOf(Advisor advisor)
The return value of this method can be used to index into the advisors array.
advisor
- the advisor to search forboolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException
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.
a
- the advisor to replaceb
- the advisor to replace it withfalse
and does nothing.AopConfigException
- in case of invalid advicevoid addAdvice(Advice advice) throws AopConfigException
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.
advice
- advice to add to the tail of the chainAopConfigException
- in case of invalid adviceaddAdvice(int, Advice)
,
DefaultPointcutAdvisor
void addAdvice(int pos, Advice advice) throws AopConfigException
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.
pos
- index from 0 (head)advice
- advice to add at the specified position in the advice chainAopConfigException
- in case of invalid adviceboolean removeAdvice(Advice advice)
advice
- the advice to removetrue
of the advice was found and removed;
false
if there was no such adviceint indexOf(Advice advice)
The return value of this method can be used to index into the advisors array.
advice
- AOP Alliance advice to search forjava.lang.String toProxyConfigString()
toString()
will normally be delegated to the target,
this returns the equivalent for the AOP proxy.