FileDocCategorySizeDatePackage
Client.javaAPI DocExample1639Sun Mar 07 08:56:24 GMT 1999com.titan.reservation

Client

public class Client extends Object

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

    Properties p = new Properties();
    // ... specify the JNDI properties specific to the vendor
    return new InitialContext(p);
  
public static voidmain(java.lang.String[] args)

        try{


        Context jndiContext = getInitialContext();
        CustomerHome custHome =  (CustomerHome)jndiContext.lookup("CustomerHome");
        Customer customer = custHome.findByPrimaryKey(new CustomerPK(1));
        CruiseHome cruiseHome =  (CruiseHome)jndiContext.lookup("CruiseHome");
        Cruise cruise = cruiseHome.findByPrimaryKey(new CruisePK(1));
        CabinHome cabinHome =  (CabinHome)jndiContext.lookup("CabinHome");
        CabinPK pk = new CabinPK();
        pk.id = 22;
        Cabin cabin = cabinHome.findByPrimaryKey(pk);

        ReservationHome home = (ReservationHome)jndiContext.lookup("ReservationHome");
        Reservation res = home.create(customer,cruise,cabin,1300);

        System.out.println(res.getCustomerID());
        System.out.println(res.getCruiseID());
        System.out.println(res.getCabinID());

        }catch(java.rmi.RemoteException re)
           {
             System.out.println("RemoteException thrown");
             re.printStackTrace();
           }
        catch(Throwable t)
           {
            t.printStackTrace();
           }