com.thoughtworks.proxy.toys.decorate
Interface InvocationDecorator

All Superinterfaces:
Serializable
All Known Implementing Classes:
EchoDecorator, InvocationDecoratorSupport

public interface InvocationDecorator
extends Serializable

Decorates a method invocation

Since:
0.1
Author:
Dan North

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.
 

Method Detail

beforeMethodStarts

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.

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)
Since:
0.1

decorateResult

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

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)
Since:
0.2, different arguments in 0.1

decorateTargetException

Throwable decorateTargetException(Object proxy,
                                  Method method,
                                  Object[] args,
                                  Throwable cause)
Called when a called method fails, to possibly decorate the type of error.

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)
Since:
0.2, different arguments in 0.1

decorateInvocationException

Exception decorateInvocationException(Object proxy,
                                      Method method,
                                      Object[] args,
                                      Exception cause)
Called when a method cannot be invoked, to possibly decorate the type of error.

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)
Since:
0.2, different arguments in 0.1