Interface InterlokMessage


  • public interface InterlokMessage
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method 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.
      java.lang.Object resolveObject​(java.lang.String s)
      Resolve against this message's object 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.
    • 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 AddMetadataService that 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 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.

        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 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.

        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.IOException
        Return 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.IOException
        Return 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.IOException
        Return 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.IOException
        Return 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.IOException
        Return 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 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.

        Parameters:
        object - the Object to set as metadata
        key - the key to store this object against.
      • getObjectHeaders

        java.util.Map<java.lang.Object,​java.lang.Object> getObjectHeaders()

        Returns the Map of Object metadata.

        Returns:
        the Map of Object metadata
      • 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 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

        Parameters:
        s - string to resolve.
        multiline - whether to resolve in Pattern.DOTALL mode, 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 with key1 (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 of MessageWrapper
        Returns:
        the wrapped object
        Throws:
        java.lang.Exception