consciouscode.util
Class CallTraceProxy

java.lang.Object
  extended by consciouscode.util.CallTraceProxy
All Implemented Interfaces:
InvocationHandler

public class CallTraceProxy
extends Object
implements InvocationHandler

A dynamic proxy that logs all method invocations for debugging purposes.

To trace invocations on a subject, call create(Object, Log) with the subject and (optionally) a Log. The proxy returned implements the same interfaces as the subject. As long as the proxy's log is not null, method invocations (through the proxy) will generate debug output logging entry and exit, along with any arguments, return values, and exceptions.

Instances of this class are not serializable, since there are no meaningful semantics for serializing a Log.

See Also:
Dynamic Proxy Classes

Method Summary
static Class<?>[] computeInterfaceClosure(Class<?> type)
           
static Object create(Object subject)
          Creates a disabled tracing proxy for a given subject.
static Object create(Object subject, Log log)
          Creates a tracing proxy for a given subject.
 Log getLog()
          Gets the log to which method invocations are being traced.
 Object invoke(Object proxy, Method method, Object[] args)
           
 void setLog(Log log)
          Sets the log to which method invocations will be traced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Object create(Object subject)
Creates a disabled tracing proxy for a given subject.


create

public static Object create(Object subject,
                            Log log)
Creates a tracing proxy for a given subject.


computeInterfaceClosure

public static Class<?>[] computeInterfaceClosure(Class<?> type)

getLog

public Log getLog()
Gets the log to which method invocations are being traced.


setLog

public void setLog(Log log)
Sets the log to which method invocations will be traced. If log is null, no tracing will be performed.


invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.