Search in sources :

Example 1 with QueueConnectionFactory

use of com.sun.messaging.QueueConnectionFactory in project openmq by eclipse-ee4j.

the class CFObjectFactory method getObjectInstance.

/**
 * Creates an instance of the object represented by a Reference object.
 *
 * @param obj The Reference object.
 *
 * @return an instance of the class named in the Reference object <code>obj</code>,
 *         null if <code>obj</code> is not an instance of a Reference object.
 *
 * @throws MissingVersionNumberException if either <code>obj</code> references an object that is not an instance of a
 * <code>com.sun.messaging.Queue</code> object or the version number is missing from the Reference object.
 * @throws UnsupportedVersionNumberException if an unsupported version number is present in the Reference.
 * @throws CorruptedConfigurationPropertiesException if <code>obj</code> does not have the minimum information
 * neccessary to recreate an instance of a a valid <code>com.sun.messaging.AdministeredObject</code>.
 */
@Override
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env) throws Exception {
    if (obj instanceof Reference) {
        Reference ref = (Reference) obj;
        String refClassName = ref.getClassName();
        ConnectionFactory cf;
        if (refClassName.equals(com.sun.messaging.QueueConnectionFactory.class.getName())) {
            cf = new QueueConnectionFactory();
        } else {
            if (refClassName.equals(com.sun.messaging.TopicConnectionFactory.class.getName())) {
                cf = new TopicConnectionFactory();
            } else {
                throw new MissingVersionNumberException();
            }
        }
        // version number MUST exist and it MUST be the same as AO_VERSION_STR_JMQ1
        RefAddr versionAddr = ref.get(REF_VERSION);
        if (versionAddr == null) {
            // version number does not exist
            throw new MissingVersionNumberException();
        } else {
            // version number does not match
            String version = null;
            if (!AO_VERSION_STR_JMQ1.equals(version = (String) versionAddr.getContent())) {
                throw new UnsupportedVersionNumberException(version);
            }
            cf.setStoredVersion(version);
        }
        // retreive the security port value from the Reference
        RefAddr securityPortAddr = ref.get(REF_SECURITYPORT);
        if (securityPortAddr != null) {
            securityPortAddr.getContent();
        } else {
            // securityPort is missing - corrupted?
            throw new CorruptedConfigurationPropertiesException();
        }
        /*
             * try { parm = (String) (((RefAddr)ref.get(REF_PARM)).getContent()); host = (String)
             * (((RefAddr)ref.get(REF_HOST)).getContent()); subnet = (String) (((RefAddr)ref.get(REF_SUBNET)).getContent());
             * ackTimeout = (String) (((RefAddr)ref.get(REF_ACKTIMEOUT)).getContent()); } catch (NullPointerException e) { // this
             * should NOT happen under normal operations // this will happen when the object was modified outside // of its intended
             * use throw new CorruptedConfigurationPropertiesException(); }
             */
        recreateConfigurationObject(cf, ref);
        setJMSXProperties(cf, ref);
        return cf;
    }
    return null;
}
Also used : RefAddr(javax.naming.RefAddr) TopicConnectionFactory(com.sun.messaging.TopicConnectionFactory) TopicConnectionFactory(com.sun.messaging.TopicConnectionFactory) ConnectionFactory(com.sun.messaging.ConnectionFactory) QueueConnectionFactory(com.sun.messaging.QueueConnectionFactory) Reference(javax.naming.Reference) QueueConnectionFactory(com.sun.messaging.QueueConnectionFactory)

Example 2 with QueueConnectionFactory

use of com.sun.messaging.QueueConnectionFactory in project openmq by eclipse-ee4j.

the class JMSAdminImpl method createFactory.

private void createFactory(Properties connectionProps) throws JMSException {
    qcf = new QueueConnectionFactory();
    qcf.setConnectionType(ClientConstants.CONNECTIONTYPE_ADMIN);
    for (Enumeration e = connectionProps.propertyNames(); e.hasMoreElements(); ) {
        String propName = (String) e.nextElement();
        String value = connectionProps.getProperty(propName);
        if (value != null) {
            qcf.setProperty(propName, value);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) QueueConnectionFactory(com.sun.messaging.QueueConnectionFactory)

Example 3 with QueueConnectionFactory

use of com.sun.messaging.QueueConnectionFactory in project openmq by eclipse-ee4j.

the class BrokerAdminConn method createFactory.

private void createFactory(Properties brokerAttrs) throws BrokerAdminException {
    BrokerAdminException bae;
    qcf = new QueueConnectionFactory();
    try {
        qcf.setConnectionType(ClientConstants.CONNECTIONTYPE_ADMIN);
        for (Enumeration e = brokerAttrs.propertyNames(); e.hasMoreElements(); ) {
            String propName = (String) e.nextElement();
            String value = brokerAttrs.getProperty(propName);
            if (value != null) {
                qcf.setProperty(propName, value);
            }
        }
    } catch (Exception e) {
        bae = new BrokerAdminException(BrokerAdminException.CONNECT_ERROR);
        bae.setLinkedException(e);
        bae.setBrokerHost(getBrokerHost());
        bae.setBrokerPort(getBrokerPort());
        throw bae;
    }
    if (debug) {
        CommonGlobals.stdOutPrintln("***** BrokerAdminConn instance: " + getKey());
        CommonGlobals.stdOutPrintln("BrokerAdminConn created with timeout set to: " + (this.timeout / 1000) + " seconds");
        CommonGlobals.stdOutPrintln("BrokerAdminConn created with num retries set to: " + this.numRetries);
    }
}
Also used : Enumeration(java.util.Enumeration) QueueConnectionFactory(com.sun.messaging.QueueConnectionFactory) EOFException(java.io.EOFException)

Aggregations

QueueConnectionFactory (com.sun.messaging.QueueConnectionFactory)3 Enumeration (java.util.Enumeration)2 ConnectionFactory (com.sun.messaging.ConnectionFactory)1 TopicConnectionFactory (com.sun.messaging.TopicConnectionFactory)1 EOFException (java.io.EOFException)1 RefAddr (javax.naming.RefAddr)1 Reference (javax.naming.Reference)1