com.triactive.jdo.util
Class ProxyFactory

java.lang.Object
  extended bycom.triactive.jdo.util.ProxyFactory

public class ProxyFactory
extends java.lang.Object

A high-performance factory for dynamic proxy objects.

A ProxyFactory performs the same function as java.lang.reflect.Proxy.newProxyInstance(), but does so for a single set of interfaces. It holds a (soft) reference to the proxy class constructor and so can create many proxies of the same type with very little overhead.

The generated proxy class is assigned the same class loader as the ProxyFactory class itself.

Author:
Mike Martin

Constructor Summary
ProxyFactory(java.lang.Class intfc)
          Creates a factory for proxy objects that implement the specified interface.
ProxyFactory(java.lang.Class[] interfaces)
          Creates a factory for proxy objects that implement the specified interface(s).
 
Method Summary
 java.lang.Object newInstance(java.lang.reflect.InvocationHandler handler)
          Returns an instance of a proxy class for this factory's interfaces that dispatches method invocations to the specified invocation handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyFactory

public ProxyFactory(java.lang.Class intfc)
Creates a factory for proxy objects that implement the specified interface.

Parameters:
intfc - the interface for the proxy class to implement

ProxyFactory

public ProxyFactory(java.lang.Class[] interfaces)
Creates a factory for proxy objects that implement the specified interface(s).

Parameters:
interfaces - the list of interfaces for the proxy class to implement
Method Detail

newInstance

public java.lang.Object newInstance(java.lang.reflect.InvocationHandler handler)
Returns an instance of a proxy class for this factory's interfaces that dispatches method invocations to the specified invocation handler. ProxyFactory.newInstance throws IllegalArgumentException for the same reasons that Proxy.getProxyClass does.

Parameters:
handler - the invocation handler to dispatch method invocations to
Returns:
a proxy instance with the specified invocation handler of a proxy class that implements this factory's specified interfaces
Throws:
java.lang.IllegalArgumentException - if any of the restrictions on the parameters that may be passed to getProxyClass are violated
java.lang.NullPointerException - if the invocation handler is null


Copyright 2001-2007 The TJDO Project All Rights Reserved.