1 22 package org.jboss.mq; 23 24 import java.io.Serializable ; 25 import java.util.Properties ; 26 27 import javax.jms.JMSException ; 28 import javax.jms.XAConnection ; 29 import javax.jms.XAConnectionFactory ; 30 import javax.jms.XAQueueConnection ; 31 import javax.jms.XAQueueConnectionFactory ; 32 import javax.jms.XATopicConnection ; 33 import javax.jms.XATopicConnectionFactory ; 34 import javax.naming.NamingException ; 35 import javax.naming.Reference ; 36 37 46 public class SpyXAConnectionFactory extends SpyConnectionFactory 47 implements Serializable , XAConnectionFactory , XAQueueConnectionFactory , XATopicConnectionFactory 48 { 49 51 52 static final long serialVersionUID = -3869656253676593051L; 53 54 56 58 60 65 public SpyXAConnectionFactory(GenericConnectionFactory factory) 66 { 67 super(factory); 68 } 69 70 75 public SpyXAConnectionFactory(Properties config) 76 { 77 super(config); 78 } 79 80 82 84 public XAConnection createXAConnection() throws JMSException 85 { 86 try 87 { 88 return new SpyXAConnection(factory); 89 } 90 catch (JMSException e) 91 { 92 throw e; 93 } 94 catch (Exception e) 95 { 96 throw new SpyJMSException("Failed to create XAConnection", e); 97 } 98 } 99 100 public XAConnection createXAConnection(String userName, String password) throws JMSException 101 { 102 try 103 { 104 if (userName == null) 105 throw new SpyJMSException("Username is null"); 106 if (password == null) 107 throw new SpyJMSException("Password is null"); 108 109 return new SpyXAConnection(userName, password, factory); 110 } 111 catch (JMSException e) 112 { 113 throw e; 114 } 115 catch (Exception e) 116 { 117 throw new SpyJMSException("Failed to create XAConnection", e); 118 } 119 } 120 121 123 public XAQueueConnection createXAQueueConnection() throws JMSException 124 { 125 return (XAQueueConnection ) createXAConnection(); 126 } 127 128 public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException 129 { 130 return (XAQueueConnection ) createXAConnection(userName, password); 131 } 132 133 135 public XATopicConnection createXATopicConnection() throws JMSException 136 { 137 return (XATopicConnection ) createXAConnection(); 138 } 139 140 public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException 141 { 142 return (XATopicConnection ) createXAConnection(userName, password); 143 } 144 145 147 public Reference getReference() throws NamingException 148 { 149 150 return new Reference ("org.jboss.mq.SpyXAConnectionFactory", new org.jboss.mq.referenceable.ObjectRefAddr("DCF", 151 factory), 152 "org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory", null); 153 } 154 155 157 159 161 } | Popular Tags |