1 package test.load.imr; 2 3 import java.io.*; 4 5 import org.omg.CORBA.*; 6 import org.omg.PortableServer.*; 7 8 9 public class Server 10 { 11 public static void main(String [] args) 12 { 13 if( args.length != 1 ) 14 { 15 System.out.println( 16 "Usage: jaco test.load.imr.Server <ior_file>"); 17 System.exit( 1 ); 18 } 19 20 try 21 { 22 System.setProperty( "jacorb.implname", "loadtest" ); 23 System.setProperty( "jacorb.use_imr", "on" ); 24 25 ORB orb = ORB.init( args, null ); 27 28 POA root_poa = 30 POAHelper.narrow( orb.resolve_initial_references( "RootPOA" )); 31 32 root_poa.the_POAManager().activate(); 33 org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy [2]; 34 35 policies[0] = root_poa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT); 36 policies[1] = root_poa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID); 37 POA test_poa = root_poa.create_POA( "TestServerPOA", 38 root_poa.the_POAManager(), 39 policies ); 40 for (int i=0; i<policies.length; i++) 41 policies[i].destroy(); 42 43 GoodDayImpl goodDayImpl = new GoodDayImpl( "" ); 45 46 byte[] id = "test".getBytes(); 47 48 test_poa.activate_object_with_id( id, goodDayImpl ); 49 50 51 org.omg.CORBA.Object obj = 53 test_poa.servant_to_reference( goodDayImpl ); 54 55 PrintWriter pw = 56 new PrintWriter( new FileWriter( args[ 0 ] )); 57 58 pw.println( orb.object_to_string( obj )); 60 61 pw.flush(); 62 pw.close(); 63 64 orb.run(); 66 } 67 catch( Exception e ) 68 { 69 System.out.println( e ); 70 } 71 } 72 } 73 | Popular Tags |