Class MultipartMessageTranslator

  • All Implemented Interfaces:
    AdaptrisMessageTranslator, ComponentLifecycle, MessageTypeTranslator, MetadataHandlerContext

    public class MultipartMessageTranslator
    extends MessageTypeTranslatorImp

    Translates between AdaptrisMessage and progress.message.jclient.MultipartMessage.

    When translating to an AdaptrisMessage, If no multipart-index is specified then each Part of the progress.message.jclient.MultipartMessage is taken and stored as a MimeBodyPart in the resulting AdaptrisMessage. If a multipart-index is specified, then only that Part is taken to form the body of the AdaptrisMessage. The other parts will be discarded. All the header information associated with each part carried-over will either be stored as metadata on the AdaptrisMessage or as headers on the MimeBodyPart.

    In addition to handling progress.message.jclient.MultipartMessage, this translator delegates ByteMessage, ObjectMessage, TextMessage and XMLMessage (defaults only for XMLMessage) to the appropriate translator

    When translating to a progress.message.jclient.MultipartMessage, if the AdaptrisMessage object is considered MIME Encoded ( CoreConstants.MSG_MIME_ENCODED) then each part is added as a separate part to progress.message.jclient.MultipartMessage. Header information on each MimeBodyPart will be carried over. If the AdaptrisMessage is not considered MIME Encoded, then it is added as a single part to the progress.message.jclient.MultipartMessage.

    See Also:
    CoreConstants.MSG_MIME_ENCODED

    In the adapter configuration file this class is aliased as sonic-multipart-message-translator which is the preferred alternative to the fully qualified classname when building your configuration.

    License Required: BASIC

    • Field Detail

      • MULTIPART_MIXED_TYPE

        public static final java.lang.String MULTIPART_MIXED_TYPE
        See Also:
        Constant Field Values
    • Constructor Detail

      • MultipartMessageTranslator

        public MultipartMessageTranslator()
      • MultipartMessageTranslator

        public MultipartMessageTranslator​(JmsPartWriter writer)
    • Method Detail

      • translate

        public javax.jms.Message translate​(AdaptrisMessage msg)
                                    throws javax.jms.JMSException

        Translates an AdaptrisMessage into a MultipartMessage.

        Parameters:
        msg - the AdaptrisMessage to translate
        Returns:
        a new MultipartMessage
        Throws:
        javax.jms.JMSException
      • translate

        public AdaptrisMessage translate​(javax.jms.Message msg)
                                  throws javax.jms.JMSException

        Translates a MultipartMessage into an AdaptrisMessage. Will also parse a BytesMessage or a TextMessage

        Parameters:
        msg - the Message to translate
        Returns:
        an AdaptrisMessage
        Throws:
        javax.jms.JMSException
      • getMultipartIndex

        public int getMultipartIndex()
        Get the part index.
        Returns:
        Returns the partIndex.
        See Also:
        setMultipartIndex(int)
      • setMultipartIndex

        public void setMultipartIndex​(int partIndex)
        Set the part Index that will be used as the body of the AdaptrisMessage when converting from a MultipartMessage.
        Parameters:
        partIndex - The partIndex to set, if set to -1 (the default), then all message parts are simply appended together as AdaptrisMessage. 0 is the first part
      • stop

        public void stop()
      • close

        public void close()
      • setJmsPartWriter

        public void setJmsPartWriter​(JmsPartWriter writer)
        Configure how each JMS Part is written.

        From testing; it has been shown that the various JMS Test tools that are available do not handle the use of the raw OutputStream that is used to generate each Part in the MultipartMessage. As a result, they may not display correctly in these tools. Use this writer the control how each part is generated.

        Parameters:
        writer - the jmsPartWriter default is JmsPartOutputStreamWriter
        See Also:
        JmsPartWriter, JmsPartOutputStreamWriter, JmsPartStringWriter