Package org.objectweb.joram.client.jms

Examples of org.objectweb.joram.client.jms.ConnectionFactory


    User.create("anonymous", "anonymous", 0);
    User.create("anonymous", "anonymous", 1);
    User.create("anonymous", "anonymous", 2);

    ConnectionFactory cf0 = TcpConnectionFactory.create("localhost", 16010);
    ConnectionFactory cf1 = TcpConnectionFactory.create("localhost", 16011);
    ConnectionFactory cf2 = TcpConnectionFactory.create("localhost", 16012);

    ictx.bind("cf0", cf0);
    ictx.bind("cf1", cf1);
    ictx.bind("cf2", cf2);
View Full Code Here


        if (rawName.equals(ELT_ADMINMODULE)) {
        } else if (rawName.equals(ELT_CONNECT)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "JoramSaxWrapper creates wrapper (TCP): " + host + ',' + port + ',' + name);
          ConnectionFactory cf = TcpConnectionFactory.create(host, port, reliableClass);
          cf.getParameters().connectingTimer = cnxTimer;
          cf.setIdentityClassName(identityClass);

          cnx = cf.createConnection(name, password);
          cnx.start();
          wrapper = new AdminWrapper(cnx);
        } else if (rawName.equals(ELT_HACONNECT)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "JoramSaxWrapper creates wrapper (HA): " + url + ',' + name);
         
          ConnectionFactory cf = HATcpConnectionFactory.create(url);
          cf.getParameters().connectingTimer = cnxTimer;
          cf.setIdentityClassName(identityClass);

          cnx = cf.createConnection(name, password);
          cnx.start();
          wrapper = new AdminWrapper(cnx);
        } else if (rawName.equals(ELT_COLLOCATEDCONNECT)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "JoramSaxWrapper creates wrapper (Local): " + name);
         
          ConnectionFactory cf = LocalConnectionFactory.create();
          cf.setIdentityClassName(identityClass);

          cnx = cf.createConnection(name, password);
          cnx.start();
          wrapper = new AdminWrapper(cnx);
        } else if (rawName.equals(ELT_CONNECTIONFACTORY)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "cf \""+ name + "\"= " + obj);
          // set identity className
          if (isSet(identityClass))
            ((AbstractConnectionFactory) obj).setIdentityClassName(identityClass);
          // Bind the ConnectionFactory in JNDI.
          // Be Careful, currently only one binding is handled.
          if (isSet(jndiName))
            toBind.put(jndiName, obj);
          jndiName = null;
          // Register the CF in order to handle it later (cluster, etc.)
          if (isSet(name)){
            cfs.put(name, obj);
          }
          //Add interceptors if any
          if ((inInterceptorClassname!=null) && (!inInterceptorClassname.isEmpty())) {
            for (Iterator it=inInterceptorClassname.iterator(); it.hasNext(); ) {
              String iicn = (String) it.next();
              ((AbstractConnectionFactory) obj).getParameters().addInInterceptor(iicn);
            }
            inInterceptorClassname.clear();
          }
          if ((outInterceptorClassname != null) && (!outInterceptorClassname.isEmpty())) {
            for (Iterator it=outInterceptorClassname.iterator(); it.hasNext(); ) {
              String oicn = (String) it.next();
              ((AbstractConnectionFactory) obj).getParameters().addOutInterceptor(oicn);
            }
            outInterceptorClassname.clear();
          }
          className = null;
          obj = null;
          identityClass = null;
        } else if (rawName.equals(ELT_TCP)) {
          try {
            Class clazz = Class.forName(className);
            Class [] classParams = {new String().getClass(),
                                    Integer.TYPE,
                                    new String().getClass()};
            Method methode = clazz.getMethod("create", classParams);
            Object[] objParams = {host, new Integer(port), reliableClass};
            obj = methode.invoke(null, objParams);
          } catch (Throwable exc) {
            logger.log(BasicLevel.ERROR,
                       "JoramSaxWrapper: Cannot instantiate " + className, exc);
            throw new SAXException(exc.getMessage());
          }
        } else if (rawName.equals(ELT_LOCAL)) {
          try {
            Class clazz = Class.forName(className);
            Method methode = clazz.getMethod("create", new Class[0]);
            obj = methode.invoke(null, new Object[0]);
          } catch (Throwable exc) {
            logger.log(BasicLevel.ERROR,
                       "JoramSaxWrapper: Cannot instantiate " + className, exc);
            throw new SAXException(exc.getMessage());
          }
        } else if (rawName.equals(ELT_HATCP)) {
          try {
            Class clazz = Class.forName(className);
            Class [] classParams = {new String().getClass(),
                                    new String().getClass()};
            Method methode = clazz.getMethod("create",classParams);
            Object[] objParams = {url,reliableClass};
            obj = methode.invoke(null,objParams);
          } catch (Throwable exc) {
            logger.log(BasicLevel.ERROR,
                       "JoramSaxWrapper: Cannot instantiate " + className, exc);
            throw new SAXException(exc.getMessage());
          }
        } else if (rawName.equals(ELT_HALOCAL)) {
          try {
            Class clazz = Class.forName(className);
            Method methode = clazz.getMethod("create", new Class[0]);
            obj = methode.invoke(null, new Object[0]);
          } catch (Throwable exc) {
            logger.log(BasicLevel.ERROR,
                       "JoramSaxWrapper: Cannot instantiate " + className, exc);
            throw new SAXException(exc.getMessage());
          }
        } else if (rawName.equals(ELT_SOAP)) {
          try {
            Class clazz = Class.forName(className);
            Class [] classParams = {new String().getClass(),
                                    Integer.TYPE,
                                    Integer.TYPE};
            Method methode = clazz.getMethod("create", classParams);
            Object[] objParams = {host, new Integer(port), new Integer(timeout)};
            obj = methode.invoke(null, objParams);
          } catch (Throwable exc) {
            logger.log(BasicLevel.ERROR,
                       "JoramSaxWrapper: Cannot instantiate " + className, exc);
            throw new SAXException(exc.getMessage());
          }
        } else if (rawName.equals(ELT_JNDI)) {
        } else if (rawName.equals(ELT_SERVER)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "Server.configure(" + serverId + ")");
         
          if (threshold > 0)
            getWrapper().setDefaultThreshold(serverId, threshold);

          if (isSet(dmq)) {
            if (dmqs.containsKey(dmq)) {
              getWrapper().setDefaultDMQ(serverId, (DeadMQueue) dmqs.get(dmq));
            } else {
              logger.log(BasicLevel.ERROR,
                         "Cannot set default DMQ, unknown DMQ: " + dmq);
            }
          }
        } else if (rawName.equals(ELT_USER)) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "User.create(" + name + "," + login + "," + "-," + serverId + " ," + properties + ")");
         
          if (! isSet(login)) login = name;
          if (! isSet(identityClass)) identityClass = SimpleIdentity.class.getName();
          User user = getWrapper().createUser(login, password, serverId, identityClass, properties);
          users.put(name, user);

          if (threshold > 0)
            user.setThreshold(threshold);

          if (isSet(dmq)) {
            if (dmqs.containsKey(dmq)) {
              user.setDMQ((DeadMQueue) dmqs.get(dmq));
            } else {
              logger.log(BasicLevel.ERROR,
                         "User.create(), unknown DMQ: " + dmq);
            }
          }
          properties = null;
        } else if (rawName.equals(ELT_DESTINATION)) {
          Destination dest = null;
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "dest type =" + type);

          if (type.equals("queue")) {
            if (className == null)
              className = "org.objectweb.joram.mom.dest.Queue";
           
            if (logger.isLoggable(BasicLevel.DEBUG))
              logger.log(BasicLevel.DEBUG,
                         "Queue.create(" + serverId + "," + name + "," + className + "," + properties + ")");
           
            dest = getWrapper().createQueue(serverId, name, className, properties);
          } else if (type.equals("topic")) {
            if (className == null)
              className = "org.objectweb.joram.mom.dest.Topic";
           
            if (logger.isLoggable(BasicLevel.DEBUG))
              logger.log(BasicLevel.DEBUG,
                         "Topic.create(" + serverId + "," + name + "," + className + "," + properties + ")");
           
            dest = getWrapper().createTopic(serverId, name, className, properties);
          } else
            throw new Exception("type " + type + " bad value. (queue or topic)");

          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "destination = " + dest);

          properties = null;

          configureDestination(dest);

          // Bind the destination in JNDI.
          // Be Careful, currently only one binding is handled.
          if (isSet(jndiName))
            toBind.put(jndiName, dest);
          jndiName = null;
          // Register the destination in order to handle it later.
          String name = dest.getAdminName();
          if (! isSet(name))
            name = dest.getName();
          if (dest instanceof Queue) {
            queues.put(name, dest);
          } else {
            // It's a Topic
            topics.put(name, dest);
          }
          // Fix DMQ if any
          setDestinationDMQ(dest, dmq);
        } else if (rawName.equals(ELT_QUEUE)) {
          if (className == null)
            className = "org.objectweb.joram.mom.dest.Queue";
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "Queue.create(" + serverId + "," + name + "," + className + "," + properties + ")");
          Queue queue = (Queue) getWrapper().createQueue(serverId, name, className, properties);
          properties = null;

          configureDestination(queue);

          if (threshold > 0)
            queue.setThreshold(threshold);

          if (nbMaxMsg > 0)
            queue.setNbMaxMsg(nbMaxMsg);

          // Bind the queue in JNDI.
          // Be Careful, currently only one binding is handled.
          if (isSet(jndiName))
            toBind.put(jndiName, queue);
          jndiName = null;
          // Register the queue in order to handle it later (cluster, etc.)
          String name = queue.getAdminName();
          if (! isSet(name)) name = queue.getName();
          queues.put(name, queue);
          // Fix DMQ if any
          setDestinationDMQ(queue, dmq);
        } else if (rawName.equals(ELT_TOPIC)) {
          if (className == null)
            className = "org.objectweb.joram.mom.dest.Topic";
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "Topic.create(" + serverId + "," + name + "," + className + "," + properties + ")");
          Topic topic = (Topic) getWrapper().createTopic(serverId, name, className, properties);
          properties = null;

          configureDestination(topic);

          if (isSet(parent)) {
            // TODO (AF): may be we should search the parent topic: JNDI? Joram?
            if (topics.containsKey(parent)) {
              topic.setParent((Topic) topics.get(parent));
            } else {
              logger.log(BasicLevel.ERROR,
                   "Topic.create(): Unknown parent: " + parent);
            }
          }
          // Bind the topic in JNDI.
          // Be Careful, currently only one binding is handled.
          if (isSet(jndiName))
            toBind.put(jndiName, topic);
          jndiName = null;
          // Register the topic in order to handle it later (cluster, etc.)
          String name = topic.getAdminName();
          if (! isSet(name)) name = topic.getName();
          topics.put(name, topic);
          // Fix DMQ if any
          setDestinationDMQ(topic, dmq);
        } else if (rawName.equals(ELT_DMQUEUE)) {
          className = "org.objectweb.joram.mom.dest.Queue";
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG,
                       "DeadMQueue.create(" + serverId + "," + name + ")");

          DeadMQueue dmq = (DeadMQueue) getWrapper().createDeadMQueue(serverId, name);

          configureDestination(dmq);

          // Bind the destination in JNDI.
          // Be Careful, currently only one binding is handled.
          if (isSet(jndiName))
            toBind.put(jndiName, dmq);
          jndiName = null;
          // Register the DMQ in order to handle it later.
          if (isSet(name))
            dmqs.put(name, dmq);
        } else if (rawName.equals(ELT_PROPERTY)) {
        } else if (rawName.equals(ELT_READER)) {
          readers.add(user);
        } else if (rawName.equals(ELT_WRITER)) {
          writers.add(user);
        } else if (rawName.equals(ELT_FREEREADER)) {
        } else if (rawName.equals(ELT_FREEWRITER)) {
        } else if (rawName.equals(ELT_INITIALCONTEXT)) {
          try {
            jndiCtx = new javax.naming.InitialContext(properties);
          } catch (NamingException exc) {
            logger.log(BasicLevel.ERROR,"",exc);
          }
        } else if (rawName.equals(ELT_CLUSTER_ELEMENT)) {
        } else if (rawName.equals(ELT_CLUSTER_CF)) {
          Map.Entry entries[] = new Map.Entry [cluster.size()];
          cluster.entrySet().toArray(entries);
          ClusterConnectionFactory clusterCF = new ClusterConnectionFactory();

          for (int i=0; i<entries.length; i++) {
            ConnectionFactory cf = (ConnectionFactory) cfs.get(entries[i].getKey());
            clusterCF.addConnectionFactory((String) entries[i].getValue(), cf);
          }
          cluster.clear();

          // Bind the destination in JNDI.
View Full Code Here

                                String name,
                                String password,
                                int cnxTimer,
                                String reliableClass,
                                String identityClass) throws UnknownHostException, ConnectException, AdminException {
    ConnectionFactory cf =null;

    if (isHa) {
      String urlHa = "hajoram://" + host + ":" + port;
      cf = HATcpConnectionFactory.create(urlHa);

    } else {
      cf = TcpConnectionFactory.create(host, port, reliableClass);
    }
    cf.getParameters().connectingTimer = cnxTimer;

    doConnect(cf, name, password, identityClass);
  }
