org.pfsw.extender
Class DelegatingInvocationHandler<TDelegate>

java.lang.Object
  extended by org.pfsw.extender.DelegatingInvocationHandler<TDelegate>
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
ExtendedObject

public class DelegatingInvocationHandler<TDelegate>
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

A generic InvocationHandler that passes all method calls through to a delegate object. If that delegate object is not available initially then an ObjectRetrievalService and an identifier will be used to get it.


Constructor Summary
protected DelegatingInvocationHandler()
           
  DelegatingInvocationHandler(TDelegate object)
          Initialize the new instance with an object to delegate all method calls to.
 
Method Summary
 TDelegate getDelegate()
          Returns the object to which the requested method calls will be delegated.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Executes the given method with the specified args against the internal delegate.
protected  void setDelegate(TDelegate delegate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingInvocationHandler

protected DelegatingInvocationHandler()

DelegatingInvocationHandler

public DelegatingInvocationHandler(TDelegate object)
Initialize the new instance with an object to delegate all method calls to.

Parameters:
object - The object to which method calls are delegated.
Throws:
java.lang.IllegalArgumentException - if object is null.
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Executes the given method with the specified args against the internal delegate.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

getDelegate

public TDelegate getDelegate()
Returns the object to which the requested method calls will be delegated.


setDelegate

protected void setDelegate(TDelegate delegate)