ch.elca.el4j.util.socketstatistics
Class ReflectiveDelegator

java.lang.Object
  extended by ch.elca.el4j.util.socketstatistics.ReflectiveDelegator

public class ReflectiveDelegator
extends Object

Delegator for the use of SocketImpl using reflection. Inspired by http://www.javaspecialists.eu/archive/Issue168.html

Author:
Jonas Hauenstein (JHN)
File-location:
ReflectiveDelegator
Last check-in date:
2009-09-25 16:38:41 +0200 (Fr, 25. Sep 2009) by jonasha for revision 3929

Nested Class Summary
 class ReflectiveDelegator.DelegatorMethodFinder
          Internal class for explicitly defined method calls using delegateTo.
 
Constructor Summary
ReflectiveDelegator(Object source, Class superclass, Object delegate)
          Constructor.
ReflectiveDelegator(Object source, Class superclass, String delegateClassName)
          Constructor.
 
Method Summary
 ReflectiveDelegator.DelegatorMethodFinder delegateTo(String methodName, Class<?>... parameters)
          Method for explicit delegation of method call.
<T> T
invoke(Object... args)
          Method for invocation on delegated class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectiveDelegator

public ReflectiveDelegator(Object source,
                           Class superclass,
                           Object delegate)
Constructor.

Parameters:
source - source class for reflection
superclass - class used for delegation
delegate - reference to class for delegated method calls

ReflectiveDelegator

public ReflectiveDelegator(Object source,
                           Class superclass,
                           String delegateClassName)
Constructor.

Parameters:
source - source class for reflection
superclass - class used for delegation
delegateClassName - name of the class for delegated method calls
Method Detail

invoke

public final <T> T invoke(Object... args)
Method for invocation on delegated class.

Type Parameters:
T - generic return type
Parameters:
args - arguments to be passed to the original method
Returns:
return value of original method

delegateTo

public ReflectiveDelegator.DelegatorMethodFinder delegateTo(String methodName,
                                                            Class<?>... parameters)
Method for explicit delegation of method call.

Parameters:
methodName - name of method to be called
parameters - parameters to be passed to called method
Returns:
return value of called method


Copyright © 2005-2011 ELCA. All Rights Reserved.