toolbox.services
Class LoggingInterceptor

Package class diagram package LoggingInterceptor
java.lang.Object
  extended by toolbox.services.AbstractInterceptor
      extended by toolbox.services.LoggingInterceptor
All Implemented Interfaces:
java.lang.reflect.InvocationHandler, Interceptor

public class LoggingInterceptor
extends AbstractInterceptor

Interceptor implementation to log method entry and exit events using the standard Java Logging facilities.


Constructor Summary
LoggingInterceptor()
          Default constructor.
 
Method Summary
 void init(java.util.Map config)
          Initialise this interceptor with the given configuration.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Invoke the given method on the target service and log method entry and exit.
 
Methods inherited from class toolbox.services.AbstractInterceptor
getObject, getTarget, invokeMethod, setObject, setTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingInterceptor

public LoggingInterceptor()
Default constructor.

Method Detail

init

public void init(java.util.Map config)
          throws ServiceException
Initialise this interceptor with the given configuration. This will use the provided configuration parameters to create or obtain a java.util.logging.Logger instance.

Parameters:
config - Map instance containing configuration parameters. This implemenation requires the following:
  • javaLogger - String indicating the logger name.
  • successLevel - String indicating log level for normal operation.
  • exceptionLevel - String indicating log level for exceptions.
Throws:
ServiceException - if the interceptor cannot be initialised.

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Invoke the given method on the target service and log method entry and exit.

Parameters:
proxy - Proxy instance method was invoked on.
method - Method instance, of an interface method, that was invoked on the proxy.
args - Method arguments.
Returns:
Object instance containing the result of the invocation.
Throws:
java.lang.Throwable - that occured during the method invocation.