类 AdvisedSupport
- 所有已实现的接口:
Advised,TargetClassAware,Serializable
- 直接已知子类:
ProxyCreatorSupport
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.
- 从以下版本开始:
- 3.0 2021/2/1 20:23
- 作者:
- Rod Johnson, Juergen Hoeller, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类修饰符和类型类说明private static classStub for an Advisor instance that is just needed for key purposes, allowing for efficient equals and hashCode comparisons against the advice class and the pointcut.(专用程序包) static final classSimple wrapper class around a Method. -
字段概要
字段修饰符和类型字段说明List of minimalAdvisedSupport.AdvisorKeyEntryinstances, to be assigned to theadvisorsfield on reduction.List of Advisors.private MethodInterceptor[]Cache with shared interceptors which are not method-specific.static final TargetSourceCanonical TargetSource when there's no target, and behavior is supplied by the advisors.private InterceptorChainFactoryThe InterceptorChainFactory to use.Interfaces to be implemented by the proxy.Cache with Method as key and advisor chain List as value.private booleanWhether the Advisors are already filtered for the specific target class.(专用程序包) ObjectOptional field forAopProxyimplementations to store metadata in.private static final long(专用程序包) TargetSourcePackage-protected to allow direct access for efficiency.从类继承的字段 infra.aop.framework.ProxyConfig
exposeProxy, opaque -
构造器概要
构造器构造器说明No-arg constructor for use as a JavaBean.AdvisedSupport(Class<?>... interfaces) Create a AdvisedSupport instance with the given parameters. -
方法概要
修饰符和类型方法说明voidCannot add introductions this way unless the advice implements IntroductionInfo.voidAdd 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.(专用程序包) voidaddAdvisorInternal(int pos, Advisor advisor) voidaddAdvisors(Advisor... advisors) Add all of the given advisors to this proxy configuration.voidaddAdvisors(Collection<Advisor> advisors) Add all of the given advisors to this proxy configuration.voidaddInterface(Class<?> ifc) Add a new proxied interface.protected voidInvoked when advice has changed.booleanadviceIncluded(Advice advice) Is the given advice included in any advisor within this proxy configuration?protected voidCall 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 voidcopyConfigurationFrom(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.intcountAdvicesOfType(Class<?> adviceClass) Count advices of the given class.intReturn the number of advisors applying to this proxy.final Advisor[]Return the advisors applying to this proxy.(专用程序包) AdvisedSupportBuild a configuration-only copy of this AdvisedSupport, replacing the TargetSource.Return the advisor chain factory to use (nevernull).getInterceptors(Method method, Class<?> targetClass) Determine an array ofMethodInterceptorobjects for the given method, based on this configuration.Class<?>[]Return the interfaces proxied by the AOP proxy.Class<?>Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).Return theTargetSourceused by thisAdvisedobject.(专用程序包) booleanintReturn the index (from 0) of the given advisor, or -1 if no such advisor applies to this proxy.intReturn the index (from 0) of the given AOP Alliance Advice, or -1 if no such advice is an advice for this proxy.private booleanisAdvisorIntroducedInterface(Class<?> ifc) booleanisInterfaceProxied(Class<?> ifc) Determine whether the given interface is proxied.booleanReturn whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).private void(专用程序包) voidbooleanremoveAdvice(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.booleanremoveInterface(Class<?> ifc) Remove a proxied interface.booleanreplaceAdvisor(Advisor a, Advisor b) Replace the given advisor.voidsetInterceptorChainFactory(InterceptorChainFactory interceptorChainFactory) Set the advisor chain factory to use.voidsetInterfaces(Class<?>... interfaces) Set the interfaces to be proxied.voidsetPreFiltered(boolean preFiltered) Set whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).voidSet the given object as target.voidsetTargetClass(Class<?> targetClass) Set a target class to be proxied, indicating that the proxy should be cast-able to the given class.voidsetTargetSource(TargetSource targetSource) Change theTargetSourceused by thisAdvisedobject.AstoString()will normally be delegated to the target, this returns the equivalent for the AOP proxy.toString()For debugging/diagnostic use.private void从类继承的方法 infra.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从接口继承的方法 infra.aop.framework.Advised
isExposeProxy, isFrozen, isProxyTargetClass, setExposeProxy
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
EMPTY_TARGET_SOURCE
Canonical TargetSource when there's no target, and behavior is supplied by the advisors. -
targetSource
TargetSource targetSourcePackage-protected to allow direct access for efficiency. -
preFiltered
private boolean preFilteredWhether the Advisors are already filtered for the specific target class. -
interceptorChainFactory
The InterceptorChainFactory to use. -
interfaces
Interfaces to be implemented by the proxy. Held in List to keep the order of registration, to create JDK proxy with specified order of interfaces. -
advisors
List of Advisors. If Advice is added, it will be wrapped in an Advisor before being added to this List. -
advisorKey
List of minimalAdvisedSupport.AdvisorKeyEntryinstances, to be assigned to theadvisorsfield on reduction.- 从以下版本开始:
- 4.0
- 另请参阅:
-
methodCache
@Nullable private transient ConcurrentHashMap<AdvisedSupport.MethodCacheKey,MethodInterceptor[]> methodCacheCache with Method as key and advisor chain List as value. -
cachedInterceptors
Cache with shared interceptors which are not method-specific.- 从以下版本开始:
- 4.0
-
proxyMetadataCache
Optional field forAopProxyimplementations to store metadata in. Used forJdkDynamicAopProxy.ProxiedInterfacesCache.- 从以下版本开始:
- 4.0
- 另请参阅:
-
-
构造器详细资料
-
AdvisedSupport
public AdvisedSupport()No-arg constructor for use as a JavaBean. -
AdvisedSupport
Create a AdvisedSupport instance with the given parameters.- 参数:
interfaces- the proxied interfaces
-
-
方法详细资料
-
setTarget
Set the given object as target. Will create a SingletonTargetSource for the object. -
setTargetSource
从接口复制的说明:Advised- 指定者:
setTargetSource在接口中Advised- 参数:
targetSource- new TargetSource to use
-
getTargetSource
从接口复制的说明:AdvisedReturn theTargetSourceused by thisAdvisedobject.- 指定者:
getTargetSource在接口中Advised
-
setInterceptorChainFactory
Set the advisor chain factory to use.Default is a
DefaultInterceptorChainFactory.- 从以下版本开始:
- 4.0
-
getInterceptorChainFactory
Return the advisor chain factory to use (nevernull).- 从以下版本开始:
- 4.0
-
setTargetClass
Set a target class to be proxied, indicating that the proxy should be cast-able to the given class.Internally, an
EmptyTargetSourcefor 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
从接口复制的说明:TargetClassAwareReturn the target class behind the implementing object (typically a proxy configuration or an actual proxy).- 指定者:
getTargetClass在接口中TargetClassAware- 返回:
- the target Class, or
nullif not known
-
setPreFiltered
public void setPreFiltered(boolean preFiltered) 从接口复制的说明:AdvisedSet 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- 另请参阅:
-
isPreFiltered
public boolean isPreFiltered()从接口复制的说明:AdvisedReturn whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).- 指定者:
isPreFiltered在接口中Advised
-
setInterfaces
Set the interfaces to be proxied. -
addInterface
Add a new proxied interface.- 参数:
ifc- the additional interface to proxy
-
removeInterface
Remove a proxied interface.Does nothing if the given interface isn't proxied.
- 参数:
ifc- the interface to remove from the proxy- 返回:
trueif the interface was removed;falseif the interface was not found and hence could not be removed
-
getProxiedInterfaces
从接口复制的说明:AdvisedReturn the interfaces proxied by the AOP proxy.Will not include the target class, which may also be proxied.
- 指定者:
getProxiedInterfaces在接口中Advised
-
isInterfaceProxied
从接口复制的说明:AdvisedDetermine whether the given interface is proxied.- 指定者:
isInterfaceProxied在接口中Advised- 参数:
ifc- the interface to check
-
hasUserSuppliedInterfaces
boolean hasUserSuppliedInterfaces() -
isAdvisorIntroducedInterface
-
getAdvisors
从接口复制的说明:AdvisedReturn the advisors applying to this proxy.- 指定者:
getAdvisors在接口中Advised- 返回:
- an array of Advisors applying to this proxy (never
null)
-
getAdvisorCount
public int getAdvisorCount()从接口复制的说明:AdvisedReturn the number of advisors applying to this proxy.The default implementation delegates to
getAdvisors().length.- 指定者:
getAdvisorCount在接口中Advised
-
addAdvisor
从接口复制的说明:AdvisedAdd 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
从接口复制的说明:AdvisedAdd 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
-
removeAdvisor
从接口复制的说明:AdvisedRemove the given advisor.- 指定者:
removeAdvisor在接口中Advised- 参数:
advisor- the advisor to remove- 返回:
trueif the advisor was removed;falseif the advisor was not found and hence could not be removed
-
removeAdvisor
public void removeAdvisor(int index) 从接口复制的说明:AdvisedRemove the advisor at the given index.- 指定者:
removeAdvisor在接口中Advised- 参数:
index- the index of advisor to remove
-
indexOf
从接口复制的说明:AdvisedReturn 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
从接口复制的说明:AdvisedReplace 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.- 指定者:
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
falseand does nothing. - 抛出:
AopConfigException- in case of invalid advice
-
addAdvisors
Add all of the given advisors to this proxy configuration.- 参数:
advisors- the advisors to register
-
addAdvisors
Add all of the given advisors to this proxy configuration.- 参数:
advisors- the advisors to register
-
validateIntroductionAdvisor
-
addAdvisorInternal
-
getAdvisorsInternal
Allows uncontrolled access to theListofAdvisors.Use with care, and remember to
fire advice changed eventswhen making any modifications. -
addAdvice
从接口复制的说明:AdvisedAdd 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- 另请参阅:
-
addAdvice
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
从接口复制的说明:AdvisedRemove the Advisor containing the given advice.- 指定者:
removeAdvice在接口中Advised- 参数:
advice- the advice to remove- 返回:
trueof the advice was found and removed;falseif there was no such advice- 抛出:
AopConfigException
-
indexOf
从接口复制的说明:AdvisedReturn 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
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
Count advices of the given class.- 参数:
adviceClass- the advice class to check- 返回:
- the count of the interceptors of this class or subclasses
-
getInterceptors
Determine an array ofMethodInterceptorobjects for the given method, based on this configuration.ordered
MethodInterceptorarray- 参数:
method- the proxied methodtargetClass- the target class- 返回:
- a array of MethodInterceptors (may also include
RuntimeMethodInterceptor) - 另请参阅:
-
adviceChanged
protected void adviceChanged()Invoked when advice has changed. -
copyConfigurationFrom
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
-
getConfigurationOnlyCopy
AdvisedSupport getConfigurationOnlyCopy()Build a configuration-only copy of this AdvisedSupport, replacing the TargetSource. -
reduceToAdvisorKey
void reduceToAdvisorKey() -
readObject
-
toProxyConfigString
从接口复制的说明:AdvisedAstoString()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
For debugging/diagnostic use.- 覆盖:
toString在类中ProxyConfig
-