Smartproxy
0.2

net.ggtools.smartproxy
Class ProxyFactory

java.lang.Object
  extended bynet.ggtools.smartproxy.ProxyFactory

public class ProxyFactory
extends Object

A factory to create proxified objects.

Author:
Christophe Labouisse

Constructor Summary
protected ProxyFactory(String proxyClassName, Class implementor, Class baseInterface)
          Constructor, create a new ProxyFactory object.
 
Method Summary
 Object createProxy(Object[] arguments)
          Instanciate a new proxy object.
 void dumpClass(String destDir)
          Dump the current class to the specified directory.
 Class getBaseInterface()
          Read accessor to baseInterface.
 String getBaseInterfaceName()
          Read accessor to baseInterfaceName.
 Class getImplementor()
          Read accessor to implementor.
 String getImplementorName()
          Read accessor to implementorName.
static ProxyFactory getInstance(Class implementor, Class baseInterface)
          Returns an instance of a proxy factory.
 Class getProxyClass()
          Read accessor to proxyClass.
 String getProxyClassName()
          Read accessor to proxyClassName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyFactory

protected ProxyFactory(String proxyClassName,
                       Class implementor,
                       Class baseInterface)
Constructor, create a new ProxyFactory object. This constructor should not be called directly.

Parameters:
implementor - the abstract class extended by the created class.
baseInterface - the interface to be implemented.
Method Detail

getInstance

public static ProxyFactory getInstance(Class implementor,
                                       Class baseInterface)
Returns an instance of a proxy factory. This method should be used instead of the constructor because it insures that the class generation work will be done only once for a specific set of parameters. Calling twice this method with the same set of parameters may return the same factory.

Parameters:
implementor - implementation class for the proxified objects.
baseInterface - interface to implement.
Returns:
a proxified object factory.
Throws:
ClassCastException - if implementor does not implements PROXIFIED_OBJECT_INTERFACE or baseInterface

createProxy

public Object createProxy(Object[] arguments)
                   throws SecurityException,
                          NoSuchMethodException,
                          IllegalArgumentException,
                          InstantiationException,
                          IllegalAccessException,
                          InvocationTargetException
Instanciate a new proxy object. This method tries to select the appropriate constructor depending on the parameters.

Parameters:
arguments - the arguments to be passed to the constructor as an array of Object.
Returns:
a new proxy object.
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException

dumpClass

public void dumpClass(String destDir)
               throws IOException
Dump the current class to the specified directory.

Parameters:
destDir - the directory where the class will be dumped to.
Throws:
IOException - when dump fails.

getBaseInterface

public Class getBaseInterface()
Read accessor to baseInterface.

Returns:
the base interface.

getBaseInterfaceName

public String getBaseInterfaceName()
Read accessor to baseInterfaceName.

Returns:
the base interface name

getImplementor

public Class getImplementor()
Read accessor to implementor.

Returns:
the implementor class.

getImplementorName

public String getImplementorName()
Read accessor to implementorName.

Returns:
the implementor class name.

getProxyClassName

public String getProxyClassName()
Read accessor to proxyClassName.

Returns:
the proxy class name.

getProxyClass

public Class getProxyClass()
Read accessor to proxyClass. Creates and load the class if not already done.

Returns:
the proxy class.

Smartproxy
0.2