Package javax.naming.spi

Examples of javax.naming.spi.InitialContextFactory


        if (BROKER.startsWith("vm://"))
        {
            ApplicationRegistry.getInstance(1);
            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


        System.err.println("_logger.isDebug:" + _logger.isDebugEnabled() + ":" + _logger.isEnabledFor(Level.DEBUG));
        System.err.println("_logger.isTrace:" + _logger.isTraceEnabled() + ":" + _logger.isEnabledFor(Level.TRACE));

        System.err.println(Logger.getRootLogger().getLoggerRepository());

        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

public class SimpleNamingContextTests {

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

    DataSource ds = new StubDataSource();
    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<String, String> env2 = new Hashtable<String, String>();
    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

        }
      }
    }

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

        }
      }
    }

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

        super.setUp();

        environment.put("useEmbeddedBroker", "true");
        environment.put("brokerURL", "vm://localhost");

        InitialContextFactory factory = new ActiveMQInitialContextFactory();
        context = factory.getInitialContext(environment);
        assertTrue("No context created", context != null);
    }
View Full Code Here

   // InitialContextFactoryBuilder implementation --------------------------------------------------

   public InitialContextFactory createInitialContextFactory(final Hashtable environment) throws NamingException
   {

      InitialContextFactory icf = null;

      if (environment != null)
      {
         String icfName = (String)environment.get("java.naming.factory.initial");
View Full Code Here

   public InitialContextFactory createInitialContextFactory(Hashtable environment)
         throws NamingException
   {

      InitialContextFactory icf = null;

      if (environment != null)
      {
         String icfName = (String)environment.get("java.naming.factory.initial");
View Full Code Here

        super.tearDown();
    }

    public void testPassiveTTL() throws JMSException, NamingException
    {
        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 context = factory.getInitialContext(env);

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

        //Create Client 1
        Connection clientConnection = ((ConnectionFactory) context.lookup("connection")).createConnection();
View Full Code Here

    {
        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 + "'");

        // Ensure that the queue is unique for each test run.
        // There appears to be other old sesssion/consumers when looping the tests this means that sometimes a message
        // will disappear. When it has actually gone to the old client.
        env.put("queue.queue", QUEUE + "-" + System.currentTimeMillis());

        _context = factory.getInitialContext(env);

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

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

TOP

Related Classes of javax.naming.spi.InitialContextFactory

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.