com.thoughtworks.proxy.toys.decorate
Class Decorator<T>

java.lang.Object
  extended by com.thoughtworks.proxy.toys.decorate.Decorator<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EchoDecorator

public abstract class Decorator<T>
extends Object
implements Serializable

Identity implementation for a Decorator. The implementation will just pass through any values. Override all methods that should behave differently.

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

Constructor Summary
Decorator()
           
 
Method Summary
 Object[] beforeMethodStarts(T 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(T proxy, Method method, Object[] args, Exception cause)
          Called when a method cannot be invoked, to possibly decorate the type of error.
 Object decorateResult(T proxy, Method method, Object[] args, Object result)
          Called on the way back from a method invocation, to possibly decorate the result.
 Throwable decorateTargetException(T 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

Decorator

public Decorator()
Method Detail

beforeMethodStarts

public Object[] beforeMethodStarts(T 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:
1.0

decorateResult

public Object decorateResult(T 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:
1.0

decorateTargetException

public Throwable decorateTargetException(T 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:
1.0

decorateInvocationException

public Exception decorateInvocationException(T 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:
1.0


Copyright © 2005-2010 Codehaus. All Rights Reserved.