|
Oracle Fusion Middleware User Messaging Service 11.1.1.3.0 Java API Reference E14011-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Message
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 MessagingFactory
.
Examples that show how to set the content of a Message:
Message message = MessageFactory.getInstance().createMessage(); StringDataSource ds = new StringDataSource("This is a Plain Text message.", "text/plain"); message.setDataHandler(new DataHandler(ds));
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);
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);
Please see the example in the documentation for
HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
.
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 |
---|
static final java.lang.String HEADER_CONTENT_DISPOSITION
static final java.lang.String HEADER_CONTENT_TRANSFER_ENCODING
static final java.lang.String HEADER_CONTENT_TYPE
static final java.lang.String HEADER_SDPM_MULTIPLE_PAYLOAD
Note: There is a convenience method available, setMultiplePayload(boolean), that takes care of setting this header.
setMultiplePayload(boolean)
,
HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
,
Constant Field Valuesstatic final java.lang.String HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
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);
setMultiplePayload(boolean)
,
Constant Field ValuesMethod Detail |
---|
void addAllRecipients(Address[] recipients)
recipients
- an array of addresses of recipients.void addAllReplyTos(Address[] replyTos)
replyTos
- an array of 'reply to' addresses.void addAllSenders(Address[] senders)
senders
- an array of addresses.void addRecipient(Address recipient)
recipient
- the address of a recipient.void addReplyTo(Address replyTo)
addSender(Address)
for more details.
replyTo
- alternative 'reply to' address of the sendervoid addSender(Address sender)
sender
- the address of the sender.void clearRecipients()
void clearReplyTos()
void clearSenders()
Set<java.lang.String> getAllHeaderNames()
java.lang.String getId()
MessageInfo getMessageInfo()
MessageInfo
object of this message. You can get this object and
set various delivery-related properties for this message.
Address[] getRecipients()
Address[] getReplyTos()
Address[] getSenders()
java.lang.String getSubject()
boolean isMultiplePayload()
setMultiplePayload(boolean)
boolean removeRecipient(Address recipient)
recipient
- the recipient to remove.
boolean removeReplyTo(Address replyTo)
replyTo
- the 'reply to' address to remove.
boolean removeSender(Address sender)
void setContent(java.lang.Object content, java.lang.String contentType)
setContent
in interface Part
content
- the content objectcontentType
- the content type of the objectvoid setId(java.lang.String id)
id
- the message identifiervoid setMessageInfo(MessageInfo messageInfo)
MessageInfo
object which specifies various delivery-related
properties that may be used by SDP Messaging.
messageInfo
- the message info object.void setMultiplePayload(boolean multiplePayloadFlag)
multiplePayloadFlag
- true - marks the message as containing
multiple payloads,HEADER_SDPM_PAYLOAD_PART_DELIVERY_TYPE
void setSubject(java.lang.String subject)
subject
- the subject of the message.
|
Oracle Fusion Middleware User Messaging Service 11.1.1.3.0 Java API Reference E14011-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |