org.apache.servicemix.mail.marshaler
Class DefaultMailMarshaler

java.lang.Object
  extended by org.apache.servicemix.components.util.MarshalerSupport
      extended by org.apache.servicemix.mail.marshaler.AbstractMailMarshaler
          extended by org.apache.servicemix.mail.marshaler.DefaultMailMarshaler

public class DefaultMailMarshaler
extends AbstractMailMarshaler

this is the default marshaler for conversion between the normalized message format and the mail message format

Author:
lhein

Field Summary
 
Fields inherited from class org.apache.servicemix.mail.marshaler.AbstractMailMarshaler
DEFAULT_SENDER, DUMMY_CONTENT, DUMMY_SUBJECT, MAIL_TAG_BCC, MAIL_TAG_CC, MAIL_TAG_FROM, MAIL_TAG_REPLYTO, MAIL_TAG_SENTDATE, MAIL_TAG_SUBJECT, MAIL_TAG_TO, MSG_TAG_BCC, MSG_TAG_CC, MSG_TAG_FROM, MSG_TAG_HOST, MSG_TAG_HTML, MSG_TAG_MAIL_CHARSET, MSG_TAG_MAIL_CONTENT_TYPE, MSG_TAG_MAIL_USE_INLINE_ATTACHMENTS, MSG_TAG_PASSWORD, MSG_TAG_PORT, MSG_TAG_PROTOCOL, MSG_TAG_REPLYTO, MSG_TAG_SENTDATE, MSG_TAG_SUBJECT, MSG_TAG_TEXT, MSG_TAG_TO, MSG_TAG_USER
 
Constructor Summary
DefaultMailMarshaler()
           
 
Method Summary
protected  void appendAttachments(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg, javax.mail.internet.MimeMultipart multipart, java.lang.String partType)
          appends all attachments to the mime message
 void convertJBIToMail(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg, java.lang.String configuredSender, java.lang.String configuredReceiver)
          This method is used to convert a normalized message from the bus into a mime mail message to be sent to a mail server.
 void convertMailToJBI(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg, javax.mail.internet.MimeMessage mailMsg)
          This method is used to convert a mime mail message received via an email server into a normalized message which will be sent to the bus.
protected  void fillMailBodyAndAttachments(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg)
          fills all attachments from the normalized message into the mail message
protected  void fillMailHeaders(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.NormalizedMessage nmsg, java.lang.String configuredSender, java.lang.String configuredReceiver)
          fills the mail headers according to the normalized message headers
protected  void prepareAlternativeMail(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg)
          prepares a multipart alternative mail message (both html and text)
protected  void prepareMixedMail(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage nmsg)
          prepares a multipart mixed mail message
protected  void preparePlainTextMail(javax.mail.internet.MimeMessage mimeMessage, javax.jbi.messaging.NormalizedMessage nmsg)
          prepares a plain text mail message
 
Methods inherited from class org.apache.servicemix.mail.marshaler.AbstractMailMarshaler
addTemporaryResource, cleanUpResources, getAttachmentsMapFromNormalizedMessage, getDefaultSenderForOutgoingMails
 
Methods inherited from class org.apache.servicemix.components.util.MarshalerSupport
asString, getTransformer, setTransformer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMailMarshaler

public DefaultMailMarshaler()
Method Detail

convertMailToJBI

public void convertMailToJBI(javax.jbi.messaging.MessageExchange exchange,
                             javax.jbi.messaging.NormalizedMessage nmsg,
                             javax.mail.internet.MimeMessage mailMsg)
                      throws javax.mail.MessagingException
Description copied from class: AbstractMailMarshaler
This method is used to convert a mime mail message received via an email server into a normalized message which will be sent to the bus. If you want to specify your own conversion behaviour you have to override this method with your own logic.

Specified by:
convertMailToJBI in class AbstractMailMarshaler
Parameters:
exchange - the message exchange that will be sent to the bus
nmsg - the normalized in-message to be filled by this method
mailMsg - the mail message that was received via mail server
Throws:
javax.mail.MessagingException - on any conversion errors

