FileDocCategorySizeDatePackage
Client_2.javaAPI DocExample1856Sat Mar 06 09:47:02 GMT 1999com.titan.travelagent

Client_2

public class Client_2 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 javax.naming.InitialContext(p);
    
public static voidmain(java.lang.String[] args)

        try{
            Context jndiContext = getInitialContext();

            // Obtain a list of all the cabins for ship 1 with 3 bed count
            TravelAgentHome agentHome =
              (TravelAgentHome)jndiContext.lookup("TravelAgentHome");
            TravelAgent agent = agentHome.create();
            String list [] = agent.listCabins(1,3);
            System.out.println("1st List: Before deleting cabin number 30");
            for(int i = 0; i < list.length; i++){
                System.out.println(list[i]);
            }

            // obtain the CabinHome and remove cabin 30. Rerun the same cabin list.
            CabinHome c_home = (CabinHome)jndiContext.lookup("CabinHome");
            CabinPK pk = new CabinPK();
            pk.id = 30;
            c_home.remove(pk);
            list = agent.listCabins(1,3);
            System.out.println("2nd List: After deleting cabin number 30");
            for(int i = 0; i < list.length; i++){
                System.out.println(list[i]);
            }


        }catch(java.rmi.RemoteException re){re.printStackTrace();}
         catch(Throwable t){t.printStackTrace();}