rendered paste body// EDS CORBA 2.6 QM 1/09/2004
// JDK1.4.2 with JacORB 2.2
// ns\timer\TimerClient.java
// simple client using COS Naming
package bank;
import javax.naming.*;
import java.rmi.*;
import java.io.*;
import java.util.Hashtable;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import javax.rmi.PortableRemoteObject;
import org.omg.CosNaming.*;
public class BankClient
{
public static void main(String args[])
{
try
{
// create and initialize the ORB
ORB orb = ORB.init(args, null);
ORB orbtest= ORB.init(args,null);
// get a reference to the naming service
org.omg.CORBA.Object o = orb.resolve_initial_references("NameService");
NamingContextExt rootContext = NamingContextExtHelper.narrow( o );
// Find a name with a context called MyServer.CalcServer
NameComponent nc = new NameComponent ("MyBankServer", "BankServer");
NameComponent path[] = {nc};
bank.Manager managerRef = bank.ManagerHelper.narrow(rootContext.resolve(path));
System.err.println("Object Reference successfully imported from Naming Service.");
// Call the time server object and print results
managerRef.createAccount("Mike",100);
/*
// Lookup account object
Hashtable accountTable = new Hashtable();
accountTable.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
//accountTable.put("java.naming.provider.url", "iiop://objhost.org:900");
Context ctx = new InitialContext(accountTable);
Account myAcct =
(Account)PortableRemoteObject.narrow(ctx.lookup("Mike"),Account.class);
// Report results and balance.
System.out.println("banlance is" +
myAcct.balance());
*/
System.err.println("Account name is: " );
} // try
catch (Exception e)
{
System.err.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
} // main
} // class