convertJBIToMail

public void convertJBIToMail(javax.mail.internet.MimeMessage mimeMessage,
                             javax.jbi.messaging.MessageExchange exchange,
                             javax.jbi.messaging.NormalizedMessage nmsg,
                             java.lang.String configuredSender,
                             java.lang.String configuredReceiver)
                      throws javax.mail.MessagingException
Description copied from class: AbstractMailMarshaler
This method is used to convert a normalized message from the bus into a mime mail message to be sent to a mail server. If you want to specify your own conversion behaviour you have to override this method with your own logic.

Specified by:
convertJBIToMail in class AbstractMailMarshaler
Parameters:
mimeMessage - the mime mail message to be filled by this method
exchange - the message exchange from JBI bus
nmsg - the normalized message to transform to mail message
configuredSender - the sender configured in the xbean
configuredReceiver - the receiver configured in the xbean
Throws:
javax.mail.MessagingException - on conversion errors

fillMailBodyAndAttachments

protected void fillMailBodyAndAttachments(javax.mail.internet.MimeMessage mimeMessage,
                                          javax.jbi.messaging.MessageExchange exchange,
                                          javax.jbi.messaging.NormalizedMessage nmsg)
                                   throws java.lang.Exception
fills all attachments from the normalized message into the mail message

Parameters:
mimeMessage - the mail message to fill
exchange - the received exchange
nmsg - the normalized message received
Throws:
java.lang.Exception - on any errors

preparePlainTextMail

protected void preparePlainTextMail(javax.mail.internet.MimeMessage mimeMessage,
                                    javax.jbi.messaging.NormalizedMessage nmsg)
                             throws java.lang.Exception
prepares a plain text mail message

Parameters:
mimeMessage - the mail message
nmsg - the normalized message
Throws:
java.lang.Exception - on errors

prepareMixedMail

protected void prepareMixedMail(javax.mail.internet.MimeMessage mimeMessage,
                                javax.jbi.messaging.MessageExchange exchange,
                                javax.jbi.messaging.NormalizedMessage nmsg)
                         throws java.lang.Exception
prepares a multipart mixed mail message

Parameters:
mimeMessage - the mail message
exchange - the message exchange
nmsg - the normalized message
Throws:
java.lang.Exception - on errors

prepareAlternativeMail

protected void prepareAlternativeMail(javax.mail.internet.MimeMessage mimeMessage,
                                      javax.jbi.messaging.MessageExchange exchange,
                                      javax.jbi.messaging.NormalizedMessage nmsg)
                               throws java.lang.Exception
prepares a multipart alternative mail message (both html and text)

Parameters:
mimeMessage - the mail message
exchange - the message exchange
nmsg - the normalized message
Throws:
java.lang.Exception - on errors

appendAttachments

protected void appendAttachments(javax.jbi.messaging.MessageExchange exchange,
                                 javax.jbi.messaging.NormalizedMessage nmsg,
                                 javax.mail.internet.MimeMultipart multipart,
                                 java.lang.String partType)
                          throws java.lang.Exception
appends all attachments to the mime message

Parameters:
exchange - the message exchange
nmsg - the normalized message
multipart - the mime multipart
partType - the part type (INLINE / ATTACHMENT)
Throws:
java.lang.Exception - on any errors

fillMailHeaders

protected void fillMailHeaders(javax.mail.internet.MimeMessage mimeMessage,
                               javax.jbi.messaging.NormalizedMessage nmsg,
                               java.lang.String configuredSender,
                               java.lang.String configuredReceiver)
                        throws java.lang.Exception
fills the mail headers according to the normalized message headers

Parameters:
mimeMessage - the mail message to fill
nmsg - the normalized message received
configuredSender - the configured sender from xbean
configuredReceiver - the configured receiver from xbean
Throws:
java.lang.Exception - on errors


Copyright © 2005-2012 FuseSource. All Rights Reserved.