FileDocCategorySizeDatePackage
Client.javaAPI DocExample1514Sun Mar 07 08:57:20 GMT 1999com.titan.processpayment

Client.java

package com.titan.processpayment;

import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
import com.titan.customer.*;

public class Client {
  public static void main(String [] agrs){
    try{
        Context ctx = getInitialContext();

        CustomerHome ch = (CustomerHome)getInitialContext().lookup("CustomerHome");
        CustomerPK pk = new CustomerPK();
        pk.id = 1;
        Customer customer = ch.findByPrimaryKey(pk);

        ProcessPaymentHome home = (ProcessPaymentHome)ctx.lookup("ProcessPaymentHome");
        ProcessPayment p = home.create( );
        boolean b;
        java.util.GregorianCalendar calendar = new java.util.GregorianCalendar();
        calendar.add(java.util.GregorianCalendar.DAY_OF_YEAR,1);
        CreditCard card = new CreditCard(4029302, calendar.getTime(), CreditCard.VISA);
        try{
        b = p.byCredit(customer,card, 7400.00);
        System.out.println(b);
        }catch(PaymentException pe){
        pe.printStackTrace();
        }
        b = p.byCash(customer,774.00);
        System.out.println(b);
        Check check = new Check("8374938-48384",100);
        b = p.byCheck(customer, check, 8438.09);
        System.out.println(b);
        }catch(Exception e){e.printStackTrace();}
 }
 public static Context getInitialContext() throws Exception {
   Properties p = new Properties();
    // ... specify the JNDI properties specific to the vendor
   return new InitialContext(p);
 }
}