1 55 56 package org.jboss.axis.transport.jms; 57 58 import org.jboss.axis.components.jms.JMSVendorAdapter; 59 import org.jboss.axis.components.jms.JMSVendorAdapterFactory; 60 61 import java.util.HashMap ; 62 63 73 public class JMSConnectorFactory 74 { 75 86 public static JMSConnector createServerConnector(HashMap connectorConfig, 87 HashMap cfConfig, 88 String username, 89 String password) 90 throws Exception 91 { 92 return createConnector(connectorConfig, cfConfig, true, 93 username, password); 94 } 95 96 107 public static JMSConnector createClientConnector(HashMap connectorConfig, 108 HashMap cfConfig, 109 String username, 110 String password) 111 throws Exception 112 { 113 return createConnector(connectorConfig, cfConfig, false, 114 username, password); 115 } 116 117 private static JMSConnector createConnector(HashMap connectorConfig, 118 HashMap cfConfig, 119 boolean allowReceive, 120 String username, 121 String password) 122 throws Exception 123 { 124 if (connectorConfig != null) 125 connectorConfig = (HashMap )connectorConfig.clone(); 126 int numRetries = MapUtils.removeIntProperty(connectorConfig, 127 JMSConstants.NUM_RETRIES, 128 JMSConstants.DEFAULT_NUM_RETRIES); 129 130 int numSessions = MapUtils.removeIntProperty(connectorConfig, 131 JMSConstants.NUM_SESSIONS, 132 JMSConstants.DEFAULT_NUM_SESSIONS); 133 134 long connectRetryInterval = MapUtils.removeLongProperty(connectorConfig, 135 JMSConstants.CONNECT_RETRY_INTERVAL, 136 JMSConstants.DEFAULT_CONNECT_RETRY_INTERVAL); 137 138 long interactRetryInterval = MapUtils.removeLongProperty(connectorConfig, 139 JMSConstants.INTERACT_RETRY_INTERVAL, 140 JMSConstants.DEFAULT_INTERACT_RETRY_INTERVAL); 141 142 long timeoutTime = MapUtils.removeLongProperty(connectorConfig, 143 JMSConstants.TIMEOUT_TIME, 144 JMSConstants.DEFAULT_TIMEOUT_TIME); 145 146 String clientID = MapUtils.removeStringProperty(connectorConfig, 147 JMSConstants.CLIENT_ID, 148 null); 149 String domain = MapUtils.removeStringProperty(connectorConfig, 150 JMSConstants.DOMAIN, 151 JMSConstants.DOMAIN_DEFAULT); 152 153 if (cfConfig == null) 154 throw new IllegalArgumentException ("noCfConfig"); 155 156 JMSVendorAdapter adapter = JMSVendorAdapterFactory.getJMSVendorAdapter(); 157 if (domain.equals(JMSConstants.DOMAIN_QUEUE)) 158 { 159 return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig), 160 numRetries, numSessions, connectRetryInterval, 161 interactRetryInterval, timeoutTime, 162 allowReceive, clientID, username, password, 163 adapter); 164 } 165 else { 167 return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig), 168 numRetries, numSessions, connectRetryInterval, 169 interactRetryInterval, timeoutTime, 170 allowReceive, clientID, username, password, 171 adapter); 172 } 173 } 174 } | Popular Tags |