KickJava   Java API By Example, From Geeks To Geeks.

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


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>ConsumerSubRequest</code> is sent by a constructing
31  * <code>MessageConsumer</code> destinated to consume messages on a topic.
32  */

33 public class ConsumerSubRequest extends AbstractJmsRequest
34 {
35   /** The subscription's name. */
36   private String JavaDoc subName;
37   /** The selector for filtering messages. */
38   private String JavaDoc selector;
39   /**
40    * <code>true</code> if the subscriber does not wish to consume messages
41    * produced by its connection.
42    */

43   private boolean noLocal;
44   /** <code>true</code> if the subscription is durable. */
45   private boolean durable;
46
47   /**
48    * Constructs a <code>ConsumerSubRequest</code>.
49    *
50    * @param topic The topic identifier the client wishes to subscribe to.
51    * @param subName The subscription's name.
52    * @param selector The selector for filtering messages, if any.
53    * @param noLocal <code>true</code> for not consuming the local messages.
54    * @param durable <code>true</code> for a durable subscription.
55    */

56   public ConsumerSubRequest(String JavaDoc topic, String JavaDoc subName, String JavaDoc selector,
57                             boolean noLocal, boolean durable)
58   {
59     super(topic);
60     this.subName = subName;
61     this.selector = selector;
62     this.noLocal = noLocal;
63     this.durable = durable;
64   }
65
66   /**
67    * Constructs a <code>ConsumerSubRequest</code>.
68    */

69   public ConsumerSubRequest()
70   {}
71
72   /** Sets the subscription name. */
73   public void setSubName(String JavaDoc subName)
74   {
75     this.subName = subName;
76   }
77
78   /** Sets the selector. */
79   public void setSelector(String JavaDoc selector)
80   {
81     this.selector = selector;
82   }
83
84   /** Sets the noLocal attribute. */
85   public void setNoLocal(boolean noLocal)
86   {
87     this.noLocal = noLocal;
88   }
89
90   /** Sets the durable attribute. */
91   public void setDurable(boolean durable)
92   {
93     this.durable = durable;
94   }
95
96   /** Returns the name of the subscription. */
97   public String JavaDoc getSubName()
98   {
99     return subName;
100   }
101
102   /** Returns the selector for filtering the messages. */
103   public String JavaDoc getSelector()
104   {
105     return selector;
106   }
107
108   /** Returns <code>true</code> for not consuming the local messages. */
109   public boolean getNoLocal()
110   {
111     return noLocal;
112   }
113
114   /** Returns <code>true</code> for a durable subscription. */
115   public boolean getDurable()
116   {
117     return durable;
118   }
119
120   public Hashtable JavaDoc soapCode() {
121     Hashtable JavaDoc h = super.soapCode();
122     if (subName != null)
123       h.put("subName",subName);
124     if (selector != null)
125       h.put("selector",selector);
126     h.put("noLocal",new Boolean JavaDoc(noLocal));
127     h.put("durable",new Boolean JavaDoc(durable));
128     return h;
129   }
130
131   public static Object JavaDoc soapDecode(Hashtable JavaDoc h) {
132     ConsumerSubRequest req = new ConsumerSubRequest();
133     req.setRequestId(((Integer JavaDoc) h.get("requestId")).intValue());
134     req.setTarget((String JavaDoc) h.get("target"));
135     req.setSubName((String JavaDoc) h.get("subName"));
136     req.setSelector((String JavaDoc) h.get("selector"));
137     req.setNoLocal(((Boolean JavaDoc) h.get("noLocal")).booleanValue());
138     req.setDurable(((Boolean JavaDoc) h.get("durable")).booleanValue());
139     return req;
140   }
141 }
142
Popular Tags