com.thoughtworks.proxy.factory
Class CglibProxyFactory

java.lang.Object
  extended by com.thoughtworks.proxy.factory.CglibProxyFactory
All Implemented Interfaces:
ProxyFactory, Serializable

public class CglibProxyFactory
extends Object

A ProxyFactory based on CGLIB.

Since:
0.1
Author:
Aslak Hellesøy
See Also:
com.thoughtworks.proxy.factory, Serialized Form

Field Summary
static Method getInvoker
          The getInvoker method.
 
Constructor Summary
CglibProxyFactory()
           
 
Method Summary
 boolean canProxy(Class type)
          Test if the ProxyFactory implementation is capable of creating a proxy instance for the given type.
 Object createProxy(Class[] types, Invoker invoker)
          Create a new proxy instance.
 Invoker getInvoker(Object proxy)
          Retrieve the invocation handler of the proxy. The implementation of this method relies on the implementation of the derived factory to add the interface InvokerReference to every proxy instance.
 boolean isProxyClass(Class type)
          Test if the given type is a proxy class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

getInvoker

public static final Method getInvoker
The getInvoker method.

Constructor Detail

CglibProxyFactory

public CglibProxyFactory()
Method Detail

createProxy

public Object createProxy(Class[] types,
                          Invoker invoker)
Create a new proxy instance.

Note: If any type the proxy instance must fullfill are all interfaces, the factory will currently create a proxy based on the JDK.

Parameters:
types - the types the proxy must emulate.
invoker - the invocation handler.
Returns:
the new proxy instance.
Since:
0.1

canProxy

public boolean canProxy(Class type)
Description copied from interface: ProxyFactory
Test if the ProxyFactory implementation is capable of creating a proxy instance for the given type.

Parameters:
type - the type to create a proxy instance for.
Returns:
true if the type is supported.

isProxyClass

public boolean isProxyClass(Class type)
Description copied from interface: ProxyFactory
Test if the given type is a proxy class.

Parameters:
type - the type to examin.
Returns:
true if the given type is a proxy class.

getInvoker

public Invoker getInvoker(Object proxy)
Retrieve the invocation handler of the proxy. The implementation of this method relies on the implementation of the derived factory to add the interface InvokerReference to every proxy instance.

Specified by:
getInvoker in interface ProxyFactory
Parameters:
proxy - the proxy instance.
Returns:
the Invoker instance acting as invocation handler.
Since:
0.1