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

java.lang.Object
  extended by ch.elca.el4j.services.exceptionhandler.handler.AbstractExceptionHandler
      extended by ch.elca.el4j.services.exceptionhandler.handler.AbstractRetryExceptionHandler
All Implemented Interfaces:
ExceptionHandler
Direct Known Subclasses:
AbstractReconfigureExceptionHandler, AbstractSwappableTargetExceptionHandler, RetryExceptionHandler

public abstract class AbstractRetryExceptionHandler
extends AbstractExceptionHandler

Retry exception handlers force the AbstractExceptionHandlerInterceptor to rerun the complete invocation. They signal a retry with the RetryException which contains the expected number of retries. The exception handler interceptor however is free to choose another number of retries (e.g. if different retry exception handler are used).

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

Constructor Summary
AbstractRetryExceptionHandler()
           
 
Method Summary
protected  int getRetries()
           
 Object handleException(Throwable t, AbstractExceptionHandlerInterceptor exceptionInvoker, org.aopalliance.intercept.MethodInvocation invocation, org.slf4j.Logger logger)
          Handles the given throwable thrown by the method invocation.
protected abstract  Object retry(Throwable t, AbstractExceptionHandlerInterceptor exceptionInvoker, org.aopalliance.intercept.MethodInvocation invocation, org.slf4j.Logger logger)
          Creates a new retry exception.
 void setRetries(int retries)
          Sets the number of retires.
 
Methods inherited from class ch.elca.el4j.services.exceptionhandler.handler.AbstractExceptionHandler
getInvocationDescription, handleException, setUseDynamicLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRetryExceptionHandler

public AbstractRetryExceptionHandler()
Method Detail

setRetries

public void setRetries(int retries)
Sets the number of retires. Default is 5.

Parameters:
retries - The number of retries to set.

getRetries

protected int getRetries()
Returns:
Returns the number of expected retires.

handleException

public 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.

Specified by:
handleException in class AbstractExceptionHandler
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.

retry

protected abstract Object retry(Throwable t,
                                AbstractExceptionHandlerInterceptor exceptionInvoker,
                                org.aopalliance.intercept.MethodInvocation invocation,
                                org.slf4j.Logger logger)
                         throws Throwable
Creates a new retry exception. Subclasses may also do some other tasks (e.g. waiting). This method is called only if the number of retires is not already exceeded.

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 - Whenever something goes wrong.


Copyright © 2005-2011 ELCA. All Rights Reserved.