FileDocCategorySizeDatePackage
Client_5.javaAPI DocExample1799Sun Mar 07 08:38:24 GMT 1999com.titan.travelagent

Client_5.java

package com.titan.travelagent;

import javax.naming.*;
import java.rmi.*;
import com.titan.cabin.*;
import com.titan.customer.*;
import java.util.*;
import com.titan.processpayment.*;

public class Client_5 {

    public static void main(String args[]){
        try{


            Context jndiContext = getInitialContext();
            CustomerHome ch = (CustomerHome)jndiContext.lookup("CustomerHome");


            CustomerPK pk = new CustomerPK();
            pk.id = 1;
            Customer customer = ch.findByPrimaryKey(pk);

            TravelAgentHome home = (TravelAgentHome)jndiContext.lookup("TravelagentHome");

            TravelAgent agent = home.create(customer);

            agent.setCruiseID(1);
            String list [] = agent.listAvailableCabins(2);

            for(int i = 0; i < list.length; i++){
                System.out.println(list[i]);
            }

            agent.setCabinID(1);
            GregorianCalendar gc = new GregorianCalendar();
            gc.set(1999,10,31);
            CreditCard card = new CreditCard(83872938749209l,gc.getTime() , CreditCard.VISA);
            Ticket t = agent.bookPassage(card,27999.99d);
            System.out.println(t);



        }catch(java.rmi.RemoteException re)
           {
             System.out.println("RemoteException thrown");
             re.printStackTrace();
             if(re.detail != null)
                re.detail.printStackTrace();
           }
        catch(Throwable t)
           {
            t.printStackTrace();
           }
  }
  static public Context getInitialContext() throws Exception {
    Properties p = new Properties();
    // ... specify the JNDI properties specific to the vendor
    return new InitialContext(p);
  }

}