JMSTransportpublic class JMSTransport extends org.apache.axis.client.Transport JMSTransport is the JMS-specific implemenation of org.apache.axis.client.Transport.
It implements the setupMessageContextImpl() function to set JMS-specific message
context fields and transport chains.
There are two
Connector and connection factory
properties are passed in during instantiation and are in turn passed through
when creating a connector. |
Fields Summary |
---|
protected static Log | log | private static HashMap | vendorConnectorPools | private HashMap | defaultConnectorProps | private HashMap | defaultConnectionFactoryProps |
Constructors Summary |
---|
public JMSTransport()
// add a shutdown hook to close JMS connections
Runtime.getRuntime().addShutdownHook(
new Thread()
{
public void run()
{
JMSTransport.closeAllConnectors();
}
}
);
transportName = "JMSTransport";
| public JMSTransport(HashMap connectorProps, HashMap connectionFactoryProps)
this();
defaultConnectorProps = connectorProps;
defaultConnectionFactoryProps = connectionFactoryProps;
|
Methods Summary |
---|
public static void | closeAllConnectors()Closes all JMS connectors
if (log.isDebugEnabled()) {
log.debug("Enter: JMSTransport::closeAllConnectors");
}
JMSConnectorManager.getInstance().closeAllConnectors();
if (log.isDebugEnabled()) {
log.debug("Exit: JMSTransport::closeAllConnectors");
}
| public static void | closeMatchingJMSConnectors(java.lang.String endpointAddr, java.lang.String username, java.lang.String password)Closes JMS connectors that match the specified endpoint address
if (log.isDebugEnabled()) {
log.debug("Enter: JMSTransport::closeMatchingJMSConnectors");
}
try
{
JMSURLHelper jmsurl = new JMSURLHelper(new java.net.URL(endpointAddr));
String vendorId = jmsurl.getVendor();
JMSVendorAdapter vendorAdapter = null;
if (vendorId == null)
vendorId = JMSConstants.JNDI_VENDOR_ID;
vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
// the vendor adapter may not exist
if (vendorAdapter == null)
return;
// determine the set of properties to be used for matching the connection
HashMap connectorProps = vendorAdapter.getJMSConnectorProperties(jmsurl);
HashMap cfProps = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
JMSConnectorManager.getInstance().closeMatchingJMSConnectors(connectorProps, cfProps,
username, password,
vendorAdapter);
}
catch (java.net.MalformedURLException e)
{
log.warn(Messages.getMessage("malformedURLException00"), e);
}
if (log.isDebugEnabled()) {
log.debug("Exit: JMSTransport::closeMatchingJMSConnectors");
}
| public void | setupMessageContextImpl(org.apache.axis.MessageContext context, org.apache.axis.client.Call message, org.apache.axis.AxisEngine engine)Set up any transport-specific derived properties in the message context.
if (log.isDebugEnabled()) {
log.debug("Enter: JMSTransport::setupMessageContextImpl");
}
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");
}
| public void | shutdown()Shuts down the connectors managed by this JMSTransport.
if (log.isDebugEnabled()) {
log.debug("Enter: JMSTransport::shutdown");
}
closeAllConnectors();
if (log.isDebugEnabled()) {
log.debug("Exit: JMSTransport::shutdown");
}
|
|