01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html or
09: * 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: package javax.jms;
25:
26: import java.io.Serializable;
27:
28: /**
29: * An <CODE>ObjectMessage</CODE> object is used to send a message that
30: * contains a serializable object in the Java programming language ("Java
31: * object"). It inherits from the <CODE>Message</CODE> interface and adds a
32: * body containing a single reference to an object. Only <CODE>Serializable</CODE>
33: * Java objects can be used.
34: *
35: * <P>
36: * If a collection of Java objects must be sent, one of the <CODE>Collection</CODE>
37: * classes provided since JDK 1.2 can be used.
38: *
39: * <P>
40: * When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only
41: * mode. If a client attempts to write to the message at this point, a <CODE>MessageNotWriteableException</CODE>
42: * is thrown. If <CODE>clearBody</CODE> is called, the message can now be both
43: * read from and written to.
44: *
45: * @version 1.0 - 6 August 1998
46: * @author Mark Hapner
47: * @author Rich Burridge
48: *
49: * @see javax.jms.Session#createObjectMessage()
50: * @see javax.jms.Session#createObjectMessage(Serializable)
51: * @see javax.jms.BytesMessage
52: * @see javax.jms.MapMessage
53: * @see javax.jms.Message
54: * @see javax.jms.StreamMessage
55: * @see javax.jms.TextMessage
56: */
57:
58: public interface ObjectMessage extends Message {
59:
60: /**
61: * Sets the serializable object containing this message's data. It is
62: * important to note that an <CODE>ObjectMessage</CODE> contains a
63: * snapshot of the object at the time <CODE>setObject()</CODE> is called;
64: * subsequent modifications of the object will have no effect on the <CODE>ObjectMessage</CODE>
65: * body.
66: *
67: * @param object
68: * the message's data
69: *
70: * @exception JMSException
71: * if the JMS provider fails to set the object due to some
72: * internal error.
73: * @exception MessageFormatException
74: * if object serialization fails.
75: * @exception MessageNotWriteableException
76: * if the message is in read-only mode.
77: */
78:
79: void setObject(Serializable object) throws JMSException;
80:
81: /**
82: * Gets the serializable object containing this message's data. The default
83: * value is null.
84: *
85: * @return the serializable object containing this message's data
86: *
87: * @exception JMSException
88: * if the JMS provider fails to get the object due to some
89: * internal error.
90: * @exception MessageFormatException
91: * if object deserialization fails.
92: */
93:
94: Serializable getObject() throws JMSException;
95: }
|