com.thoughtworks.proxy.toys.delegate
Class Delegating

java.lang.Object
  extended by com.thoughtworks.proxy.toys.delegate.Delegating

public class Delegating
extends Object

Toy factory to create proxies delegating to another object.

Such a proxy is used to mask the methods of an object, that are not part of a public interface. Or it is used to make an object compatible, e.g. when an object implements the methods of an interface, but does not implement the interface itself.

Since:
0.1
Author:
Dan North
See Also:
com.thoughtworks.proxy.toys.delegate

Field Summary
static boolean DYNAMIC_TYPING
          Deprecated. since 0.2, use MODE_SIGNATURE
static int MODE_DIRECT
          Delegate must implement the method's interface
static int MODE_SIGNATURE
          Delegate must have method with same name and matching signature - not necessarily the same
static boolean STATIC_TYPING
          Deprecated. since 0.2, use MODE_DIRECT
 
Method Summary
static Object object(Class type, Object delegate)
          Creating a delegating proxy for a signature compatible object.
static Object object(Class type, Object delegate, int delegationMode)
          Creating a delegating proxy for an object with a defined delegation mode.
static Object object(Class type, Object delegate, ProxyFactory factory)
          Creating a delegating proxy for a signature compatible object using a special ProxyFactory.
static Object object(Class type, Object delegate, ProxyFactory factory, int delegationMode)
          Creating a delegating proxy for an object with a defined delegation mode using a special ProxyFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATIC_TYPING

public static final boolean STATIC_TYPING
Deprecated. since 0.2, use MODE_DIRECT
Delegate must implement the method's interface.

See Also:
Constant Field Values

DYNAMIC_TYPING

public static final boolean DYNAMIC_TYPING
Deprecated. since 0.2, use MODE_SIGNATURE
Delegate must have method with same name and matching signature - not necessarily the same.

See Also:
Constant Field Values

MODE_DIRECT

public static final int MODE_DIRECT
Delegate must implement the method's interface

See Also:
Constant Field Values

MODE_SIGNATURE

public static final int MODE_SIGNATURE
Delegate must have method with same name and matching signature - not necessarily the same

See Also:
Constant Field Values
Method Detail

object

public static Object object(Class type,
                            Object delegate)
Creating a delegating proxy for a signature compatible object.

Parameters:
type - the type of the created proxy,
delegate - the object the proxy delegates to.
Returns:
a new proxy of the specified type.
Since:
0.1

object

public static Object object(Class type,
                            Object delegate,
                            int delegationMode)
Creating a delegating proxy for an object with a defined delegation mode.

Parameters:
type - the type of the created proxy,
delegate - the object the proxy delegates to.
delegationMode - one of the delegation modes MODE_DIRECT or MODE_SIGNATURE
Returns:
a new proxy of the specified type.
Throws:
IllegalArgumentException - if the delegationMode is not one of the predefined constants
Since:
0.2

object

public static Object object(Class type,
                            Object delegate,
                            ProxyFactory factory)
Creating a delegating proxy for a signature compatible object using a special ProxyFactory.

Parameters:
type - the type of the created proxy,
delegate - the object the proxy delegates to.
factory - the ProxyFactory to use creating the proxy.
Returns:
a new proxy of the specified type.
Since:
0.1

object

public static Object object(Class type,
                            Object delegate,
                            ProxyFactory factory,
                            int delegationMode)
Creating a delegating proxy for an object with a defined delegation mode using a special ProxyFactory.

Parameters:
type - the type of the created proxy,
delegate - the object the proxy delegates to.
factory - the ProxyFactory to use creating the proxy.
delegationMode - one of the delegation modes MODE_DIRECT or MODE_SIGNATURE
Returns:
a new proxy of the specified type.
Since:
0.2.1