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

JNDIVendorAdapter

public class JNDIVendorAdapter extends JMSVendorAdapter
Uses JNDI to locate ConnectionFactory and Destinations
author
Jaime Meritt (jmeritt@sonicsoftware.com)
author
Ray Chun (rchun@sonicsoftware.com)

Fields Summary
public static final String
CONTEXT_FACTORY
public static final String
PROVIDER_URL
public static final String
_CONNECTION_FACTORY_JNDI_NAME
public static final String
CONNECTION_FACTORY_JNDI_NAME
private Context
context
Constructors Summary
Methods Summary
public voidaddVendorConnectionFactoryProperties(org.apache.axis.transport.jms.JMSURLHelper jmsurl, java.util.HashMap cfConfig)
Populates the connection factory config table with properties from the JMS URL query string

param
jmsurl The target endpoint address of the Axis call
param
cfConfig The set of properties necessary to create/configure the connection factory

        // add the connection factory jndi name
        String cfJNDIName = jmsurl.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
        if (cfJNDIName != null)
            cfConfig.put(CONNECTION_FACTORY_JNDI_NAME, cfJNDIName);

        // add the initial ctx factory
        String ctxFactory = jmsurl.getPropertyValue(CONTEXT_FACTORY);
        if (ctxFactory != null)
            cfConfig.put(CONTEXT_FACTORY, ctxFactory);

        // add the provider url
        String providerURL = jmsurl.getPropertyValue(PROVIDER_URL);
        if (providerURL != null)
            cfConfig.put(PROVIDER_URL, providerURL);
    
private javax.jms.ConnectionFactorygetConnectionFactory(java.util.HashMap cfProps)

        if(cfProps == null)
                throw new IllegalArgumentException("noCFProps");
        String jndiName = (String)cfProps.get(CONNECTION_FACTORY_JNDI_NAME);
        if(jndiName == null || jndiName.trim().length() == 0)
            throw new IllegalArgumentException("noCFName");

        Hashtable environment = new Hashtable(cfProps);

        // set the context factory if provided in the JMS URL
        String ctxFactory = (String)cfProps.get(CONTEXT_FACTORY);
        if (ctxFactory != null)
            environment.put(CONTEXT_FACTORY, ctxFactory);

        // set the provider url if provided in the JMS URL
        String providerURL = (String)cfProps.get(PROVIDER_URL);
        if (providerURL != null)
            environment.put(PROVIDER_URL, providerURL);

        context = new InitialContext(environment);

        return (ConnectionFactory)context.lookup(jndiName);
    
public javax.jms.QueuegetQueue(javax.jms.QueueSession session, java.lang.String name)

        return (Queue)context.lookup(name);
    
public javax.jms.QueueConnectionFactorygetQueueConnectionFactory(java.util.HashMap cfConfig)


       
         
    
        return (QueueConnectionFactory)getConnectionFactory(cfConfig);
    
public javax.jms.TopicgetTopic(javax.jms.TopicSession session, java.lang.String name)

        return (Topic)context.lookup(name);
    
public javax.jms.TopicConnectionFactorygetTopicConnectionFactory(java.util.HashMap cfConfig)

        return (TopicConnectionFactory)getConnectionFactory(cfConfig);
    
public booleanisMatchingConnectionFactory(javax.jms.ConnectionFactory cf, org.apache.axis.transport.jms.JMSURLHelper originalJMSURL, java.util.HashMap cfProps)
Check that the attributes of the candidate connection factory match the requested connection factory properties.

param
cf the candidate connection factory
param
originalJMSURL the URL which was used to create the connection factory
param
cfProps the set of properties that should be used to determine the match
return
true or false to indicate whether a match has been found

        JMSURLHelper jmsurl = (JMSURLHelper)cfProps.get(JMSConstants.JMS_URL);

        // just check the connection factory jndi name
        String cfJndiName = jmsurl.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);
        String originalCfJndiName = originalJMSURL.getPropertyValue(_CONNECTION_FACTORY_JNDI_NAME);

        if (cfJndiName.equalsIgnoreCase(originalCfJndiName))
            return true;

        return false;