/*
 *
 * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the proprietary information of Sun Microsystems, Inc.  
 * Use is subject to license terms.
 * 
 */

package com.web_tomorrow.item;

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

public class ItemClient {

   public static void main(String[] args) {

	Properties env = new Properties();
      env.setProperty("java.naming.factory.initial",  "org.jnp.interfaces.NamingContextFactory");
      env.setProperty("java.naming.provider.url",  "localhost:1099");
      env.setProperty("java.naming.factory.url.pkgs",  "org.jboss.naming");
      
       try {
           Context initial = new InitialContext(env);
           Object objref = initial.lookup("MyItem");

           ItemHome home = 
               (ItemHome)PortableRemoteObject.narrow(objref, 
                                            ItemHome.class);

           Item item1 = home.create("01", "00000000000127", "Puleva", 120.00);
           double price = item1.getPrice();
           System.out.println("price = " + String.valueOf(price));
//           item1.remove();

           Item item2 = home.create("01", "00000000000840", "Atun", 100.00);
           price = item2.getPrice();
           System.out.println("price = " + String.valueOf(price));
       } catch (Exception ex) {
       
           System.err.println("Caught an exception." );
           ex.printStackTrace();
       }
   } 
} 