1 package test.load.imr; 2 3 import java.io.*; 4 import java.util.*; 5 import org.omg.CORBA.*; 6 7 public class Client2 8 { 9 private static ORB orb = null; 10 11 public static void main( String args[] ) 12 { 13 if( args.length != 1 ) 14 { 15 System.out.println( "Usage: jaco test.load.imr.Client <ior_file>" ); 16 System.exit( 1 ); 17 } 18 19 try 20 { 21 File f = new File( args[ 0 ] ); 22 23 if( ! f.exists() ) 25 { 26 System.out.println("File " + args[0] + 27 " does not exist."); 28 29 System.exit( -1 ); 30 } 31 32 if( f.isDirectory() ) 34 { 35 System.out.println("File " + args[0] + 36 " is a directory."); 37 38 System.exit( -1 ); 39 } 40 41 orb = ORB.init( args, null ); 43 44 BufferedReader br = 45 new BufferedReader( new FileReader( f )); 46 47 49 String ior = br.readLine(); 50 br.close(); 51 52 for( int i = 0; i < 20; i++ ) 53 { 54 Thread th = new Thread ( new CallRunnable( ior, i )); 55 th.start(); 56 } 57 } 58 catch( Exception ex ) 59 { 60 System.err.println( ex ); 61 } 62 } 63 64 private static class CallRunnable 65 implements Runnable 66 { 67 private int me = 0; 68 private String ior = null; 69 private Random rnd = null; 70 71 public CallRunnable( String ior, 72 int me ) 73 { 74 this.ior = ior; 75 this.me = me; 76 77 rnd = new Random(); 78 } 79 80 public void run() 81 { 82 try 83 { 84 while( true ) 85 { 86 org.omg.CORBA.Object obj = 87 orb.string_to_object( ior ); 88 89 GoodDay goodDay = GoodDayHelper.narrow( obj ); 92 93 goodDay.hello_simple( me ); 94 95 } 97 } 98 catch( Throwable th ) 99 { 100 th.printStackTrace(); 101 102 System.exit( -1 ); 103 } 104 } 105 } 106 } 107 108 | Popular Tags |