com.thoughtworks.proxy.toys.echo
Class EchoDecorator<T>

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

public class EchoDecorator<T>
extends Decorator<T>

A Decorator implementation that echoes any invocation to a PrintWriter.

The implementation will try to create new proxies for every return value, that can be proxied by the ProxyFactory in use.

Since:
0.1
Author:
Dan North, Jörg Schaible
See Also:
Serialized Form

Constructor Summary
EchoDecorator(PrintWriter out, ProxyFactory factory)
          Construct an EchoingDecorator.
 
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

EchoDecorator

public EchoDecorator(PrintWriter out,
                     ProxyFactory factory)
Construct an EchoingDecorator.

Parameters:
out - the PrintWriter receiving the logs
factory - the ProxyFactory to use
Since:
0.2
Method Detail

beforeMethodStarts

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

Overrides:
beforeMethodStarts in class Decorator<T>
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(T proxy,
                             Method method,
                             Object[] args,
                             Object result)
Description copied from class: Decorator
Called on the way back from a method invocation, to possibly decorate the result.

Overrides:
decorateResult in class Decorator<T>
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(T proxy,
                                         Method method,
                                         Object[] args,
                                         Throwable cause)
Description copied from class: Decorator
Called when a called method fails, to possibly decorate the type of error.

Overrides:
decorateTargetException in class Decorator<T>
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(T proxy,
                                             Method method,
                                             Object[] args,
                                             Exception cause)
Description copied from class: Decorator
Called when a method cannot be invoked, to possibly decorate the type of error.

Overrides:
decorateInvocationException in class Decorator<T>
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)


Copyright © 2005-2010 Codehaus. All Rights Reserved.