KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.walend.somnifugi;
2
3 import java.util.Map JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import java.util.Set JavaDoc;
6 import java.util.HashSet JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.Hashtable JavaDoc;
9
10 import javax.naming.Referenceable JavaDoc;
11 import javax.naming.Reference JavaDoc;
12 import javax.naming.NamingException JavaDoc;
13 import javax.naming.Context JavaDoc;
14
15 import javax.jms.Topic JavaDoc;
16 import javax.jms.JMSException JavaDoc;
17 import javax.jms.Message JavaDoc;
18
19 import net.walend.somnifugi.channel.Puttable;
20 import net.walend.somnifugi.channel.Takable;
21 import net.walend.somnifugi.channel.Channel;
22 import net.walend.somnifugi.channel.ChannelFactory;
23 import net.walend.somnifugi.channel.FanOut;
24 import net.walend.somnifugi.channel.FanOutFactory;
25
26 import net.walend.somnifugi.juc.SimpleFanOut;
27
28 /**
29 A Topic. A Destionation that takes messages in from a SomniPublisher and fans them out to all subscribed SomniSubscribers.
30 <p>
31 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
32  */

33
34 public class SomniTopic
35     extends SomniDestination
36     implements Topic JavaDoc, Referenceable JavaDoc
37 {
38     private static final long serialVersionUID = 0L;
39
40     private final FanOut<Message JavaDoc> fanOut;
41
42     protected SomniTopic(String JavaDoc name,ChannelFactory<Message JavaDoc> factory,FanOutFactory<Message JavaDoc> fanOutFactory,Context JavaDoc context)
43         throws SomniNamingException
44     {
45         super(name,factory,context);
46         fanOut = fanOutFactory.createFanOut(name,context,factory);
47     }
48
49     /**
50 Gets the name of this topic.
51  
52 <P>Clients that depend upon the name are not portable.
53  
54 @return the topic name
55  
56 @exception JMSException if the JMS provider implementation of
57                         <CODE>Topic</CODE> fails to return the topic
58                         name due to some internal
59                         error.
60       */

61     public String JavaDoc getTopicName()
62         throws JMSException JavaDoc
63     {
64         return getName();
65     }
66
67     /**
68 Returns a string representation of this object.
69
70 @return the provider-specific identity values for this topic
71       */

72     public String JavaDoc toString()
73     {
74         return getName();
75     }
76     
77     protected Puttable<Message JavaDoc> getPuttable()
78     {
79         return fanOut;
80     }
81
82     protected Takable<Message JavaDoc> addSubscriber(String JavaDoc subscriber,boolean durable,SomniMessageSelector messageSelector,boolean noLocal,String JavaDoc subscriberConnectionClientID)
83         throws SomniNamingException
84     {
85         return fanOut.addSubscriber(subscriber,durable,messageSelector,noLocal,subscriberConnectionClientID);
86     }
87
88     protected void removeSubscriber(String JavaDoc subscriber)
89     {
90         fanOut.removeSubscriber(subscriber);
91     }
92
93     protected void removeDurableSubscriber(String JavaDoc subscriber)
94     {
95         fanOut.removeDurableSubscriber(subscriber);
96     }
97
98     //Referenceable
99
public Reference JavaDoc getReference()
100         throws NamingException JavaDoc
101     {
102         return new Reference JavaDoc(this.getClass().getName(),SomniTopicFactory.class.getName(),null);
103     }
104
105 }
106
107 /* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
108 All rights reserved.
109
110 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
111
112 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
113
114 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.
115
116 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.
117
118 Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
119
120 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.
121 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.
122
123 =================================================================================
124
125 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>.
126  */

127
Popular Tags