ch.elca.el4j.services.exceptionhandler.handler
Class AbstractExceptionHandler

java.lang.Object
  extended by ch.elca.el4j.services.exceptionhandler.handler.AbstractExceptionHandler
All Implemented Interfaces:
ExceptionHandler
Direct Known Subclasses:
AbstractExceptionTransformerExceptionHandler, AbstractRetryExceptionHandler, SequenceExceptionHandler, SimpleLogExceptionHandler

public abstract class AbstractExceptionHandler
extends Object
implements ExceptionHandler

This class provides a logging setup that allows to use the target's log as well as the exception handler's.

Author:
Andreas Bur (ABU)
File-location:
AbstractExceptionHandler
Last check-in date:
2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) by swismer for revision 3873

Constructor Summary
AbstractExceptionHandler()
           
 
Method Summary
protected  String getInvocationDescription(org.aopalliance.intercept.MethodInvocation invocation)
          Pretty-prints the invocation.
 Object handleException(Throwable t, AbstractExceptionHandlerInterceptor exceptionInvoker, org.aopalliance.intercept.MethodInvocation invocation)
          Handles the given exception that occurred in the invocation of the given MethodInvocation.
protected abstract  Object handleException(Throwable t, AbstractExceptionHandlerInterceptor exceptionInvoker, org.aopalliance.intercept.MethodInvocation invocation, org.slf4j.Logger logger)
          Handles the given throwable thrown by the method invocation.
 void setUseDynamicLogger(boolean useDyanmicLog)
          Sets whether the dynamic logger which is the one of the target class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractExceptionHandler

public AbstractExceptionHandler()
Method Detail

setUseDynamicLogger

public void setUseDynamicLogger(boolean useDyanmicLog)
Sets whether the dynamic logger which is the one of the target class.

Parameters:
useDyanmicLog - If true the target class' logger will be used or the one of the concrete exception handler otherwise.

handleException

public Object handleException(Throwable t,
                              AbstractExceptionHandlerInterceptor exceptionInvoker,
                              org.aopalliance.intercept.MethodInvocation invocation)
                       throws Throwable
Handles the given exception that occurred in the invocation of the given MethodInvocation.

Specified by:
handleException in interface ExceptionHandler
Parameters:
t - The throwable to handle.
exceptionInvoker - The exception invoker that called this exception handler.
invocation - The invocation which has resulted in the given throwable.
Returns:
Returns an object that is treated as the original invocation's return value.
Throws:
RetryException - Signals that the complete invocation has to be rerun.
Throwable - Any exception thrown by the handler.

handleException

protected abstract Object handleException(Throwable t,
                                          AbstractExceptionHandlerInterceptor exceptionInvoker,
                                          org.aopalliance.intercept.MethodInvocation invocation,
                                          org.slf4j.Logger logger)
                                   throws Throwable
Handles the given throwable thrown by the method invocation. This method is called with the appropriate logger.

Parameters:
t - The exception thrown in the method invocation.
exceptionInvoker - The exception invoker that called this exception handler.
invocation - The original method invocation.
logger - The logger to be used by subclasses.
Returns:
Returns an object that is treated as the original invocation's return value.
Throws:
Throwable - Any exception thrown by the handler.

getInvocationDescription

protected String getInvocationDescription(org.aopalliance.intercept.MethodInvocation invocation)
Pretty-prints the invocation. This method is intended to be used for logging purposes. If the dynamic logger is used only the method's name is included.

Parameters:
invocation - The called method invocation.
Returns:
Returns the method invocation, pretty-printed.


Copyright © 2005-2011 ELCA. All Rights Reserved.