net.sf.cglib
Class Delegator

java.lang.Object
  extended bynet.sf.cglib.Delegator

public class Delegator
extends java.lang.Object

Delegator provides a number of static methods that allow multiple objects to be combined into a single larger object. The methods in the generated object simply call the original methods in the underlying "delegate" objects.

Version:
$Id: Delegator.java,v 1.19 2003/06/07 05:51:33 herbyderby Exp $

Method Summary
static java.lang.Object create(java.lang.Class[] interfaces, java.lang.Object[] delegates, java.lang.ClassLoader loader)
          Returns an object that implements all of the specified interfaces.
static java.lang.Object create(java.lang.Object[] delegates, java.lang.ClassLoader loader)
          Returns an object that implements all of the interfaces implemented by the specified objects.
static java.lang.Object createBean(java.lang.Object[] beans, java.lang.ClassLoader loader)
          Combines an array of JavaBeans into a single "super" bean.
static java.util.Map getInterfaceMap(java.lang.Object[] delegates)
          Returns a Map that describes how interfaces would be delegated.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static java.lang.Object create(java.lang.Class[] interfaces,
                                      java.lang.Object[] delegates,
                                      java.lang.ClassLoader loader)
Returns an object that implements all of the specified interfaces. For each interface, all methods are delegated to the respective object in the delegates argument array.

Parameters:
interfaces - the array of interfaces to implement
delegates - The array of delegates. Must be the same length as the interface array, and each delegates must implements the corresponding interface.
loader - The ClassLoader to use. If null uses the one that loaded this class.
Returns:
the dynamically created object

create

public static java.lang.Object create(java.lang.Object[] delegates,
                                      java.lang.ClassLoader loader)
Returns an object that implements all of the interfaces implemented by the specified objects. For each interface, all methods are delegated to the first object in the argument array which implements the interface.

Note: interfaces which have no methods (marker interfaces) are not implemented by the returned object.

Parameters:
delegates - the array of delegates
loader - The ClassLoader to use. If null uses the one that loaded this class.
Returns:
the dynamically created object
See Also:
getInterfaceMap(Object[])

getInterfaceMap

public static java.util.Map getInterfaceMap(java.lang.Object[] delegates)
Returns a Map that describes how interfaces would be delegated. The keys are interfaces (Class objects) that would be implemented by the object returned by the create methods. For each interface, the Map value is the objects from the argument array that would be used as a delegate.

Parameters:
delegates - the array of delegates
Returns:
the Map of interfaces -> delegates
See Also:
#makeDelegator(Object[])

createBean

public static java.lang.Object createBean(java.lang.Object[] beans,
                                          java.lang.ClassLoader loader)
Combines an array of JavaBeans into a single "super" bean. Calls to the super bean will delegate to the underlying beans. In the case of a property name conflicts, the first bean is used.

Parameters:
beans - the list of beans to delegate to
loader - The ClassLoader to use. If null uses the one that loaded this class.
Returns:
the dynamically created bean


Copyright (c) 2001 - Apache Software Foundation