Package org.opensaml.messaging.encoder
Class AbstractMessageEncoder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.encoder.AbstractMessageEncoder
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,UnmodifiableComponent,MessageEncoder
- Direct Known Subclasses:
AbstractHttpClientRequestMessageEncoder,AbstractHttpServletResponseMessageEncoder
public abstract class AbstractMessageEncoder extends AbstractInitializableComponent implements MessageEncoder, UnmodifiableComponent
Abstract message encoder.
-
-
Field Summary
Fields Modifier and Type Field Description private MessageContextmessageContextThe message context.
-
Constructor Summary
Constructors Constructor Description AbstractMessageEncoder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoDestroy()protected abstract voiddoEncode()Performs the encoding logic.protected voiddoInitialize()voidencode()Encode theMessageContextsupplied viaMessageEncoder.setMessageContext(MessageContext)to the sink.protected MessageContextgetMessageContext()Get the message context.voidprepareContext()This method should prepare the message context by creating and populating any binding-specific data structures required in the MessageContext, prior to actually encoding.voidsetMessageContext(MessageContext context)Set theMessageContextwhich is to be encoded.-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, 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.DestructableComponent
destroy, isDestroyed
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
messageContext
@Nullable private MessageContext messageContext
The message context.
-
-
Method Detail
-
setMessageContext
public void setMessageContext(@Nullable MessageContext context)Set theMessageContextwhich is to be encoded.- Specified by:
setMessageContextin interfaceMessageEncoder- Parameters:
context- the message context
-
encode
public void encode() throws MessageEncodingExceptionEncode theMessageContextsupplied viaMessageEncoder.setMessageContext(MessageContext)to the sink.- Specified by:
encodein interfaceMessageEncoder- Throws:
MessageEncodingException- if there is a problem encoding the message context
-
prepareContext
public void prepareContext() throws MessageEncodingExceptionThis method should prepare the message context by creating and populating any binding-specific data structures required in the MessageContext, prior to actually encoding.This method should be called after the MessageContext has been set, and before any binding-specific Handler or HandlerChains are invoked.
Example: For a SOAP encoder, this method would create and store the basic SOAP Envelope structure in the message context, so that Handlers that are invoked have a place to which to add headers.
This method may be a no-op if not required by the binding, or if the message type of the context implies that the binding-specific structures have already been created elsewhere (e.g. message-oriented code where the calling code already knows its SOAP, and is operating on the raw SOAP envelope anyway).
. Default implementation is a no-op.- Specified by:
prepareContextin interfaceMessageEncoder- Throws:
MessageEncodingException- if there is a problem preparing the message context for encoding
-
getMessageContext
@Nullable protected MessageContext getMessageContext()
Get the message context.- Returns:
- the message context.
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classAbstractInitializableComponent
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doEncode
protected abstract void doEncode() throws MessageEncodingExceptionPerforms the encoding logic. By the time this is called, this encoder has already been initialized and checked to ensure that it has not been destroyed.- Throws:
MessageEncodingException- thrown if there is a problem encoding the message
-
-