1 18 package org.apache.activemq.axis; 19 20 import org.apache.activemq.ActiveMQConnectionFactory; 21 import org.apache.axis.components.jms.BeanVendorAdapter; 22 import org.apache.axis.transport.jms.JMSURLHelper; 23 24 import javax.jms.ConnectionFactory ; 25 import javax.jms.QueueConnectionFactory ; 26 import javax.jms.TopicConnectionFactory ; 27 import java.util.HashMap ; 28 29 34 public class ActiveMQVendorAdapter extends BeanVendorAdapter { 35 36 protected final static String QCF_CLASS = ActiveMQConnectionFactory.class.getName(); 37 protected final static String TCF_CLASS = QCF_CLASS; 38 39 40 43 public final static String BROKER_URL = "brokerURL"; 44 45 48 public final static String DEFAULT_USERNAME = "defaultUser"; 49 50 53 public final static String DEFAULT_PASSWORD = "defaultPassword"; 54 55 56 public QueueConnectionFactory getQueueConnectionFactory(HashMap properties) 57 throws Exception { 58 properties = (HashMap ) properties.clone(); 59 properties.put(CONNECTION_FACTORY_CLASS, QCF_CLASS); 60 return super.getQueueConnectionFactory(properties); 61 } 62 63 public TopicConnectionFactory getTopicConnectionFactory(HashMap properties) 64 throws Exception { 65 properties = (HashMap ) properties.clone(); 66 properties.put(CONNECTION_FACTORY_CLASS, TCF_CLASS); 67 return super.getTopicConnectionFactory(properties); 68 } 69 70 71 public void addVendorConnectionFactoryProperties(JMSURLHelper jmsUrl, HashMap properties) { 72 if (jmsUrl.getPropertyValue(BROKER_URL) != null) { 73 properties.put(BROKER_URL, jmsUrl.getPropertyValue(BROKER_URL)); 74 } 75 76 if (jmsUrl.getPropertyValue(DEFAULT_USERNAME) != null) { 77 properties.put(DEFAULT_USERNAME, jmsUrl.getPropertyValue(DEFAULT_USERNAME)); 78 } 79 if (jmsUrl.getPropertyValue(DEFAULT_PASSWORD) != null) { 80 properties.put(DEFAULT_PASSWORD, jmsUrl.getPropertyValue(DEFAULT_PASSWORD)); 81 } 82 } 83 84 public boolean isMatchingConnectionFactory(ConnectionFactory connectionFactory, JMSURLHelper jmsURL, HashMap properties) { 85 String brokerURL = null; 86 87 if (connectionFactory instanceof ActiveMQConnectionFactory) { 88 ActiveMQConnectionFactory amqConnectionFactory = 89 (ActiveMQConnectionFactory) connectionFactory; 90 91 brokerURL = amqConnectionFactory.getBrokerURL(); 93 } 94 95 String propertyBrokerURL = (String ) properties.get(BROKER_URL); 97 if (!brokerURL.equals(propertyBrokerURL)) { 98 return false; 99 } 100 return true; 101 } 102 } 103 | Popular Tags |