FileDocCategorySizeDatePackage
Client_122a.javaAPI DocExample1347Wed May 29 18:18:58 BST 2002com.titan.clients

Client_122a.java

package com.titan.clients;

import com.titan.travelagent.*;

import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.naming.Context;
import javax.naming.NamingException;
import java.util.Properties;
import java.util.*;

/**
 * Creates Customer, Cabin, Ship, and Cruise objects for use in this exercise and the following exercises
 *
 */

public class Client_122a
{   
   public static void main (String [] args) throws Exception
   {      
      Context jndiContext = getInitialContext ();
      Object obj = jndiContext.lookup ("TravelAgentHomeRemote");
      TravelAgentHomeRemote tahome = (TravelAgentHomeRemote)
      javax.rmi.PortableRemoteObject.narrow (obj, TravelAgentHomeRemote.class);
      
      TravelAgentRemote tagent = tahome.create (null);
      
      System.out.println ("Calling TravelAgentBean to create sample data..");      
      Collection results = tagent.buildSampleData ();
      
      tagent.remove ();
      
      Iterator iterator = results.iterator ();
      while (iterator.hasNext ())
      {
         String ss = (String)(iterator.next ());
         System.out.println (ss);
      }
   }
   
   public static Context getInitialContext ()
      throws javax.naming.NamingException
   {
      return new InitialContext ();
   }   
}