Package javax.naming

Examples of javax.naming.Context


    public static Context build(final EasyBeansEjbJarClassMetadata bean,
                                final Factory<?, ?> easyBeansFactory,
                                final IEventDispatcher dispatcher)
            throws JavaContextHelperException {

        Context javaCtx = null;
        try {
            javaCtx = NamingManager.getInstance().createEnvironmentContext(bean.getClassName());
        } catch (NamingException e) {
            throw new IllegalStateException("Cannot build a new environment", e);
        }
View Full Code Here


                            }
                            // Sets the bean info
                            this.ejbJarInfo.addBeanInfo(beanInfo);

                            // Build java: Context
                            Context javaContext;
                            try {
                                javaContext = JavaContextHelper.build(classAnnotationMetadata, factory, eventDispatcher);
                            } catch (JavaContextHelperException e) {
                                throw new EZBContainerException("Cannot build environment", e);
                            }
View Full Code Here

     * @return result of the next invocation (to chain interceptors).
     * @throws Exception needs for signature of interceptor.
     */
    @Override
    public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception {
        Context oldContext = (Context) this.setComponentContextMethod.invoke(this.jonasNamingManager, invocationContext
                .getFactory().getJavaContext());
        try {
            return invocationContext.proceed();
        } finally {
            this.resetComponentContextMethod.invoke(this.jonasNamingManager, oldContext);
View Full Code Here

                globalContext = new ContextImpl("global");
            }
            this.bindings.put("global", globalContext);

            // Add comp
            Context compContext = createSubcontext("comp");

            // Add comp/env
            compContext.createSubcontext("env");

            // module is the same than comp
            this.bindings.put("module", compContext);

            // App context
View Full Code Here

        if (n.size() > 1) {
            // sub context in the env tree
            String suffix = n.getSuffix(1).toString();
            // should throw exception if sub context not found!
            Context subctx = lookupCtx(n.get(0));
            return subctx.lookup(suffix);
        }
        // leaf in the env tree
        Object ret = this.bindings.get(name);
        if (ret == null) {
            logger.debug(" {0} not found.", name);
View Full Code Here

            this.bindings.put(name, obj);
        } else {
            // sub context in the env tree
            String suffix = n.getSuffix(1).toString();
            // must create the subcontext first if it does not exist yet.
            Context subctx;
            try {
                subctx = lookupCtx(n.get(0));
            } catch (NameNotFoundException e) {
                subctx = createSubcontext(n.get(0));
            }
            subctx.bind(suffix, obj);
        }
    }
View Full Code Here

            this.bindings.put(name, obj);
        } else {
            // sub context in the env tree
            String suffix = n.getSuffix(1).toString();
            // must create the subcontext first if it does not exist yet.
            Context subctx;
            try {
                subctx = lookupCtx(n.get(0));
            } catch (NameNotFoundException e) {
                subctx = createSubcontext(n.get(0));
            }
            subctx.rebind(suffix, obj);
        }
    }
View Full Code Here

            this.bindings.remove(name);
        } else {
            // sub context in the env tree
            String suffix = n.getSuffix(1).toString();
            // should throw exception if sub context not found!
            Context subctx = lookupCtx(n.get(0));
            subctx.unbind(suffix);
        }
    }
View Full Code Here

        if (n.size() < 1) {
            logger.error("CompNamingContext createSubcontext with empty name ?");
            throw new InvalidNameException("CompNamingContext cannot create empty Subcontext");
        }

        Context ctx = null; // returned ctx
        if (n.size() == 1) {
            // leaf in the env tree: create ctx and bind it in parent.
            ctx = new ContextImpl(this.compId, this.environment);
            this.bindings.put(name, ctx);
        } else {
            // as for bind, we must create first all the subcontexts
            // if they don't exist yet.
            String suffix = n.getSuffix(1).toString();
            Context subctx;
            String newName = n.get(0);
            try {
                subctx = lookupCtx(newName);
            } catch (NameNotFoundException e) {
                subctx = createSubcontext(newName);
            }
            ctx = subctx.createSubcontext(suffix);
        }
        return ctx;
    }
View Full Code Here

     * @throws Exception if exception is found.
     */
    public static void main(final String[] args) throws Exception {

        // Lookup the Remote Bean interface through JNDI
        Context initialContext = getInitialContext();
        BusinessInterface facadeBean = (BusinessInterface) initialContext.lookup("JPA2Bean");

        // Init (if not done)
        System.out.println("Initializing the database with some employees...");
        facadeBean.init();

View Full Code Here

TOP

Related Classes of javax.naming.Context

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.