类 AdvisedSupport
- java.lang.Object
- org.springframework.aop.framework.ProxyConfig
- org.springframework.aop.framework.AdvisedSupport
- 所有已实现的接口:
Serializable
,Advised
,TargetClassAware
- 直接已知子类:
ProxyCreatorSupport
public class AdvisedSupport extends ProxyConfig implements Advised
Base class for AOP proxy configuration managers. These are not themselves AOP proxies, but subclasses of this class are normally factories from which AOP proxy instances are obtained directly.This class frees subclasses of the housekeeping of Advices and Advisors, but doesn't actually implement proxy creation methods, which are provided by subclasses.
This class is serializable; subclasses need not be. This class is used to hold snapshots of proxies.
字段概要
字段 修饰符和类型 字段 说明 static TargetSource
EMPTY_TARGET_SOURCE
Canonical TargetSource when there's no target, and behavior is supplied by the advisors.
构造器概要
构造器 构造器 说明 AdvisedSupport()
No-arg constructor for use as a JavaBean.AdvisedSupport(Class<?>... interfaces)
Create a AdvisedSupport instance with the given parameters.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addAdvice(int pos, Advice advice)
Cannot add introductions this way unless the advice implements IntroductionInfo.void
addAdvice(Advice advice)
Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.void
addAdvisor(int pos, Advisor advisor)
Add an Advisor at the specified position in the chain.void
addAdvisor(Advisor advisor)
Add an advisor at the end of the advisor chain.void
addAdvisors(Collection<Advisor> advisors)
Add all of the given advisors to this proxy configuration.void
addAdvisors(Advisor... advisors)
Add all of the given advisors to this proxy configuration.void
addInterface(Class<?> intf)
Add a new proxied interface.protected void
adviceChanged()
Invoked when advice has changed.boolean
adviceIncluded(Advice advice)
Is the given advice included in any advisor within this proxy configuration?protected void
copyConfigurationFrom(AdvisedSupport other)
Call this method on a new instance created by the no-arg constructor to create an independent copy of the configuration from the given object.protected void
copyConfigurationFrom(AdvisedSupport other, TargetSource targetSource, List<Advisor> advisors)
Copy the AOP configuration from the given AdvisedSupport object, but allow substitution of a fresh TargetSource and a given interceptor chain.int
countAdvicesOfType(Class<?> adviceClass)
Count advices of the given class.AdvisorChainFactory
getAdvisorChainFactory()
Return the advisor chain factory to use (nevernull
).Advisor[]
getAdvisors()
Return the advisors applying to this proxy.protected List<Advisor>
getAdvisorsInternal()
List<Object>
getInterceptorsAndDynamicInterceptionAdvice(Method method, Class<?> targetClass)
Determine a list ofMethodInterceptor
objects for the given method, based on this configuration.Class<?>[]
getProxiedInterfaces()
Return the interfaces proxied by the AOP proxy.Class<?>
getTargetClass()
Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).TargetSource
getTargetSource()
Return theTargetSource
used by thisAdvised
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
isInterfaceProxied(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
removeAdvice(Advice advice)
Remove the Advisor containing the given advice.void
removeAdvisor(int index)
Remove the advisor at the given index.boolean
removeAdvisor(Advisor advisor)
Remove the given advisor.boolean
removeInterface(Class<?> intf)
Remove a proxied interface.boolean
replaceAdvisor(Advisor a, Advisor b)
Replace the given advisor.void
setAdvisorChainFactory(AdvisorChainFactory advisorChainFactory)
Set the advisor chain factory to use.void
setInterfaces(Class<?>... interfaces)
Set the interfaces to be proxied.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
setTarget(Object target)
Set the given object as target.void
setTargetClass(Class<?> targetClass)
Set a target class to be proxied, indicating that the proxy should be castable to the given class.void
setTargetSource(TargetSource targetSource)
Change theTargetSource
used by thisAdvised
object.String
toProxyConfigString()
AstoString()
will normally be delegated to the target, this returns the equivalent for the AOP proxy.String
toString()
For debugging/diagnostic use.protected void
updateAdvisorArray()
Bring the array up to date with the list.从类继承的方法 org.springframework.aop.framework.ProxyConfig
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.aop.framework.Advised
isExposeProxy, isFrozen, isProxyTargetClass, setExposeProxy
字段详细资料
EMPTY_TARGET_SOURCE
public static final TargetSource EMPTY_TARGET_SOURCE
Canonical TargetSource when there's no target, and behavior is supplied by the advisors.
构造器详细资料
AdvisedSupport
public AdvisedSupport()
No-arg constructor for use as a JavaBean.
AdvisedSupport
public AdvisedSupport(Class<?>... interfaces)
Create a AdvisedSupport instance with the given parameters.- 参数:
interfaces
- the proxied interfaces
方法详细资料
setTarget
public void setTarget(Object target)
Set the given object as target. Will create a SingletonTargetSource for the object.
setTargetSource
public void setTargetSource(@Nullable TargetSource targetSource)
从接口复制的说明:Advised
- 指定者:
setTargetSource
在接口中Advised
- 参数:
targetSource
- new TargetSource to use
getTargetSource
public TargetSource getTargetSource()
从接口复制的说明:Advised
Return theTargetSource
used by thisAdvised
object.- 指定者:
getTargetSource
在接口中Advised
setTargetClass
public void setTargetClass(@Nullable Class<?> targetClass)
Set a target class to be proxied, indicating that the proxy should be castable to the given class.Internally, an
EmptyTargetSource
for the given target class will be used. The kind of proxy needed will be determined on actual creation of the proxy.This is a replacement for setting a "targetSource" or "target", for the case where we want a proxy based on a target class (which can be an interface or a concrete class) without having a fully capable TargetSource available.
getTargetClass
@Nullable public Class<?> getTargetClass()
从接口复制的说明:TargetClassAware
Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).- 指定者:
getTargetClass
在接口中TargetClassAware
- 返回:
- the target Class, or
null
if not known
setPreFiltered
public void setPreFiltered(boolean preFiltered)
从接口复制的说明:Advised
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.
- 指定者:
setPreFiltered
在接口中Advised
- 另请参阅:
ClassFilter
isPreFiltered
public boolean isPreFiltered()
从接口复制的说明:Advised
Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).- 指定者:
isPreFiltered
在接口中Advised
setAdvisorChainFactory
public void setAdvisorChainFactory(AdvisorChainFactory advisorChainFactory)
Set the advisor chain factory to use.Default is a
DefaultAdvisorChainFactory
.
getAdvisorChainFactory
public AdvisorChainFactory getAdvisorChainFactory()
Return the advisor chain factory to use (nevernull
).
setInterfaces
public void setInterfaces(Class<?>... interfaces)
Set the interfaces to be proxied.
addInterface
public void addInterface(Class<?> intf)
Add a new proxied interface.- 参数:
intf
- the additional interface to proxy
removeInterface
public boolean removeInterface(Class<?> intf)
Remove a proxied interface.Does nothing if the given interface isn't proxied.
- 参数:
intf
- the interface to remove from the proxy- 返回:
true
if the interface was removed;false
if the interface was not found and hence could not be removed
getProxiedInterfaces
public Class<?>[] getProxiedInterfaces()
从接口复制的说明:Advised
Return the interfaces proxied by the AOP proxy.Will not include the target class, which may also be proxied.
- 指定者:
getProxiedInterfaces
在接口中Advised
isInterfaceProxied
public boolean isInterfaceProxied(Class<?> intf)
从接口复制的说明:Advised
Determine whether the given interface is proxied.- 指定者:
isInterfaceProxied
在接口中Advised
- 参数:
intf
- the interface to check
getAdvisors
public final Advisor[] getAdvisors()
从接口复制的说明:Advised
Return the advisors applying to this proxy.- 指定者:
getAdvisors
在接口中Advised
- 返回:
- a list of Advisors applying to this proxy (never
null
)
addAdvisor
public void addAdvisor(Advisor advisor)
从接口复制的说明:Advised
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.- 指定者:
addAdvisor
在接口中Advised
- 参数:
advisor
- the advisor to add to the end of the chain
addAdvisor
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException
从接口复制的说明:Advised
Add an Advisor at the specified position in the chain.- 指定者:
addAdvisor
在接口中Advised
- 参数:
pos
- position in chain (0 is head). Must be valid.advisor
- the advisor to add at the specified position in the chain- 抛出:
AopConfigException
- in case of invalid advice
removeAdvisor
public boolean removeAdvisor(Advisor advisor)
从接口复制的说明:Advised
Remove the given advisor.- 指定者:
removeAdvisor
在接口中Advised
- 参数:
advisor
- the advisor to remove- 返回:
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
从接口复制的说明:Advised
Remove the advisor at the given index.- 指定者:
removeAdvisor
在接口中Advised
- 参数:
index
- the index of advisor to remove- 抛出:
AopConfigException
- if the index is invalid
indexOf
public int indexOf(Advisor advisor)
从接口复制的说明:Advised
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.
replaceAdvisor
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException
从接口复制的说明:Advised
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.- 指定者:
replaceAdvisor
在接口中Advised
- 参数:
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
false
and does nothing. - 抛出:
AopConfigException
- in case of invalid advice
addAdvisors
public void addAdvisors(Advisor... advisors)
Add all of the given advisors to this proxy configuration.- 参数:
advisors
- the advisors to register
addAdvisors
public void addAdvisors(Collection<Advisor> advisors)
Add all of the given advisors to this proxy configuration.- 参数:
advisors
- the advisors to register
updateAdvisorArray
protected final void updateAdvisorArray()
Bring the array up to date with the list.
getAdvisorsInternal
protected final List<Advisor> getAdvisorsInternal()
Allows uncontrolled access to theList
ofAdvisors
.Use with care, and remember to
refresh the advisor array
andfire advice changed events
when making any modifications.
addAdvice
public void addAdvice(Advice advice) throws AopConfigException
从接口复制的说明:Advised
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.- 指定者:
addAdvice
在接口中Advised
- 参数:
advice
- the advice to add to the tail of the chain- 抛出:
AopConfigException
- in case of invalid advice- 另请参阅:
Advised.addAdvice(int, Advice)
,DefaultPointcutAdvisor
addAdvice
public void addAdvice(int pos, Advice advice) throws AopConfigException
Cannot add introductions this way unless the advice implements IntroductionInfo.- 指定者:
addAdvice
在接口中Advised
- 参数:
pos
- index from 0 (head)advice
- the advice to add at the specified position in the advice chain- 抛出:
AopConfigException
- in case of invalid advice
removeAdvice
public boolean removeAdvice(Advice advice) throws AopConfigException
从接口复制的说明:Advised
Remove the Advisor containing the given advice.- 指定者:
removeAdvice
在接口中Advised
- 参数:
advice
- the advice to remove- 返回:
true
of the advice was found and removed;false
if there was no such advice- 抛出:
AopConfigException
indexOf
public int indexOf(Advice advice)
从接口复制的说明:Advised
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.
adviceIncluded
public boolean adviceIncluded(@Nullable Advice advice)
Is the given advice included in any advisor within this proxy configuration?- 参数:
advice
- the advice to check inclusion of- 返回:
- whether this advice instance is included
countAdvicesOfType
public int countAdvicesOfType(@Nullable Class<?> adviceClass)
Count advices of the given class.- 参数:
adviceClass
- the advice class to check- 返回:
- the count of the interceptors of this class or subclasses
getInterceptorsAndDynamicInterceptionAdvice
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(Method method, @Nullable Class<?> targetClass)
Determine a list ofMethodInterceptor
objects for the given method, based on this configuration.- 参数:
method
- the proxied methodtargetClass
- the target class- 返回:
- a List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
adviceChanged
protected void adviceChanged()
Invoked when advice has changed.
copyConfigurationFrom
protected void copyConfigurationFrom(AdvisedSupport other)
Call this method on a new instance created by the no-arg constructor to create an independent copy of the configuration from the given object.- 参数:
other
- the AdvisedSupport object to copy configuration from
copyConfigurationFrom
protected void copyConfigurationFrom(AdvisedSupport other, TargetSource targetSource, List<Advisor> advisors)
Copy the AOP configuration from the given AdvisedSupport object, but allow substitution of a fresh TargetSource and a given interceptor chain.- 参数:
other
- the AdvisedSupport object to take proxy configuration fromtargetSource
- the new TargetSourceadvisors
- the Advisors for the chain
toProxyConfigString
public String toProxyConfigString()
从接口复制的说明:Advised
AstoString()
will normally be delegated to the target, this returns the equivalent for the AOP proxy.- 指定者:
toProxyConfigString
在接口中Advised
- 返回:
- a string description of the proxy configuration
toString
public String toString()
For debugging/diagnostic use.- 覆盖:
toString
在类中ProxyConfig