FileDocCategorySizeDatePackage
JMSVendorAdapter.javaAPI DocApache Axis 1.412033Sat Apr 22 18:57:26 BST 2006org.apache.axis.components.jms

JMSVendorAdapter

public abstract class JMSVendorAdapter extends Object
SPI Interface that all JMSVendorAdaptors must implement. Allows for ConnectionFactory creation and Destination lookup
author
Jaime Meritt (jmeritt@sonicsoftware.com)
author
Ray Chun (rchun@sonicsoftware.com)

Fields Summary
public static final int
SEND_ACTION
public static final int
CONNECT_ACTION
public static final int
SUBSCRIBE_ACTION
public static final int
RECEIVE_ACTION
public static final int
ON_EXCEPTION_ACTION
Constructors Summary
Methods Summary
public abstract voidaddVendorConnectionFactoryProperties(org.apache.axis.transport.jms.JMSURLHelper jmsurl, java.util.HashMap cfProps)

public java.util.HashMapgetJMSConnectionFactoryProperties(org.apache.axis.transport.jms.JMSURLHelper jmsurl)
Creates a connection factory property table using values supplied in the endpoint address

param
jmsurl the endpoint address
return
the set of properties to be used for instantiating the connection factory

        HashMap cfProps = new HashMap();

        // hold on to the original address (this will be useful when the JNDI vendor adapter
        // matches connectors)
        cfProps.put(JMSConstants.JMS_URL, jmsurl);

        // JMSConstants.DOMAIN
        String domain = jmsurl.getPropertyValue(JMSConstants._DOMAIN);
        if (domain != null)
            cfProps.put(JMSConstants.DOMAIN, domain);

        // allow vendors to customize the cf properties table
        addVendorConnectionFactoryProperties(jmsurl, cfProps);

        return cfProps;
    
public java.util.HashMapgetJMSConnectorProperties(org.apache.axis.transport.jms.JMSURLHelper jmsurl)
Creates a JMS connector property table using values supplied in the endpoint address. Properties are translated from the short form in the endpoint address to the long form (prefixed by "transport.jms.")

param
jmsurl the endpoint address
return
the set of properties to be used for instantiating the JMS connector

        HashMap connectorProps = new HashMap();

        // the JMS URL may be useful when matching connectors
        connectorProps.put(JMSConstants.JMS_URL, jmsurl);

        // JMSConstants.CLIENT_ID,
        String clientID = jmsurl.getPropertyValue(JMSConstants._CLIENT_ID);
        if (clientID != null)
            connectorProps.put(JMSConstants.CLIENT_ID, clientID);

        // JMSConstants.CONNECT_RETRY_INTERVAL,
        String connectRetryInterval = jmsurl.getPropertyValue(JMSConstants._CONNECT_RETRY_INTERVAL);
        if (connectRetryInterval != null)
            connectorProps.put(JMSConstants.CONNECT_RETRY_INTERVAL, connectRetryInterval);

        // JMSConstants.INTERACT_RETRY_INTERVAL,
        String interactRetryInterval = jmsurl.getPropertyValue(JMSConstants._INTERACT_RETRY_INTERVAL);
        if (interactRetryInterval != null)
            connectorProps.put(JMSConstants.INTERACT_RETRY_INTERVAL, interactRetryInterval);

        // JMSConstants.DOMAIN
        String domain = jmsurl.getPropertyValue(JMSConstants._DOMAIN);
        if (domain != null)
            connectorProps.put(JMSConstants.DOMAIN, domain);

        // JMSConstants.NUM_RETRIES
        String numRetries = jmsurl.getPropertyValue(JMSConstants._NUM_RETRIES);
        if (numRetries != null)
            connectorProps.put(JMSConstants.NUM_RETRIES, numRetries);

        // JMSConstants.NUM_SESSIONS
        String numSessions = jmsurl.getPropertyValue(JMSConstants._NUM_SESSIONS);
        if (numSessions != null)
            connectorProps.put(JMSConstants.NUM_SESSIONS, numSessions);

        // JMSConstants.TIMEOUT_TIME,
        String timeoutTime = jmsurl.getPropertyValue(JMSConstants._TIMEOUT_TIME);
        if (timeoutTime != null)
            connectorProps.put(JMSConstants.TIMEOUT_TIME, timeoutTime);

        return connectorProps;
    
public javax.jms.QueuegetQueue(javax.jms.QueueSession session, java.lang.String name)

        return session.createQueue(name);
    
public abstract javax.jms.QueueConnectionFactorygetQueueConnectionFactory(java.util.HashMap cfProps)

public javax.jms.TopicgetTopic(javax.jms.TopicSession session, java.lang.String name)

        return session.createTopic(name);
    
public abstract javax.jms.TopicConnectionFactorygetTopicConnectionFactory(java.util.HashMap cfProps)

public java.lang.StringgetVendorId()


        
         
        
         

    // let adapters add vendor-specific properties or override standard ones
          

    // let adapters match connectors using vendor-specific connection factory properties
            

    // returns <adapter> in 'org.apache.axis.components.jms.<adapter>VendorAdapter'
      
    
        String name = this.getClass().getName();

        // cut off the trailing 'VendorAdapter'
        if (name.endsWith(JMSConstants.ADAPTER_POSTFIX))
        {
            int index = name.lastIndexOf(JMSConstants.ADAPTER_POSTFIX);
            name = name.substring(0,index);
        }

        // cut off the leading 'org.apache.axis.components.jms.'
        int index = name.lastIndexOf(".");
        if (index > 0)
            name = name.substring(index+1);

        return name;
    
