Package javax.naming

Examples of javax.naming.Context.addToEnvironment()


    public void modifyEnvironment(){
        try {
            Context initCtx = new InitialContext();
            Context myEnv = (Context) initCtx.lookup("java:comp/env");

            myEnv.addToEnvironment("flt00", new Float(INJECTED_FLOAT));
            myEnv.removeFromEnvironment("flt00");

        } catch (NamingException e) {
            throw new IllegalStateException("The context could not be obtained.");
        }
View Full Code Here


    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
        Context ctx = getDefaultContext();

        if (ctx != null) {
            ctx.addToEnvironment(propName, propVal);
        }
       
        return env.put(propName, propVal);
    }
View Full Code Here

        if (toReturn != null) {
            String packages = Utils.getSystemProperty(Context.URL_PKG_PREFIXES, null);

            if (packages != null) {
                toReturn.addToEnvironment(Context.URL_PKG_PREFIXES, packages);
            }
        }

        return toReturn;
    }
View Full Code Here


            //check locking the context
            Context ectx = (Context)initCtx.lookup("java:comp");
            ectx.bind("crud", "xxx");
            ectx.addToEnvironment("org.mortbay.jndi.immutable", "TRUE");
            assertEquals ("xxx", (String)initCtx.lookup("java:comp/crud"));
            try
            {
                ectx.bind("crud2", "xxx2");
            }
View Full Code Here

    {
        Random random = new Random ();
        _key = new Integer(random.nextInt());
        Context context = new InitialContext();
        Context compCtx = (Context)context.lookup("java:comp");
        compCtx.addToEnvironment("org.mortbay.jndi.lock", _key);
    }
   
    protected void unlockCompEnv ()
    throws Exception
    {
View Full Code Here

    {
        if (_key!=null)
        {
            Context context = new InitialContext();
            Context compCtx = (Context)context.lookup("java:comp");
            compCtx.addToEnvironment("org.mortbay.jndi.unlock", _key);
        }
    }

    /**
     * @see org.mortbay.jetty.plus.webapp.AbstractConfiguration#parseAnnotations()
View Full Code Here

    public Object addToEnvironment(String propName, Object propVal) throws NamingException {
        Context ctx = getDefaultContext();

        if (ctx != null) {
            ctx.addToEnvironment(propName, propVal);
        }
       
        return env.put(propName, propVal);
    }
View Full Code Here

          }
        }

        public void add(String name, Object obj) {
          try {
            namingContext.addToEnvironment(name, obj);
          } catch (NamingException nce) {
            throw new RuntimeException("Can't delegate naming context operation", nce);
          }
        }
View Full Code Here

            PrintWriter out = resp.getWriter();

            try {
                Context ctx1 = new InitialContext();
                Context env1 = (Context) ctx1.lookup("java:comp/env");
                env1.addToEnvironment("TestName", EXPECTED);

                out.print(env1.getEnvironment().get("TestName"));

                try {
                    env1.close();
View Full Code Here

    Context context3 = (Context) context2.lookup("");
    context3.rename("java:comp/env/jdbc/myds", "jdbc/myds");
    context3.unbind("myobject");

    assertTrue("Correct environment", context3.getEnvironment() != context2.getEnvironment());
    context3.addToEnvironment("key2", "value2");
    assertTrue("key2 added", "value2".equals(context3.getEnvironment().get("key2")));
    context3.removeFromEnvironment("key1");
    assertTrue("key1 removed", context3.getEnvironment().get("key1") == null);

    assertTrue("Correct DataSource registered", context1.lookup("jdbc/myds") == ds);
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.