MessageType - the type of message handled by the handlerpublic class MessageHandlerErrorStrategyAdapter<MessageType> extends AbstractMessageHandler<MessageType>
MessageHandler which wraps and invokes another handler, catches any Throwable which is
thrown by the wrapped handler's MessageHandler.invoke(MessageContext), and applies
a list of configured TypedMessageErrorHandler strategies.
The configured error handlers are iterated in the supplied order, and each will be given an opportunity to
handle the error if the thrown Throwable is an instance a type supported by the error handler,
as determined by TypedMessageErrorHandler.handlesError(Throwable). This iteration is essentially a
"dynamic catch block". The first handler to indicate it has handled the error via the return value of
MessageErrorHandler.handleError(Throwable, MessageContext) terminates the error handler iteration.
A configured error handler may simply adjust or decorate the MessageContext with additional
information (e.g. to register a SOAP fault on behalf of a non-SOAP aware handler), or it may itself directly emit
an error response in a protocol- or technology-specific manner.
Whether the thrown Throwable is rethrown by this handler is determined by the flags
setRethrowIfHandled(boolean) and setRethrowIfNotHandled(boolean).
| Modifier and Type | Field and Description |
|---|---|
private List<TypedMessageErrorHandler> |
errorHandlers
The list of typed error handlers.
|
private org.slf4j.Logger |
log
Logger.
|
private boolean |
rethrowIfHandled
Flag indicating whether the wrapped handler's exception should be rethrown after being handled successfully.
|
private boolean |
rethrowIfNotHandled
Flag indicating whether the wrapped handler's exception should be rethrown if not handled successfully
by any configured error handler.
|
private MessageHandler<MessageType> |
wrappedHandler
The wrapped message handler.
|
| Constructor and Description |
|---|
MessageHandlerErrorStrategyAdapter(MessageHandler<MessageType> messageHandler,
List<TypedMessageErrorHandler> typedErrorHandlers)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doInvoke(MessageContext<MessageType> messageContext) |
void |
setRethrowIfHandled(boolean flag)
Set whether to rethrow the error if it is successfully handled by one of the
configured
TypedMessageErrorHandler. |
void |
setRethrowIfNotHandled(boolean flag)
Set whether to rethrow the error if it is NOT successfully handled by any of the
configured
TypedMessageErrorHandler. |
doPostInvoke, doPostInvoke, doPreInvoke, getActivationCondition, getLogPrefix, invoke, setActivationConditiondestroy, doDestroy, doInitialize, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitialize, isInitializedprivate org.slf4j.Logger log
private MessageHandler<MessageType> wrappedHandler
private List<TypedMessageErrorHandler> errorHandlers
private boolean rethrowIfHandled
private boolean rethrowIfNotHandled
public MessageHandlerErrorStrategyAdapter(@Nonnull MessageHandler<MessageType> messageHandler, @Nonnull List<TypedMessageErrorHandler> typedErrorHandlers)
messageHandler - the wrapped message handlertypedErrorHandlers - the list of typed error handlers to applypublic void setRethrowIfHandled(boolean flag)
TypedMessageErrorHandler.
Default is: false
flag - true if should rethrow, false if notpublic void setRethrowIfNotHandled(boolean flag)
TypedMessageErrorHandler.
Default is: true
flag - true if should rethrow, false if notprotected void doInvoke(MessageContext<MessageType> messageContext) throws MessageHandlerException
doInvoke in class AbstractMessageHandler<MessageType>MessageHandlerExceptionCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.