Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.aop.framework
Class AdvisedSupport

    java.lang.Object
      org.springframework.aop.framework.ProxyConfig
          org.springframework.aop.framework.AdvisedSupport

All Implemented Interfaces:
  java.io.Serializable, Advised, TargetClassAware

Direct Known Subclasses:
  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.

Author:
  Rod Johnson, Juergen Hoeller
See Also:
  `AopProxy`, Serialized Form

Field Summary
`static TargetSource` | `EMPTY_TARGET_SOURCE` Canonical TargetSource when there's no target, and behavior is supplied by the advisors.

Constructor Summary
`AdvisedSupport()` No-arg constructor for use as a JavaBean.
`AdvisedSupport(java.lang.Class[] interfaces)` Create a AdvisedSupport instance with the given parameters.

Method Summary
`void` | `addAdvice(org.aopalliance.aop.Advice advice)` Add the given AOP Alliance advice to the tail of the advice (interceptor) chain.
`void` | `addAdvice(int pos, org.aopalliance.aop.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` | `addAdvisors(Advisor... advisors)` Add all of the given advisors to this proxy configuration.
`void` | `addAdvisors(java.util.Collection<Advisor> advisors)` Add all of the given advisors to this proxy configuration.
`void` | `addAllAdvisors(Advisor[] advisors)` Deprecated. as of Spring 3.0, in favor of `addAdvisors(org.springframework.aop.Advisor...)`
`void` | `addInterface(java.lang.Class intf)` Add a new proxied interface.
`protected void` | `adviceChanged()` Invoked when advice has changed.
`boolean` | `adviceIncluded(org.aopalliance.aop.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, java.util.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(java.lang.Class adviceClass)` Count advices of the given class.
`AdvisorChainFactory` | `getAdvisorChainFactory()` Return the advisor chain factory to use (never `null`).
`Advisor[]` | `getAdvisors()` Return the advisors applying to this proxy.
`protected java.util.List<Advisor>` | `getAdvisorsInternal()` Allows uncontrolled access to the `List` of `Advisors`.
`java.util.List<java.lang.Object>` | `getInterceptorsAndDynamicInterceptionAdvice(java.lang.reflect.Method method, java.lang.Class targetClass)` Determine a list of `MethodInterceptor` objects for the given method, based on this configuration.
`java.lang.Class[]` | `getProxiedInterfaces()` Return the interfaces proxied by the AOP proxy.
`java.lang.Class<?>` | `getTargetClass()` Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).
`TargetSource` | `getTargetSource()` Return the TargetSource used by this Advised object.
`int` | `indexOf(org.aopalliance.aop.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(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` | `removeAdvice(org.aopalliance.aop.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(java.lang.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(java.lang.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(java.lang.Object target)` Set the given object as target.
`void` | `setTargetClass(java.lang.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 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.
`java.lang.String` | `toString()` For debugging/diagnostic use.
`protected void` | `updateAdvisorArray()` Bring the array up to date with the list.

Methods inherited from class org.springframework.aop.framework.ProxyConfig
`copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, 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

### EMPTY_TARGET_SOURCE

    public static final TargetSource EMPTY_TARGET_SOURCE

  Canonical TargetSource when there's no target, and behavior is supplied by the advisors.

Constructor Detail

### AdvisedSupport

    public AdvisedSupport()

  No-arg constructor for use as a JavaBean.

### AdvisedSupport

    public AdvisedSupport(java.lang.Class[] interfaces)

  Create a AdvisedSupport instance with the given parameters.

  Parameters:
    `interfaces` - the proxied interfaces

Method Detail

### setTarget

    public void setTarget(java.lang.Object target)

  Set the given object as target. Will create a SingletonTargetSource for the object.

  See Also:
    `setTargetSource(org.springframework.aop.TargetSource)`, `SingletonTargetSource`

### setTargetSource

    public void setTargetSource(TargetSource targetSource)

  Description copied from interface: `Advised`
  Change the TargetSource used by this Advised object. Only works if the configuration isn't frozen.

  Specified by:
    `setTargetSource` in interface `Advised`
  Parameters:
    `targetSource` - new TargetSource to use

### getTargetSource

    public TargetSource getTargetSource()

  Description copied from interface: `Advised`
  Return the TargetSource used by this Advised object.

  Specified by:
    `getTargetSource` in interface `Advised`

