// OrderEntryClerkClient.java
// mini Client for accessing bean OrderEntryClerk

package org.objectweb.jonas.stests.appli;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

/**
 *
 */
public class OrderEntryClerkClient {

    static Context ctx = null; 
    static OrderEntryClerkHome oechome = null;
    static CustomerHome chome = null;

    public static void main(String[] arg) {

	// Get InitialContext
	try {
	    ctx = new InitialContext();
	} catch (NamingException e) {
	    e.printStackTrace();
	    System.exit(2);
	}

	// Lookup bean home 
	String oecName = "OrderEntryClerkHome";
    String cName = "CustomerHome";
	try {
	    oechome = (OrderEntryClerkHome) PortableRemoteObject.narrow(ctx.lookup(oecName), OrderEntryClerkHome.class);
	    OrderEntryClerk oecbean = oechome.create();
        oecbean.createAllTables();
        System.out.println("all tables created");
	    oecbean.setCustomer(new Integer(9));
        oecbean.addOrderLine(new Integer(20),24);
        oecbean.addOrderLine(new Integer(10),12);
        oecbean.addOrderLine(new Integer(1),1);
        oecbean.addOrderLine(new Integer(2),6);
        String numorder = oecbean.placeOrder();
        System.out.println("numorder = "+numorder);
	    oecbean.setCustomer(new Integer(5));
        oecbean.addOrderLine(new Integer(20),24);
        oecbean.addOrderLine(new Integer(10),12);
        oecbean.addOrderLine(new Integer(1),1);
        oecbean.addOrderLine(new Integer(2),6);
        numorder = oecbean.placeOrder();
        System.out.println("numorder = "+numorder);

	} catch(Exception e) {
	    e.printStackTrace();
	    System.exit(2);
	}

	// ...
    }
}
