KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > jms > ConsumerDenyRequest


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - 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): Nicolas Tachker (ScalAgent)
23  */

24 package com.scalagent.kjoram.jms;
25
26 import java.util.Vector JavaDoc;
27 import java.util.Hashtable JavaDoc;
28 import java.util.Enumeration JavaDoc;
29
30 /**
31  * A <code>ConsumerDenyRequest</code> instance is used by a
32  * <code>MessageConsumer</code> for denying a received message.
33  */

34 public class ConsumerDenyRequest extends AbstractJmsRequest
35 {
36   /** Message identifier. */
37   private String JavaDoc id;
38   /** <code>true</code> if the request is destinated to a queue. */
39   private boolean queueMode;
40   /** <code>true</code> if the request must not be acked by the server. */
41   private boolean doNotAck = false;
42
43   /**
44    * Constructs a <code>ConsumerDenyRequest</code> instance.
45    *
46    * @param targetName Name of the target queue or subscription.
47    * @param id The message identifier.
48    * @param queueMode <code>true</code> if this request is destinated to
49    * a queue.
50    */

51   public ConsumerDenyRequest(String JavaDoc targetName, String JavaDoc id, boolean queueMode)
52   {
53     super(targetName);
54     this.id = id;
55     this.queueMode = queueMode;
56   }
57
58   /**
59    * Constructs a <code>ConsumerDenyRequest</code> instance.
60    *
61    * @param targetName Name of the target queue or subscription.
62    * @param id The message identifier.
63    * @param queueMode <code>true</code> if this request is destinated to
64    * a queue.
65    * @param doNotAck <code>true</code> if this request must not be acked by
66    * the server.
67    */

68   public ConsumerDenyRequest(String JavaDoc targetName, String JavaDoc id, boolean queueMode,
69                              boolean doNotAck)
70   {
71     super(targetName);
72     this.id = id;
73     this.queueMode = queueMode;
74     this.doNotAck = doNotAck;
75   }
76
77   /**
78    * Constructs a <code>ConsumerDenyRequest</code> instance.
79    */

80   public ConsumerDenyRequest()
81   {}
82
83   /** Sets the denied message identifier. */
84   public void setId(String JavaDoc id)
85   {
86     this.id = id;
87   }
88
89   /** Sets the target destination type. */
90   public void setQueueMode(boolean queueMode)
91   {
92     this.queueMode = queueMode;
93   }
94
95   /** Sets the server ack policy. */
96   public void setDoNotAck(boolean doNotAck)
97   {
98     this.doNotAck = doNotAck;
99   }
100
101   /** Returns the denied message identifier. */
102   public String JavaDoc getId()
103   {
104     return id;
105   }
106
107   /** Returns <code>true</code> if the request is destinated to a queue. */
108   public boolean getQueueMode()
109   {
110     return queueMode;
111   }
112
113   /**
114    * Returns <code>true</code> if the request must not be acked by the
115    * server.
116    */

117   public boolean getDoNotAck()
118   {
119     return doNotAck;
120   }
121
122   public Hashtable JavaDoc soapCode() {
123     Hashtable JavaDoc h = super.soapCode();
124     if (id != null)
125       h.put("id",id);
126     h.put("queueMode",new Boolean JavaDoc(queueMode));
127     h.put("doNotAck",new Boolean JavaDoc(doNotAck));
128     return h;
129   }
130
131   public static Object JavaDoc soapDecode(Hashtable JavaDoc h) {
132     ConsumerDenyRequest req = new ConsumerDenyRequest();
133     req.setRequestId(((Integer JavaDoc) h.get("requestId")).intValue());
134     req.setTarget((String JavaDoc) h.get("target"));
135     req.setId((String JavaDoc) h.get("id"));
136     req.setQueueMode(((Boolean JavaDoc) h.get("queueMode")).booleanValue());
137     req.setDoNotAck(((Boolean JavaDoc) h.get("doNotAck")).booleanValue());
138     return req;
139   }
140 }
141
Popular Tags