public class EchoDecorator<T> extends Decorator<T>
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.
| Modifier and Type | Field and Description |
|---|---|
private ProxyFactory |
factory |
private java.io.PrintWriter |
out |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
EchoDecorator(java.io.PrintWriter out,
ProxyFactory factory)
Construct an EchoingDecorator.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object[] |
beforeMethodStarts(T proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Called before a method is invoked on an object, to possibly decorate the arguments being passed to the method
invocation.
|
java.lang.Exception |
decorateInvocationException(T proxy,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Exception cause)
Called when a method cannot be invoked, to possibly decorate the type of error.
|
java.lang.Object |
decorateResult(T proxy,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Object result)
Called on the way back from a method invocation, to possibly decorate the result.
|
java.lang.Throwable |
decorateTargetException(T proxy,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Throwable cause)
Called when a called method fails, to possibly decorate the type of error.
|
private void |
printInvocationException(java.lang.Throwable throwable) |
private void |
printMethodCall(java.lang.reflect.Method method,
java.lang.Object[] args) |
private void |
printMethodResult(java.lang.Object result) |
private void |
printTargetException(java.lang.Throwable throwable) |
private static final long serialVersionUID
private final java.io.PrintWriter out
private final ProxyFactory factory
public EchoDecorator(java.io.PrintWriter out,
ProxyFactory factory)
out - the PrintWriter receiving the logsfactory - the ProxyFactory to usepublic java.lang.Object[] beforeMethodStarts(T proxy, java.lang.reflect.Method method, java.lang.Object[] args)
DecoratorbeforeMethodStarts in class Decorator<T>proxy - the proxy the method will be invoked onmethod - the method to be invokedargs - the arguments being passed to the methodpublic java.lang.Object decorateResult(T proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object result)
DecoratordecorateResult in class Decorator<T>proxy - the proxy the method was be invoked onmethod - the invoked methodargs - the arguments passed to the methodresult - the result of the method invocationpublic java.lang.Throwable decorateTargetException(T proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Throwable cause)
DecoratordecorateTargetException in class Decorator<T>proxy - the proxy the method was be invoked onmethod - the invoked methodargs - the arguments passed to the methodcause - the original exception thrownpublic java.lang.Exception decorateInvocationException(T proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Exception cause)
DecoratordecorateInvocationException in class Decorator<T>proxy - the proxy the method was be invoked onmethod - the invoked methodargs - the arguments passed to the methodcause - the original exception thrownprivate void printMethodCall(java.lang.reflect.Method method,
java.lang.Object[] args)
private void printMethodResult(java.lang.Object result)
private void printTargetException(java.lang.Throwable throwable)
private void printInvocationException(java.lang.Throwable throwable)