org.apache.servicemix.mail.marshaler
Class AbstractMailMarshaler

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

public abstract class AbstractMailMarshaler
extends org.apache.servicemix.components.util.MarshalerSupport

this is the abstract super class of all marshalers which want to convert between normalized messages and mail messages and vice versa.

Author:
lhein

Field Summary
static java.lang.String DEFAULT_SENDER
          the default sender address for outgoing mails
static java.lang.String DUMMY_CONTENT
          the dummy content - set if no content was provided
static java.lang.String DUMMY_SUBJECT
          the dummy subject - set if no subject was provided
static java.lang.String MAIL_TAG_BCC
          this is the tag for the "Bcc" field of the email
static java.lang.String MAIL_TAG_CC
          this is the tag for the "Cc" field of the email
static java.lang.String MAIL_TAG_FROM
          this is the tag for the "From" field of the email
static java.lang.String MAIL_TAG_REPLYTO
          this is the tag for the "Reply-To" field of the email
static java.lang.String MAIL_TAG_SENTDATE
          this is the tag for the "Date" field of the email
static java.lang.String MAIL_TAG_SUBJECT
          this is the tag for the "Subject" field of the email
static java.lang.String MAIL_TAG_TO
          this is the tag for the "To" field of the email
static java.lang.String MSG_TAG_BCC
          this tag is used in normalized messages to represent the BCC address this exchange should be mailed to
static java.lang.String MSG_TAG_CC
          this tag is used in normalized messages to represent the CC address the mail was sent to OR the CC address this exchange should be mailed to
static java.lang.String MSG_TAG_FROM
          this tag is used in normalized messages to represent the address the mail was received from OR the address this exchange should be sent from
static java.lang.String MSG_TAG_HOST
          this tag is used in normalized messages to represent the mail server hostname
static java.lang.String MSG_TAG_HTML
          this tag is used in normalized messages to represent the html content used in the received mail or to be used in the mail to be sent
static java.lang.String MSG_TAG_MAIL_CHARSET
          this tag is used in normalized messages to represent the charset used in the received mail or to be used in the mail to be sent
static java.lang.String MSG_TAG_MAIL_CONTENT_TYPE
          this tag is used in normalized messages to represent the content type of the mail received or the mail to be sent
static java.lang.String MSG_TAG_MAIL_USE_INLINE_ATTACHMENTS
          this tag is used in normalized messages to flag that the attachments have to be treatened as inline attachments
static java.lang.String MSG_TAG_PASSWORD
          this tag is used in normalized messages to represent the password of the mail account
static java.lang.String MSG_TAG_PORT
          this tag is used in normalized messages to represent the port number used for mail server
static java.lang.String MSG_TAG_PROTOCOL
          this tag is used in normalized messages to represent the used protocol
static java.lang.String MSG_TAG_REPLYTO
          this tag is used in normalized messages to represent the reply-to address of the mail received OR the reply-to address of the mail to be sent
static java.lang.String MSG_TAG_SENTDATE
          this tag is used in normalized messages to represent the date when the mail was sent
static java.lang.String MSG_TAG_SUBJECT
          this tag is used in normalized messages to represent the subject of the mail received OR the subject of the mail to be sent
static java.lang.String MSG_TAG_TEXT
          this tag is used in normalized messages to represent the plain text content used in the received mail or to be used in the mail to be sent
static java.lang.String MSG_TAG_TO
          this tag is used in normalized messages to represent the address the mail was sent to OR the address this exchange should be mailed to
static java.lang.String MSG_TAG_USER
          this tag is used in normalized messages to represent the user which owns the mail account
 
Constructor Summary
AbstractMailMarshaler()
           
 
Method Summary
protected  void addTemporaryResource(java.lang.String id, java.io.File tmpFile)
          adds a temporary file resource to the list of to be cleaned up resources
 void cleanUpResources(java.lang.String id)
          deletes all temporary resources of a given exchange id
abstract  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.
abstract  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  java.util.Map<java.lang.String,javax.activation.DataSource> getAttachmentsMapFromNormalizedMessage(javax.jbi.messaging.NormalizedMessage normalizedMessage)
          This helper method extracts all attachments from the normalized message into a map of attachments which may be used for filling the attachments of an outgoing mail
 java.lang.String getDefaultSenderForOutgoingMails()
          returns the default sender for outgoing mails Override this method to deliver your own default sender!
 
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
 

Field Detail

MAIL_TAG_TO

public static final java.lang.String MAIL_TAG_TO
this is the tag for the "To" field of the email

See Also:
Constant Field Values

MAIL_TAG_CC

public static final java.lang.String MAIL_TAG_CC
this is the tag for the "Cc" field of the email

See Also:
Constant Field Values

MAIL_TAG_BCC

public static final java.lang.String MAIL_TAG_BCC
this is the tag for the "Bcc" field of the email

See Also:
Constant Field Values

MAIL_TAG_FROM

public static final java.lang.String MAIL_TAG_FROM
this is the tag for the "From" field of the email

See Also:
Constant Field Values

MAIL_TAG_SUBJECT

public static final java.lang.String MAIL_TAG_SUBJECT
this is the tag for the "Subject" field of the email

See Also:
Constant Field Values

MAIL_TAG_REPLYTO

public static final java.lang.String MAIL_TAG_REPLYTO
this is the tag for the "Reply-To" field of the email

See Also:
Constant Field Values

MAIL_TAG_SENTDATE

public static final java.lang.String MAIL_TAG_SENTDATE
this is the tag for the "Date" field of the email

See Also:
Constant Field Values

