Holger's
Java API

com.antelmann.util
Interface InterfaceMonitor

All Known Implementing Classes:
InterfaceMonitor.Adapter

public interface InterfaceMonitor

allows to monitor all method calls to an object through a proxy object based on a specified interface. The specified methods are executed within the same thread as the call to the proxy object that handles the method calls.

Since:
06/21/06
Author:
Holger Antelmann
See Also:
InterfaceWrapper

Nested Class Summary
static class InterfaceMonitor.Adapter
          a helper class to faciliate the implementation of the embedding interface
 
Method Summary
 void methodInvoked(Object object, Method method, Object[] args, long timeTaken, Object returnValue, Throwable throwable)
          called after the given method on the given ojbect with the given arguments has been executed.
 Throwable prepareInvokation(Object object, Method method, Object[] args)
          called before the given method is executed on the given object with the given parameters.
 

Method Detail

prepareInvokation

Throwable prepareInvokation(Object object,
                            Method method,
                            Object[] args)
called before the given method is executed on the given object with the given parameters. If the given method is to be called, this method is to return null to allow the method to be executed; in this case, the methodInvoked method of this interface is called after the invokation is done. If the return value is not null, the returned exception is directly thrown instead of invoking the given method; this way, method invokation can be prevented.

Parameters:
object - the original object that the given method is going to be executed on (if null is returned on this method)
method - the method that is to be executed on the given object
args - the arguments that are to be used for the given method execution
Returns:
null if the method is to be called and an exception to be thrown instead of the method call

methodInvoked

void methodInvoked(Object object,
                   Method method,
                   Object[] args,
                   long timeTaken,
                   Object returnValue,
                   Throwable throwable)
called after the given method on the given ojbect with the given arguments has been executed. Of the last two arguments, one is always null while the other contains a value. Note that this method is synchronously called before the return value (or the exception to be thrown) is passed to the caller of the proxy object.

Parameters:
object - the original object that the given method was invoked on
method - the method that was executed on the given object
args - the arguments that were used for the given method call
timeTaken - the time it took to execute the given method in milliseconds
returnValue - the value returned by the given method call (if no exception was thrown; otherwise null)
throwable - contains the exception thrown by the given method call (if any); if the throwable is null, the returnValue is not and vice versa.


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads