org.springframework.aop.framework

## 类 ProxyFactory

- java.lang.Object
- - org.springframework.aop.framework.ProxyConfig
  - - org.springframework.aop.framework.AdvisedSupport
    - - org.springframework.aop.framework.ProxyCreatorSupport
      - - org.springframework.aop.framework.ProxyFactory

- 所有已实现的接口:
    Serializable, Advised, TargetClassAware

      public class ProxyFactory
      extends ProxyCreatorSupport

  Factory for AOP proxies for programmatic use, rather than via declarative setup in a bean factory. This class provides a simple way of obtaining and configuring AOP proxy instances in custom user code.
  从以下版本开始:
    14.03.2003
  作者:
    Rod Johnson, Juergen Hoeller, Rob Harrop
  另请参阅:
    序列化表格

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.aop.framework.AdvisedSupport

      `EMPTY_TARGET_SOURCE`

  - ### 构造器概要

    构造器
    构造器和说明
    `ProxyFactory()` Create a new ProxyFactory.
    `ProxyFactory(Class<?>... proxyInterfaces)` Create a new ProxyFactory.
    `ProxyFactory(Class<?> proxyInterface, Interceptor interceptor)` Create a new ProxyFactory for the given interface and interceptor.
    `ProxyFactory(Class<?> proxyInterface, TargetSource targetSource)` Create a ProxyFactory for the specified `TargetSource`, making the proxy implement the specified interface.
    `ProxyFactory(Object target)` Create a new ProxyFactory.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object` | `getProxy()` Create a new proxy according to the settings in this factory.
    `static <T> T` | `getProxy(Class<T> proxyInterface, Interceptor interceptor)` Create a new proxy for the given interface and interceptor.
    `static <T> T` | `getProxy(Class<T> proxyInterface, TargetSource targetSource)` Create a proxy for the specified `TargetSource`, implementing the specified interface.
    `Object` | `getProxy(ClassLoader classLoader)` Create a new proxy according to the settings in this factory.
    `static Object` | `getProxy(TargetSource targetSource)` Create a proxy for the specified `TargetSource` that extends the target class of the `TargetSource`.

    - ### 从类继承的方法 org.springframework.aop.framework.ProxyCreatorSupport

      `addListener, adviceChanged, createAopProxy, getAopProxyFactory, isActive, removeListener, setAopProxyFactory`

    - ### 从类继承的方法 org.springframework.aop.framework.AdvisedSupport

      `addAdvice, addAdvice, addAdvisor, addAdvisor, addAdvisors, addAdvisors, addInterface, adviceIncluded, copyConfigurationFrom, copyConfigurationFrom, countAdvicesOfType, getAdvisorChainFactory, getAdvisors, getAdvisorsInternal, getInterceptorsAndDynamicInterceptionAdvice, getProxiedInterfaces, getTargetClass, getTargetSource, indexOf, indexOf, isInterfaceProxied, isPreFiltered, removeAdvice, removeAdvisor, removeAdvisor, removeInterface, replaceAdvisor, setAdvisorChainFactory, setInterfaces, setPreFiltered, setTarget, setTargetClass, setTargetSource, toProxyConfigString, toString, updateAdvisorArray`

    - ### 从类继承的方法 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`

- - ### 构造器详细资料

    - #### ProxyFactory

          public ProxyFactory()

      Create a new ProxyFactory.

    - #### ProxyFactory

          public ProxyFactory(Object target)

      Create a new ProxyFactory.

      Will proxy all interfaces that the given target implements.

      参数:
        `target` - the target object to be proxied

    - #### ProxyFactory

          public ProxyFactory(Class<?>... proxyInterfaces)

      Create a new ProxyFactory.

      No target, only interfaces. Must add interceptors.

      参数:
        `proxyInterfaces` - the interfaces that the proxy should implement

    - #### ProxyFactory

          public ProxyFactory(Class<?> proxyInterface,
                              Interceptor interceptor)

      Create a new ProxyFactory for the given interface and interceptor.

      Convenience method for creating a proxy for a single interceptor, assuming that the interceptor handles all calls itself rather than delegating to a target, like in the case of remoting proxies.

      参数:
        `proxyInterface` - the interface that the proxy should implement
        `interceptor` - the interceptor that the proxy should invoke

    - #### ProxyFactory

          public ProxyFactory(Class<?> proxyInterface,
                              TargetSource targetSource)

      Create a ProxyFactory for the specified `TargetSource`, making the proxy implement the specified interface.
      参数:
        `proxyInterface` - the interface that the proxy should implement
        `targetSource` - the TargetSource that the proxy should invoke

  - ### 方法详细资料

    - #### getProxy

          public Object getProxy()

      Create a new proxy according to the settings in this factory.

      Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.

      Uses a default class loader: Usually, the thread context class loader (if necessary for proxy creation).

      返回:
        the proxy object

    - #### getProxy

          public Object getProxy(@Nullable
                                 ClassLoader classLoader)

      Create a new proxy according to the settings in this factory.

      Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.

      Uses the given class loader (if necessary for proxy creation).

      参数:
        `classLoader` - the class loader to create the proxy with (or `null` for the low-level proxy facility's default)
      返回:
        the proxy object

    - #### getProxy

          public static <T> T getProxy(Class<T> proxyInterface,
                                       Interceptor interceptor)

      Create a new proxy for the given interface and interceptor.

      Convenience method for creating a proxy for a single interceptor, assuming that the interceptor handles all calls itself rather than delegating to a target, like in the case of remoting proxies.

      参数:
        `proxyInterface` - the interface that the proxy should implement
        `interceptor` - the interceptor that the proxy should invoke
      返回:
        the proxy object
      另请参阅:
        `ProxyFactory(Class, org.aopalliance.intercept.Interceptor)`

    - #### getProxy

          public static <T> T getProxy(Class<T> proxyInterface,
                                       TargetSource targetSource)

      Create a proxy for the specified `TargetSource`, implementing the specified interface.
      参数:
        `proxyInterface` - the interface that the proxy should implement
        `targetSource` - the TargetSource that the proxy should invoke
      返回:
        the proxy object
      另请参阅:
        `ProxyFactory(Class, org.springframework.aop.TargetSource)`

    - #### getProxy

          public static Object getProxy(TargetSource targetSource)

      Create a proxy for the specified `TargetSource` that extends the target class of the `TargetSource`.
      参数:
        `targetSource` - the TargetSource that the proxy should invoke
      返回:
        the proxy object