com.emarsys.ecommon.exceptions.handling
Class InternalExceptionHandlerPool

java.lang.Object
  extended by com.emarsys.ecommon.exceptions.handling.InternalExceptionHandlerPool
All Implemented Interfaces:
ExceptionHandling

public class InternalExceptionHandlerPool
extends java.lang.Object
implements ExceptionHandling

An InternalExceptionHandlerPool represents an ExceptionHandlerPool that is associated with a single instance's class.

All exception scenarios internally will have a prefix

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

Field Summary
protected  java.lang.Object client
           
protected  ExceptionHandlerPool pool
           
 
Constructor Summary
InternalExceptionHandlerPool(java.lang.Object client)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

protected ExceptionHandlerPool pool

client

protected java.lang.Object client
Constructor Detail

InternalExceptionHandlerPool

public InternalExceptionHandlerPool(java.lang.Object client)
Method Detail

getExceptionHandler

public <E extends java.lang.Exception,T extends java.lang.Exception> ExceptionHandler<E,T> getExceptionHandler(ExceptionScenario<E,T> scenario)
Specified by:
getExceptionHandler in interface ExceptionHandling
Type Parameters:
E -
T -
Parameters:
scenario -
Returns:
See Also:
ExceptionHandlerPool.getExceptionHandler(com.emarsys.ecommon.exceptions.handling.ExceptionScenario)

registerExceptionHandler

public <E extends java.lang.Exception,T extends java.lang.Exception> void registerExceptionHandler(ExceptionScenario<E,T> scenario,
                                                                                                   ExceptionHandler<E,T> handler)
Specified by:
registerExceptionHandler in interface ExceptionHandling
Type Parameters:
E -
T -
Parameters:
scenario -
handler -
See Also:
ExceptionHandlerPool.registerExceptionHandler(com.emarsys.ecommon.exceptions.handling.ExceptionScenario, com.emarsys.ecommon.exceptions.handling.ExceptionHandler)

unregisterExceptionHandler

public <E extends java.lang.Exception,T extends java.lang.Exception> void unregisterExceptionHandler(ExceptionScenario<E,T> scenario)
Description copied from interface: ExceptionHandling
Unregisters the ExceptionHandler associated with the passed scenario if present.

Specified by:
unregisterExceptionHandler in interface ExceptionHandling
Type Parameters:
E -
T -
Parameters:
scenario -
See Also:
ExceptionHandlerPool.unregisterExceptionHandler(com.emarsys.ecommon.exceptions.handling.ExceptionScenario)

getExceptionHandlers

public java.util.Map<ExceptionScenario<?,?>,ExceptionHandler<?,?>> getExceptionHandlers()
Description copied from interface: ExceptionHandling

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.

Specified by:
getExceptionHandlers in interface ExceptionHandling
Returns:
See Also:
ExceptionHandlerPool.getExceptionHandlers()

unionExceptionHandling

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

Specified by:
unionExceptionHandling in interface ExceptionHandling
Returns:
the ExceptionHandling now in use.
See Also:
ExceptionHandlerPool.unionExceptionHandling(com.emarsys.ecommon.exceptions.handling.ExceptionHandling)

useExceptionHandling

public ExceptionHandling useExceptionHandling(ExceptionHandling handling)
Description copied from interface: ExceptionHandling
Will overwrite this exception handlings behavior with the passed instance's one.

Specified by:
useExceptionHandling in interface ExceptionHandling
Parameters:
handling -
Returns:
the ExceptionHandling now in use, needs not to be the same (identical) instance as the passed one.
See Also:
ExceptionHandlerPool.useExceptionHandling(com.emarsys.ecommon.exceptions.handling.ExceptionHandling)


Copyright © 2010 emarsys AG. All Rights Reserved.