KickJava   Java API By Example, From Geeks To Geeks.

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


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.Hashtable JavaDoc;
27 import java.util.Enumeration JavaDoc;
28
29 /**
30  * A <code>ConsumerAckRequest</code> instance is used by a
31  * <code>MessageConsumer</code> for acknowledging a received message.
32  */

33 public class ConsumerAckRequest extends AbstractJmsRequest
34 {
35   /** Message identifier. */
36   private String JavaDoc id;
37   /** <code>true</code> if the request is destinated to a queue. */
38   private boolean queueMode;
39
40   /**
41    * Constructs a <code>ConsumerAckRequest</code> instance.
42    *
43    * @param targetName Name of the target queue or subscription.
44    * @param id The message identifier.
45    * @param queueMode <code>true</code> if this request is destinated to
46    * a queue.
47    */

48   public ConsumerAckRequest(String JavaDoc targetName, String JavaDoc id, boolean queueMode)
49   {
50     super(targetName);
51     this.id = id;
52     this.queueMode = queueMode;
53   }
54
55   /**
56    * Constructs a <code>ConsumerAckRequest</code> instance.
57    */

58   public ConsumerAckRequest()
59   {}
60
61   /** Sets the acknowledged message identifier. */
62   public void setId(String JavaDoc id)
63   {
64     this.id = id;
65   }
66
67   /** Sets the target destination type. */
68   public void setQueueMode(boolean queueMode)
69   {
70     this.queueMode = queueMode;
71   }
72
73   /** Returns the acknowledged message identifier. */
74   public String JavaDoc getId()
75   {
76     return id;
77   }
78
79   /** Returns <code>true</code> if the request is destinated to a queue. */
80   public boolean getQueueMode()
81   {
82     return queueMode;
83   }
84
85   public Hashtable JavaDoc soapCode() {
86     Hashtable JavaDoc h = super.soapCode();
87     if (id != null)
88       h.put("id",id);
89     h.put("queueMode",new Boolean JavaDoc(queueMode));
90     return h;
91   }
92
93   public static Object JavaDoc soapDecode(Hashtable JavaDoc h) {
94     ConsumerAckRequest req = new ConsumerAckRequest();
95     req.setRequestId(((Integer JavaDoc) h.get("requestId")).intValue());
96     req.setTarget((String JavaDoc) h.get("target"));
97     req.setId((String JavaDoc) h.get("id"));
98     req.setQueueMode(((Boolean JavaDoc) h.get("queueMode")).booleanValue());
99     return req;
100   }
101 }
102
Popular Tags