KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.objectweb.joram.shared.stream.Streamable;
32 import org.objectweb.joram.shared.stream.StreamUtil;
33
34 /**
35  * A <code>ConsumerUnsetListRequest</code> is sent by a
36  * <code>MessageConsumer</code> which listener is unset.
37  */

38 public final class ConsumerUnsetListRequest extends AbstractJmsRequest {
39   /** <code>true</code> if the listener is listening to a queue. */
40   private boolean queueMode;
41
42   /** Sets the listener mode (queue or topic listener). */
43   public void setQueueMode(boolean queueMode) {
44     this.queueMode = queueMode;
45   }
46
47   /** Returns <code>true</code> for a queue listener. */
48   public boolean getQueueMode() {
49     return queueMode;
50   }
51
52   /**
53    * Identifier of the last listener request, cancelled by this
54    * request, queue mode only.
55    */

56   private int cancelledRequestId = -1;
57
58   /**
59    * Sets the identifier of the last listener request, cancelled by this
60    * request, queue mode only.
61    */

62   public void setCancelledRequestId(int cancelledRequestId) {
63     this.cancelledRequestId = cancelledRequestId;
64   }
65
66   /**
67    * Returns the identifier of the last listener request, cancelled by this
68    * request, queue mode only.
69    */

70   public int getCancelledRequestId() {
71     return cancelledRequestId;
72   }
73
74   protected int getClassId() {
75     return CONSUMER_UNSET_LIST_REQUEST;
76   }
77
78   /**
79    * Constructs a <code>ConsumerUnsetListRequest</code>.
80    *
81    * @param queueMode <code>true</code> if the listener is listening to a
82    * queue.
83    */

84   public ConsumerUnsetListRequest(boolean queueMode) {
85     this.queueMode = queueMode;
86   }
87
88   /**
89    * Constructs a <code>ConsumerUnsetListRequest</code>.
90    */

91   public ConsumerUnsetListRequest() {}
92
93   public void toString(StringBuffer JavaDoc strbuf) {
94     super.toString(strbuf);
95     strbuf.append(",queueMode=").append(queueMode);
96     strbuf.append(",cancelledRequestId=").append(cancelledRequestId);
97     strbuf.append(')');
98   }
99
100   /* ***** ***** ***** ***** *****
101    * Streamable interface
102    * ***** ***** ***** ***** ***** */

103
104   /**
105    * The object implements the writeTo method to write its contents to
106    * the output stream.
107    *
108    * @param os the stream to write the object to
109    */

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

122   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
123     super.readFrom(is);
124     queueMode = StreamUtil.readBooleanFrom(is);
125     cancelledRequestId = StreamUtil.readIntFrom(is);
126   }
127 }
128
Popular Tags