com.thoughtworks.proxy
Interface ProxyFactory

All Superinterfaces:
Serializable
All Known Implementing Classes:
com.thoughtworks.proxy.factory.AbstractProxyFactory

public interface ProxyFactory
extends Serializable

Abstraction layer for proxy generation. Depending on this interface (rather than Proxy directly) will allow you to use Java's standard proxy mechanism interchangeably with e.g. CGLIB.

Since:
0.1
Author:
Aslak Hellesøy

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.
 boolean isProxyClass(Class type)
          Test if the given type is a proxy class.
 

Method Detail

createProxy

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

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)
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.
Since:
0.1

isProxyClass

public boolean isProxyClass(Class type)
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.
Since:
0.1

getInvoker

public Invoker getInvoker(Object proxy)
Retrieve the invocation handler of the proxy.

Parameters:
proxy - the proxy instance.
Returns:
the Invoker instance acting as invocation handler.
Since:
0.1