|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.aop.framework.ProxyConfig org.springframework.aop.framework.AdvisedSupport
public class AdvisedSupport
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.
AopProxy
,
Serialized FormField Summary | |
---|---|
(package private) AdvisorChainFactory |
advisorChainFactory
The AdvisorChainFactory to use |
static TargetSource |
EMPTY_TARGET_SOURCE
Canonical TargetSource when there's no target, and behavior is supplied by the advisors. |
(package private) TargetSource |
targetSource
Package-protected to allow direct access for efficiency |
Fields inherited from class org.springframework.aop.framework.ProxyConfig |
---|
exposeProxy, logger |
Constructor Summary | |
---|---|
AdvisedSupport()
No-arg constructor for use as a JavaBean. |
|
AdvisedSupport(Class[] interfaces)
Create a AdvisedSupport instance with the given parameters. |
Method Summary | |
---|---|
void |
addAdvice(Advice advice)
Add the given AOP Alliance advice to the tail of the advice (interceptor) chain. |
void |
addAdvice(int pos,
Advice advice)
Cannot add introductions this way unless the advice implements IntroductionInfo. |
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. |
void |
addAdvisor(int pos,
IntroductionAdvisor advisor)
|
void |
addInterface(Class intf)
Add a new proxied interface. |
void |
addListener(AdvisedSupportListener listener)
Add the given AdvisedSupportListener to this proxy configuration. |
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 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. |
protected AopProxy |
createAopProxy()
Subclasses should call this to get a new AOP proxy. |
AdvisorChainFactory |
getAdvisorChainFactory()
Return the advisor chain factory to use (never null ). |
Advisor[] |
getAdvisors()
Return the advisors applying to this proxy. |
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. |
protected boolean |
isActive()
Subclasses can call this to check whether any AOP proxies have been created yet. |
boolean |
isInterfaceProxied(Class intf)
Determine whether the given interface is proxied. |
protected Object |
readResolve()
Initializes transient fields. |
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 |
removeInterface(Class intf)
Remove a proxied interface. |
void |
removeListener(AdvisedSupportListener listener)
Remove the given AdvisedSupportListener from this proxy configuration. |
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 |
setTarget(Object target)
Set the given object as target. |
void |
setTargetSource(TargetSource targetSource)
Change the TargetSource used by this Advised object. |
String |
toProxyConfigString()
As toString() will normally be delegated to the target,
this returns the equivalent for the AOP proxy. |
String |
toString()
For debugging/diagnostic use. |
protected Object |
writeReplace()
Serializes a copy of the state of this class, ignoring subclass state. |
Methods inherited from class org.springframework.aop.framework.ProxyConfig |
---|
copyFrom, getAopProxyFactory, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setAopProxyFactory, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.aop.framework.Advised |
---|
isExposeProxy, isFrozen, isProxyTargetClass, setExposeProxy |
Field Detail |
---|
public static final TargetSource EMPTY_TARGET_SOURCE
TargetSource targetSource
transient AdvisorChainFactory advisorChainFactory
Constructor Detail |
---|
public AdvisedSupport()
public AdvisedSupport(Class[] interfaces)
interfaces
- the proxied interfacesMethod Detail |
---|
public void setTarget(Object target)
public void setTargetSource(TargetSource targetSource)
Advised
setTargetSource
in interface Advised
targetSource
- new TargetSource to usepublic TargetSource getTargetSource()
Advised
getTargetSource
in interface Advised
public void setAdvisorChainFactory(AdvisorChainFactory advisorChainFactory)
Default is a HashMapCachingAdvisorChainFactory
.
public AdvisorChainFactory getAdvisorChainFactory()
null
).
public void addListener(AdvisedSupportListener listener)
listener
- the listener to registerpublic void removeListener(AdvisedSupportListener listener)
listener
- the listener to deregisterpublic void setInterfaces(Class[] interfaces)
public void addInterface(Class intf)
intf
- the additional interface to proxypublic boolean removeInterface(Class intf)
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 removedpublic Class[] getProxiedInterfaces()
Advised
getProxiedInterfaces
in interface Advised
public boolean isInterfaceProxied(Class intf)
Advised
isInterfaceProxied
in interface Advised
intf
- the interface to checkpublic final Advisor[] getAdvisors()
Advised
getAdvisors
in interface Advised
null
)public void addAdvisor(Advisor advisor)
Advised
The Advisor may be an IntroductionAdvisor
,
in which new interfaces will be available when a proxy is next obtained
from the relevant factory.
addAdvisor
in interface Advised
advisor
- the advisor to add to the end of the chainpublic void addAdvisor(int pos, Advisor advisor) throws AopConfigException
Advised
addAdvisor
in interface 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 advicepublic boolean removeAdvisor(Advisor advisor)
Advised
removeAdvisor
in interface Advised
advisor
- the advisor to remove
true
if the advisor was removed; false
if the advisor was not found and hence could not be removedpublic void removeAdvisor(int index) throws AopConfigException
Advised
removeAdvisor
in interface Advised
index
- index of advisor to remove
AopConfigException
- if the index is invalidpublic int indexOf(Advisor advisor)
Advised
The return value of this method can be used to index into the advisors array.
advisor
- the advisor to search for
public boolean replaceAdvisor(Advisor a, Advisor b) throws AopConfigException
Advised
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
in interface Advised
a
- the advisor to replaceb
- the advisor to replace it with
false
and does nothing.
AopConfigException
- in case of invalid advicepublic void addAdvisor(int pos, IntroductionAdvisor advisor) throws AopConfigException
AopConfigException
public void addAdvice(Advice advice) throws AopConfigException
Advised
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 chain
AopConfigException
- in case of invalid adviceAdvised.addAdvice(int, Advice)
,
DefaultPointcutAdvisor
public void addAdvice(int pos, Advice advice) throws AopConfigException
pos
- index from 0 (head)advice
- advice to add at the specified position in the advice chain
AopConfigException
- in case of invalid advicepublic boolean removeAdvice(Advice advice) throws AopConfigException
Advised
removeAdvice
in interface Advised
advice
- the advice to remove
true
of the advice was found and removed;
false
if there was no such advice
AopConfigException
public int indexOf(Advice advice)
Advised
The return value of this method can be used to index into the advisors array.
advice
- AOP Alliance advice to search for
public boolean adviceIncluded(Advice advice)
advice
- the advice to check inclusion of
public int countAdvicesOfType(Class adviceClass)
adviceClass
- the advice class to check
protected void copyConfigurationFrom(AdvisedSupport other)
other
- the AdvisedSupport object to copy configuration fromprotected void copyConfigurationFrom(AdvisedSupport other, TargetSource targetSource, List advisors)
other
- the AdvisedSupport object to take proxy configuration fromtargetSource
- the new TargetSourceadvisors
- the Advisors for the chainprotected AopProxy createAopProxy()
protected final boolean isActive()
protected Object writeReplace() throws ObjectStreamException
ObjectStreamException
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
public String toProxyConfigString()
Advised
toString()
will normally be delegated to the target,
this returns the equivalent for the AOP proxy.
toProxyConfigString
in interface Advised
public String toString()
toString
in class ProxyConfig
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |