public interface InterlokMessage
Modifier and Type | Method and Description |
---|---|
void |
addMessageHeader(java.lang.String key,
java.lang.String value) |
void |
addObjectHeader(java.lang.Object key,
java.lang.Object object)
Adds an
Object to this message as metadata. |
java.lang.String |
getContent() |
java.lang.String |
getContentEncoding() |
java.io.InputStream |
getInputStream()
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 the
Map of Object metadata. |
java.io.OutputStream |
getOutputStream()
Return an ouputstream ready for writing the payload.
|
java.io.Reader |
getReader()
Return a reader representation of the payload.
|
java.lang.String |
getUniqueId()
Returns a unique identifier for this message.
|
java.io.Writer |
getWriter()
Return a writer ready for writing the payload.
|
java.io.Writer |
getWriter(java.lang.String encoding)
Return a writer ready for writing the payload.
|
boolean |
headersContainsKey(java.lang.String key)
Returns true if the message contains metadata against the passed key.
|
void |
removeMessageHeader(java.lang.String key) |
default java.lang.String |
resolve(java.lang.String s)
Resolve against this message's metadata.
|
java.lang.String |
resolve(java.lang.String s,
boolean multiline)
Resolve against this message's metadata.
|
void |
setContent(java.lang.String payload,
java.lang.String encoding) |
void |
setContentEncoding(java.lang.String payloadEncoding) |
void |
setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)
Overwrite all the headers.
|
void |
setUniqueId(java.lang.String uniqueId)
Sets this message's unique id.
|
default <T> T |
wrap(MessageWrapper<T> wrapper)
Wrap the interlok message as another type of thing.
|
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
AddMetadataService
that assigns a higher level application
unique id.
void setUniqueId(java.lang.String uniqueId)
Sets this message's unique id. This is necessary to allow
AdaptrisMessageFactory
to 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.
uniqueId
- the unique identifier for the messagejava.lang.String getContent()
void setContent(java.lang.String payload, java.lang.String encoding)
java.util.Map<java.lang.String,java.lang.String> getMessageHeaders()
Any changes to the returned Map
are not guaranteed to be reflected in underlying map.
You should treat the returned Map as a read only view of the current message headers. Use
addMessageHeader(String, String)
or removeMessageHeader(String)
to manipulate
individual headers.
void setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)
Clear and overwrite all the headers
metadata
- void addMessageHeader(java.lang.String key, java.lang.String value)
void removeMessageHeader(java.lang.String key)
java.lang.String getContentEncoding()
void setContentEncoding(java.lang.String payloadEncoding)
java.io.Reader getReader() throws java.io.IOException
java.io.IOException
- if the Reader could not be created.java.io.Writer getWriter() throws java.io.IOException
java.io.IOException
- if the Writer could not be created.java.io.Writer getWriter(java.lang.String encoding) throws java.io.IOException
encoding
- the encoding for the writer, which will also be used to change the character encoding of the message.java.io.IOException
- if the Writer could not be created.setContentEncoding(String)
java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- if the InputStream could not be created.java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- if the OutputStream could not be created.void addObjectHeader(java.lang.Object key, java.lang.Object object)
Adds an Object
to this message as metadata. Object metadata is
intended to be used within a single Workflow
only and will not
be encoded or otherwise transported between Workflows.
object
- the Object
to set as metadatakey
- the key to store this object against.java.util.Map<java.lang.Object,java.lang.Object> getObjectHeaders()
Returns the Map
of Object
metadata.
Map
of Object
metadataboolean headersContainsKey(java.lang.String key)
Returns true if the message contains metadata against the passed key.
key
- the key to look fordefault java.lang.String resolve(java.lang.String s)
s
- string to resolve.resolve(String, boolean)
resolve(String, boolean)
.java.lang.String resolve(java.lang.String s, boolean multiline)
This is a helper method that allows you to pass in %message{key1}
and get the metadata
associated with key1
. 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
s
- string to resolve.multiline
- whether to resolve in Pattern.DOTALL
mode, allowing
you to match against multiple lines.default <T> T wrap(MessageWrapper<T> wrapper) throws java.lang.Exception
wrapper
- an implementation of MessageWrapper
java.lang.Exception