1 package demo.benchmark; 2 3 import org.omg.CosNaming.*; 4 import org.omg.PortableServer.*; 5 6 public class Server 7 { 8 public static void main( String [] args ) 9 { 10 try 11 { 12 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); 13 org.omg.PortableServer.POA rootPOA = 14 org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 15 16 org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy [2]; 17 18 policies[0] = 19 rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID); 20 policies[1] = 21 rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT); 22 23 POA benchPOA = 24 rootPOA.create_POA("BenchPOA",rootPOA.the_POAManager(),policies); 25 26 rootPOA.the_POAManager().activate(); 27 28 byte [] oid = "benchServer".getBytes(); 29 30 benchPOA.activate_object_with_id(oid, new benchImpl()); 31 32 org.omg.CORBA.Object o = benchPOA.id_to_reference(oid); 33 34 if( args.length == 0 ) 35 { 36 NamingContextExt nc = 37 NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); 38 nc.bind(nc.to_name("benchmark"), o); 39 } 40 else 41 { 42 try 43 { 44 String ref = orb.object_to_string( o ); 45 String refFile = args[0]; 46 java.io.PrintWriter out = 47 new java.io.PrintWriter (new java.io.FileOutputStream (refFile)); 48 out.println(ref); 49 out.flush(); 50 } 51 catch(java.io.IOException ex) 52 { 53 System.err.println("Server: can't write to `" + 54 ex.getMessage() + "'"); 55 System.exit( 1 ); 56 } 57 } 58 orb.run(); 59 } 60 catch (Exception e ) 61 { 62 e.printStackTrace(); 63 } 64 } 65 } 66 67 68 69 70 | Popular Tags |