com.emarsys.ecommon.exceptions.handling
Interface ExceptionHandling

All Known Implementing Classes:
ExceptionHandlerPool, InternalExceptionHandlerPool, JMailFolder, JMailStorage

public interface ExceptionHandling

Encapsulates a pluggable ExceptionHandling mechanism.

A Class implementing ExceptionHandling provides an interface to (un)register ExceptionHandlers which will handle Exceptions in a specific ExceptionScenario.
Associated exception scenarios and handlers always have to fit together, i.e. the must have the same type parameters.

NOTE: the whole pluggable exception handling (PEH) module is highly experimental and still under heavy development, don't use it in production code unless you know what you're doing!

Author:
Michael "kULO" Kulovits

See Also:
ExceptionHandler,


Method Summary
<E extends java.lang.Exception,T extends java.lang.Exception>
ExceptionHandler<E,T>
getExceptionHandler(ExceptionScenario<E,T> scenario)
           
 java.util.Map<ExceptionScenario<?,?>,ExceptionHandler<?,?>> getExceptionHandlers()
           The passed Map must not be the ExceptionHandling's interal, modifyable representation in order to protect from violating invariants.
<E extends java.lang.Exception,T extends java.lang.Exception>
void
registerExceptionHandler(ExceptionScenario<E,T> scenario, ExceptionHandler<E,T> handler)
           
 ExceptionHandling unionExceptionHandling(ExceptionHandling handling)
          Will add all ExceptionHandlers from the passed handling and overwrite already existing ones; already registered distinct handlers will remain registered.
<E extends java.lang.Exception,T extends java.lang.Exception>
void
unregisterExceptionHandler(ExceptionScenario<E,T> scenario)
          Unregisters the ExceptionHandler associated with the passed scenario if present.
 ExceptionHandling useExceptionHandling(ExceptionHandling handling)
          Will overwrite this exception handlings behavior with the passed instance's one.
 

Method Detail

getExceptionHandler

<E extends java.lang.Exception,T extends java.lang.Exception> ExceptionHandler<E,T> getExceptionHandler(ExceptionScenario<E,T> scenario)
Type Parameters:
E -
T -
Parameters:
scenario -
Returns:
the ExceptionHandler registered for the passed ExceptionScenario or null if not present.

getExceptionHandlers

java.util.Map<ExceptionScenario<?,?>,ExceptionHandler<?,?>> getExceptionHandlers()

The passed Map must not be the ExceptionHandling's interal, modifyable representation in order to protect from violating invariants. So the returned map might be a copy or a an immutable proxy of the exception handlings internal state.

Returns:
all ExceptionHandlers registered with this instance togheter with their associated ExceptionScenarios but never null, if no handler is present an empty Map will be returned.


registerExceptionHandler

<E extends java.lang.Exception,T extends java.lang.Exception> void registerExceptionHandler(ExceptionScenario<E,T> scenario,
                                                                                            ExceptionHandler<E,T> handler)
Type Parameters:
E -
T -
Parameters:
scenario -
handler -

unregisterExceptionHandler

<E extends java.lang.Exception,T extends java.lang.Exception> void unregisterExceptionHandler(ExceptionScenario<E,T> scenario)
Unregisters the ExceptionHandler associated with the passed scenario if present.

Type Parameters:
E -
T -
Parameters:
scenario -

useExceptionHandling

ExceptionHandling useExceptionHandling(ExceptionHandling handling)
Will overwrite this exception handlings behavior with the passed instance's one.

Parameters:
handling -
Returns:
the ExceptionHandling now in use, needs not to be the same (identical) instance as the passed one.

unionExceptionHandling

ExceptionHandling unionExceptionHandling(ExceptionHandling handling)
Will add all ExceptionHandlers from the passed handling and overwrite already existing ones; already registered distinct handlers will remain registered.

Parameters:
handling -
Returns:
the ExceptionHandling now in use.


Copyright © 2010 emarsys AG. All Rights Reserved.