Examples of InitialContextFactory


Examples of javax.naming.spi.InitialContextFactory

                    return;
                }
            }

            try {
                InitialContextFactory defaultFactory = null;
                if (originalBuilder != null) {
                    defaultFactory = originalBuilder
                        .createInitialContextFactory(new Hashtable<String, String>());
                }
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);

    }
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 = (Queue) _context.lookup("queue");

        //Create Client 1
        _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);
        env.put("queue.badQueue", QUEUE);

        _context = factory.getInitialContext(env);

        getBrokerInitialState();
    }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

    protected void setUp() throws Exception {
        super.setUp();

        configureEnvironment();

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

Examples of javax.naming.spi.InitialContextFactory

                });
               
                if (references != null) {
                    Context initialContext = null;
                    for (ServiceReference reference : references) {
                        InitialContextFactory factory = (InitialContextFactory) Utils.getServicePrivileged(context, reference);
                        try {
                            initialContext = factory.getInitialContext(environment);
                            if (initialContext != null) {
                              provider = new SingleContextProvider(context, reference, initialContext);
                              break;
                          }
                        } finally {
                            if (provider == null) context.ungetService(reference);
                        }
                    }
                }
            }
        } else {
            ServiceReference ref = ServiceTrackerCustomizers.ICF_CACHE.find(contextFactoryClass);
           
            if (ref != null) {
              Context initialContext = null;
              InitialContextFactory factory = (InitialContextFactory) Utils.getServicePrivileged(context, ref);
              if (factory != null) {
                try {
                    initialContext = factory.getInitialContext(environment);
                    provider = new SingleContextProvider(context, ref, initialContext);
                } finally {
                    if (provider == null) context.ungetService(ref);
                }
              }
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

                return Activator.getInitialContextFactoryBuilderServices();
            }           
        });
           
        if (refs != null) {
            InitialContextFactory factory = null;
            for (ServiceReference ref : refs) {                   
                InitialContextFactoryBuilder builder = (InitialContextFactoryBuilder) Utils.getServicePrivileged(context, ref);
                try {
                  factory = builder.createInitialContextFactory(environment);
                } catch (NamingException ne) {
                  // TODO: log
                  // ignore this, if the builder fails we want to move onto the next one
                }
               
                if (factory != null) {
                  try {
                    provider = new SingleContextProvider(context, ref, factory.getInitialContext(environment));
                  } finally {
                    if (provider == null) context.ungetService(ref); // we didn't get something back, so this was no good.
                  }
                  break;
                } else {
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

  }

  @Test
  public void testLookupWithICF() throws NamingException
  {
    InitialContextFactory icf = Skeleton.newMock(InitialContextFactory.class);
    bc.registerService(new String[] {InitialContextFactory.class.getName(), icf.getClass().getName()}, icf, new Properties());
    Skeleton.getSkeleton(icf).setReturnValue(new MethodCall(Context.class, "lookup", "/"), Skeleton.newMock(Context.class));
   
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, icf.getClass().getName());
    props.put(JNDIConstants.BUNDLE_CONTEXT, bc);
    InitialContext ctx = new InitialContext(props);
   
    Context namingCtx = (Context) ctx.lookup("/");
    assertTrue("Context returned isn't the raw naming context: " + namingCtx, Skeleton.isSkeleton(namingCtx));
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

  {
    InitialContextFactoryBuilder icf = Skeleton.newMock(InitialContextFactoryBuilder.class);
    bc.registerService(new String[] {InitialContextFactoryBuilder.class.getName(), icf.getClass().getName()}, icf, new Properties());
   
    LdapContext backCtx = Skeleton.newMock(LdapContext.class);
    InitialContextFactory fac = Skeleton.newMock(InitialContextFactory.class);
    Skeleton.getSkeleton(fac).setReturnValue(
        new MethodCall(InitialContextFactory.class, "getInitialContext", Hashtable.class),
        backCtx);
    Skeleton.getSkeleton(icf).setReturnValue(
        new MethodCall(InitialContextFactoryBuilder.class, "createInitialContextFactory", Hashtable.class),
View Full Code Here

Examples of javax.naming.spi.InitialContextFactory

    {

        Context context = mock(Context.class);
        when(context.lookup(NAME)).thenReturn(RESOLVED_NAME);

        InitialContextFactory jndiContextFactory = mock(InitialContextFactory.class);
        when(jndiContextFactory.getInitialContext(any(Hashtable.class))).thenReturn(context);

        CachedJndiNameResolver jndiNameResolver = new CachedJndiNameResolver();
        jndiNameResolver.setContextFactory(jndiContextFactory);
        jndiNameResolver.setJndiInitialFactory("initialFactory");
        jndiNameResolver.initialise();
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.