Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.meta.reflect.proxy
Class ProxyFactory.Handler

java.lang.Object
  extended by dk.rode.thesis.meta.reflect.proxy.ProxyFactory.Handler
All Implemented Interfaces:
InvocationHandler
Enclosing class:
ProxyFactory

private class ProxyFactory.Handler
extends Object
implements InvocationHandler

A handler is used to decorate all invocation handlers used by proxies created by any proxy factory.

A handler logs access to any method accessed via the proxy, and ensures correct ProxyFactory.Proxy functionality.

Author:
Gunni Rode / rode.dk

Field Summary
private  InvocationHandler handler
          The decorated handler.
 
Constructor Summary
private ProxyFactory.Handler(InvocationHandler handler)
          Constructor.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Logs each method invoked.
 String toString()
          Return the string representation of this handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

private final InvocationHandler handler
The decorated handler.

Never null.

Constructor Detail

ProxyFactory.Handler

private ProxyFactory.Handler(InvocationHandler handler)
Constructor.

Parameters:
handler - The actual invocation handler; cannot be null.
Throws:
NullPointerException - If handler is null.
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Logs each method invoked.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

toString

public String toString()
Return the string representation of this handler.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.