Oracle Fusion Middleware User Messaging Service 11.1.1.1.0 Java API Reference
E14011-01

oracle.sdp.messaging
Interface Message

All Superinterfaces:
java.lang.Cloneable, Externalizable, MessagingObject, MimePart, Part, Serializable

public interface Message
extends MimePart, MessagingObject, Externalizable, java.lang.Cloneable

Message interface models a MIME style message for the SDP Messaging. It allows applications to represent complex message content, which is MIME based and potentially multipart.

The actual MIME content of a message is described by the javax.mail.internet.MimePart interface. The Message interface encapsulates a few message-wide properties used by Messaging such as sender and recipient addresses.

It implements the Externalizable interface for faster serialization. Instances of Message can potentially be persisted after externalization depending on how the system routes the message.

To create Message objects, use the MessageFactory.

Examples that show how to set the content of a Message:

  1. Plain Text Message:

     Message message = MessageFactory.getInstance().createMessage();
     StringDataSource ds = new StringDataSource("This is a Plain Text message.", "text/plain");
     message.setDataHandler(new DataHandler(ds));
     

  2. Multipart/alternative Message (with text/plain and text/html parts):

     Message message = MessageFactory.getInstance().createMessage();
     MimeMultipart mp = new MimeMultipart("alternative");
     MimeBodyPart mp_partPlain = new MimeBodyPart();
     StringDataSource plainDS = new StringDataSource("This is a Plain Text part.", "text/plain");
     mp_partPlain.setDataHandler(new DataHandler(plainDS));
     mp.addBodyPart(mp_partPlain);
     MimeBodyPart mp_partRich = new MimeBodyPart();
     StringDataSource richDS = new StringDataSource("<html><head></head><body><b><i>This is an HTML part.</i></b></body></html>",
                     "text/html");
     mp_partRich.setDataHandler(richDS);
                     
     mp.addBodyPart(mp_partRich);
     message.setContent(mp);
     

  3. Multipart/mixed Message (with text/plain and binary parts):

     Message message = MessageFactory.getInstance().createMessage();
     MimeMultipart mp = new MimeMultipart("alternative");
     MimeBodyPart mp_partPlain = new MimeBodyPart();
     StringDataSource plainDS = new StringDataSource("This is a Plain Text part.", "text/plain");
     mp_partPlain.setDataHandler(new DataHandler(plainDS));
     mp.addBodyPart(mp_partPlain);
     
     byte[] imageData; 
     // Create or load image data as a byte array
     MimeBodyPart mp_partBinary = new MimeBodyPart();
     StringDataSource binaryDS = new ByteArrayDataSource(imageData,
                     "image/gif");
     mp_partBinary.setDataHandler(binaryDS);
                     
     mp.addBodyPart(mp_partBinary);
     message.setContent(mp);
     

  4. Channel (DeliveryType) specific Payloads in a single message for recipients with different delivery types:

    Please see the example in the documentation for HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE.

Since:
11.0.0

Field Summary
static java.lang.String HEADER_CONTENT_DISPOSITION
           
static java.lang.String HEADER_CONTENT_TRANSFER_ENCODING
           
static java.lang.String HEADER_CONTENT_TYPE
           
static java.lang.String HEADER_SDPM_MULTIPLE_PAYLOAD
          An SDP Messaging-specific Header to mark a message containing delivery-type (channel) specific content (payload) as one or more parts of a multipart/alternative MIME message.
static java.lang.String HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
          An SDP Messaging-specific Header to use in conjunction with a Message containing the header HEADER_SDPM_MULTIPLE_PAYLOAD.
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
Fields inherited from interface oracle.sdp.messaging.MessagingObject
NAMESPACE_NOTIFICATION_PREFERENCES, NAMESPACE_SDPM
 
Method Summary
 void addAllRecipients(Address[] recipients)
          Add a set of recipients to the message.
 void addAllReplyTos(Address[] replyTos)
          Add a set of alternative 'reply to' addresses to the message.
 void addAllSenders(Address[] senders)
          Add a set of sender (from) addresses to the message.
 void addRecipient(Address recipient)
          Add a recipient to the message.
 void addReplyTo(Address replyTo)
          Add an alternative 'reply to' address to the message.
