1 7 package org.jboss.jms.client; 8 9 import java.util.Enumeration ; 10 11 import javax.jms.Connection ; 12 import javax.jms.ConnectionConsumer ; 13 import javax.jms.ConnectionMetaData ; 14 import javax.jms.Destination ; 15 import javax.jms.ExceptionListener ; 16 import javax.jms.JMSException ; 17 import javax.jms.Queue ; 18 import javax.jms.QueueConnection ; 19 import javax.jms.QueueSession ; 20 import javax.jms.ServerSessionPool ; 21 import javax.jms.Session ; 22 import javax.jms.Topic ; 23 import javax.jms.TopicConnection ; 24 import javax.jms.TopicSession ; 25 import javax.jms.XAConnection ; 26 import javax.jms.XAQueueConnection ; 27 import javax.jms.XAQueueSession ; 28 import javax.jms.XASession ; 29 import javax.jms.XATopicConnection ; 30 import javax.jms.XATopicSession ; 31 32 38 public class JBossConnection 39 implements Connection , QueueConnection , TopicConnection , 40 XAConnection , XAQueueConnection , XATopicConnection 41 { 42 44 46 47 private ConnectionDelegate delegate; 48 49 50 private ExceptionListener listener; 51 52 53 private boolean isXAConnection; 54 55 57 59 public JBossConnection(ConnectionDelegate delegate, boolean isXAConnection) 60 throws JMSException 61 { 62 this.delegate = delegate; 63 this.isXAConnection = isXAConnection; 64 } 65 66 68 71 public Enumeration getJMSXPropertyNames() 72 throws JMSException 73 { 74 return delegate.getJMSXPropertyNames(); 75 } 76 77 79 public void close() throws JMSException 80 { 81 delegate.closing(); 82 delegate.close(); 83 } 84 85 public ConnectionConsumer createConnectionConsumer( 86 Destination destination, 87 String messageSelector, 88 ServerSessionPool sessionPool, 89 int maxMessages) 90 throws JMSException 91 { 92 return null; 94 } 95 96 public ConnectionConsumer createDurableConnectionConsumer( 97 Topic topic, 98 String subscriptionName, 99 String messageSelector, 100 ServerSessionPool sessionPool, 101 int maxMessages) 102 throws JMSException 103 { 104 return null; 106 } 107 108 public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException 109 { 110 if (transacted) 111 acknowledgeMode = Session.SESSION_TRANSACTED; 112 return new JBossSession(delegate.createSession(false, transacted, acknowledgeMode), false, transacted, acknowledgeMode); 113 } 114 115 public String getClientID() throws JMSException 116 { 117 return delegate.getClientID(); 118 } 119 120 public ExceptionListener getExceptionListener() throws JMSException 121 { 122 return listener; 123 } 124 125 public ConnectionMetaData getMetaData() throws JMSException 126 { 127 return new JBossConnectionMetaData(delegate); 128 } 129 130 public void setClientID(String clientID) throws JMSException 131 { 132 delegate.setClientID(clientID); 133 } 134 135 public void setExceptionListener(ExceptionListener listener) throws JMSException 136 { 137 delegate.setExceptionListener(listener); 138 this.listener = listener; 139 } 140 141 public void start() throws JMSException 142 { 143 delegate.start(); 144 } 145 146 public void stop() throws JMSException 147 { 148 delegate.stop(); 149 } 150 151 153 public ConnectionConsumer createConnectionConsumer( 154 Queue queue, 155 String messageSelector, 156 ServerSessionPool sessionPool, 157 int maxMessages) 158 throws JMSException 159 { 160 return createConnectionConsumer((Destination ) queue, messageSelector, sessionPool, maxMessages); 161 } 162 163 public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException 164 { 165 return (QueueSession ) createSession(transacted, acknowledgeMode); 166 } 167 168 170 public ConnectionConsumer createConnectionConsumer( 171 Topic topic, 172 String messageSelector, 173 ServerSessionPool sessionPool, 174 int maxMessages) 175 throws JMSException 176 { 177 return createConnectionConsumer((Destination ) topic, messageSelector, sessionPool, maxMessages); 178 } 179 180 public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) 181 throws JMSException 182 { 183 return (TopicSession ) createSession(transacted, acknowledgeMode); 184 } 185 186 188 public XASession createXASession() throws JMSException 189 { 190 if (isXAConnection == false) 191 throw new JMSException ("Not an xa connection"); 192 return new JBossSession(delegate.createSession(true, true, Session.SESSION_TRANSACTED), true, true, Session.SESSION_TRANSACTED); 193 } 194 195 197 public XAQueueSession createXAQueueSession() throws JMSException 198 { 199 return (XAQueueSession ) createXASession(); 200 } 201 202 204 public XATopicSession createXATopicSession() throws JMSException 205 { 206 return (XATopicSession ) createXASession(); 207 } 208 209 211 213 215 } 217 | Popular Tags |