net.sf.composite.util
Class DelegatingInvocationHandler

java.lang.Object
  extended by net.sf.composite.util.DelegatingInvocationHandler
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class DelegatingInvocationHandler
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

An invocation handler that delegates method calls to a delegate object. This invocation handler is useful for declaring that a class implements a given interface at runtime rather than at compile time. The delegate object must already have implementations for each method declared in the interface.

Since:
Dec 27, 2004
Author:
Matt Sgarlata

Constructor Summary
DelegatingInvocationHandler(java.lang.Object delegate)
          Creates a new invocation handler that delegates invocation requests to the specified delegate.
 
Method Summary
 java.lang.Object getDelegate()
           
protected  java.lang.Object getDelegate(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
protected  java.lang.reflect.Method getDelegateMethod(java.lang.Object delegate, java.lang.reflect.Method method, java.lang.Object[] args)
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
 void setDelegate(java.lang.Object delegate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingInvocationHandler

public DelegatingInvocationHandler(java.lang.Object delegate)
Creates a new invocation handler that delegates invocation requests to the specified delegate.

Parameters:
delegate - the delegate that will be used
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
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

getDelegateMethod

protected java.lang.reflect.Method getDelegateMethod(java.lang.Object delegate,
                                                     java.lang.reflect.Method method,
                                                     java.lang.Object[] args)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

getDelegate

protected java.lang.Object getDelegate(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)

getDelegate

public java.lang.Object getDelegate()

setDelegate

public void setDelegate(java.lang.Object delegate)


Copyright © 2005-2008.