### setTargetClass

    public void setTargetClass(java.lang.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.

  See Also:
    `setTargetSource(org.springframework.aop.TargetSource)`, `setTarget(java.lang.Object)`

### getTargetClass

    public java.lang.Class<?> getTargetClass()

  Description copied from interface: `TargetClassAware`
  Return the target class behind the implementing object (typically a proxy configuration or an actual proxy).

  Specified by:
    `getTargetClass` in interface `TargetClassAware`
  Returns:
    the target Class, or `null` if not known

### setPreFiltered

    public void setPreFiltered(boolean preFiltered)

  Description copied from interface: `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.

  Specified by:
    `setPreFiltered` in interface `Advised`
  See Also:
    `ClassFilter`

### isPreFiltered

    public boolean isPreFiltered()

  Description copied from interface: `Advised`
  Return whether this proxy configuration is pre-filtered so that it only contains applicable advisors (matching this proxy's target class).

  Specified by:
    `isPreFiltered` in interface `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 (never `null`).

### setInterfaces

    public void setInterfaces(java.lang.Class[] interfaces)

  Set the interfaces to be proxied.

### addInterface

    public void addInterface(java.lang.Class intf)

  Add a new proxied interface.

  Parameters:
    `intf` - the additional interface to proxy

### removeInterface

    public boolean removeInterface(java.lang.Class intf)

  Remove a proxied interface.

  Does nothing if the given interface isn't proxied.

  Parameters:
    `intf` - the interface to remove from the proxy
  Returns:
    `true` if the interface was removed; `false` if the interface was not found and hence could not be removed

### getProxiedInterfaces

    public java.lang.Class[] getProxiedInterfaces()

  Description copied from interface: `Advised`
  Return the interfaces proxied by the AOP proxy. Will not include the target class, which may also be proxied.

  Specified by:
    `getProxiedInterfaces` in interface `Advised`

### isInterfaceProxied

    public boolean isInterfaceProxied(java.lang.Class intf)

  Description copied from interface: `Advised`
  Determine whether the given interface is proxied.

  Specified by:
    `isInterfaceProxied` in interface `Advised`
  Parameters:
    `intf` - the interface to check

### getAdvisors

    public final Advisor[] getAdvisors()

  Description copied from interface: `Advised`
  Return the advisors applying to this proxy.

  Specified by:
    `getAdvisors` in interface `Advised`
  Returns:
    a list of Advisors applying to this proxy (never `null`)

### addAdvisor

    public void addAdvisor(Advisor advisor)

  Description copied from interface: `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.

  Specified by:
    `addAdvisor` in interface `Advised`
  Parameters:
    `advisor` - the advisor to add to the end of the chain

### addAdvisor

    public void addAdvisor(int pos,
                           Advisor advisor)
                    throws AopConfigException

  Description copied from interface: `Advised`
  Add an Advisor at the specified position in the chain.

  Specified by:
    `addAdvisor` in interface `Advised`
  Parameters:
    `pos` - position in chain (0 is head). Must be valid.
    `advisor` - the advisor to add at the specified position in the chain
  Throws:
    `AopConfigException` - in case of invalid advice

### removeAdvisor

    public boolean removeAdvisor(Advisor advisor)

  Description copied from interface: `Advised`
  Remove the given advisor.

  Specified by:
    `removeAdvisor` in interface `Advised`
  Parameters:
    `advisor` - the advisor to remove
  Returns:
    `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

  Description copied from interface: `Advised`
  Remove the advisor at the given index.

  Specified by:
    `removeAdvisor` in interface `Advised`
  Parameters:
    `index` - index of advisor to remove
  Throws:
    `AopConfigException` - if the index is invalid

### indexOf

    public int indexOf(Advisor advisor)

  Description copied from interface: `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.

  Specified by:
    `indexOf` in interface `Advised`
  Parameters:
    `advisor` - the advisor to search for
  Returns:
    index from 0 of this advisor, or -1 if there's no such advisor

### replaceAdvisor

    public boolean replaceAdvisor(Advisor a,
                                  Advisor b)
                           throws AopConfigException

  Description copied from interface: `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.

  Specified by:
    `replaceAdvisor` in interface `Advised`
  Parameters:
    `a` - the advisor to replace
    `b` - the advisor to replace it with
  Returns:
    whether it was replaced. If the advisor wasn't found in the list of advisors, this method returns `false` and does nothing.
  Throws:
    `AopConfigException` - in case of invalid advice

### addAllAdvisors

    @Deprecated
    public void addAllAdvisors(Advisor[] advisors)

  Deprecated. as of Spring 3.0, in favor of `addAdvisors(org.springframework.aop.Advisor...)`

  Add all of the given advisors to this proxy configuration.

  Parameters:
    `advisors` - the advisors to register

### addAdvisors

    public void addAdvisors(Advisor... advisors)

  Add all of the given advisors to this proxy configuration.

  Parameters:
    `advisors` - the advisors to register

### addAdvisors

    public void addAdvisors(java.util.Collection<Advisor> advisors)

  Add all of the given advisors to this proxy configuration.

  Parameters:
    `advisors` - the advisors to register

### updateAdvisorArray

    protected final void updateAdvisorArray()

  Bring the array up to date with the list.

### getAdvisorsInternal

    protected final java.util.List<Advisor> getAdvisorsInternal()

  Allows uncontrolled access to the `List` of `Advisors`.

  Use with care, and remember to `refresh the advisor array` and `fire advice changed events` when making any modifications.

### addAdvice

    public void addAdvice(org.aopalliance.aop.Advice advice)
                   throws AopConfigException

  Description copied from interface: `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.

  Specified by:
    `addAdvice` in interface `Advised`
  Parameters:
    `advice` - advice to add to the tail of the chain
  Throws:
    `AopConfigException` - in case of invalid advice
  See Also:
    `Advised.addAdvice(int, Advice)`, `DefaultPointcutAdvisor`

### addAdvice

    public void addAdvice(int pos,
                          org.aopalliance.aop.Advice advice)
                   throws AopConfigException

  Cannot add introductions this way unless the advice implements IntroductionInfo.

  Specified by:
    `addAdvice` in interface `Advised`
  Parameters:
    `pos` - index from 0 (head)
    `advice` - advice to add at the specified position in the advice chain
  Throws:
    `AopConfigException` - in case of invalid advice

### removeAdvice

    public boolean removeAdvice(org.aopalliance.aop.Advice advice)
                         throws AopConfigException

  Description copied from interface: `Advised`
  Remove the Advisor containing the given advice.

  Specified by:
    `removeAdvice` in interface `Advised`
  Parameters:
    `advice` - the advice to remove
  Returns:
    `true` of the advice was found and removed; `false` if there was no such advice
  Throws:
    `AopConfigException`

### indexOf

    public int indexOf(org.aopalliance.aop.Advice advice)

  Description copied from interface: `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.

  Specified by:
    `indexOf` in interface `Advised`
  Parameters:
    `advice` - AOP Alliance advice to search for
  Returns:
    index from 0 of this advice, or -1 if there's no such advice

### adviceIncluded

    public boolean adviceIncluded(org.aopalliance.aop.Advice advice)

  Is the given advice included in any advisor within this proxy configuration?

  Parameters:
    `advice` - the advice to check inclusion of
  Returns:
    whether this advice instance is included

### countAdvicesOfType

    public int countAdvicesOfType(java.lang.Class adviceClass)

  Count advices of the given class.

  Parameters:
    `adviceClass` - the advice class to check
  Returns:
    the count of the interceptors of this class or subclasses

### getInterceptorsAndDynamicInterceptionAdvice

    public java.util.List<java.lang.Object> getInterceptorsAndDynamicInterceptionAdvice(java.lang.reflect.Method method,
                                                                                        java.lang.Class targetClass)

  Determine a list of `MethodInterceptor` objects for the given method, based on this configuration.

  Parameters:
    `method` - the proxied method
    `targetClass` - the target class
  Returns:
    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.

  Parameters:
    `other` - the AdvisedSupport object to copy configuration from

### copyConfigurationFrom

    protected void copyConfigurationFrom(AdvisedSupport other,
                                         TargetSource targetSource,
                                         java.util.List<Advisor> advisors)

  Copy the AOP configuration from the given AdvisedSupport object, but allow substitution of a fresh TargetSource and a given interceptor chain.

  Parameters:
    `other` - the AdvisedSupport object to take proxy configuration from
    `targetSource` - the new TargetSource
    `advisors` - the Advisors for the chain

### toProxyConfigString

    public java.lang.String toProxyConfigString()

  Description copied from interface: `Advised`
  As `toString()` will normally be delegated to the target, this returns the equivalent for the AOP proxy.

  Specified by:
    `toProxyConfigString` in interface `Advised`
  Returns:
    a string description of the proxy configuration

### toString

    public java.lang.String toString()

  For debugging/diagnostic use.

  Overrides:
    `toString` in class `ProxyConfig`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD