KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > shared > client > QBrowseReply


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - 2000 Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s): ScalAgent Distributed Technologies
23  */

24 package org.objectweb.joram.shared.client;
25
26 import java.io.Externalizable JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.io.OutputStream JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.util.Vector JavaDoc;
31
32 import org.objectweb.joram.shared.messages.Message;
33 import org.objectweb.joram.shared.stream.Streamable;
34 import org.objectweb.joram.shared.stream.StreamUtil;
35
36 /**
37  * A <code>QBrowseReply</code> instance is used by a JMS client proxy for
38  * forwarding a <code>BrowseReply</code> destination notification,
39  * actually replying to a client <code>QBrowseRequest</code>.
40  */

41 public final class QBrowseReply extends AbstractJmsReply {
42   /** The vector of messages carried by this reply. */
43   private Vector JavaDoc messages = null;
44
45   /** Returns the vector of messages carried by this reply. */
46   public Vector JavaDoc getMessages() {
47     if (messages == null)
48       messages = new Vector JavaDoc();
49     return messages;
50   }
51
52   public void addMessage(Message msg) {
53     if (messages == null)
54       messages = new Vector JavaDoc();
55     messages.addElement(msg);
56   }
57
58   protected int getClassId() {
59     return QBROWSE_REPLY;
60   }
61
62   /**
63    * Constructs an empty <code>QBrowseReply</code>.
64    */

65   private QBrowseReply(int correlationId) {
66     super(correlationId);
67   }
68
69   /**
70    * Constructs a <code>QBrowseReply</code>.
71    */

72   private QBrowseReply(int correlationId, Message message) {
73     super(correlationId);
74     messages = new Vector JavaDoc();
75     messages.addElement(message);
76   }
77
78   /**
79    * Constructs a <code>QBrowseReply</code>.
80    */

81   public QBrowseReply(int correlationId, Vector JavaDoc messages) {
82     super(correlationId);
83     this.messages = messages;
84   }
85
86   /**
87    * Public no-arg constructor needed by Externalizable.
88    */

89   public QBrowseReply() {
90   }
91
92   /* ***** ***** ***** ***** *****
93    * Streamable interface
94    * ***** ***** ***** ***** ***** */

95
96   /**
97    * The object implements the writeTo method to write its contents to
98    * the output stream.
99    *
100    * @param os the stream to write the object to
101    */

102   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
103     super.writeTo(os);
104     Message.writeVectorTo(messages, os);
105   }
106
107   /**
108    * The object implements the readFrom method to restore its contents from
109    * the input stream.
110    *
111    * @param is the stream to read data from in order to restore the object
112    */

113   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
114     super.readFrom(is);
115     messages = Message.readVectorFrom(is);
116   }
117 }
118
Popular Tags