CountPOAClient

CountPOAClient - if (nameService == null) {

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// CountPOAClient.java Static Client, VisiBroker for Java / import org.omg.CosNaming.*; import java.io.*; i class CountPOAClient { 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); CounterPOA.Count counter=null; if(new File("ior.txt").exists()) { try { BufferedReader b_In = new BufferedReader( new InputStreamReader( new FileInputStream("ior.txt"))); counter= CounterPOA.CountHelper.narrow(orb.string_to_object(b_In.readLine())); } catch(IOException IOe) { System.out.println("failed to read ior.txt"); System.exit(1); } } else { // Get a reference to the Naming service org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references ("NameService"); if (nameServiceObj == null) { System.out.println("nameServiceObj = null"); return; } org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow (nameServiceObj);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (nameService == null) { System.out.println("nameService = null"); return; } // resolve the Count object in the Naming service NameComponent countName = {new NameComponent("countName", "")}; counter = CounterPOA.CountHelper.narrow(nameService.resolve(countName)); } // Set sum to initial value of 0 //System.out.println("Setting sum to 0"); //counter.sum((int)0); // Calculate Start time long startTime = System.currentTimeMillis(); // Increment 10 times System.out.println("Incrementing"); for (int i = 0 ; i < 10 ; 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("Exception"); System.err.println(e); } } }...
View Full Document

Page1 / 2

CountPOAClient - if (nameService == null) {

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online