KickJava   Java API By Example, From Geeks To Geeks.

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


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>ConsumerDenyRequest</code> instance is used by a
36  * <code>MessageConsumer</code> for denying a received message.
37  */

38 public final class ConsumerDenyRequest extends AbstractJmsRequest {
39   /** Message identifier. */
40   private String JavaDoc id;
41
42   /** Sets the denied message identifier. */
43   public void setId(String JavaDoc id) {
44     this.id = id;
45   }
46
47   /** Returns the denied message identifier. */
48   public String JavaDoc getId() {
49     return id;
50   }
51
52   /** <code>true</code> if the request is destinated to a queue. */
53   private boolean queueMode;
54
55   /** Sets the target destination type. */
56   public void setQueueMode(boolean queueMode) {
57     this.queueMode = queueMode;
58   }
59
60   /** Returns <code>true</code> if the request is destinated to a queue. */
61   public boolean getQueueMode() {
62     return queueMode;
63   }
64
65   /** <code>true</code> if the request must not be acked by the server. */
66   private boolean doNotAck = false;
67
68   /** Sets the server ack policy. */
69   public void setDoNotAck(boolean doNotAck) {
70     this.doNotAck = doNotAck;
71   }
72
73   /**
74    * Returns <code>true</code> if the request must not be acked by the
75    * server.
76    */

77   public boolean getDoNotAck() {
78     return doNotAck;
79   }
80
81   protected int getClassId() {
82     return CONSUMER_DENY_REQUEST;
83   }
84
85   /**
86    * Constructs a <code>ConsumerDenyRequest</code> instance.
87    *
88    * @param targetName Name of the target queue or subscription.
89    * @param id The message identifier.
90    * @param queueMode <code>true</code> if this request is destinated to
91    * a queue.
92    */

93   public ConsumerDenyRequest(String JavaDoc targetName, String JavaDoc id, boolean queueMode) {
94     super(targetName);
95     this.id = id;
96     this.queueMode = queueMode;
97   }
98
99   /**
100    * Constructs a <code>ConsumerDenyRequest</code> instance.
101    *
102    * @param targetName Name of the target queue or subscription.
103    * @param id The message identifier.
104    * @param queueMode <code>true</code> if this request is destinated to
105    * a queue.
106    * @param doNotAck <code>true</code> if this request must not be acked by
107    * the server.
108    */

109   public ConsumerDenyRequest(String JavaDoc targetName, String JavaDoc id, boolean queueMode,
110                              boolean doNotAck) {
111     super(targetName);
112     this.id = id;
113     this.queueMode = queueMode;
114     this.doNotAck = doNotAck;
115   }
116
117   /**
118    * Constructs a <code>ConsumerDenyRequest</code> instance.
119    */

120   public ConsumerDenyRequest() {}
121
122   /* ***** ***** ***** ***** *****
123    * Streamable interface
124    * ***** ***** ***** ***** ***** */

125
126   /**
127    * The object implements the writeTo method to write its contents to
128    * the output stream.
129    *
130    * @param os the stream to write the object to
131    */

132   public void writeTo(OutputStream JavaDoc os) throws IOException JavaDoc {
133     super.writeTo(os);
134     StreamUtil.writeTo(id, os);
135     StreamUtil.writeTo(queueMode, os);
136     StreamUtil.writeTo(doNotAck, os);
137   }
138
139   /**
140    * The object implements the readFrom method to restore its contents from
141    * the input stream.
142    *
143    * @param is the stream to read data from in order to restore the object
144    */

145   public void readFrom(InputStream JavaDoc is) throws IOException JavaDoc {
146     super.readFrom(is);
147     id = StreamUtil.readStringFrom(is);
148     queueMode = StreamUtil.readBooleanFrom(is);
149     doNotAck = StreamUtil.readBooleanFrom(is);
150   }
151 }
152
Popular Tags