// CountClient.java Static Client, JDK 1.2 import org.omg.CosNaming.*; import org.omg.CORBA.*; class CountClient { public static void main(String args[]) { try { // Initialize the ORB System.out.println("Initializing the ORB"); org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); // Resolve initial references: Naming, Count org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef = NamingContextHelper.narrow(objRef); NameComponent nc = new NameComponent("Count", ""); NameComponent path[] = {nc}; Counter.Count counter = Counter.CountHelper.narrow(ncRef.resolve(path)); // Set sum to initial value of 0 System.out.println("Setting sum to 0"); counter.setSum((int)0); // Calculate Start time long startTime = System.currentTimeMillis(); // Increment 1000 times System.out.println("Incrementing"); for (int i = 0 ; i < 1000 ; i++ ) { counter.increment(); } // Calculate stop time; print out statistics long stopTime = System.currentTimeMillis(); System.out.println("Avg Ping = " + ((stopTime - startTime)/1000f) + " msecs"); System.out.println("Sum = " + counter.sum()); } catch(Exception e) { System.err.println("System Exception"); System.err.println(e); } } }