1 package net.walend.somnifugi; 2 3 import java.util.Map ; 4 import java.util.HashMap ; 5 import java.util.Set ; 6 import java.util.HashSet ; 7 import java.util.Iterator ; 8 import java.util.Hashtable ; 9 10 import javax.naming.Referenceable ; 11 import javax.naming.Reference ; 12 import javax.naming.NamingException ; 13 import javax.naming.Context ; 14 15 import javax.jms.Topic ; 16 import javax.jms.JMSException ; 17 import javax.jms.Message ; 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 33 34 public class SomniTopic 35 extends SomniDestination 36 implements Topic , Referenceable 37 { 38 private static final long serialVersionUID = 0L; 39 40 private final FanOut<Message > fanOut; 41 42 protected SomniTopic(String name,ChannelFactory<Message > factory,FanOutFactory<Message > fanOutFactory,Context context) 43 throws SomniNamingException 44 { 45 super(name,factory,context); 46 fanOut = fanOutFactory.createFanOut(name,context,factory); 47 } 48 49 61 public String getTopicName() 62 throws JMSException 63 { 64 return getName(); 65 } 66 67 72 public String toString() 73 { 74 return getName(); 75 } 76 77 protected Puttable<Message > getPuttable() 78 { 79 return fanOut; 80 } 81 82 protected Takable<Message > addSubscriber(String subscriber,boolean durable,SomniMessageSelector messageSelector,boolean noLocal,String subscriberConnectionClientID) 83 throws SomniNamingException 84 { 85 return fanOut.addSubscriber(subscriber,durable,messageSelector,noLocal,subscriberConnectionClientID); 86 } 87 88 protected void removeSubscriber(String subscriber) 89 { 90 fanOut.removeSubscriber(subscriber); 91 } 92 93 protected void removeDurableSubscriber(String subscriber) 94 { 95 fanOut.removeDurableSubscriber(subscriber); 96 } 97 98 public Reference getReference() 100 throws NamingException 101 { 102 return new Reference (this.getClass().getName(),SomniTopicFactory.class.getName(),null); 103 } 104 105 } 106 107 127 | Popular Tags |