FileDocCategorySizeDatePackage
Client_1.javaAPI DocExample3266Sun Dec 19 01:35:08 GMT 1999com.titan.cabin

Client_1

public class Client_1 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static javax.naming.ContextgetGemstoneInitialContext()

       Properties p = new Properties();
       // Uncomment if you have the com.gemstone.* classes available
       //p.put(com.gemstone.naming.Defaults.NAME_SERVICE_HOST,"localhost");
       String port = System.getProperty("com.gemstone.naming.NameServicePort",
                                        "10200");
       // Uncomment if you have the com.gemstone.* classes available
       //p.put(com.gemstone.naming.Defaults.NAME_SERVICE_PORT, port);
       p.put(Context.INITIAL_CONTEXT_FACTORY,"com.gemstone.naming.GsCtxFactory");
       return new InitialContext(p);
    
public static javax.naming.ContextgetInitialContext()


        Properties p = new Properties();
        // ... Specify the JNDI properties specific to the vendor.
        //return new javax.naming.InitialContext(p);
        return getJ2EERIInitialContext();
    
public static javax.naming.ContextgetJ2EERIInitialContext()


        return new javax.naming.InitialContext();
    
public static javax.naming.ContextgetWeblogicInitialContext()

       Properties p = new Properties();
       p.put(Context.INITIAL_CONTEXT_FACTORY,
             "weblogic.jndi.TengahInitialContextFactory");
       p.put(Context.PROVIDER_URL, "t3://localhost:7001");
       return new javax.naming.InitialContext(p);
    
public static voidmain(java.lang.String[] args)

        try {
            Context jndiContext = getInitialContext();
            Object obj = jndiContext.lookup("java:comp/env/ejb/CabinHome");
            CabinHome home = (CabinHome) javax.rmi.PortableRemoteObject.narrow(obj, CabinHome.class);

            Cabin cabin_1 = home.create(1);
            System.out.println("created it!");
            cabin_1.setName("Master Suite");
            cabin_1.setDeckLevel(1);
            cabin_1.setShip(1);
            cabin_1.setBedCount(3);
                   
            CabinPK pk = new CabinPK();
            pk.id = 1;
            System.out.println("keyed it! ="+ pk);
            
            Cabin cabin_2 = home.findByPrimaryKey(pk);
            System.out.println("found by key! ="+ cabin_2);
            System.out.println(cabin_2.getName());
            System.out.println(cabin_2.getDeckLevel());
            System.out.println(cabin_2.getShip());
            System.out.println(cabin_2.getBedCount());

        } catch (java.rmi.RemoteException re){re.printStackTrace();}
          catch (javax.naming.NamingException ne){ne.printStackTrace();}
          catch (javax.ejb.CreateException ce){ce.printStackTrace();}
          catch (javax.ejb.FinderException fe){fe.printStackTrace();}