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
.
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
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MULTIPART_MIXED_TYPE |
helper, log, session
Constructor and Description |
---|
MultipartMessageTranslator() |
MultipartMessageTranslator(JmsPartWriter writer) |
Modifier and Type | Method and 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 an
AdaptrisMessage into a MultipartMessage . |
AdaptrisMessage |
translate(javax.jms.Message msg)
Translates a
MultipartMessage into an AdaptrisMessage . |
copyConfiguration, currentMessageFactory, currentSession, getMetadataConverters, getMetadataFilter, getMoveJmsHeaders, getReportAllErrors, metadataConverters, metadataFilter, moveJmsHeaders, registerMessageFactory, reportAllErrors, setMetadataConverters, setMetadataFilter, setMoveJmsHeaders, setReportAllErrors, start, stop, translate, withMetadataConverters, withMetadataConverters, withMetadataFilter, withMoveJmsHeaders, withReportAllErrors
public static final java.lang.String MULTIPART_MIXED_TYPE
public MultipartMessageTranslator()
public MultipartMessageTranslator(JmsPartWriter writer)
public javax.jms.Message translate(AdaptrisMessage msg) throws javax.jms.JMSException
Translates an AdaptrisMessage
into a MultipartMessage
.
msg
- the AdaptrisMessage
to translateMultipartMessage
javax.jms.JMSException
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
msg
- the Message
to translateAdaptrisMessage
javax.jms.JMSException
public int getMultipartIndex()
setMultipartIndex(int)
public void setMultipartIndex(int partIndex)
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 partpublic void init() throws CoreException
CoreException
public void start() throws CoreException
CoreException
public void stop()
public void close()
public JmsPartWriter getJmsPartWriter()
public void setJmsPartWriter(JmsPartWriter writer)
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.
writer
- the jmsPartWriter default is JmsPartOutputStreamWriter
JmsPartWriter
,
JmsPartOutputStreamWriter
,
JmsPartStringWriter
public void registerSession(javax.jms.Session s)
registerSession
in interface MessageTypeTranslator
registerSession
in class MessageTypeTranslatorImp