JMSConnectorFactorypublic abstract class JMSConnectorFactory extends Object JMSConnectorFactory is a factory class for creating JMSConnectors. It can
create both client connectors and server connectors. A server connector
is configured to allow asynchronous message receipt, while a client
connector is not.
JMSConnectorFactory can also be used to select an appropriately configured
JMSConnector from an existing pool of connectors. |
Fields Summary |
---|
protected static Log | log |
Methods Summary |
---|
public static JMSConnector | createClientConnector(java.util.HashMap connectorConfig, java.util.HashMap cfConfig, java.lang.String username, java.lang.String password, org.apache.axis.components.jms.JMSVendorAdapter adapter)Static method to create a client connector. Client connectors cannot
accept incoming requests.
return createConnector(connectorConfig, cfConfig, false,
username, password, adapter);
| private static JMSConnector | createConnector(java.util.HashMap connectorConfig, java.util.HashMap cfConfig, boolean allowReceive, java.lang.String username, java.lang.String password, org.apache.axis.components.jms.JMSVendorAdapter adapter)
if(connectorConfig != null)
connectorConfig = (HashMap)connectorConfig.clone();
int numRetries = MapUtils.removeIntProperty(connectorConfig,
JMSConstants.NUM_RETRIES,
JMSConstants.DEFAULT_NUM_RETRIES);
int numSessions = MapUtils.removeIntProperty(connectorConfig,
JMSConstants.NUM_SESSIONS,
JMSConstants.DEFAULT_NUM_SESSIONS);
long connectRetryInterval = MapUtils.removeLongProperty(connectorConfig,
JMSConstants.CONNECT_RETRY_INTERVAL,
JMSConstants.DEFAULT_CONNECT_RETRY_INTERVAL);
long interactRetryInterval = MapUtils.removeLongProperty(connectorConfig,
JMSConstants.INTERACT_RETRY_INTERVAL,
JMSConstants.DEFAULT_INTERACT_RETRY_INTERVAL);
long timeoutTime = MapUtils.removeLongProperty(connectorConfig,
JMSConstants.TIMEOUT_TIME,
JMSConstants.DEFAULT_TIMEOUT_TIME);
String clientID = MapUtils.removeStringProperty(connectorConfig,
JMSConstants.CLIENT_ID,
null);
String domain = MapUtils.removeStringProperty(connectorConfig,
JMSConstants.DOMAIN,
JMSConstants.DOMAIN_DEFAULT);
// this will be set if the target endpoint address was set on the Axis call
JMSURLHelper jmsurl = (JMSURLHelper)connectorConfig.get(JMSConstants.JMS_URL);
if(cfConfig == null)
throw new IllegalArgumentException("noCfConfig");
if(domain.equals(JMSConstants.DOMAIN_QUEUE))
{
return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig),
numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime,
allowReceive, clientID, username, password,
adapter, jmsurl);
}
else // domain is Topic
{
return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig),
numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime,
allowReceive, clientID, username, password,
adapter, jmsurl);
}
| public static JMSConnector | createServerConnector(java.util.HashMap connectorConfig, java.util.HashMap cfConfig, java.lang.String username, java.lang.String password, org.apache.axis.components.jms.JMSVendorAdapter adapter)Static method to create a server connector. Server connectors can
accept incoming requests.
return createConnector(connectorConfig, cfConfig, true,
username, password, adapter);
| public static JMSConnector | matchConnector(java.util.Set connectors, java.util.HashMap connectorProps, java.util.HashMap cfProps, java.lang.String username, java.lang.String password, org.apache.axis.components.jms.JMSVendorAdapter adapter)Performs an initial check on the connector properties, and then defers
to the vendor adapter for matching on the vendor-specific connection factory.
java.util.Iterator iter = connectors.iterator();
while (iter.hasNext())
{
JMSConnector conn = (JMSConnector) iter.next();
// username
String connectorUsername = conn.getUsername();
if (!( ((connectorUsername == null) && (username == null)) ||
((connectorUsername != null) && (username != null) && (connectorUsername.equals(username))) ))
continue;
// password
String connectorPassword = conn.getPassword();
if (!( ((connectorPassword == null) && (password == null)) ||
((connectorPassword != null) && (password != null) && (connectorPassword.equals(password))) ))
continue;
// num retries
int connectorNumRetries = conn.getNumRetries();
String propertyNumRetries = (String)connectorProps.get(JMSConstants.NUM_RETRIES);
int numRetries = JMSConstants.DEFAULT_NUM_RETRIES;
if (propertyNumRetries != null)
numRetries = Integer.parseInt(propertyNumRetries);
if (connectorNumRetries != numRetries)
continue;
// client id
String connectorClientID = conn.getClientID();
String clientID = (String)connectorProps.get(JMSConstants.CLIENT_ID);
if (!( ((connectorClientID == null) && (clientID == null))
||
((connectorClientID != null) && (clientID != null) && connectorClientID.equals(clientID)) ))
continue;
// domain
String connectorDomain = (conn instanceof QueueConnector) ? JMSConstants.DOMAIN_QUEUE : JMSConstants.DOMAIN_TOPIC;
String propertyDomain = (String)connectorProps.get(JMSConstants.DOMAIN);
String domain = JMSConstants.DOMAIN_DEFAULT;
if (propertyDomain != null)
domain = propertyDomain;
if (!( ((connectorDomain == null) && (domain == null))
||
((connectorDomain != null) && (domain != null) && connectorDomain.equalsIgnoreCase(domain)) ))
continue;
// the connection factory must also match for the connector to be reused
JMSURLHelper jmsurl = conn.getJMSURL();
if (adapter.isMatchingConnectionFactory(conn.getConnectionFactory(), jmsurl, cfProps))
{
// attempt to reserve the connector
try
{
JMSConnectorManager.getInstance().reserve(conn);
if (log.isDebugEnabled()) {
log.debug("JMSConnectorFactory: Found matching connector");
}
}
catch (Exception e)
{
// ignore. the connector may be in the process of shutting down, so try the next element
continue;
}
return conn;
}
}
if (log.isDebugEnabled()) {
log.debug("JMSConnectorFactory: No matching connectors found");
}
return null;
|
|