Examples of ImmutableContext


Examples of org.apache.xbean.naming.context.ImmutableContext

    public static class MockInitialContextFactory implements InitialContextFactory {
        private static ImmutableContext immutableContext;

        @SuppressWarnings("unchecked")
        public static void install(final Map bindings) throws NamingException {
            immutableContext = new ImmutableContext(bindings);
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, MockInitialContextFactory.class.getName());
            new InitialContext();
        }
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

                ((ClassLoaderAwareReference) value).setClassLoader(classLoader);
            }
        }

        if (!containsEnv) {
            Context env = new ImmutableContext("java:comp/env", Collections.EMPTY_MAP, false);
            map.put("env", env);
        }

        if (userTransaction != null) {
            map.put("UserTransaction", userTransaction);
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        return createEnterpriseNamingContext(map);
    }

    public static Context createEnterpriseNamingContext(Map context) throws NamingException {
        return new ImmutableContext(context, false);
    }
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        envBinding.put("link", link);

        RootContext.setComponentContext(readOnlyContext);

        Context javaCompContext = new JavaCompContextGBean();
        Context globalContext = new ImmutableContext(Collections.<String, Object>singletonMap(javaCompContext.getNameInNamespace(), javaCompContext));
        GlobalContextManager.setGlobalContext(globalContext);

        initialContext = new InitialContext();
        compContext = (Context) initialContext.lookup("java:comp");
        envContext = (Context) initialContext.lookup("java:comp/env");
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

    public void testLookupEnv() throws Exception {
        Map javaCompBindings = new HashMap();
        javaCompBindings.put("foo", "bar");

        // a regular context doesn't contain env
        RootContext.setComponentContext(new ImmutableContext(javaCompBindings));
        try {
            new InitialContext(contextEnv).lookup("java:comp/env");
            fail("Expected NameNotFoundException");
        } catch (NameNotFoundException expected) {
            // expected
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        Map globalBindings = new HashMap(javaCompOnlyBindings);
        globalBindings.put("test/env/foo", new Integer(42));
        globalBindings.put("test/baz", "caz");

        Map javaCompBindings = getNestedBindings(globalBindings, "java:comp/");
        ImmutableContext javaCompContext = new ImmutableContext(javaCompBindings);
        RootContext.setComponentContext(javaCompContext);

        GBeanData javaComp = configurationData.addGBean("JavaComp", JavaCompContextGBean.GBEAN_INFO);
        AbstractName javaCompName = javaComp.getAbstractName();
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

            }
        }


        if (!containsEnv) {
            Context env = new ImmutableContext("java:" + prefix + "env", Collections.<String, Object>emptyMap(), false);
            map.put(prefix + "env", env);
        }

        if (userTransaction != null) {
            map.put(prefix + "UserTransaction", userTransaction);
        }

        return new ImmutableContext(map, false);
    }
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        Map globalBindings = new HashMap(javaCompOnlyBindings);
        globalBindings.put("test/env/foo", new Integer(42));
        globalBindings.put("test/baz", "caz");

        Map javaCompBindings = getNestedBindings(globalBindings, "java:");
        ImmutableContext javaCompContext = new ImmutableContext(javaCompBindings);
        RootContext.setComponentContext(javaCompContext);

        GBeanData javaComp = configurationData.addGBean("JavaComp", JavaCompContextGBean.class);
        AbstractName javaCompName = javaComp.getAbstractName();
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        envBinding.put("link", link);

        RootContext.setComponentContext(readOnlyContext);

        Context javaCompContext = new JavaCompContextGBean();
        Context globalContext = new ImmutableContext(Collections.<String, Object>singletonMap(javaCompContext.getNameInNamespace(), javaCompContext));
        GlobalContextManager.setGlobalContext(globalContext);

        initialContext = new InitialContext(contextEnv);
        compContext = (Context) initialContext.lookup("java:comp");
        envContext = (Context) initialContext.lookup("java:comp/env");
View Full Code Here

Examples of org.apache.xbean.naming.context.ImmutableContext

        Map javaCompBindings = new HashMap();
        javaCompBindings.put("foo", "bar");

        // a regular context doesn't contain env
        Thread.currentThread().setContextClassLoader(javaURLContextFactory.class.getClassLoader());
        RootContext.setComponentContext(new ImmutableContext(javaCompBindings));
        try {
            new InitialContext(contextEnv).lookup("java:comp/env");
            fail("Expected NameNotFoundException");
        } catch (NotContextException expected) {
            // expected
        } catch (NameNotFoundException expected) {
            // expected
        }

        // ENC adds env if not present
        javaCompBindings.put("comp/env/foo", "bar");
        RootContext.setComponentContext(new ImmutableContext(javaCompBindings));
        new InitialContext(contextEnv).lookup("java:comp/env");
    }
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.