org.perfectjpattern.core.extras.delegate
Class AbstractDelegator.DelegateProxy

java.lang.Object
  extended by org.perfectjpattern.core.extras.delegate.AbstractDelegator.DelegateProxy
All Implemented Interfaces:
InvocationHandler, IDelegate
Enclosing class:
AbstractDelegator<I>

protected class AbstractDelegator.DelegateProxy
extends Object
implements IDelegate, InvocationHandler

 

Constructor Summary
AbstractDelegator.DelegateProxy(Object aTarget, Class aTargetClass, String aMethodName, AbstractDelegator aTemplate)
          Constructs a DelegateProxy supplying a Class passing in types not template.
 
Method Summary
protected  Method getMethod()
          Returns the method.
protected  Object getTarget()
          Returns the target Object.
 Object invoke(Object... anArguments)
          Returns the Result of the target call; primitive types are wrapped; may return void result.
 Object invoke(Object aProxy, Method aMethod, Object[] anArguments)
          
protected  void validateArgs(Object[] anArguments, Class[] anExpectedArguments)
          Validate actual arguments to match those expected from the Delegate type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDelegator.DelegateProxy

public AbstractDelegator.DelegateProxy(Object aTarget,
                                       Class aTargetClass,
                                       String aMethodName,
                                       AbstractDelegator aTemplate)
                                throws UnsupportedOperationException
Constructs a DelegateProxy supplying a Class passing in types not template.

Parameters:
aTarget -
aTargetClass -
aMethodName -
aTemplate -
Throws:
UnsupportedOperationException
Method Detail

invoke

public Object invoke(Object aProxy,
                     Method aMethod,
                     Object[] anArguments)

Specified by:
invoke in interface InvocationHandler

invoke

public Object invoke(Object... anArguments)
              throws IllegalArgumentException,
                     UnsupportedOperationException
Returns the Result of the target call; primitive types are wrapped; may return void result. Executes the target method using the input arguments and returns the appropriate result if any.

Specified by:
invoke in interface IDelegate
Parameters:
anArguments - List of input arguments.
Returns:
Result of the target call; primitive types are wrapped; may return void result.
Throws:
IllegalArgumentException
UnsupportedOperationException

validateArgs

protected void validateArgs(Object[] anArguments,
                            Class[] anExpectedArguments)
                     throws IllegalArgumentException
Validate actual arguments to match those expected from the Delegate type.

Parameters:
anArguments - Arguments to validate
anExpectedArguments - Expected arguments signature
Throws:
IllegalArgumentException - 'anExpectedArguments' must not be null
IllegalArgumentException - Delegator required 'N' arguments
IllegalArgumentException - Argument 'i' must be of type 'X'

getMethod

protected Method getMethod()
Returns the method.

Returns:
Method.

getTarget

protected Object getTarget()
Returns the target Object.

Returns:
Target Object.


Copyright © 2007-2009. All Rights Reserved.