com.h3c.util.proxy

## Class DynamicProxy<I>

- java.lang.Object
- - com.h3c.util.proxy.DynamicProxy<I>

- Type Parameters:
    `I` - the type of interface to handle invocations for.
  All Implemented Interfaces:
    InvocationHandler

      public class DynamicProxy<I>
      extends Object
      implements InvocationHandler

  Dynamic Proxy.

  Example:

  ``

       private  T prepareProxy(T myInterface) {
            T preparedProxy = myInterface;
            preparedProxy = DynamicProxy.createProxy(preparedProxy, new LatencyEmulatorProxy());
            preparedProxy = DynamicProxy.createProxy(preparedProxy, new SwingThreadMonitorProxy());
            return preparedProxy;
        }

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `DynamicProxy.DynamicProxyInvocationHandler<I>` Dynamic proxy invocation handler.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T,I extends T> T` | `createProxy(I delegate, DynamicProxy.DynamicProxyInvocationHandler<I> invocationHandler)` Creates a dynamic proxy.
    `static <T> String` | `getMethodSignature(Class<T> clazz, Method method)` Gets a string representing the method signature (For debug purposes).
    `Object` | `invoke(Object proxy, Method method, Object[] args)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createProxy

          public static <T,I extends T> T createProxy(I delegate,
                                      DynamicProxy.DynamicProxyInvocationHandler<I> invocationHandler)

      Creates a dynamic proxy.
      Type Parameters:
        `T` - type of the interface to create a proxy for. T must be an interface.
        `I` - type of the subclass to delegate invocations to.
      Parameters:
        `delegate` - delegate to create a proxy for.
        `invocationHandler` - proxy invocation handler.
      Returns:
        A dynamic proxy for the given delegate.

    - #### invoke

          public Object invoke(Object proxy,
                      Method method,
                      Object[] args)
                        throws Throwable

      Specified by:
        `invoke` in interface `InvocationHandler`
      Throws:
        `Throwable`

    - #### getMethodSignature

          public static <T> String getMethodSignature(Class<T> clazz,
                                      Method method)

      Gets a string representing the method signature (For debug purposes).
      Type Parameters:
        `T` - Type of the class.
      Parameters:
        `clazz` - Class to get the method signature for.
        `method` - Method.
      Returns:
        a string representing the method signature.

Copyright © 2014. All Rights Reserved.