Examples of InitialContextFactory


Examples of javax.naming.spi.InitialContextFactory

        if (BROKER.startsWith("vm://"))
        {
            TransportConnection.createVMBroker(1);
        }
        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        env.put("connectionfactory.connection", "amqp://guest:guest@TTL_TEST_ID/" + VHOST + "?brokerlist='" + BROKER + "'");
        env.put("queue.queue", QUEUE);

        _context = factory.getInitialContext(env);

        _messages = new Message[MSG_COUNT];
        _queue = (Queue) _context.lookup("queue");
        init();
    }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        }
      }
    }

    // Default case...
    return new InitialContextFactory() {
      @SuppressWarnings("unchecked")
      public Context getInitialContext(Hashtable<?,?> environment) {
        return new SimpleNamingContext("", boundObjects, (Hashtable<String, Object>) environment);
      }
    };
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

   * Simple InitialContextFactoryBuilder implementation,
   * creating a new SimpleNamingContext instance.
   * @see SimpleNamingContext
   */
  public InitialContextFactory createInitialContextFactory(Hashtable environment) {
    return new InitialContextFactory() {
      public Context getInitialContext(Hashtable environment) {
        return new SimpleNamingContext("", boundObjects, environment);
      }
    };
  }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

*/
public class SimpleNamingContextTests extends TestCase {

  public void testNamingContextBuilder() throws NamingException {
    SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
    InitialContextFactory factory = builder.createInitialContextFactory(null);

    DataSource ds = new DriverManagerDataSource();
    builder.bind("java:comp/env/jdbc/myds", ds);
    Object obj = new Object();
    builder.bind("myobject", obj);

    Context context1 = factory.getInitialContext(null);
    assertTrue("Correct DataSource registered", context1.lookup("java:comp/env/jdbc/myds") == ds);
    assertTrue("Correct Object registered", context1.lookup("myobject") == obj);

    Hashtable env2 = new Hashtable();
    env2.put("key1", "value1");
    Context context2 = factory.getInitialContext(env2);
    assertTrue("Correct DataSource registered", context2.lookup("java:comp/env/jdbc/myds") == ds);
    assertTrue("Correct Object registered", context2.lookup("myobject") == obj);
    assertTrue("Correct environment", context2.getEnvironment() != env2);
    assertTrue("Correct key1", "value1".equals(context2.getEnvironment().get("key1")));

View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        }
      }
    }

    // Default case...
    return new InitialContextFactory() {
      public Context getInitialContext(Hashtable environment) {
        return new SimpleNamingContext("", boundObjects, environment);
      }
    };
  }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        super.tearDown();
    }

    public void testPriority() throws JMSException, NamingException, AMQException
    {
        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        env.put("connectionfactory.connection", "amqp://guest:guest@PRIORITY_TEST_ID" + VHOST + "?brokerlist='" + BROKER + "'");
        env.put("queue.queue", QUEUE);

        Context context = factory.getInitialContext(env);

        Connection producerConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();

        Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        catch (Exception e)
        {
            fail("Unable to create broker: " + e);
        }

        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        if (_clientID == null)
        {
            _clientID = this.getClass().getName();
        }

        if (_virtualhost == null)
        {
            _virtualhost = "/test";
        }

        if (_brokerlist == null)
        {
            _brokerlist = "vm://:1";
        }

        env.put("connectionfactory.connection", "amqp://guest:guest@" + _clientID + _virtualhost + "?brokerlist='"
            + _brokerlist + "'");

        for (Map.Entry<String, String> c : _connections.entrySet())
        {
            env.put("connectionfactory." + c.getKey(), c.getValue());
        }

        env.put("queue.queue", "queue");

        for (Map.Entry<String, String> q : _queues.entrySet())
        {
            env.put("queue." + q.getKey(), q.getValue());
        }

        env.put("topic.topic", "topic");

        for (Map.Entry<String, String> t : _topics.entrySet())
        {
            env.put("topic." + t.getKey(), t.getValue());
        }

        _context = factory.getInitialContext(env);
    }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        if (BROKER.contains("vm://"))
        {
            TransportConnection.createVMBroker(1);
        }

        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        env.put("connectionfactory.connection", "amqp://guest:guest@MLT_ID/" + VHOST + "?brokerlist='" + BROKER + "'");
        env.put("queue.queue", "MessageListenerTest");

        _context = factory.getInitialContext(env);

        Queue queue = (Queue) _context.lookup("queue");

        // Create Client
        _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

    {
        if (BROKER.startsWith("vm://"))
        {
            TransportConnection.createVMBroker(1);
        }
        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        env.put("connectionfactory.connection", "amqp://guest:guest@TTL_TEST_ID" + VHOST + "?brokerlist='" + BROKER + "'");
        env.put("queue.queue", QUEUE);

        _context = factory.getInitialContext(env);

        _queue = (Queue) _context.lookup("queue");

        //Create Client 1
        _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

        TransportConnection.createVMBroker(1);

        oldImmediatePrefetch = System.getProperty(AMQSession.IMMEDIATE_PREFETCH);
        System.setProperty(AMQSession.IMMEDIATE_PREFETCH, "true");

        InitialContextFactory factory = new PropertiesFileInitialContextFactory();

        Hashtable<String, String> env = new Hashtable<String, String>();

        env.put("connectionfactory.connection", "amqp://guest:guest@MLT_ID/test?brokerlist='vm://:1'");
        env.put("queue.queue", "direct://amq.direct//ResetMessageListenerTest");

        _context = factory.getInitialContext(env);

        Queue queue = (Queue) _context.lookup("queue");

        // Create Client 1
        _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.