JMSConnector connector = null;
HashMap connectorProperties = null;
HashMap connectionFactoryProperties = null;
JMSVendorAdapter vendorAdapter = null;
JMSURLHelper jmsurl = null;
// a security context is required to create/use JMSConnectors
String username = message.getUsername();
String password = message.getPassword();
// the presence of an endpoint address indicates whether the client application
// is instantiating the JMSTransport directly (deprecated) or indirectly via JMS URL
String endpointAddr = message.getTargetEndpointAddress();
if (endpointAddr != null)
{
try
{
// performs minimal validation ('jms:/destination?...')
jmsurl = new JMSURLHelper(new java.net.URL(endpointAddr));
// lookup the appropriate vendor adapter
String vendorId = jmsurl.getVendor();
if (vendorId == null)
vendorId = JMSConstants.JNDI_VENDOR_ID;
if (log.isDebugEnabled())
log.debug("JMSTransport.setupMessageContextImpl(): endpt=" + endpointAddr +
", vendor=" + vendorId);
vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
if (vendorAdapter == null)
{
throw new AxisFault("cannotLoadAdapterClass:" + vendorId);
}
// populate the connector and connection factory properties tables
connectorProperties = vendorAdapter.getJMSConnectorProperties(jmsurl);
connectionFactoryProperties = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
}
catch (java.net.MalformedURLException e)
{
log.error(Messages.getMessage("malformedURLException00"), e);
throw new AxisFault(Messages.getMessage("malformedURLException00"), e);
}
}
else
{
// the JMSTransport was instantiated directly, use the default adapter
vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
if (vendorAdapter == null)
{
throw new AxisFault("cannotLoadAdapterClass");
}
// use the properties passed in to the constructor
connectorProperties = defaultConnectorProps;
connectionFactoryProperties = defaultConnectionFactoryProps;
}
try
{
connector = JMSConnectorManager.getInstance().getConnector(connectorProperties, connectionFactoryProperties,
username, password, vendorAdapter);
}
catch (Exception e)
{
log.error(Messages.getMessage("cannotConnectError"), e);
if(e instanceof AxisFault)
throw (AxisFault)e;
throw new AxisFault("cannotConnect", e);
}
// store these in the context for later use
context.setProperty(JMSConstants.CONNECTOR, connector);
context.setProperty(JMSConstants.VENDOR_ADAPTER, vendorAdapter);
// vendors may populate the message context
vendorAdapter.setupMessageContext(context, message, jmsurl);
if (log.isDebugEnabled()) {
log.debug("Exit: JMSTransport::setupMessageContextImpl");
}
}