'reply to' address has the same rules and constraints as 'sender address':
1.
 void addSender(Address sender)
          Add a sender (from) address to the message.
 void clearRecipients()
          Remove all recipient addresses from the message.
 void clearReplyTos()
          Remove all 'reply to' addresses from the message.
 void clearSenders()
          Remove all sender addresses from the message.
 Set<java.lang.String> getAllHeaderNames()
          Get all the header names.
 java.lang.String getId()
          Get the message identifier of this message.
 MessageInfo getMessageInfo()
          Get the MessageInfo object of this message.
 Address[] getRecipients()
          Get the recipients of the message.
 Address[] getReplyTos()
          Get a copy of the reply-to addresses.
 Address[] getSenders()
          Get a copy of the from (sender) addresses.
 java.lang.String getSubject()
          Gets the subject of the message.
 boolean isMultiplePayload()
          Check if the SDP Messaging-specific multiple payload header flag is set.
 boolean removeRecipient(Address recipient)
          Remove a recipient from the message.
 boolean removeReplyTo(Address replyTo)
          Remove a 'reply to' address from the message.
 boolean removeSender(Address sender)
          Remove a sender address from the message.
 void setContent(java.lang.Object content, java.lang.String contentType)
          A convenience method for setting this message's content and Content-Type.
 void setId(java.lang.String id)
          Set the message identifier of this message.
 void setMessageInfo(MessageInfo messageInfo)
          Set a MessageInfo object which specifies various delivery-related properties that may be used by SDP Messaging.
 void setMultiplePayload(boolean multiplePayloadFlag)
          An SDP Messaging-specific header flag to mark a message containing delivery-type (channel) specific content (payload) as one or more parts of a multipart/alternative MIME message.
 void setSubject(java.lang.String subject)
          Sets the subject of the message.
 
Methods inherited from interface javax.mail.internet.MimePart
addHeaderLine, getAllHeaderLines, getContentID, getContentLanguage, getContentMD5, getEncoding, getHeader, getMatchingHeaderLines, getNonMatchingHeaderLines, setContentLanguage, setContentMD5, setText, setText, setText
 
Methods inherited from interface javax.mail.Part
addHeader, getAllHeaders, getContent, getContentType, getDataHandler, getDescription, getDisposition, getFileName, getHeader, getInputStream, getLineCount, getMatchingHeaders, getNonMatchingHeaders, getSize, isMimeType, removeHeader, setContent, setDataHandler, setDescription, setDisposition, setFileName, setHeader, writeTo
 
Methods inherited from interface oracle.sdp.messaging.MessagingObject
getAllNamespaces, getMetaData, getMetaDataNames, setMetaData
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

HEADER_CONTENT_DISPOSITION

static final java.lang.String HEADER_CONTENT_DISPOSITION
See Also:
Constant Field Values

HEADER_CONTENT_TRANSFER_ENCODING

static final java.lang.String HEADER_CONTENT_TRANSFER_ENCODING
See Also:
Constant Field Values

HEADER_CONTENT_TYPE

static final java.lang.String HEADER_CONTENT_TYPE
See Also:
Constant Field Values

HEADER_SDPM_MULTIPLE_PAYLOAD

static final java.lang.String HEADER_SDPM_MULTIPLE_PAYLOAD
An SDP Messaging-specific Header to mark a message containing delivery-type (channel) specific content (payload) as one or more parts of a multipart/alternative MIME message. Setting this header's value to "true" triggers the Messaging Server to treat this message as having multiple content payloads.

Note: There is a convenience method available, setMultiplePayload(boolean), that takes care of setting this header.

See Also:
setMultiplePayload(boolean), HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE, Constant Field Values

HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE

static final java.lang.String HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
An SDP Messaging-specific Header to use in conjunction with a Message containing the header HEADER_SDPM_MULTIPLE_PAYLOAD. Each top-level part of a multiple payload multipart/alternative message should contain one or more values of this header. The value of this header should be the name of a valid delivery type (see DeliveryType for a list of available delivery types) that this part's content should be used for delivery to recipients of the specified delivery type.

For example:

 Message message = MessageFactory.getInstance().createMessage();
 
 // create a top-level multipart/alternative MimeMultipart object.
 MimeMultipart mp = new MimeMultipart("alternative");
 
 // create first part for SMS payload content.
 MimeBodyPart part1 = new MimeBodyPart();
 StringDataSource textDS = new StringDataSource("Text content for SMS.", "text/plain");
 part1.setDataHandler(new DataHandler(textDS));
 
 part1.setHeader(Message.HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE, "SMS");

 // add first part
 mp.addBodyPart(part1);
 
 // create second part for EMAIL and IM payload content.
 MimeBodyPart part2 = new MimeBodyPart();
 MimeMultipart part2_mp = new MimeMultipart("alternative");
 MimeBodyPart part2_mp_partPlain = new MimeBodyPart();
 StringDataSource plainDS = new StringDataSource("Text content for EMAIL/IM.", "text/plain");
 part2_mp_partPlain.setDataHandler(new DataHandler(ds));
 part2_mp.addBodyPart(part2_mp_partPlain);
 MimeBodyPart part2_mp_partRich = new MimeBodyPart();
 StringDataSource richDS = new StringDataSource("<html><head></head><body><b><i>HTML content for EMAIL/IM.</i></b></body></html>", "text/html");
 part2_mp_partRich.setDataHandler(new DataHandler(ds));
 part2_mp.addBodyPart(part2_mp_partRich);
 part2.setContent(part2_mp);
 
 part2.addHeader(Message.HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE, "EMAIL");
 part2.addHeader(Message.HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE, "IM");
 
 // add second part
 mp.addBodyPart(part2);
 
 // set the content of the message
 message.setContent(mp);
 
 // set the MultiplePayload flag to true 
 message.setMultiplePayload(true);
 
 

See Also:
setMultiplePayload(boolean), Constant Field Values
Method Detail

addAllRecipients

