接口 Advised
- 所有超级接口:
TargetClassAware
public interface Advised extends TargetClassAware
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.
- 从以下版本开始:
- 13.03.2003
- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
AdvisedSupport
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidaddAdvice(int pos, Advice advice)Add the given AOP Alliance Advice at the specified position in the advice chain.voidaddAdvice(Advice advice)Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.voidaddAdvisor(int pos, Advisor advisor)Add an Advisor at the specified position in the chain.voidaddAdvisor(Advisor advisor)Add an advisor at the end of the advisor chain.Advisor[]getAdvisors()Return the advisors applying to this proxy.Class<?>[]getProxiedInterfaces()Return the interfaces proxied by the AOP proxy.TargetSourcegetTargetSource()Return theTargetSourceused by thisAdvisedobject.intindexOf(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.intindexOf(Advisor advisor)Return the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.booleanisExposeProxy()Return whether the factory should expose the proxy as aThreadLocal.booleanisFrozen()Return whether the Advised configuration is frozen, in which case no advice changes can be made.booleanisInterfaceProxied(Class<?> intf)Determine whether the given interface is proxied.booleanisPreFiltered()Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).booleanisProxyTargetClass()Are we proxying the full target class instead of specified interfaces?booleanremoveAdvice(Advice advice)Remove the Advisor containing the given advice.voidremoveAdvisor(int index)Remove the advisor at the given index.booleanremoveAdvisor(Advisor advisor)Remove the given advisor.booleanreplaceAdvisor(Advisor a, Advisor b)Replace the given advisor.voidsetExposeProxy(boolean exposeProxy)Set whether the proxy should be exposed by the AOP framework as aThreadLocalfor retrieval via theAopContextclass.voidsetPreFiltered(boolean preFiltered)Set whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).voidsetTargetSource(TargetSource targetSource)Change theTargetSourceused by thisAdvisedobject.StringtoProxyConfigString()AstoString()will normally be delegated to the target, this returns the equivalent for the AOP proxy.从接口继承的方法 org.springframework.aop.TargetClassAware
getTargetClass
方法详细资料
isFrozen
boolean isFrozen()
Return whether the Advised configuration is frozen, in which case no advice changes can be made.
isProxyTargetClass
boolean isProxyTargetClass()
Are we proxying the full target class instead of specified interfaces?
getProxiedInterfaces
Class<?>[] getProxiedInterfaces()
Return the interfaces proxied by the AOP proxy.Will not include the target class, which may also be proxied.
isInterfaceProxied
boolean isInterfaceProxied(Class<?> intf)
Determine whether the given interface is proxied.- 参数:
intf- the interface to check
setTargetSource
void setTargetSource(TargetSource targetSource)
- 参数:
targetSource- new TargetSource to use
getTargetSource
TargetSource getTargetSource()
Return theTargetSourceused by thisAdvisedobject.
setExposeProxy
void setExposeProxy(boolean exposeProxy)
Set whether the proxy should be exposed by the AOP framework as aThreadLocalfor retrieval via theAopContextclass.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.
isExposeProxy
boolean isExposeProxy()
Return whether the factory should expose the proxy as aThreadLocal.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().- 另请参阅:
AopContext
setPreFiltered
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.
- 另请参阅:
ClassFilter
isPreFiltered
boolean isPreFiltered()
Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).
getAdvisors
Advisor[] getAdvisors()
Return the advisors applying to this proxy.- 返回:
- a list of Advisors applying to this proxy (never
null)
addAdvisor
void addAdvisor(Advisor advisor) throws AopConfigException
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.- 参数:
advisor- the advisor to add to the end of the chain- 抛出:
AopConfigException- in case of invalid advice
addAdvisor
void addAdvisor(int pos, Advisor advisor) throws AopConfigException
Add an Advisor at the specified position in the chain.- 参数:
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 advice
removeAdvisor
boolean removeAdvisor(Advisor advisor)
Remove the given advisor.- 参数:
advisor- the advisor to remove- 返回:
trueif the advisor was removed;falseif the advisor was not found and hence could not be removed
removeAdvisor
void removeAdvisor(int index) throws AopConfigException
Remove the advisor at the given index.- 参数:
index- index of advisor to remove- 抛出:
AopConfigException- if the index is invalid
indexOf
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.
- 参数:
advisor- the advisor to search for- 返回:
- index from 0 of this advisor, or -1 if there's no such advisor
replaceAdvisor
boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException
Replace the given advisor.Note: If the advisor is an
IntroductionAdvisorand 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 with- 返回:
- whether it was replaced. If the advisor wasn't found in the list of advisors, this method returns
falseand does nothing. - 抛出:
AopConfigException- in case of invalid advice
addAdvice
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.Noitle="org.springframework.aop.support中的类">
DefaultPointcutAdvisoraddAdvice
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
DefaultPointcutAdvisorwith a pointcut that always applies, and returned from thegetAdvisors()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 chain- 抛出:
AopConfigException- in case of invalid advice
removeAdvice
boolean removeAdvice(Advice advice)
Remove the Advisor containing the given advice.- 参数:
advice- the advice to remove- 返回:
trueof the advice was found and removed;falseif there was no such advice
indexOf
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.
- 参数:
advice- AOP Alliance advice to search for- 返回:
- index from 0 of this advice, or -1 if there's no such advice
toProxyConfigString
String toProxyConfigString()
AstoString()will normally be delegated to the target, this returns the equivalent for the AOP proxy.- 返回:
- a string description of the proxy configuration