KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > walend > somnifugi > SomniTopicSubscriber


1 package net.walend.somnifugi;
2
3 import javax.jms.TopicSubscriber JavaDoc;
4 import javax.jms.Topic JavaDoc;
5 import javax.jms.JMSException JavaDoc;
6 import javax.jms.Message JavaDoc;
7
8 import net.walend.somnifugi.channel.Takable;
9
10 /**
11 A Subscriber for a Topic.
12
13 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
14 @author @pwang@ added support for client acknowledgement.
15  */

16
17 public class SomniTopicSubscriber
18     extends SomniMessageConsumer
19     implements TopicSubscriber JavaDoc
20 {
21     private SomniTopic topic;
22     private String JavaDoc name;
23
24     protected SomniTopicSubscriber(SomniTopic topic,Takable<Message JavaDoc> feed,String JavaDoc name,SomniExceptionListener exceptionListener,SomniSession session)
25     {
26         super(feed,exceptionListener,session);
27         this.name = name;
28         this.topic = topic;
29     }
30
31     protected SomniTopicSubscriber(SomniTopic topic,Takable<Message JavaDoc> feed,String JavaDoc name,SomniExceptionListener exceptionListener,SomniMessageSelector messageSelector,SomniSession session)
32     {
33         super(feed,exceptionListener,messageSelector,session);
34         this.name = name;
35         this.topic = topic;
36     }
37
38     /** Gets the <CODE>Topic</CODE> associated with this subscriber.
39  
40 @return this subscriber's <CODE>Topic</CODE>
41  
42 @exception JMSException if the JMS provider fails to get the topic for
43                         this topic subscriber
44                         due to some internal error.
45       */

46     public Topic JavaDoc getTopic()
47         throws JMSException JavaDoc
48     {
49         return topic;
50     }
51
52     /** Gets the <CODE>NoLocal</CODE> attribute for this subscriber.
53 The default value for this attribute is false.
54 <p>
55 Since all messages in SomnifugiJMS are local, ask yourself hard questions about why you're calling this method...
56  
57 @return true if locally published messages are being inhibited
58  
59 @exception JMSException if the JMS provider fails to get the
60                         <CODE>NoLocal</CODE> attribute for
61                         this topic subscriber
62                         due to some internal error.
63       */

64     public boolean getNoLocal()
65         throws JMSException JavaDoc
66     {
67         return false;
68     }
69
70     public void close()
71         throws JMSException JavaDoc
72     {
73         super.close();
74         //remove the feed from the topic
75
topic.removeSubscriber(name);
76     }
77
78     protected SomniDestination getDestination()
79     {
80         return topic;
81     }
82
83     public String JavaDoc getName()
84     {
85         return name;
86     }
87 }
88
89 /* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
90 All rights reserved.
91
92 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
93
94 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
95
96 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
97
98 Neither the name of the SomnifugiJMS Project, walend.net, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission from David Walend.
99
100 Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
101
102 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 The net.walend.somnifugi.sql92 package is modified code from the openmq project, https://mq.dev.java.net/ , Copyright (c) of Sun, and carries the CDDL license, repeated here: You can obtain a copy of the license at https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations under the License.
104
105 =================================================================================
106
107 For more information and the latest version of this software, please see http://somnifugi.sourceforge.net and http://walend.net or email <a HREF="mailto:david@walend.net">david@walend.net</a>.
108  */

109
Popular Tags