public abstract booleanisMatchingConnectionFactory(javax.jms.ConnectionFactory cf, org.apache.axis.transport.jms.JMSURLHelper jmsurl, java.util.HashMap cfProps)

public booleanisRecoverable(java.lang.Throwable thrown, int action)

        if(thrown instanceof RuntimeException ||
           thrown instanceof Error ||
           thrown instanceof JMSSecurityException ||
           thrown instanceof InvalidDestinationException)
            return false;
        if(action == ON_EXCEPTION_ACTION)
            return false;
        return true;
    
public voidsetProperties(javax.jms.Message message, java.util.HashMap props)

        Iterator iter = props.keySet().iterator();
        while (iter.hasNext())
        {
            String key = (String)iter.next();
            String value = (String)props.get(key);

            message.setStringProperty(key, value);
        }
    
public voidsetupApplicationProperties(org.apache.axis.MessageContext context, org.apache.axis.client.Call call, org.apache.axis.transport.jms.JMSURLHelper jmsurl)

        //start with application properties from the URL
        Map appProps = new HashMap();
        if (jmsurl != null && jmsurl.getApplicationProperties() != null) {
            for(Iterator itr=jmsurl.getApplicationProperties().iterator();
                itr.hasNext();) {
                String name = (String)itr.next();
                appProps.put(name,jmsurl.getPropertyValue(name));
            }
        }
        
        //next add application properties from the message context
        Map ctxProps = 
           (Map)context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS);
        if (ctxProps != null) {
            appProps.putAll(ctxProps);
        }
        
        //finally add the properties from the call
        Map callProps = 
            (Map)call.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS);
        if (callProps != null) {
            appProps.putAll(callProps);
        }
        
        //now tore these properties within the context
        context.setProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS,appProps);
    
public voidsetupMessageContext(org.apache.axis.MessageContext context, org.apache.axis.client.Call call, org.apache.axis.transport.jms.JMSURLHelper jmsurl)
Set JMS properties in the message context. TODO: just copy all properties that are not used for the JMS connector or connection factory

        Object tmp = null;

        String jmsurlDestination = null;
        if (jmsurl != null)
            jmsurlDestination = jmsurl.getDestination();
        if (jmsurlDestination != null)
            context.setProperty(JMSConstants.DESTINATION, jmsurlDestination);
        else
        {
            tmp = call.getProperty(JMSConstants.DESTINATION);
            if (tmp != null && tmp instanceof String)
                context.setProperty(JMSConstants.DESTINATION, tmp);
            else
                context.removeProperty(JMSConstants.DESTINATION);
        }

        String delivMode = null;
        if (jmsurl != null)
            delivMode = jmsurl.getPropertyValue(JMSConstants._DELIVERY_MODE);
        if (delivMode != null)
        {
            int mode = JMSConstants.DEFAULT_DELIVERY_MODE;
            if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_PERSISTENT))
                mode = javax.jms.DeliveryMode.PERSISTENT;
            else if (delivMode.equalsIgnoreCase(JMSConstants.DELIVERY_MODE_NONPERSISTENT))
                mode = javax.jms.DeliveryMode.NON_PERSISTENT;
            context.setProperty(JMSConstants.DELIVERY_MODE, new Integer(mode));
        }
        else
        {
            tmp = call.getProperty(JMSConstants.DELIVERY_MODE);
            if(tmp != null && tmp instanceof Integer)
                context.setProperty(JMSConstants.DELIVERY_MODE, tmp);
            else
                context.removeProperty(JMSConstants.DELIVERY_MODE);
        }

        String prio = null;
        if (jmsurl != null)
            prio = jmsurl.getPropertyValue(JMSConstants._PRIORITY);
        if (prio != null)
            context.setProperty(JMSConstants.PRIORITY, Integer.valueOf(prio));
        else
        {
            tmp = call.getProperty(JMSConstants.PRIORITY);
            if(tmp != null && tmp instanceof Integer)
                context.setProperty(JMSConstants.PRIORITY, tmp);
            else
                context.removeProperty(JMSConstants.PRIORITY);
        }

        String ttl = null;
        if (jmsurl != null)
            ttl = jmsurl.getPropertyValue(JMSConstants._TIME_TO_LIVE);
        if (ttl != null)
            context.setProperty(JMSConstants.TIME_TO_LIVE, Long.valueOf(ttl));
        else
        {
            tmp = call.getProperty(JMSConstants.TIME_TO_LIVE);
            if(tmp != null && tmp instanceof Long)
                context.setProperty(JMSConstants.TIME_TO_LIVE, tmp);
            else
                context.removeProperty(JMSConstants.TIME_TO_LIVE);
        }

        String wait = null;
        if (jmsurl != null)
            wait = jmsurl.getPropertyValue(JMSConstants._WAIT_FOR_RESPONSE);
        if (wait != null)
            context.setProperty(JMSConstants.WAIT_FOR_RESPONSE, Boolean.valueOf(wait));
        else
        {
            tmp = call.getProperty(JMSConstants.WAIT_FOR_RESPONSE);
            if(tmp != null && tmp instanceof Boolean)
                context.setProperty(JMSConstants.WAIT_FOR_RESPONSE, tmp);
            else
                context.removeProperty(JMSConstants.WAIT_FOR_RESPONSE);
        }
        setupApplicationProperties(context, call, jmsurl);