Class MultipartMessageTranslator
- java.lang.Object
-
- com.adaptris.core.jms.MessageTypeTranslatorImp
-
- com.adaptris.core.jms.sonic.MultipartMessageTranslator
-
- All Implemented Interfaces:
AdaptrisMessageTranslator
,ComponentLifecycle
,MessageTypeTranslator
,MetadataHandlerContext
public class MultipartMessageTranslator extends MessageTypeTranslatorImp
Translates between
AdaptrisMessage
andprogress.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 translatorWhen 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 toprogress.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 theprogress.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 Summary
Fields Modifier and Type Field Description static java.lang.String
MULTIPART_MIXED_TYPE
-
Fields inherited from class com.adaptris.core.jms.MessageTypeTranslatorImp
helper, log, session
-
-
Constructor Summary
Constructors Constructor Description MultipartMessageTranslator()
MultipartMessageTranslator(JmsPartWriter writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
JmsPartWriter
getJmsPartWriter()
int
getMultipartIndex()
Get the part index.void
init()
void
registerSession(javax.jms.Session s)
void
setJmsPartWriter(JmsPartWriter writer)
Configure how each JMS Part is written.void
setMultipartIndex(int partIndex)
Set the part Index that will be used as the body of the AdaptrisMessage when converting from a MultipartMessage.void
start()
void
stop()
javax.jms.Message
translate(AdaptrisMessage msg)
Translates anAdaptrisMessage
into aMultipartMessage
.AdaptrisMessage
translate(javax.jms.Message msg)
Translates aMultipartMessage
into anAdaptrisMessage
.-
Methods inherited from class com.adaptris.core.jms.MessageTypeTranslatorImp
copyConfiguration, currentMessageFactory, currentSession, getMetadataConverters, getMetadataFilter, getMoveJmsHeaders, getReportAllErrors, metadataConverters, metadataFilter, moveJmsHeaders, registerMessageFactory, reportAllErrors, setMetadataConverters, setMetadataFilter, setMoveJmsHeaders, setReportAllErrors, start, stop, translate, withMetadataConverters, withMetadataConverters, withMetadataFilter, withMoveJmsHeaders, withReportAllErrors
-
-
-
-
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 aMultipartMessage
.- Parameters:
msg
- theAdaptrisMessage
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 anAdaptrisMessage
. Will also parse aBytesMessage
or aTextMessage
- Parameters:
msg
- theMessage
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
-
init
public void init() throws CoreException
- Throws:
CoreException
-
start
public void start() throws CoreException
- Throws:
CoreException
-
stop
public void stop()
-
close
public void close()
-
getJmsPartWriter
public JmsPartWriter getJmsPartWriter()
-
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 isJmsPartOutputStreamWriter
- See Also:
JmsPartWriter
,JmsPartOutputStreamWriter
,JmsPartStringWriter
-
registerSession
public void registerSession(javax.jms.Session s)
- Specified by:
registerSession
in interfaceMessageTypeTranslator
- Overrides:
registerSession
in classMessageTypeTranslatorImp
-
-