package testclient;

import javax.naming.InitialContext;

import juno2Beans.sellPositions.CmdSellPosition;
import juno2Beans.sellPositions.CmdSellPositionHome;

/**
 * @author yashtalwar
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class TestClient {

	public static void main(String[] args) {
		
		Juno2.CmdSellPositionImpl service = new Juno2.CmdSellPositionImpl();
		
		Juno2.PositionListCVO myPosCVO = new Juno2.PositionListCVO();
		
//		myPosCVO = service.doSellPosition("0SQLSDDH05","0SQLSDDH05", "QPF0OCME05", "FKM");
//		System.out.println("firstName " + myPosCVO.getUserId());

		CmdSellPositionHome ejbHome = null;
		CmdSellPosition ejb = null;

		//The logic of this servlet is putting text message to JMS queue
		try {
			System.out.println("I am here");
			InitialContext initCtx = new InitialContext();

			// Lookup for EJB Home reference object and then narrow (cast) it to EJB Home
			ejbHome =
				(CmdSellPositionHome) javax.rmi.PortableRemoteObject.narrow(
					initCtx.lookup("ejb/juno2Beans/sellPositions/CmdSellPositionHome"),
					CmdSellPositionHome.class);

		} catch (Exception ex) {
			System.out.println(" Could not lookup EJB Home object");
			ex.printStackTrace();
		}

		try {
			ejb = ejbHome.create();
	//		myPosCVO = ejb.doSellPosition("0SQLSDDH05","0SQLSDDH05", "QPF0OCME05", "FKM");
			myPosCVO = ejb.doSellPosition("SPZ2LT5W05","SPZ2LT5W05", "QPF0OCME05", "FKM");
			System.out.println("firstName " + myPosCVO.getUserId());
			System.out.println(myPosCVO);
		} catch (Exception ex) {
			System.out.println("Could not create ejb");
			ex.printStackTrace();
		}

	}
}
