MessageType
- the type of message being handled@Prototype public abstract class AbstractMessageHandler<MessageType> extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent implements MessageHandler<MessageType>
MessageHandler
.Modifier and Type | Field and Description |
---|---|
private com.google.common.base.Predicate<MessageContext> |
activationCondition
Condition dictating whether to run or not.
|
private Logger |
log
Logger.
|
Constructor and Description |
---|
AbstractMessageHandler()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doInvoke(MessageContext<MessageType> messageContext)
Performs the handler logic.
|
protected void |
doPostInvoke(MessageContext<MessageType> messageContext)
Called after execution, handlers may override this method to perform post-processing for a request.
|
protected void |
doPostInvoke(MessageContext<MessageType> messageContext,
Exception e)
Called after execution, handlers may override this method to perform post-processing for a request.
|
protected boolean |
doPreInvoke(MessageContext<MessageType> messageContext)
Called prior to execution, handlers may override this method to perform pre-processing for a request.
|
com.google.common.base.Predicate<MessageContext> |
getActivationCondition()
Get activation condition indicating whether the handler should be invoked.
|
protected String |
getLogPrefix()
Return a prefix for logging messages for this component.
|
void |
invoke(MessageContext<MessageType> messageContext)
Invoke the handler on the specified message context.
|
void |
setActivationCondition(com.google.common.base.Predicate<MessageContext> condition)
Set activation condition indicating whether the handler should be invoked.
|
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
private Logger log
@Nonnull private com.google.common.base.Predicate<MessageContext> activationCondition
@Nonnull public com.google.common.base.Predicate<MessageContext> getActivationCondition()
Defaults to a predicate which always returns true
.
public void setActivationCondition(@Nonnull com.google.common.base.Predicate<MessageContext> condition)
Defaults to a predicate which always returns true
.
condition
- predicate to applypublic void invoke(@Nonnull MessageContext<MessageType> messageContext) throws MessageHandlerException
invoke
in interface MessageHandler<MessageType>
messageContext
- the message context on which to invoke the handlerMessageHandlerException
- if the there is an error invoking the handler on the message contextprotected boolean doPreInvoke(@Nonnull MessageContext<MessageType> messageContext) throws MessageHandlerException
The default impl applies the Predicate
set via the setActivationCondition(Predicate)
.
If false is returned, execution will not proceed.
Subclasses which override this method should generally invoke the super version of this method first, so that the activation condition will be applied up front, and immediately return false if the super version returns false. This avoids unnecessary execution of the remaining pre-invocation code if the handler ultimately will not execute.
messageContext
- the message context on which to invoke the handlerMessageHandlerException
- if there is a problem executing the handler pre-routineprotected abstract void doInvoke(@Nonnull MessageContext<MessageType> messageContext) throws MessageHandlerException
messageContext
- the message context on which to invoke the handlerMessageHandlerException
- if there is an error invoking the handler on the message contextprotected void doPostInvoke(@Nonnull MessageContext<MessageType> messageContext)
Handlers must not "fail" during this step. This method will not be called if doPreInvoke(org.opensaml.messaging.context.MessageContext<MessageType>)
fails, but is
called if an exception is raised by doInvoke(org.opensaml.messaging.context.MessageContext<MessageType>)
.
messageContext
- the message context on which the handler was invokedprotected void doPostInvoke(@Nonnull MessageContext<MessageType> messageContext, @Nonnull Exception e)
Handlers must not "fail" during this step. This method will not be called if doPreInvoke(org.opensaml.messaging.context.MessageContext<MessageType>)
fails, but is
called if an exception is raised by doInvoke(org.opensaml.messaging.context.MessageContext<MessageType>)
.
This version of the method will be called if an exception is raised during execution of the handler. The overall handler result will be to raise this error, so any errors inadvertently raised by this method will be logged and superseded.
The default implementation simply calls the error-less version of this method.
messageContext
- the message context on which the handler was invokede
- an exception raised by the doInvoke(org.opensaml.messaging.context.MessageContext<MessageType>)
methodCopyright © 1999–2015. All rights reserved.