com.thoughtworks.proxy.toys.decorate
Class InvocationDecoratorSupport

java.lang.Object
  extended by com.thoughtworks.proxy.toys.decorate.InvocationDecoratorSupport
All Implemented Interfaces:
InvocationDecorator, Serializable
Direct Known Subclasses:
EchoDecorator

public class InvocationDecoratorSupport
extends Object
implements InvocationDecorator

Identity implementation for a InvokerDecorator. The implementation will just pass through any values. Use this as base class for derived implementations, that do not override all of the methods.

Since:
0.1
Author:
Dan North
See Also:
Serialized Form

Constructor Summary
InvocationDecoratorSupport()
           
 
Method Summary
 Object[] beforeMethodStarts(Object proxy, Method method, Object[] args)
          Called before a method is invoked on an object, to possibly decorate the arguments being passed to the method invocation.
 Exception decorateInvocationException(Object proxy, Method method, Object[] args, Exception cause)
          Called when a method cannot be invoked, to possibly decorate the type of error.
 Object decorateResult(Object proxy, Method method, Object[] args, Object result)
          Called on the way back from a method invocation, to possibly decorate the result.
 Throwable decorateTargetException(Object proxy, Method method, Object[] args, Throwable cause)
          Called when a called method fails, to possibly decorate the type of error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InvocationDecoratorSupport

public InvocationDecoratorSupport()
Method Detail

beforeMethodStarts

public Object[] beforeMethodStarts(Object proxy,
                                   Method method,
                                   Object[] args)
Description copied from interface: InvocationDecorator
Called before a method is invoked on an object, to possibly decorate the arguments being passed to the method invocation.

Specified by:
beforeMethodStarts in interface InvocationDecorator
Parameters:
proxy - the proxy the method will be invoked on
method - the method to be invoked
args - the arguments being passed to the method
Returns:
the decorated arguments (typically just the ones supplied)

decorateResult

public Object decorateResult(Object proxy,
                             Method method,
                             Object[] args,
                             Object result)
Description copied from interface: InvocationDecorator
Called on the way back from a method invocation, to possibly decorate the result.

Specified by:
decorateResult in interface InvocationDecorator
Parameters:
proxy - the proxy the method was be invoked on
method - the invoked method
args - the arguments passed to the method
result - the result of the method invocation
Returns:
the decorated result (typically just the supplied result)

decorateTargetException

public Throwable decorateTargetException(Object proxy,
                                         Method method,
                                         Object[] args,
                                         Throwable cause)
Description copied from interface: InvocationDecorator
Called when a called method fails, to possibly decorate the type of error.

Specified by:
decorateTargetException in interface InvocationDecorator
Parameters:
proxy - the proxy the method was be invoked on
method - the invoked method
args - the arguments passed to the method
cause - the original exception thrown
Returns:
the decorated exception (typically just the supplied cause)

decorateInvocationException

public Exception decorateInvocationException(Object proxy,
                                             Method method,
                                             Object[] args,
                                             Exception cause)
Description copied from interface: InvocationDecorator
Called when a method cannot be invoked, to possibly decorate the type of error.

Specified by:
decorateInvocationException in interface InvocationDecorator
Parameters:
proxy - the proxy the method was be invoked on
method - the invoked method
args - the arguments passed to the method
cause - the original exception thrown
Returns:
the decorated exception (typically just the supplied cause)