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.
<T> T
createProxy(Invoker invoker, Class<?>... types)
          Create a new proxy instance.
 Invoker getInvoker(Object proxy)
          Retrieve the invocation handler of the proxy.
 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 <T> T createProxy(Invoker invoker,
                         Class<?>... types)
Create a new proxy instance.

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

Type Parameters:
T - The proxy's type.
Parameters:
invoker - the invocation handler.
types - the types the proxy must emulate.
Returns:
the new proxy instance.

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 examine.
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


Copyright © 2005-2010 Codehaus. All Rights Reserved.