1 package demo.ami; 2 3 import java.io.*; 4 import org.omg.CORBA.*; 5 import org.omg.PortableServer.*; 6 7 public class Client 8 { 9 public static void main( String args[] ) 10 { 11 if( args.length != 1 ) 12 { 13 System.out.println("Usage: java demo.ami.Client <ior_file>"); 14 System.exit( 1 ); 15 } 16 17 try 18 { 19 File f = new File( args[ 0 ] ); 20 21 if( ! f.exists() ) 23 { 24 System.out.println("File " + args[0] + 25 " does not exist."); 26 27 System.exit( -1 ); 28 } 29 30 if( f.isDirectory() ) 32 { 33 System.out.println("File " + args[0] + 34 " is a directory."); 35 36 System.exit( -1 ); 37 } 38 39 ORB orb = ORB.init( args, null ); 41 42 POA poa = 43 POAHelper.narrow (orb.resolve_initial_references ("RootPOA")); 44 poa.the_POAManager().activate(); 45 46 BufferedReader br = 47 new BufferedReader( new FileReader( f )); 48 49 org.omg.CORBA.Object obj = 51 orb.string_to_object( br.readLine() ); 52 br.close(); 53 54 AsyncServer s = AsyncServerHelper.narrow( obj ); 55 AMI_AsyncServerHandler h = 56 new AMI_AsyncServerHandlerImpl()._this(orb); 57 58 System.out.println ("* sending async..."); 59 ((_AsyncServerStub)s).sendc_op2 (h, 2); 60 System.out.println ("* ...done. Waiting for reply..."); 61 62 try 63 { 64 Thread.currentThread().sleep ( 10000 ); 65 } 66 catch (InterruptedException ex) 67 { 68 } 69 70 } 71 catch( Exception ex ) 72 { 73 System.err.println( ex ); 74 } 75 } 76 } 77 78 | Popular Tags |