com.thoughtworks.proxy.toys.echo
Class EchoDecorator

java.lang.Object
  extended bycom.thoughtworks.proxy.toys.decorate.InvocationDecoratorSupport
      extended bycom.thoughtworks.proxy.toys.echo.EchoDecorator
All Implemented Interfaces:
InvocationDecorator, Serializable

public class EchoDecorator
extends InvocationDecoratorSupport

A InvocationDecoratorSupport 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(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

EchoDecorator

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

Parameters:
out - the PrintWriter receving the logs
factory - the ProxyFactory to use
Since:
0.2, different arguments in 0.1
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
Overrides:
beforeMethodStarts in class InvocationDecoratorSupport

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
Overrides:
decorateResult in class InvocationDecoratorSupport

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
Overrides:
decorateTargetException in class InvocationDecoratorSupport

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
Overrides:
decorateInvocationException in class InvocationDecoratorSupport