Interface InterlokMessage
-
public interface InterlokMessage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddMessageHeader(java.lang.String key, java.lang.String value)voidaddObjectHeader(java.lang.Object key, java.lang.Object object)Adds anObjectto this message as metadata.java.lang.StringgetContent()java.lang.StringgetContentEncoding()java.io.InputStreamgetInputStream()Return an inputstream representation of the payload.java.util.Map<java.lang.String,java.lang.String>getMessageHeaders()Returns a view of all the existing headers associated with the message.java.util.Map<java.lang.Object,java.lang.Object>getObjectHeaders()Returns theMapofObjectmetadata.java.io.OutputStreamgetOutputStream()Return an ouputstream ready for writing the payload.java.io.ReadergetReader()Return a reader representation of the payload.java.lang.StringgetUniqueId()Returns a unique identifier for this message.java.io.WritergetWriter()Return a writer ready for writing the payload.java.io.WritergetWriter(java.lang.String encoding)Return a writer ready for writing the payload.booleanheadersContainsKey(java.lang.String key)Returns true if the message contains metadata against the passed key.voidremoveMessageHeader(java.lang.String key)default java.lang.Stringresolve(java.lang.String s)Resolve against this message's metadata.java.lang.Stringresolve(java.lang.String s, boolean multiline)Resolve against this message's metadata.java.lang.ObjectresolveObject(java.lang.String s)Resolve against this message's object metadata.voidsetContent(java.lang.String payload, java.lang.String encoding)voidsetContentEncoding(java.lang.String payloadEncoding)voidsetMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)Overwrite all the headers.voidsetUniqueId(java.lang.String uniqueId)Sets this message's unique id.default <T> Twrap(MessageWrapper<T> wrapper)Wrap the interlok message as another type of thing.
-
-
-
Method Detail
-
getUniqueId
java.lang.String getUniqueId()
Returns a unique identifier for this message. The uniqueness of this identifier is dependent on the implementation.
This is generally considered to be a system level identifier. Each time a message is created a new unique id should be created. If an application of the framework requires a unique id that spans multiple messages (e.g. F4F request-reply) it would be better to create an instance of
AddMetadataServicethat assigns a higher level application unique id.- Returns:
- a unique identifier for this message
-
setUniqueId
void setUniqueId(java.lang.String uniqueId)
Sets this message's unique id. This is necessary to allow
AdaptrisMessageFactoryto set unique ids, the downside is that it makes unique ids mutable. Could get round this by putting unique id stuff in the message imp rather than the factory if required.- Parameters:
uniqueId- the unique identifier for the message
-
getContent
java.lang.String getContent()
-
setContent
void setContent(java.lang.String payload, java.lang.String encoding)
-
getMessageHeaders
java.util.Map<java.lang.String,java.lang.String> getMessageHeaders()
Returns a view of all the existing headers associated with the message.Any changes to the returned
Mapare not guaranteed to be reflected in underlying map. You should treat the returned Map as a read only view of the current message headers. UseaddMessageHeader(String, String)orremoveMessageHeader(String)to manipulate individual headers.- Returns:
- a read only view of the messages.
-
setMessageHeaders
void setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)
Overwrite all the headers.Clear and overwrite all the headers
- Parameters:
metadata-
-
addMessageHeader
void addMessageHeader(java.lang.String key, java.lang.String value)
-
removeMessageHeader
void removeMessageHeader(java.lang.String key)
-
getContentEncoding
java.lang.String getContentEncoding()
-
setContentEncoding
void setContentEncoding(java.lang.String payloadEncoding)
-
getReader
java.io.Reader getReader() throws java.io.IOExceptionReturn a reader representation of the payload.- Returns:
- a reader that can be used to access the payload
- Throws:
java.io.IOException- if the Reader could not be created.
-
getWriter
java.io.Writer getWriter() throws java.io.IOExceptionReturn a writer ready for writing the payload.- Returns:
- an Writer that can be used to write the payload using the existing encoding.
- Throws:
java.io.IOException- if the Writer could not be created.
-
getWriter
java.io.Writer getWriter(java.lang.String encoding) throws java.io.IOExceptionReturn a writer ready for writing the payload.- Parameters:
encoding- the encoding for the writer, which will also be used to change the character encoding of the message.- Returns:
- an Writer that can be used to access the payload.
- Throws:
java.io.IOException- if the Writer could not be created.- See Also:
setContentEncoding(String)
-
getInputStream
java.io.InputStream getInputStream() throws java.io.IOExceptionReturn an inputstream representation of the payload.- Returns:
- an InputStream that can be used to access the payload.
- Throws:
java.io.IOException- if the InputStream could not be created.
-
getOutputStream
java.io.OutputStream getOutputStream() throws java.io.IOExceptionReturn an ouputstream ready for writing the payload.- Returns:
- an OutputStream that can be used to access the payload.
- Throws:
java.io.IOException- if the OutputStream could not be created.
-
addObjectHeader
void addObjectHeader(java.lang.Object key, java.lang.Object object)Adds an
Objectto this message as metadata. Object metadata is intended to be used within a singleWorkflowonly and will not be encoded or otherwise transported between Workflows.- Parameters:
object- theObjectto set as metadatakey- the key to store this object against.
-
getObjectHeaders
java.util.Map<java.lang.Object,java.lang.Object> getObjectHeaders()
Returns the
MapofObjectmetadata.- Returns:
- the
MapofObjectmetadata
-
headersContainsKey
boolean headersContainsKey(java.lang.String key)
Returns true if the message contains metadata against the passed key.
- Parameters:
key- the key to look for- Returns:
- true if the message contains a metadata against the passed key
-
resolve
default java.lang.String resolve(java.lang.String s)
Resolve against this message's metadata.- Parameters:
s- string to resolve.- Returns:
- the original string, an item of metadata, or null (if the metadata key does not exist).
- See Also:
resolve(String, boolean)- Implementation Requirements:
- The default implementation simply calls
resolve(String, boolean).
-
resolve
java.lang.String resolve(java.lang.String s, boolean multiline)Resolve against this message's metadata.This is a helper method that allows you to pass in
%message{key1}and get the metadata associated withkey1. Strings that do not match that format will be returned as is. Support for punctuation characters is down to the implementation; the standard implementations only support a limited subset of punctuation characters in addition to standard word characters ([a-zA-Z_0-9]); They are_!"#&'+,-.:=. The magic values%message{%uniqueId}and%message{%size}should return the message unique-id and message size respectively- Parameters:
s- string to resolve.multiline- whether to resolve inPattern.DOTALLmode, allowing you to match against multiple lines.- Returns:
- the original string, an item of metadata, or null (if the metadata key does not exist).
-
resolveObject
java.lang.Object resolveObject(java.lang.String s)
Resolve against this message's object metadata.This is a helper method that allows you to pass in
%messageObject{key1}and get the object metadata associated withkey1(or null)Support for punctuation characters in the key nameis down to the implementation; the standard implementations only support a limited subset of punctuation characters in addition to standard word characters ([a-zA-Z_0-9]); They are_!"#&'+,-.:=.- Parameters:
s- string to resolve.- Returns:
- the object (or null).
-
wrap
default <T> T wrap(MessageWrapper<T> wrapper) throws java.lang.Exception
Wrap the interlok message as another type of thing.- Parameters:
wrapper- an implementation ofMessageWrapper- Returns:
- the wrapped object
- Throws:
java.lang.Exception
-
-