View Full Code Here

  /**
   * Chooses a connection factory from the cluster definition.
   */
  protected ConnectionFactory getConnectionFactory() {
    if ((cluster != null) && ! cluster.isEmpty()) {
      ConnectionFactory cf = null;
      String location = System.getProperty("location");
      if (location == null || location.equals("")) {
        int idx = new Random().nextInt(cluster.size());

        Object key[] = cluster.keySet().toArray();
View Full Code Here

   * @exception JMSSecurityException  If the default identification is
   *              incorrect.
   * @exception IllegalStateException  If the server is not listening.
   */
  public final Connection createConnection() throws JMSException {
    ConnectionFactory cf = getConnectionFactory();
    return cf.createConnection();
  }
View Full Code Here

   * @exception JMSSecurityException  If the user identification is incorrect.
   * @exception IllegalStateException  If the server is not listening.
   */
  public final Connection createConnection(String name,
                                           String password) throws JMSException {
    ConnectionFactory cf = getConnectionFactory();
    return cf.createConnection(name, password);
  }
View Full Code Here

    for (int i=0; i<entries.length; i++) {
      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".key");
      ref.add(new StringRefAddr(strbuf.toString(),
                                (String) entries[i].getKey()));
      ConnectionFactory cf = (ConnectionFactory) entries[i].getValue();

      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".class");
      ref.add(new StringRefAddr(strbuf.toString(), cf.getClass().getName()));

      strbuf.setLength(0);
      strbuf.append("CF#").append(i);
      cf.toReference(ref, strbuf.toString());
    }
  }
