FileDocCategorySizeDatePackage
IASJmsUtil.javaAPI DocGlassfish v2 API9021Fri May 04 22:35:04 BST 2007com.sun.enterprise.jms

IASJmsUtil

public class IASJmsUtil extends Object
JMS Utilities.

Fields Summary
private static final Logger
_logger
public static final String
MDB_CONTAINER_QUEUE_XACF
public static final String
MDB_CONTAINER_TOPIC_XACF
public static final String
MQ_DIR_NAME
private static final String
DEFAULT_SERVER
private static final String
DEFAULT_MQ_INSTANCE
public static final String
DEFAULT_USER
public static final String
DEFAULT_PASSWORD
public static final String
DEFAULT_MAX_ACTIVE_CONSUMERS
public static final String
MAX_ACTIVE_CONSUMERS_ATTRIBUTE
public static final String
MAX_ACTIVE_CONSUMERS_PROPERTY
private static final com.sun.enterprise.util.i18n.StringManager
_sm
private static final boolean
debug
Constructors Summary
private IASJmsUtil()

 /* disallow instantiation */ 
Methods Summary
public static voidcheckVersion(com.sun.messaging.jmq.jmsspi.JMSAdmin ja)

        float version = 0.0f;
        String vs = "?.?";

        try {
            vs = ja.getVersion();
            version = Float.parseFloat(vs);
        }
        catch (Exception e) {
            throw new RuntimeException("Error detected while parsing JMS " +
                "provider SPI version string (" + vs + ").");
        }

        if (version < 2.0 || version >= 3.0)
            throw new RuntimeException(
                "Incorrect JMS Provider SPI version detected (" +
                    vs + ")." +
                " Please make sure that you are using the correct" +
                " version of the JMS provider.");
    
public static java.lang.StringclientIDPropertyName()

return
the ClientID property name or null

 
        return getJMSAdmin().clientIDPropertyName();
    
public static java.lang.StringgetBrokerInstanceName(java.lang.String asDomain, java.lang.String asInstance, JmsService js)
Computes the instance name for the MQ broker.


        ElementProperty[] jmsProperties = js.getElementProperty();

        String instanceName = null;
        String suffix = null;

        if (jmsProperties != null) {
            for (int ii=0; ii < jmsProperties.length; ii++) {
                ElementProperty p = jmsProperties[ii];
                String name = p.getName();

                if (name.equals("instance-name"))
                    instanceName = p.getValue();
                if (name.equals("instance-name-suffix"))
                    suffix = p.getValue();
                if (name.equals("append-version") &&
                    Boolean.valueOf(p.getValue()).booleanValue()) {
                    suffix = Version.getMajorVersion() + "_" +
                        Version.getMinorVersion();
                }
            }
        }

        if (instanceName != null)
            return instanceName;

        if (asInstance.equals(DEFAULT_SERVER)) {
            instanceName = DEFAULT_MQ_INSTANCE;
        } else {
            instanceName = asDomain + "_" + asInstance;
        }  

        if (suffix != null)
            instanceName = instanceName + "_" + suffix;

        return instanceName;
    
public static java.lang.StringgetDefaultMaxActiveConsumers()
Getting default value for Maximum active Queue consumers.

        return DEFAULT_MAX_ACTIVE_CONSUMERS;
    
public static java.lang.StringgetDestinationName(Destination destination)

        String name = null;
        try {
            name = (destination instanceof javax.jms.Queue) ?
                ((javax.jms.Queue) destination).getQueueName() :
                ((javax.jms.Topic) destination).getTopicName();
        } catch(Exception e) {}
        return name;
    
protected static com.sun.messaging.jmq.jmsspi.JMSAdmingetJMSAdmin()

        JMSAdmin jmsAdmin = JmsProviderLifecycle.getJMSAdmin();
        if (jmsAdmin == null) {
            jmsAdmin = getJMSAdminFactory().getJMSAdmin();
        }
        return jmsAdmin;
    
public static com.sun.messaging.jmq.jmsspi.JMSAdminFactorygetJMSAdminFactory()
JMSAdminFactory is used to get a handle to the administration capabilities of a JMS provider. Use Class.forName() to bootstrap an instance in order to avoid compile-time dependencies on implementation class names.

        JMSAdminFactory jmsAdminFactory = null;

        Class jmsAdminFactoryClass = Class.forName("com.sun.messaging.jmq.admin.jmsspi.JMSAdminFactoryImpl");
        jmsAdminFactory = (JMSAdminFactory)jmsAdminFactoryClass.newInstance();

        checkVersion(jmsAdminFactory.getJMSAdmin());

        return jmsAdminFactory;
    
public static java.lang.StringgetMaxActiveConsumersAttribute()
Getting Name Maximum active consumers attribute;

        return MAX_ACTIVE_CONSUMERS_ATTRIBUTE;
    
public static java.lang.StringgetMaxActiveConsumersProperty()
Getting Name Maximum active consumers property;

        return MAX_ACTIVE_CONSUMERS_PROPERTY;
    
public static java.lang.StringgetXAConnectionFactoryName(java.lang.String connectionFactoryName)
Form the name of the internal XA Connection Factory for each javax.jms.ConnectionFactory



                      
        
                                                     
        return "JMSXA" + connectionFactoryName + "__jmsxa";
    
public static voidvalidateJMSSelector(java.lang.String selector)
Validate a JMS Selector for syntactic correctness.

throws
Exception if system error contacting JMS Service
throws
JMSException if syntax error


        getJMSAdmin().validateJMSSelector(selector);
    
public static java.lang.ObjectwrapJMSConnectionFactoryObject(java.lang.Object obj)
wrap a JMS standard XAQueue/TopicConnectionFactory or Queue/TopicConnectionFactory This method is used for foreign (non-built-in) JMS provider

return
a JMSXAConnectionFactory object
throws
JMSException if syntax error


        return getJMSAdmin().wrapJMSConnectionFactoryObject(obj);