1 package net.walend.somnifugi; 2 3 import javax.naming.Referenceable ; 4 import javax.naming.Reference ; 5 import javax.naming.NamingException ; 6 import javax.naming.Context ; 7 8 import javax.jms.TopicConnection ; 9 import javax.jms.TopicSession ; 10 import javax.jms.JMSException ; 11 import javax.jms.ConnectionConsumer ; 12 import javax.jms.Topic ; 13 import javax.jms.ServerSessionPool ; 14 import javax.jms.ResourceAllocationException ; 15 import javax.jms.Session ; 16 import javax.jms.Destination ; 17 18 24 25 public class SomniTopicConnection 26 extends SomniConnection 27 implements TopicConnection , Referenceable 28 { 29 protected SomniTopicConnection(SomniTopicConnectionFactory factory,String clientID,Context context) 30 { 31 super(factory,clientID,context); 32 } 33 34 54 public TopicSession createTopicSession(boolean transacted,int acknowledgeMode) 55 throws JMSException 56 { 57 if(transacted) 58 { 59 throw new ResourceAllocationException ("somnifugi sessions are nontransactional."); 60 } 61 if((acknowledgeMode!=Session.AUTO_ACKNOWLEDGE)&&(acknowledgeMode!=Session.CLIENT_ACKNOWLEDGE)) 62 { 63 throw new ResourceAllocationException ("somnifugi sessions must be AUTO_ACKNOWLEDGE or CLIENT_ACKNOWLEDGE, not "+acknowledgeMode); 64 } 65 synchronized(guard) 66 { 67 SomniTopicSession session = new SomniTopicSession(createSessionName(),(SomniExceptionListener)getExceptionListener(),isStarted(),getContext(),acknowledgeMode,getClientID()); 68 addSession(session); 69 70 return session; 71 } 72 } 73 74 99 public ConnectionConsumer createConnectionConsumer(Topic topic,String messageSelector,ServerSessionPool sessionPool,int maxMessages) 100 throws JMSException 101 { 102 throw new UnsupportedOperationException ("Don't use somnifugi in an EJB app server. It plays with Threads."); 103 } 104 105 107 108 130 131 public Session createSession(boolean transacted,int acknowledgeMode) 132 throws JMSException 133 { 134 return createTopicSession(transacted,acknowledgeMode); 135 } 136 137 163 164 public ConnectionConsumer createConnectionConsumer(Destination destination, 165 String messageSelector, 166 ServerSessionPool sessionPool, 167 int maxMessages) 168 throws JMSException 169 { 170 throw new UnsupportedOperationException ("Don't use somnifugi in an EJB app server. It plays with Threads."); 171 } 172 173 200 201 public ConnectionConsumer createDurableConnectionConsumer(Topic topic, 202 String subscriptionName, 203 String messageSelector, 204 ServerSessionPool sessionPool, 205 int maxMessages) 206 throws JMSException 207 { 208 throw new UnsupportedOperationException ("Don't use somnifugi in an EJB app server. It plays with Threads."); 209 } 210 211 public Reference getReference() 213 throws NamingException 214 { 215 return new Reference (this.getClass().getName(),SomniTopicConnectionFactory.class.getName(),null); 216 } 217 218 } 219 220 240 | Popular Tags |