KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exolab > jms > client > JmsQueueSession


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "Exolab" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of Exoffice Technologies. For written permission,
18  * please contact info@exolab.org.
19  *
20  * 4. Products derived from this Software may not be called "Exolab"
21  * nor may "Exolab" appear in their names without prior written
22  * permission of Exoffice Technologies. Exolab is a registered
23  * trademark of Exoffice Technologies.
24  *
25  * 5. Due credit should be given to the Exolab Project
26  * (http://www.exolab.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2000-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
42  */

43 package org.exolab.jms.client;
44
45 import javax.jms.JMSException JavaDoc;
46 import javax.jms.Queue JavaDoc;
47 import javax.jms.QueueReceiver JavaDoc;
48 import javax.jms.QueueSender JavaDoc;
49 import javax.jms.QueueSession JavaDoc;
50 import javax.jms.TemporaryTopic JavaDoc;
51 import javax.jms.Topic JavaDoc;
52 import javax.jms.TopicSubscriber JavaDoc;
53
54
55 /**
56  * Client implementation of the <code>javax.jms.QueueSession</code> interface.
57  *
58  * @author <a HREF="mailto:jima@exoffice.com">Jim Alateras</a>
59  * @version $Revision: 1.2 $ $Date: 2005/03/18 03:36:37 $
60  */

61 class JmsQueueSession
62         extends JmsSession
63         implements QueueSession JavaDoc {
64
65     /**
66      * Construct a new <code>JmsQueueSession</code>.
67      *
68      * @param connection the owner of the session
69      * @param transacted if <code>true</code>, the session is transacted.
70      * @param ackMode indicates whether the consumer or the client will
71      * acknowledge any messages it receives. This parameter
72      * will be ignored if the session is transacted. Legal
73      * values are <code>Session.AUTO_ACKNOWLEDGE</code>,
74      * <code>Session.CLIENT_ACKNOWLEDGE</code> and
75      * <code>Session.DUPS_OK_ACKNOWLEDGE</code>.
76      * @throws JMSException if the session cannot be created
77      */

78     public JmsQueueSession(JmsQueueConnection connection, boolean transacted,
79                            int ackMode) throws JMSException JavaDoc {
80         super(connection, transacted, ackMode);
81     }
82
83     /**
84      * Create a receiver to receive messages from the specified queue.
85      *
86      * @param queue the queue to access
87      * @return the new receiver
88      * @throws JMSException if the receiver cannot be created
89      */

90     public QueueReceiver JavaDoc createReceiver(Queue JavaDoc queue) throws JMSException JavaDoc {
91         return createReceiver(queue, null);
92     }
93
94     /**
95      * Create a receiver to receive messages from the specified queue.
96      *
97      * @param queue the queue to access
98      * @param selector the message selector to filter messages. May be
99      * <code>null</code>
100      * @return the new receiver
101      * @throws JMSException if the receiver cannot be created
102      */

103     public QueueReceiver JavaDoc createReceiver(Queue JavaDoc queue, String JavaDoc selector)
104             throws JMSException JavaDoc {
105         long consumerId = allocateConsumer(queue, selector, false);
106         JmsQueueReceiver receiver = new JmsQueueReceiver(this, consumerId,
107                                                          queue, selector);
108         addConsumer(receiver);
109         return receiver;
110     }
111
112     /**
113      * Create a sender to send messages to the specified queue.
114      *
115      * @param queue the queue to access, or <code>null</code> if this is an
116      * unidentified producer
117      * @return the new sender
118      * @throws JMSException if the sender can't be created
119      */

120     public QueueSender JavaDoc createSender(Queue JavaDoc queue) throws JMSException JavaDoc {
121         ensureOpen();
122         JmsQueueSender sender = new JmsQueueSender(this, (JmsQueue) queue);
123         addProducer(sender);
124         return sender;
125     }
126
127     /**
128      * This implementation always throws <code>IllegalStateException</code>, as
129      * per section 4.11 of the JMS specification.
130      *
131      * @throws IllegalStateException if invoked
132      */

133     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name,
134                                                    String JavaDoc messageSelector,
135                                                    boolean noLocal)
136             throws JMSException JavaDoc {
137         throw new IllegalStateException JavaDoc("Invalid operation for QueueSession");
138     }
139
140     /**
141      * This implementation always throws <code>IllegalStateException</code>, as
142      * per section 4.11 of the JMS specification.
143      *
144      * @throws IllegalStateException if invoked
145      */

146     public Topic JavaDoc createTopic(String JavaDoc topicName) throws JMSException JavaDoc {
147         throw new IllegalStateException JavaDoc("Invalid operation for QueueSession");
148     }
149
150     /**
151      * This implementation always throws <code>IllegalStateException</code>, as
152      * per section 4.11 of the JMS specification.
153      *
154      * @throws IllegalStateException if invoked
155      */

156     public TemporaryTopic JavaDoc createTemporaryTopic() throws JMSException JavaDoc {
157         throw new IllegalStateException JavaDoc("Invalid operation for QueueSession");
158     }
159
160     /**
161      * This implementation always throws <code>IllegalStateException</code>, as
162      * per section 4.11 of the JMS specification.
163      *
164      * @throws IllegalStateException if invoked
165      */

166     public void unsubscribe(String JavaDoc name) throws JMSException JavaDoc {
167         throw new IllegalStateException JavaDoc("Invalid operation for QueueSession");
168     }
169
170 }
171
Popular Tags