Package javax.naming

Examples of javax.naming.Context.lookup()


        HelloInterface hello = null;

        try {
            System.setProperty("java.rmi.server.useCodebaseOnly", "true");
            Context initialContext = getInitialContext();
            hello = (HelloInterface) initialContext.lookup(JNDI_NAME);

        } catch (NamingException ex) {
            Logger.getLogger(HelloWorldTest.class.getName()).log(Level.SEVERE, "Unable to found HelloWorld EJB.", ex);
        }
        return hello;
View Full Code Here


     */
    public void getBeanByLookup() throws NamingException, CreateException {
        // Obtain the default initial JNDI context.
        Context initCtx = new InitialContext();

        Object result = initCtx.lookup(getBeanName());

        SimpleEjb2LocalHome beanHomeLookup = (SimpleEjb2LocalHome) javax.rmi.PortableRemoteObject.narrow(result,
                SimpleEjb2LocalHome.class);

        SimpleEjb2Local beanLookup = beanHomeLookup.create(DEFAULT_NAME);
View Full Code Here

     * @throws Exception if a problem occurs
     */
    public static void checkJNDI() throws Exception{
        Context ctx = new InitialContext();

        TimerService ts = (TimerService) ctx.lookup("java:comp/TimerService");
        if (ts == null){
            throw new Exception("TimerService reference obtained using JNDI API is null.");
        }
    }
}
View Full Code Here

        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
        //gets the initialcontext
        Context initialContext = new InitialContext();
        //gets the usertransaction
        UserTransaction utx = (UserTransaction) initialContext.lookup("javax.transaction.UserTransaction");
        return utx;
    }

    /**
     * This method use the java: naming
View Full Code Here

     */
    public static UserTransaction getUserTransaction() throws NamingException {
        //gets the initialcontext
        Context initialContext = new InitialContext();
        //gets the usertransaction
        UserTransaction utx = (UserTransaction) initialContext.lookup("java:comp/UserTransaction");
        return utx;
    }
}
View Full Code Here

     * @throws Exception if a problem occurs
     */
    public static void checkJNDI() throws Exception{
        Context ctx = new InitialContext();

        UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
        if (utx == null){
            throw new Exception("UserTransaction reference obtained using JNDI API is null.");
        }
    }
}
View Full Code Here

                    "weblogic.jndi.WLInitialContextFactory");
            props.put(Context.PROVIDER_URL,         config.getURL());
            props.put(Context.SECURITY_PRINCIPAL,   config.getUsername());
            props.put(Context.SECURITY_CREDENTIALS, config.getPassword());
            Context ctx =  new InitialContext(props);
            MBeanHome home = (MBeanHome) ctx.lookup(MBeanHome.JNDI_NAME + "." +
                            "localhome");
            // Fix for 1586075: Passing context in, so that it can be closed when the connection
            //   is closed
            return new WLServerConnection(home.getMBeanServer(), ctx);
        } catch (Throwable e) {
View Full Code Here

      String remoteBusinessInterfaceJNDIName = this.getJavaGlobalJNDIName(beanName, EchoRemote.class.getName());
      String localBusinessInterfaceJNDIName = this.getJavaGlobalJNDIName(beanName, EchoLocal.class.getName());
     

      logger.info("Looking up " + remoteBusinessInterfaceJNDIName);
      EchoRemote remoteEcho = (EchoRemote) ctx.lookup(remoteBusinessInterfaceJNDIName);
      logger.info("Looking up " + localBusinessInterfaceJNDIName);
      EchoLocal localEcho = (EchoLocal) ctx.lookup(localBusinessInterfaceJNDIName);
     
      if (isEJB31)
      {
View Full Code Here

     

      logger.info("Looking up " + remoteBusinessInterfaceJNDIName);
      EchoRemote remoteEcho = (EchoRemote) ctx.lookup(remoteBusinessInterfaceJNDIName);
      logger.info("Looking up " + localBusinessInterfaceJNDIName);
      EchoLocal localEcho = (EchoLocal) ctx.lookup(localBusinessInterfaceJNDIName);
     
      if (isEJB31)
      {
         String noInterfaceViewJNDIName = this.getJavaGlobalJNDIName(beanName, beanClass.getName());
         logger.info("Looking up " + noInterfaceViewJNDIName);
View Full Code Here

     
      if (isEJB31)
      {
         String noInterfaceViewJNDIName = this.getJavaGlobalJNDIName(beanName, beanClass.getName());
         logger.info("Looking up " + noInterfaceViewJNDIName);
         Object noInterfaceView = ctx.lookup(noInterfaceViewJNDIName);
         if (!beanClass.isInstance(noInterfaceView))
         {
            throw new RuntimeException("Unexpected object " + noInterfaceView + " in JNDI for jndi name "
                  + noInterfaceViewJNDIName);
         }
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.