Package org.jpos.core.handlers.exception
Interface ExceptionHandlerAware
-
- All Known Implementing Classes:
AmexChannel
,ASCIIChannel
,BASE24Channel
,BASE24TCPChannel
,BaseChannel
,BCDChannel
,CSChannel
,FSDChannel
,GICCChannel
,GZIPChannel
,HEXChannel
,LogChannel
,NACChannel
,NCCChannel
,PADChannel
,PostChannel
,RawChannel
,RBPChannel
,TelnetXMLChannel
,VAPChannel
,X25Channel
,XMLChannel
public interface ExceptionHandlerAware
Interface that modifies an implementing class to add an exception handling pipeline.The main pipeline consists of multiple sub-pipelines:
- A pipeline for which handlers are called regardless of the type of exception handled. Stored under a null key.
- A pipeline per targeted exception type.
In the event that both of the pipelines are empty, the default behavior is to rethrow the initial exception.
There is no need to implement the methods unless you override the default behavior.
- Since:
- 2.1.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
addHandler(ExceptionHandler handler)
Add a handler to the default pipeline.default void
addHandler(ExceptionHandler handler, java.lang.Class<? extends java.lang.Exception> clazz)
Add a handler to an exception specific pipeline.java.util.Map<java.lang.Class<? extends java.lang.Exception>,java.util.List<ExceptionHandler>>
getExceptionHandlers()
default java.lang.Exception
handle(java.lang.Exception e)
Execute the pipeline by starting with the specific pipeline for the exception followed by the default pipeline.default void
removeHandler(ExceptionHandler handler)
Remove a handler from the default pipeline.default void
removeHandler(ExceptionHandler handler, java.lang.Class<? extends java.lang.Exception> clazz)
Remove a handler from an exception specific handler pipeline.default void
removeHandlers(java.lang.Class<? extends java.lang.Exception> clazz)
Remove all handler for a specific exception handling pipeline.
-
-
-
Method Detail
-
getExceptionHandlers
java.util.Map<java.lang.Class<? extends java.lang.Exception>,java.util.List<ExceptionHandler>> getExceptionHandlers()
- Returns:
- A map of exception classes to exception handlers. These handlers only execute if the exception matches.
-
addHandler
default void addHandler(ExceptionHandler handler)
Add a handler to the default pipeline.- Parameters:
handler
- ExceptionHandler to add.
-
addHandler
default void addHandler(ExceptionHandler handler, java.lang.Class<? extends java.lang.Exception> clazz)
Add a handler to an exception specific pipeline.- Parameters:
handler
- ExceptionHandler to add.clazz
- Exception handler pipeline to add it to.
-
removeHandler
default void removeHandler(ExceptionHandler handler)
Remove a handler from the default pipeline.- Parameters:
handler
- ExceptionHandler to remove.
-
removeHandler
default void removeHandler(ExceptionHandler handler, java.lang.Class<? extends java.lang.Exception> clazz)
Remove a handler from an exception specific handler pipeline. The list of exception handlers is removed once the last handler has been removed.- Parameters:
handler
- ExceptionHandler to remove.clazz
- Exception pipeline to remove it from.
-
removeHandlers
default void removeHandlers(java.lang.Class<? extends java.lang.Exception> clazz)
Remove all handler for a specific exception handling pipeline.- Parameters:
clazz
- Exception pipeline to remove.
-
handle
default java.lang.Exception handle(java.lang.Exception e) throws java.lang.Exception
Execute the pipeline by starting with the specific pipeline for the exception followed by the default pipeline.
In the event of both pipelines being empty, the original exception is rethrown.- Parameters:
e
- Initial exception.- Returns:
- Same, modified or new exception.
- Throws:
java.lang.Exception
- In the event of a handler throwing an exception. Processing by further handlers would be cancelled.
-
-