View Full Code Here

      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".class");
      String classname = (String) ref.get(strbuf.toString()).getContent();
      try {
        Class clazz = Class.forName(classname);
        ConnectionFactory cf = (ConnectionFactory) clazz.newInstance();
        strbuf.setLength(0);
        strbuf.append("CF#").append(i);
        cf.fromReference(ref, strbuf.toString());

        if (cluster == null) cluster = new Hashtable();
        cluster.put(key, cf);
      } catch (Exception exc) {
        if (logger.isLoggable(BasicLevel.ERROR))
View Full Code Here

    for (int i=0; i<entries.length; i++) {
      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".key");
      h.put(strbuf.toString(), entries[i].getKey());

      ConnectionFactory cf = (ConnectionFactory) entries[i].getValue();

      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".class");
      h.put(strbuf.toString(), cf.getClass().getName());

      strbuf.setLength(0);
      strbuf.append("CF#").append(i);
      cf.code(h, strbuf.toString());
    }

    return h;
  }
View Full Code Here

      strbuf.setLength(0);
      strbuf.append("CF#").append(i).append(".class");
      String classname = (String) h.get(strbuf.toString());
      try {
        Class clazz = Class.forName(classname);
        ConnectionFactory cf = (ConnectionFactory) clazz.newInstance();

        strbuf.setLength(0);
        strbuf.append("CF#").append(i);
        cf.decode(h, strbuf.toString());

        cluster.put(key, cf);
      } catch (Exception exc) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "", exc);
View Full Code Here

TOP

Related Classes of org.objectweb.joram.client.jms.ConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.