Class MessageHandlerErrorStrategyAdapter
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.handler.AbstractMessageHandler
-
- org.opensaml.messaging.handler.impl.MessageHandlerErrorStrategyAdapter
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
public class MessageHandlerErrorStrategyAdapter extends AbstractMessageHandler
AMessageHandlerwhich wraps and invokes another handler, catches anyThrowablewhich is thrown by the wrapped handler'sMessageHandler.invoke(MessageContext), and applies a list of configuredTypedMessageErrorHandlerstrategies.The configured error handlers are iterated in the supplied order, and each will be given an opportunity to handle the error if the thrown
Throwableis an instance a type supported by the error handler, as determined byTypedMessageErrorHandler.handlesError(Throwable). This iteration is essentially a "dynamic catch block". The first handler to indicate it has handled the error via the return value ofMessageErrorHandler.handleError(Throwable, MessageContext)terminates the error handler iteration.A configured error handler may simply adjust or decorate the
MessageContextwith 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
Throwableis rethrown by this handler is determined by the flagssetRethrowIfHandled(boolean)andsetRethrowIfNotHandled(boolean).
-
-
Field Summary
Fields Modifier and Type Field Description private List<TypedMessageErrorHandler>errorHandlersThe list of typed error handlers.private org.slf4j.LoggerlogLogger.private booleanrethrowIfHandledFlag indicating whether the wrapped handler's exception should be rethrown after being handled successfully.private booleanrethrowIfNotHandledFlag indicating whether the wrapped handler's exception should be rethrown if not handled successfully by any configured error handler.private MessageHandlerwrappedHandlerThe wrapped message handler.
-
Constructor Summary
Constructors Constructor Description MessageHandlerErrorStrategyAdapter(MessageHandler messageHandler, List<TypedMessageErrorHandler> typedErrorHandlers)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInvoke(MessageContext messageContext)voidsetRethrowIfHandled(boolean flag)Set whether to rethrow the error if it is successfully handled by one of the configuredTypedMessageErrorHandler.voidsetRethrowIfNotHandled(boolean flag)Set whether to rethrow the error if it is NOT successfully handled by any of the configuredTypedMessageErrorHandler.-
Methods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler
doPostInvoke, doPostInvoke, doPreInvoke, getActivationCondition, getLogPrefix, invoke, setActivationCondition
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private org.slf4j.Logger log
Logger.
-
wrappedHandler
@Nonnull private MessageHandler wrappedHandler
The wrapped message handler.
-
errorHandlers
@Nonnull @NonnullElements private List<TypedMessageErrorHandler> errorHandlers
The list of typed error handlers.
-
rethrowIfHandled
private boolean rethrowIfHandled
Flag indicating whether the wrapped handler's exception should be rethrown after being handled successfully.
-
rethrowIfNotHandled
private boolean rethrowIfNotHandled
Flag indicating whether the wrapped handler's exception should be rethrown if not handled successfully by any configured error handler.
-
-
Constructor Detail
-
MessageHandlerErrorStrategyAdapter
public MessageHandlerErrorStrategyAdapter(@Nonnull MessageHandler messageHandler, @Nonnull @NonnullElements List<TypedMessageErrorHandler> typedErrorHandlers)Constructor.- Parameters:
messageHandler- the wrapped message handlertypedErrorHandlers- the list of typed error handlers to apply
-
-
Method Detail
-
setRethrowIfHandled
public void setRethrowIfHandled(boolean flag)
Set whether to rethrow the error if it is successfully handled by one of the configuredTypedMessageErrorHandler.Default is: false
- Parameters:
flag- true if should rethrow, false if not
-
setRethrowIfNotHandled
public void setRethrowIfNotHandled(boolean flag)
Set whether to rethrow the error if it is NOT successfully handled by any of the configuredTypedMessageErrorHandler.Default is: true
- Parameters:
flag- true if should rethrow, false if not
-
doInvoke
protected void doInvoke(MessageContext messageContext) throws MessageHandlerException
- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
-