org.springframework.richclient.exceptionhandling.delegation
Class DelegatingExceptionHandler
java.lang.Object
org.springframework.richclient.exceptionhandling.AbstractRegisterableExceptionHandler
org.springframework.richclient.exceptionhandling.delegation.DelegatingExceptionHandler
- All Implemented Interfaces:
- Thread.UncaughtExceptionHandler, InitializingBean, RegisterableExceptionHandler
public class DelegatingExceptionHandler
- extends AbstractRegisterableExceptionHandler
- implements InitializingBean
An exception handler that selects an appropriate exception handler from a list
based on the thrown exception and delegates the handling of the exception to it.
This class works very similar to catch statements:
the first delegate which can handle the exception will handle it.
For example, consider 3 simple delegates for the following classes in this order:
NullPointerException (1), RuntimeException (2), IllegalArgumentException (3).
A thrown IllegalArgumentException will be handled by the (2) handler. The (3) handler is useless.
- Since:
- 0.3.0
- Author:
- Geoffrey De Smet
- See Also:
ExceptionHandlerDelegate
,
SimpleExceptionHandlerDelegate
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected final transient org.apache.commons.logging.Log logger
delegateList
protected List<ExceptionHandlerDelegate> delegateList
exceptionPurger
protected ExceptionPurger exceptionPurger
DelegatingExceptionHandler
public DelegatingExceptionHandler()
setDelegateList
public void setDelegateList(List<ExceptionHandlerDelegate> delegateList)
- Sets the list of delegates.
This is not a map because the order is important
and delegate selection is not a simple key based selector.
- Parameters:
delegateList
- a list of DelegatingExceptionHandlerDelegate
setExceptionPurger
public void setExceptionPurger(ExceptionPurger exceptionPurger)
- If set the throwable will first be purged before handling it.
- Parameters:
exceptionPurger
-
afterPropertiesSet
public void afterPropertiesSet()
throws Exception
- Specified by:
afterPropertiesSet
in interface InitializingBean
- Throws:
Exception
uncaughtException
public void uncaughtException(Thread thread,
Throwable throwable)
- Delegates the throwable to the appropriate delegate exception handler.
- Specified by:
uncaughtException
in interface Thread.UncaughtExceptionHandler
- Specified by:
uncaughtException
in interface RegisterableExceptionHandler
- Parameters:
thread
- the thread in which the throwable occurredthrowable
- the thrown throwable
Copyright © 2004-2008 The Spring Framework. All Rights Reserved.