KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jms > ObjectMessage


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package javax.jms;
26
27 import java.io.Serializable JavaDoc;
28
29 /** An <CODE>ObjectMessage</CODE> object is used to send a message that contains
30   * a serializable object in the Java programming language ("Java object").
31   * It inherits from the <CODE>Message</CODE> interface and adds a body
32   * containing a single reference to an object. Only <CODE>Serializable</CODE>
33   * Java objects can be used.
34   *
35   * <P>If a collection of Java objects must be sent, one of the
36   * <CODE>Collection</CODE> classes provided since JDK 1.2 can be used.
37   *
38   * <P>When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only
39   * mode. If a client attempts to write to the message at this point, a
40   * <CODE>MessageNotWriteableException</CODE> is thrown. If
41   * <CODE>clearBody</CODE> is called, the message can now be both read from and
42   * written to.
43   *
44   * @version 1.0 - 6 August 1998
45   * @author Mark Hapner
46   * @author Rich Burridge
47   *
48   * @see javax.jms.Session#createObjectMessage()
49   * @see javax.jms.Session#createObjectMessage(Serializable)
50   * @see javax.jms.BytesMessage
51   * @see javax.jms.MapMessage
52   * @see javax.jms.Message
53   * @see javax.jms.StreamMessage
54   * @see javax.jms.TextMessage
55   */

56
57 public interface ObjectMessage extends Message JavaDoc {
58
59     /** Sets the serializable object containing this message's data.
60       * It is important to note that an <CODE>ObjectMessage</CODE>
61       * contains a snapshot of the object at the time <CODE>setObject()</CODE>
62       * is called; subsequent modifications of the object will have no
63       * effect on the <CODE>ObjectMessage</CODE> body.
64       *
65       * @param object the message's data
66       *
67       * @exception JMSException if the JMS provider fails to set the object
68       * due to some internal error.
69       * @exception MessageFormatException if object serialization fails.
70       * @exception MessageNotWriteableException if the message is in read-only
71       * mode.
72       */

73
74     void
75     setObject(Serializable JavaDoc object) throws JMSException JavaDoc;
76
77
78     /** Gets the serializable object containing this message's data. The
79       * default value is null.
80       *
81       * @return the serializable object containing this message's data
82       *
83       * @exception JMSException if the JMS provider fails to get the object
84       * due to some internal error.
85       * @exception MessageFormatException if object deserialization fails.
86       */

87
88     Serializable JavaDoc
89     getObject() throws JMSException JavaDoc;
90 }
91
Popular Tags