Package javax.naming

Examples of javax.naming.Context


     * @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 = namingManager.setComponentContext(invocationContext.getFactory().getJavaContext());
        try {
            return invocationContext.proceed();
        } finally {
            namingManager.resetComponentContext(oldContext);
        }
View Full Code Here


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

        // Build Context
        Context initialContext = getInitialContext();

        // Get factory
        QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext
                .lookup(QUEUE_CONNECTION_FACTORY);

        // Lookup the Queue through its JNDI name
        Queue queue = (Queue) initialContext.lookup(SAMPLE_QUEUE);
        Queue queueContext = (QueueinitialContext.lookup(SAMPLE_QUEUE_CONTEXT);


        // Create connection
        QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();

View Full Code Here

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

        Context initialContext = getInitialContext();

        // Call EJB3 bean
        EJB3RemoteBusinessInterface ejb3Bean = (EJB3RemoteBusinessInterface) initialContext
                .lookup("org.ow2.easybeans.examples.migrationejb21.EJB2And3Bean"
                        + "_" + EJB3RemoteBusinessInterface.class.getName() + "@Remote");
        System.out.println("Calling hello() method on EJB 3.0 view of the Bean...");
        ejb3Bean.hello();


        // Call EJB2.1 bean
        EJB2RemoteHome ejb2Home = (EJB2RemoteHome) initialContext
                .lookup("org.ow2.easybeans.examples.migrationejb21.EJB2And3Bean"
                        + "_" + EJB2RemoteHome.class.getName());
        // Create bean
        EJB2RemoteInterface ejb2Bean = ejb2Home.create();
        System.out.println("Calling hello() method on Remote EJB 2.1 view of the Bean...");
View Full Code Here

        private boolean jonasIsReady() {
            String jonasName = System.getProperty("jonas.name", "jonas");

            // Get Adm object
            String admName = jonasName + "_Adm";
            Context initialContext = null;
            try {
                initialContext = new InitialContext();
            } catch (NamingException e) {
                this.logger.error("Cannot get an initial context", e);
                return false;
            }
            Object adm = null;
            try {
                adm = initialContext.lookup(admName);
            } catch (NamingException e) {
                this.logger.error("No {0} object found in the initial context", admName, e);
                return false;
            }
View Full Code Here

     */
    @SuppressWarnings("unused")
    public void test(final int n, final Class beanClass, final Class beanInterface) throws Exception {
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
        "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
        Context initialContext = new InitialContext();

        for (int i = 0; i < n; i++) {
            Object bean = initialContext.lookup(beanClass.getName() + "_" + beanInterface.getName() + ITF_REMOTE);
            this.invokeMethod(n, bean);
        }
    }
View Full Code Here

    public static EJBContext getEJBContext() throws NamingException {
        // sets the context
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");

        Context initialContext = new InitialContext();
        EJBContext ejbContext = (EJBContext) initialContext.lookup("java:comp/EJBContext");
        return ejbContext;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public static synchronized <E> E getBeanRemoteInstance(final Class beanClass, final Class<E> beanInterface) throws Exception {
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");

        Context initialContext = new InitialContext();
        E clBean = (E) initialContext.lookup(beanClass.getName() + "_" + beanInterface.getName() + ITF_REMOTE);
        return clBean;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public static synchronized <E> E getBeanLocalInstance(final Class beanClass, final Class<E> beanInterface) throws Exception {
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");

        Context initialContext = new InitialContext();
        E clBean = (E) initialContext.lookup(beanClass.getName() + "_" + beanInterface.getName() + ITF_LOCAL);
        return clBean;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public static synchronized <E> E getBeanByMappedName(final String mappedName) throws Exception {
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");

        Context initialContext = new InitialContext();
        E clBean = (E) initialContext.lookup(mappedName);
        return clBean;
    }
View Full Code Here

        // Check if the entry exists in the environment
        logger.debug("Getting reference using the JNDI API. Name = {0}", entryName);

        E eJNDI = null;
        try {
            Context initCtx = new InitialContext();
            Context myEnv = (Context) initCtx.lookup("java:comp/env");

            eJNDI = (E) myEnv.lookup(entryName);

            if (eJNDI == null) {
                logger.debug("Entry reference is null. Name = {0}", entryName);
            }
        } catch (NamingException e) {
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.