KickJava   Java API By Example, From Geeks To Geeks.

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


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

23 package org.objectweb.joram.shared.client;
24
25 import java.io.Externalizable JavaDoc;
26 import java.io.InputStream JavaDoc;
27 import java.io.OutputStream JavaDoc;
28 import java.io.IOException JavaDoc;
29
30 import java.util.Vector JavaDoc;
31
32 import org.objectweb.joram.shared.stream.Streamable;
33 import org.objectweb.joram.shared.stream.StreamUtil;
34
35 /**
36  * A <code>ConsumerAckRequest</code> instance is used by a
37  * <code>MessageConsumer</code> for acknowledging a received message.
38  */

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

78   public ConsumerAckRequest(String JavaDoc targetName, boolean queueMode) {
79     super(targetName);
80     ids = new Vector JavaDoc();
81     this.queueMode = queueMode;
82   }
83
84   /**
85    * Constructs a <code>ConsumerAckRequest</code> instance.
86    */

87   public ConsumerAckRequest() {}
88
89   /* ***** ***** ***** ***** *****
90    * Streamable interface
91    * ***** ***** ***** ***** ***** */

92
93   /**
94    * The object implements the writeTo method to write its contents to
95    * the output stream.
96    *
97    * @param os the stream to write the object to
98    */

99   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
100     super.writeTo(os);
101     StreamUtil.writeVectorOfStringTo(ids, os);
102     StreamUtil.writeTo(queueMode, os);
103   }
104
105   /**
106    * The object implements the readFrom method to restore its contents from
107    * the input stream.
108    *
109    * @param is the stream to read data from in order to restore the object
110    */

111   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
112     super.readFrom(is);
113     ids = StreamUtil.readVectorOfStringFrom(is);
114     queueMode = StreamUtil.readBooleanFrom(is);
115   }
116 }
117
Popular Tags