com.thoughtworks.proxy
Interface ProxyFactory

All Superinterfaces:
Serializable
All Known Implementing Classes:
CglibProxyFactory, StandardProxyFactory

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

Method Detail

createProxy

<T> T createProxy(Invoker invoker,
                  Class<?>... types)
Create a new proxy instance.

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

canProxy

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

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

getInvoker

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


Copyright © 2005-2010 Codehaus. All Rights Reserved.