KickJava   Java API By Example, From Geeks To Geeks.

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


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
31 import java.util.Vector JavaDoc;
32
33 import org.objectweb.joram.shared.stream.Streamable;
34 import org.objectweb.joram.shared.stream.StreamUtil;
35
36 /**
37  * A <code>SessAckRequest</code> instance is used by a <code>Session</code>
38  * for acknowledging the messages it consumed.
39  */

40 public final class SessAckRequest extends AbstractJmsRequest {
41   /** Vector of message identifiers. */
42   private Vector JavaDoc ids;
43
44   /** Sets the vector of identifiers. */
45   public void setIds(Vector JavaDoc ids) {
46     this.ids = ids;
47   }
48
49   public void addId(String JavaDoc id) {
50     ids.addElement(id);
51   }
52
53   /** Returns the vector of acknowledged messages identifiers. */
54   public Vector JavaDoc getIds() {
55     return ids;
56   }
57
58   /** <code>true</code> if the request is destinated to a queue. */
59   private boolean queueMode;
60
61   /** Sets the target destination type. */
62   public void setQueueMode(boolean queueMode) {
63     this.queueMode = queueMode;
64   }
65
66   /** Returns <code>true</code> if the request is destinated to a queue. */
67   public boolean getQueueMode() {
68     return queueMode;
69   }
70
71   protected int getClassId() {
72     return SESS_ACK_REQUEST;
73   }
74
75   /**
76    * Constructs a <code>SessAckRequest</code> instance.
77    *
78    * @param targetName Name of the target queue or subscription.
79    * @param ids Vector of acknowledged message identifiers.
80    * @param queueMode <code>true</code> if this request is destinated to a
81    * queue.
82    */

83   public SessAckRequest(String JavaDoc targetName, Vector JavaDoc ids, boolean queueMode) {
84     super(targetName);
85     this.ids = ids;
86     this.queueMode = queueMode;
87   }
88
89   /**
90    * Constructs a <code>SessAckRequest</code> instance.
91    */

92   public SessAckRequest() {
93     ids = new Vector JavaDoc();
94   }
95
96   /* ***** ***** ***** ***** *****
97    * Streamable interface
98    * ***** ***** ***** ***** ***** */

99
100   /**
101    * The object implements the writeTo method to write its contents to
102    * the output stream.
103    *
104    * @param os the stream to write the object to
105    */

106   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
107     super.writeTo(os);
108     StreamUtil.writeVectorOfStringTo(ids, os);
109     StreamUtil.writeTo(queueMode, os);
110   }
111
112   /**
113    * The object implements the readFrom method to restore its contents from
114    * the input stream.
115    *
116    * @param is the stream to read data from in order to restore the object
117    */

118   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
119     super.readFrom(is);
120     ids = StreamUtil.readVectorOfStringFrom(is);
121     queueMode = StreamUtil.readBooleanFrom(is);
122   }
123 }
124
Popular Tags