1 21 package org.objectweb.jonas_jms; 22 23 import java.util.Vector ; 24 25 import javax.jms.ConnectionFactory ; 26 import javax.jms.Queue ; 27 import javax.jms.QueueConnectionFactory ; 28 import javax.jms.Topic ; 29 import javax.jms.TopicConnectionFactory ; 30 import javax.jms.XAConnectionFactory ; 31 import javax.jms.XAQueueConnectionFactory ; 32 import javax.jms.XATopicConnectionFactory ; 33 import javax.naming.InitialContext ; 34 import javax.naming.NamingException ; 35 36 import org.objectweb.jonas_jms.api.JmsAdministration; 37 import org.objectweb.util.monolog.api.BasicLevel; 38 39 40 50 public class JmsAdminForWSMQ implements JmsAdministration { 51 52 private static String CONN_FACT_NAME="JCF"; 53 private static String QUEUE_CONN_FACT_NAME="JQCF"; 54 private static String TOPIC_CONN_FACT_NAME="JTCF"; 55 56 private InitialContext ictx = null; 57 private Vector namelist = new Vector (); 58 59 private XAConnectionFactory xacf = null; 60 private XAQueueConnectionFactory xaqcf = null; 61 private XATopicConnectionFactory xatcf = null; 62 private ConnectionFactory jcf = null; 63 private QueueConnectionFactory jqcf = null; 64 private TopicConnectionFactory jtcf = null; 65 66 67 72 public JmsAdminForWSMQ() { 73 } 74 75 85 public void start(boolean collocated, String url) throws Exception { 86 87 ictx = new InitialContext (); 89 90 try { 93 xacf = (XAConnectionFactory ) ictx.lookup("wsmqXACF"); 94 ictx.unbind("wsmqXACF"); 95 } catch (NamingException exc) { 96 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ XAConnectionFactory could not be retrieved from JNDI"); 97 } 98 try { 99 xaqcf = (XAQueueConnectionFactory ) ictx.lookup("wsmqXAQCF"); 100 ictx.unbind("wsmqXAQCF"); 101 } catch (NamingException exc) { 102 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ XAQueueConnectionFactory could not be retrieved from JNDI"); 103 } 104 try { 105 xatcf = (XATopicConnectionFactory ) ictx.lookup("wsmqXATCF"); 106 ictx.unbind("wsmqXATCF"); 107 } catch (NamingException exc) { 108 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ XATopicConnectionFactory could not be retrieved from JNDI"); 109 } 110 111 try { 114 ictx.lookup(CONN_FACT_NAME); 115 namelist.addElement(CONN_FACT_NAME); 116 } catch (NamingException exc) { 117 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ ConnectionFactory could not be retrieved from JNDI"); 118 } 119 try { 120 ictx.lookup(QUEUE_CONN_FACT_NAME); 121 namelist.addElement(QUEUE_CONN_FACT_NAME); 122 } catch (NamingException exc) { 123 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ QueueConnectionFactory could not be retrieved from JNDI"); 124 } 125 try { 126 ictx.lookup(TOPIC_CONN_FACT_NAME); 127 namelist.addElement(TOPIC_CONN_FACT_NAME); 128 } catch (NamingException exc) { 129 TraceJms.logger.log(BasicLevel.ERROR, "WebSphere MQ TopicConnectionFactory could not be retrieved from JNDI"); 130 } 131 } 132 133 136 public void stop() { 137 try { 139 ictx.unbind(CONN_FACT_NAME); 140 } catch(Exception ex) { 141 } 142 try { 143 ictx.unbind(QUEUE_CONN_FACT_NAME); 144 } catch(Exception ex) { 145 } 146 try { 147 ictx.unbind(TOPIC_CONN_FACT_NAME); 148 } catch(Exception ex) { 149 } 150 151 if (TraceJms.isDebug()) 152 TraceJms.logger.log(BasicLevel.DEBUG, "connection factories unbound"); 153 } 154 155 156 159 public XAConnectionFactory getXAConnectionFactory() { 160 return xacf; 161 } 162 163 166 public XATopicConnectionFactory getXATopicConnectionFactory() { 167 return xatcf; 168 } 169 170 173 public XAQueueConnectionFactory getXAQueueConnectionFactory() { 174 return xaqcf; 175 } 176 177 182 public Queue createQueue(String name) throws Exception { 183 throw new Exception ("WebSphere MQ Queue creation impossible from JOnAS"); 184 } 185 186 191 public Topic createTopic(String name) throws Exception { 192 throw new Exception ("WebSphere MQ Topic creation impossible from JOnAS"); 193 } 194 195 200 public void deleteDestination(String name) throws Exception { 201 throw new Exception ("WebSphere MQ destination deletion impossible from JOnAS"); 202 } 203 204 208 public int getPendingMessages(javax.jms.Queue queue) throws Exception { 209 return -1; 210 } 211 212 216 public int getPendingRequests(javax.jms.Queue queue) throws Exception { 217 return -1; 218 } 219 220 223 public int getSubscriptions(javax.jms.Topic topic) throws Exception { 224 return -1; 225 } 226 } 227 | Popular Tags |