Holger's Java API

## com.antelmann.util
Interface InterfaceMonitor

All Known Implementing Classes:
  InterfaceMonitor.Adapter, InterfaceMonitor.IMLogger, InterfaceMonitor.Profiler, PerformanceMonitor

    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`, `PerformanceMonitor`

Nested Class Summary
`static class` `InterfaceMonitor.Adapter` a helper class to facilitate the implementation of the enclosing interface
`static class` `InterfaceMonitor.IMLogger` a convenience class that simply logs all access to an interface
`static class` `InterfaceMonitor.Profiler` allows to profile the access to an 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 object with the given arguments has been executed.
`Throwable` `prepareInvocation(Object object, Method method, Object[] args)` called before the given method is executed on the given object with the given parameters.

Method Detail

### prepareInvocation

    Throwable prepareInvocation(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 invocation is done. If the return value is not null, the returned exception is directly thrown instead of invoking the given method; this way, method invocation 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 (may be null)
  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 object 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 (may be null)
    `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) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads