Class ProxyFactory<T>

  • Type Parameters:
    T - the superclass type

    public class ProxyFactory<T>
    extends AbstractProxyFactory<T>
    Proxy Factory that generates proxies that delegate all calls to an InvocationHandler.

    Typical usage looks like:

     ProxyFactory<SimpleClass> proxyFactory = new ProxyFactory<SimpleClass>(SimpleClass.class);
     SimpleClass instance = proxyFactory.newInstance(new SimpleDispatcher());
     

    This will create a proxy for SimpleClass, and return a new instance that handles invocations using the InvocationDispatcher SimpleDispatcher.

    Invocations on these proxies are very efficient, as no reflection is involved.

    Author:
    Stuart Douglas
    • Field Detail

      • INVOCATION_HANDLER_FIELD

        public static final String INVOCATION_HANDLER_FIELD
        Name of the field that holds the generated dispatcher on the generated proxy
        See Also:
        Constant Field Values
      • CONSTRUCTED_GUARD

        public static final String CONSTRUCTED_GUARD
        this field on the generated class stores if the constructor has been completed yet. No methods will be delegated to the dispatcher until the constructor has finished. This prevents virtual methods called from the constructor being delegated to a handler that is null.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ProxyFactory

        public ProxyFactory​(ProxyConfiguration<T> proxyConfiguration)
        Construct a new instance.
        Parameters:
        proxyConfiguration - The configuration to use to build the proxy