MSG_TAG_TO

public static final java.lang.String MSG_TAG_TO
this tag is used in normalized messages to represent the address the mail was sent to OR the address this exchange should be mailed to

See Also:
Constant Field Values

MSG_TAG_CC

public static final java.lang.String MSG_TAG_CC
this tag is used in normalized messages to represent the CC address the mail was sent to OR the CC address this exchange should be mailed to

See Also:
Constant Field Values

MSG_TAG_BCC

public static final java.lang.String MSG_TAG_BCC
this tag is used in normalized messages to represent the BCC address this exchange should be mailed to

See Also:
Constant Field Values

MSG_TAG_FROM

public static final java.lang.String MSG_TAG_FROM
this tag is used in normalized messages to represent the address the mail was received from OR the address this exchange should be sent from

See Also:
Constant Field Values

MSG_TAG_SUBJECT

public static final java.lang.String MSG_TAG_SUBJECT
this tag is used in normalized messages to represent the subject of the mail received OR the subject of the mail to be sent

See Also:
Constant Field Values

MSG_TAG_REPLYTO

public static final java.lang.String MSG_TAG_REPLYTO
this tag is used in normalized messages to represent the reply-to address of the mail received OR the reply-to address of the mail to be sent

See Also:
Constant Field Values

MSG_TAG_SENTDATE

public static final java.lang.String MSG_TAG_SENTDATE
this tag is used in normalized messages to represent the date when the mail was sent

See Also:
Constant Field Values

MSG_TAG_MAIL_CONTENT_TYPE

public static final java.lang.String MSG_TAG_MAIL_CONTENT_TYPE
this tag is used in normalized messages to represent the content type of the mail received or the mail to be sent

See Also:
Constant Field Values

MSG_TAG_MAIL_CHARSET

public static final java.lang.String MSG_TAG_MAIL_CHARSET
this tag is used in normalized messages to represent the charset used in the received mail or to be used in the mail to be sent

See Also:
Constant Field Values

MSG_TAG_MAIL_USE_INLINE_ATTACHMENTS

public static final java.lang.String MSG_TAG_MAIL_USE_INLINE_ATTACHMENTS
this tag is used in normalized messages to flag that the attachments have to be treatened as inline attachments

See Also:
Constant Field Values

MSG_TAG_TEXT

public static final java.lang.String MSG_TAG_TEXT
this tag is used in normalized messages to represent the plain text content used in the received mail or to be used in the mail to be sent

See Also:
Constant Field Values

MSG_TAG_HTML

public static final java.lang.String MSG_TAG_HTML
this tag is used in normalized messages to represent the html content used in the received mail or to be used in the mail to be sent

See Also:
Constant Field Values

DEFAULT_SENDER

public static final java.lang.String DEFAULT_SENDER
the default sender address for outgoing mails

See Also:
Constant Field Values

MSG_TAG_USER

public static final java.lang.String MSG_TAG_USER
this tag is used in normalized messages to represent the user which owns the mail account

See Also:
Constant Field Values

MSG_TAG_PASSWORD

public static final java.lang.String MSG_TAG_PASSWORD
this tag is used in normalized messages to represent the password of the mail account

See Also:
Constant Field Values

MSG_TAG_HOST

public static final java.lang.String MSG_TAG_HOST
this tag is used in normalized messages to represent the mail server hostname

See Also:
Constant Field Values

MSG_TAG_PROTOCOL

public static final java.lang.String MSG_TAG_PROTOCOL
this tag is used in normalized messages to represent the used protocol

See Also:
Constant Field Values

MSG_TAG_PORT

public static final java.lang.String MSG_TAG_PORT
this tag is used in normalized messages to represent the port number used for mail server

See Also:
Constant Field Values

DUMMY_SUBJECT

public static final java.lang.String DUMMY_SUBJECT
the dummy subject - set if no subject was provided

See Also:
Constant Field Values

DUMMY_CONTENT

public static final java.lang.String DUMMY_CONTENT
the dummy content - set if no content was provided

See Also:
Constant Field Values
Constructor Detail

AbstractMailMarshaler

public AbstractMailMarshaler()
Method Detail

convertMailToJBI

public abstract void convertMailToJBI(javax.jbi.messaging.MessageExchange exchange,
                                      javax.jbi.messaging.NormalizedMessage nmsg,
                                      javax.mail.internet.MimeMessage mailMsg)
                               throws javax.mail.MessagingException
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.

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

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

getDefaultSenderForOutgoingMails

public java.lang.String getDefaultSenderForOutgoingMails()
returns the default sender for outgoing mails Override this method to deliver your own default sender!

Returns:
the default sender address as string

getAttachmentsMapFromNormalizedMessage

protected final java.util.Map<java.lang.String,javax.activation.DataSource> getAttachmentsMapFromNormalizedMessage(javax.jbi.messaging.NormalizedMessage normalizedMessage)
This helper method extracts all attachments from the normalized message into a map of attachments which may be used for filling the attachments of an outgoing mail

Parameters:
normalizedMessage - the normalized message with attachments
Returns:
a map of attachments

addTemporaryResource

protected final void addTemporaryResource(java.lang.String id,
                                          java.io.File tmpFile)
adds a temporary file resource to the list of to be cleaned up resources

Parameters:
id - the id of the message exchange
tmpFile - the temp resource

cleanUpResources

public final void cleanUpResources(java.lang.String id)
deletes all temporary resources of a given exchange id

Parameters:
id - the exchange id


Copyright © 2005-2012 FuseSource. All Rights Reserved.