void addAllRecipients(Address[] recipients)
Add a set of recipients to the message.

Parameters:
recipients - an array of addresses of recipients.

addAllReplyTos

void addAllReplyTos(Address[] replyTos)
Add a set of alternative 'reply to' addresses to the message.

Parameters:
replyTos - an array of 'reply to' addresses.

addAllSenders

void addAllSenders(Address[] senders)
Add a set of sender (from) addresses to the message.

Parameters:
senders - an array of addresses.

addRecipient

void addRecipient(Address recipient)
Add a recipient to the message.

Parameters:
recipient - the address of a recipient.

addReplyTo

void addReplyTo(Address replyTo)
Add an alternative 'reply to' address to the message.
'reply to' address has the same rules and constraints as 'sender address':
1. Only one user may be specified as 'reply to user' in one message.
2. Only one device may be specified as 'reply to device address' per delivery type in the same message.
3. If both 'reply to user' and 'reply to device' are present, 'reply to device' address overrides the address of 'reply to user' for that delivery type.
Please see addSender(Address) for more details.

Parameters:
replyTo - alternative 'reply to' address of the sender

addSender

void addSender(Address sender)
Add a sender (from) address to the message. 'sender' address has the following rules and constraints:
1. Only one user address may be specified as the sender in the message.
2. Only one device may be specified as the sender 'device address' per delivery type in the message.
3. If both sender 'user address' and sender 'device address' are present, sender 'device address' overrides the address of the user for that delivery type.

Parameters:
sender - the address of the sender.

clearRecipients

void clearRecipients()
Remove all recipient addresses from the message.


clearReplyTos

void clearReplyTos()
Remove all 'reply to' addresses from the message.


clearSenders

void clearSenders()
Remove all sender addresses from the message.


getAllHeaderNames

Set<java.lang.String> getAllHeaderNames()
Get all the header names.

Returns:
a Set of strings of header names.

getId

java.lang.String getId()
Get the message identifier of this message.

Returns:
the message identifier

getMessageInfo

MessageInfo getMessageInfo()
Get the MessageInfo object of this message. You can get this object and set various delivery-related properties for this message.

Returns:
the message info object.

getRecipients

Address[] getRecipients()
Get the recipients of the message.


getReplyTos

Address[] getReplyTos()
Get a copy of the reply-to addresses.

Returns:
an array of the reply-to addresses.

getSenders

Address[] getSenders()
Get a copy of the from (sender) addresses.

Returns:
an array of the from (sender) addresses.

getSubject

java.lang.String getSubject()
Gets the subject of the message.

Returns:
the message subject represented as a String

isMultiplePayload

boolean isMultiplePayload()
Check if the SDP Messaging-specific multiple payload header flag is set.

Returns:
true if the multiple payload header flag is set,
false otherwise.
See Also:
setMultiplePayload(boolean)

removeRecipient

boolean removeRecipient(Address recipient)
Remove a recipient from the message.

Parameters:
recipient - the recipient to remove.
Returns:
true if the recipient has been removed.
false if the input has error or the recipient is not found in the message.

removeReplyTo

boolean removeReplyTo(Address replyTo)
Remove a 'reply to' address from the message.

Parameters:
replyTo - the 'reply to' address to remove.
Returns:
true if the 'reply to' address has been removed,
false if the input has error or the 'reply to' address is not found in the message.

removeSender

boolean removeSender(Address sender)
Remove a sender address from the message.

Returns:
true if the sender address has been removed,
false if the input has error or the sender address is not found in the message.

setContent

void setContent(java.lang.Object content,
                java.lang.String contentType)
A convenience method for setting this message's content and Content-Type. Note that this is not the recommended way of setting message content. Instead, setDataHandler(DataSource) should be used, as described in the documentation for this class. This method will attempt to wrap any String or byte[] content in an appropriate DataHandler. Setting any other content will succeed, but may cause problems during message processing, such as during Web Service serialization.

Specified by:
setContent in interface Part
Parameters:
content - the content object
contentType - the content type of the object

setId

void setId(java.lang.String id)
Set the message identifier of this message.

Parameters:
id - the message identifier

setMessageInfo

void setMessageInfo(MessageInfo messageInfo)
Set a MessageInfo object which specifies various delivery-related properties that may be used by SDP Messaging.

Parameters:
messageInfo - the message info object.

setMultiplePayload

void setMultiplePayload(boolean multiplePayloadFlag)
An SDP Messaging-specific header flag to mark a message containing delivery-type (channel) specific content (payload) as one or more parts of a multipart/alternative MIME message. Setting this flag's value to "true" triggers Messaging to treat this message as having multiple content payloads.

Parameters:
multiplePayloadFlag - true - marks the message as containing multiple payloads,
false - removes/unsets the multiple payload flag.
See Also:
HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE

setSubject

void setSubject(java.lang.String subject)
Sets the subject of the message.

Parameters:
subject - the subject of the message.

Oracle Fusion Middleware User Messaging Service 11.1.1.1.0 Java API Reference
E14011-01

Copyright © 2009 Oracle and/or its affiliates. All rights reserved.