1 package test.interceptor.ctx_passing; 2 3 import java.io.*; 4 import org.omg.CORBA.ORB ; 5 import org.omg.CORBA.Any ; 6 import org.omg.PortableInterceptor.*; 7 8 public class Client 9 { 10 public static void main( String args[] ) 11 { 12 if( args.length != 1 ) 13 { 14 System.out.println( "Usage: jaco test.interceptor.ctx_passing.Client <ior_file>" ); 15 System.exit( 1 ); 16 } 17 18 try 19 { 20 File f = new File( args[ 0 ] ); 21 22 if( ! f.exists() ) 24 { 25 System.out.println("File " + args[0] + 26 " does not exist."); 27 28 System.exit( -1 ); 29 } 30 31 if( f.isDirectory() ) 33 { 34 System.out.println("File " + args[0] + 35 " is a directory."); 36 37 System.exit( -1 ); 38 } 39 40 System.setProperty( "org.omg.PortableInterceptor.ORBInitializerClass.a", 41 "test.interceptor.ctx_passing.ClientInitializer" ); 42 43 ORB orb = ORB.init( args, null ); 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 53 br.close(); 54 55 TestObject to = TestObjectHelper.narrow( obj ); 56 57 Current current = 58 (Current) orb.resolve_initial_references( "PICurrent" ); 59 60 Any any = orb.create_any(); 61 any.insert_string( "This is a test!" ); 62 63 current.set_slot( ClientInitializer.slot_id, any ); 64 65 System.out.println("Client added any to PICurrent"); 66 to.foo(); 67 } 68 catch( Exception ex ) 69 { 70 System.err.println( ex ); 71 } 72 } 73 } 74 75 | Popular Tags |