package client.websphere;

import javax.naming.*;
import java.util.Properties;
import hello.*;

/* Generated by Together */


public class HelloClient {
    public static void main(String[] argv) {
          InitialContext ctx = null;
         try
         {
            Properties properties = new Properties();
            // get location of name service
            properties.put(javax.naming.Context.PROVIDER_URL, "iiop://localhost:900");
            // get name of initial context factory
            properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
                           "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
            ctx = new InitialContext(properties);
         }
         catch (Exception e)
         {
            // error getting the initial context
            e.printStackTrace();
            System.exit(0);
         }
	     // lookup the home interface using the JNDI name
      	 try
      	 {
         	java.lang.Object homeObject = ctx.lookup("hello/HelloHome"); // this is the JNDI name
         	if (homeObject instanceof org.omg.CORBA.Object)
         	{
	            Object obj = javax.rmi.PortableRemoteObject.narrow( (org.omg.CORBA.Object)homeObject, HelloHome.class);
    	        HelloHome home = (HelloHome)obj;
            	Hello hello = home.create();
    	        System.out.println(hello.hello());
    	        hello.remove();
    	    }
      }
      catch (Exception e)
      {
         // error getting the home interface
         e.printStackTrace();
         System.exit(0);
      }
    }
}
