KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > MantaQueueSession


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Nimo.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.api.jms;
47
48 import java.io.Serializable JavaDoc;
49
50 import javax.jms.IllegalStateException JavaDoc;
51 import javax.jms.JMSException JavaDoc;
52 import javax.jms.TemporaryTopic JavaDoc;
53 import javax.jms.Topic JavaDoc;
54 import javax.jms.TopicSubscriber JavaDoc;
55
56
57 /**
58  * A <CODE>QueueSession</CODE> object provides methods for creating
59   * <CODE>QueueReceiver</CODE>, <CODE>QueueSender</CODE>,
60   * <CODE>QueueBrowser</CODE>, and <CODE>TemporaryQueue</CODE> objects.
61   *
62   * <P>If there are messages that have been received but not acknowledged
63   * when a <CODE>QueueSession</CODE> terminates, these messages will be retained
64   * and redelivered when a consumer next accesses the queue.
65   *
66   *<P>A <CODE>QueueSession</CODE> is used for creating Point-to-Point specific
67   * objects. In general, use the <CODE>Session</CODE> object.
68   * The <CODE>QueueSession</CODE> is used to support
69   * existing code. Using the <CODE>Session</CODE> object simplifies the
70   * programming model, and allows transactions to be used across the two
71   * messaging domains.
72   *
73   * <P>A <CODE>QueueSession</CODE> cannot be used to create objects specific to the
74   * publish/subscribe domain. The following methods inherit from
75   * <CODE>Session</CODE>, but must throw an
76   * <CODE>IllegalStateException</CODE>
77   * if they are used from <CODE>QueueSession</CODE>:
78   *<UL>
79   * <LI><CODE>createDurableSubscriber</CODE>
80   * <LI><CODE>createTemporaryTopic</CODE>
81   * <LI><CODE>createTopic</CODE>
82   * <LI><CODE>unsubscribe</CODE>
83   * </UL>
84   *
85   * @author Nimo
86   */

87 public class MantaQueueSession extends MantaSession implements Serializable JavaDoc, javax.jms.QueueSession JavaDoc{
88     
89     /**
90      * This interface is there for compatibility with JMS1.0.2. In JMS1.1 it is
91      * preferred to use MantaSession.
92      * This constructor merely delegates the creation of the object to the
93      * Session
94      *
95      * @param clientID
96      * @param con
97      * @param transactedMode
98      * @param acknowledgeMode
99      * @throws JMSException
100      */

101     public MantaQueueSession(String JavaDoc clientID, MantaConnection con, boolean transactedMode, int acknowledgeMode)
102             throws JMSException JavaDoc {
103         super(clientID, con,acknowledgeMode,transactedMode);//, transactedMode,acknowledgeMode);
104

105         
106     }//MantaQueueSession
107

108         
109     /**
110      * This is a QueueSession, since it extends the Session -
111      * This method needs to be overridden to throw an IllegalStateException.
112      */

113     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name) throws JMSException JavaDoc {
114         throw new IllegalStateException JavaDoc("MNJMS0006E : UNALLOWED OPERATION : createDurableSubscriber() ON A QUEUE SESSION.");
115         
116     }
117     
118     /**
119      * This is a QueueSession, since it extends the Session -
120      * This method needs to be overridden to throw an IllegalStateException.
121      */

122     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name, String JavaDoc messageSelector, boolean noLocal) throws JMSException JavaDoc {
123         throw new IllegalStateException JavaDoc("MNJMS0006E : UNALLOWED OPERATION : createDurableSubscriber() ON A QUEUE SESSION.");
124     }
125     
126     /**
127      * This is a QueueSession, since it extends the Session -
128      * This method needs to be overridden to throw an IllegalStateException.
129      */

130     public TemporaryTopic JavaDoc createTemporaryTopic() throws JMSException JavaDoc {
131         throw new IllegalStateException JavaDoc("MNJMS0006F : UNALLOWED OPERATION : createTemporaryTopic() ON A QUEUE SESSION.");
132     }
133     
134     /**
135      * This is a QueueSession, since it extends the Session -
136      * This method needs to be overridden to throw an IllegalStateException.
137      */

138     public Topic JavaDoc createTopic(String JavaDoc topicName) throws JMSException JavaDoc {
139         throw new IllegalStateException JavaDoc("MNJMS00070 : UNALLOWED OPERATION : createTopic() ON A QUEUE SESSION.");
140     }
141     
142     /**
143      * This is a QueueSession, since it extends the Session -
144      * This method needs to be overridden to throw an IllegalStateException.
145      */

146     public void unsubscribe(String JavaDoc name) throws JMSException JavaDoc {
147         throw new IllegalStateException JavaDoc("MNJMS00071 : UNALLOWED OPERATION : unsubscribe() ON A QUEUE SESSION.");
148         
149     }
150     
151     
152 }//MantaQueueSession
153
Popular Tags