Package javax.naming

Examples of javax.naming.InitialContext.bind()


            ctx = new InitialContext(new Hashtable(environment));
            boolean rebind = Boolean.valueOf((String)environment.get(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE)).booleanValue();
            if (rebind)
               ctx.rebind(jndiURL, rmiServer.toStub());
            else
               ctx.bind(jndiURL, rmiServer.toStub());
            if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Bound " + rmiServer + " to " + jndiURL);
            return url;
         }
         catch (NamingException x)
         {
View Full Code Here


    public void test() throws Exception {

        Properties properties = new Properties();
        properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
        InitialContext context = new InitialContext(properties);
        context.bind("inject", this);

    }

    @Local
    @Remote
View Full Code Here

        // Set up the mock JNDI initial context
        TestJNDIContext.initialize();
        Context initCtx = new InitialContext();
        try
        {
            initCtx.bind( "java:comp/env", new TestJNDIContext() );
        }
        catch( NameAlreadyBoundException e )
        {
            // ignore
        }
View Full Code Here

        // Set up the mock JNDI initial context
        TestJNDIContext.initialize();
        Context initCtx = new InitialContext();
        try
        {
            initCtx.bind( "java:comp/env", new TestJNDIContext() );
        }
        catch( NameAlreadyBoundException e )
        {
            // ignore
        }
View Full Code Here

                        "xcp://localhost:8001");
       
        Context ctx = new InitialContext(namingProps);

        //Try a string
        ctx.bind("string", "string");
        String s = (String)ctx.lookup("string");
        Assert.assertEquals("string - lookup", "string", s);
       
        //Try a long
        long l = 100000L;
View Full Code Here

        Assert.assertEquals("string - lookup", "string", s);
       
        //Try a long
        long l = 100000L;
        Long L = new Long(l);
        ctx.bind("long", L);
        L = (Long)ctx.lookup("long");
        Assert.assertEquals("long - lookup", l, L.longValue());
       
        //Try an integer
        int i = 10;
View Full Code Here

        Assert.assertEquals("long - lookup", l, L.longValue());
       
        //Try an integer
        int i = 10;
        Integer I = new Integer(i);
        ctx.bind("integer", I);
        I = (Integer)ctx.lookup("integer");
        Assert.assertEquals("integer - lookup", i, I.intValue());
       
        //Try a hashtable
        Hashtable ht = new Hashtable();
View Full Code Here

        //Try a hashtable
        Hashtable ht = new Hashtable();
        ht.put("string", "string");
        ht.put("long", L);
        ht.put("integer", I);
        ctx.bind("hashtable", ht);
        ht = (Hashtable)ctx.lookup("hashtable");
       
        //Try a real big hashmap
        HashMap map = new HashMap();
        for(int k = 0; k < 1000; k++) {
View Full Code Here

        //Try a real big hashmap
        HashMap map = new HashMap();
        for(int k = 0; k < 1000; k++) {
            map.put("key-" + k, new Integer(k));
        }
        ctx.bind("map", map);
        map = (HashMap)ctx.lookup("map");

        /* Test sub context */

        Context subCtx = ctx.createSubcontext("myctx");
View Full Code Here

        try {
            PrintWriter pw = response.getWriter();
            try {
                Context ctx = new InitialContext();
                ctx.createSubcontext("foo");
                ctx.bind("foo/bar", "value");
                String value = (String) ctx.lookup("foo/bar");
                if ("value".equals(value)) {
                    pw.println("Value bound and retrieved from jndi default context");
                } else{
                    pw.println("Value not bound or not retrieved from jndi default context");
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.