package bank.test; import bank.Bank; import bank.BankHelper; import bank.Account; import bank.AccountHelper; import bank.AccountInformation; import bank.AccountType; import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; public class BankClient { public static void main(String args[]) { try { // create and initialize the ORB ORB orb = ORB.init(args, null); // get the root naming context //org.omg.CORBA.Object objRef = //orb.resolve_initial_references("NameService"); org.omg.CORBA.Object objRef = orb.string_to_object("corbaloc:iiop:localhost:1050/NameService"); // Use NamingContextExt instead of NamingContext. This is // part of the Interoperable naming Service. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming String name = "BankServer"; System.out.println(args.length); if(args.length == 5) name = args[4]; System.out.println("looking up Name:" + name) ; Bank theBank = BankHelper.narrow(ncRef.resolve_str(name)); //Bank theBank = BankHelper.narrow(orb.string_to_object("corbaname::localhost:1050#" + name)); System.out.println("Obtained a handle on server object"); AccountInformation accInfo = new AccountInformation(); accInfo.accNum=""; accInfo.accType = AccountType.Checking; AccountInformation accInfo2 = new AccountInformation(); accInfo2.accNum=""; accInfo2.accType = AccountType.Saving; AccountInformation accInfo3 = new AccountInformation(); accInfo3.accNum=""; accInfo3.accType = AccountType.Saving; System.out.println("opening new accounts"); Account account1 = theBank.openAccount(accInfo) ; System.out.print("opened account:") ; System.out.println( account1.accountNumber() ); Account account2 = theBank.openAccount(accInfo2) ; System.out.println("opened account:" + account2.accountNumber() ); accInfo.accNum = account2.accountNumber() ; Account[] accounts = theBank.findAccounts(accInfo3); for(int i=0; i