FileDocCategorySizeDatePackage
TestPaymentClient.javaAPI DocExample2568Tue Sep 18 22:51:04 BST 2001com.titan.paymentclient

TestPaymentClient

public class TestPaymentClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public voidcreateSampleCustomer()

	  try {
            CustomerRemote customer = getCustomerHome().create(1,"Kyle","G","Brown");
        } catch (java.rmi.RemoteException re){re.printStackTrace();}
          catch (javax.ejb.CreateException ce){ce.printStackTrace();}
	
public CustomerHomeRemotegetCustomerHome()

		CustomerHomeRemote home = null;
		try {
            	Context jndiContext = getInitialContext();
            	Object ref = jndiContext.lookup("CustomerHomeRemote");
            	home = (CustomerHomeRemote)
                      javax.rmi.PortableRemoteObject.narrow(ref,CustomerHomeRemote.class);
		} catch (NamingException ne) {
			ne.printStackTrace();
		}			
		return home;
	
public static javax.naming.ContextgetInitialContext()


		java.util.Properties properties = new java.util.Properties();
		properties.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
		properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, 
			"com.ibm.websphere.naming.WsnInitialContextFactory");
		InitialContext initialContext = new InitialContext(properties);
		return initialContext;
    
public com.titan.processpayment.ProcessPaymentHomeRemotegetProcessPaymentHome()

		ProcessPaymentHomeRemote home = null;
		try {
            	Context jndiContext = getInitialContext();
            	Object ref = jndiContext.lookup("ProcessPaymentHomeRemote");
            	home = (ProcessPaymentHomeRemote)
                      javax.rmi.PortableRemoteObject.narrow(ref,ProcessPaymentHomeRemote.class);
		} catch (NamingException ne) {
			ne.printStackTrace();
		}			
		return home;
	
public static voidmain(java.lang.String[] args)

		TestPaymentClient client = new TestPaymentClient();
		client.createSampleCustomer();
		client.payByCash();
    
public voidpayByCash()

    
		try {  
            	Integer pk = new Integer(1);
            	CustomerRemote customer = getCustomerHome().findByPrimaryKey(pk);
            	ProcessPaymentRemote paymentBean = getProcessPaymentHome().create();
			paymentBean.byCash(customer, 1000.0);
		}  catch (Exception e){
			e.printStackTrace();
		}