1 5 package persistentaccount; 6 7 import org.omg.CORBA.ORB ; 8 import org.omg.CosNaming.NamingContextExt ; 9 import org.omg.CosNaming.NamingContextExtHelper ; 10 11 import account.AccountData; 12 import account.AccountManager; 13 import account.AccountManagerHelper; 14 import account.OperationFailed; 15 16 20 public class Client 21 { 22 public static void main(String [] args) 23 { 24 try 25 { 26 ORB orb = org.omg.CORBA.ORB.init(args, null); 27 28 org.omg.CORBA.Object obj = null; 29 obj = orb.resolve_initial_references("NameService"); 30 NamingContextExt rootContext = NamingContextExtHelper.narrow(obj); 31 32 obj = rootContext.resolve_str("persistent_account"); 33 AccountManager accManager = AccountManagerHelper.narrow(obj); 34 35 accManager.deposit(1, 1000.0); 37 double balance = accManager.getBalance(1); 38 System.out.println("Balance = " + balance); 39 AccountData account = accManager.getAccountData(1); 40 System.out.println("Account ID = " + account.id); 41 System.out.println("Name = " + account.name); 42 System.out.println("Balance = " + account.balance); 43 } 44 catch (OperationFailed e) 45 { 46 System.out.println("Operation failed " + e.reason); 47 } 48 catch (Exception e) 49 { 50 System.out.println("Error: " + e.getMessage()); 51 } 52 } 53 } 54 | Popular Tags |