1 26 27 package org.objectweb.benchmark.corba.latency; 28 29 import java.io.InputStream ; 31 import java.util.Properties ; 32 33 import org.omg.CORBA.ORB ; 34 import org.omg.PortableServer.POA ; 35 import org.omg.PortableServer.POAHelper ; 36 37 44 public class Server 45 { 46 52 58 61 public Server() 62 { 63 try{ 64 Properties properties = new Properties (); 65 InputStream propStream = getClass().getClassLoader().getResourceAsStream("benchmark.properties"); 66 properties.load(propStream); 67 } catch (Exception e) { 68 e.printStackTrace(); 69 } 70 } 71 72 78 81 private void init_orb() 82 { 83 try { 84 java.io.InputStream propStream = null; 85 86 propStream = getClass().getClassLoader().getResourceAsStream("ORB.properties"); 87 System.getProperties().load(propStream); 88 } catch (Exception e) { 89 e.printStackTrace(); 90 } 91 } 92 93 99 102 public void run() 103 { 104 try{ 105 init_orb(); 107 ORB orb = ORB.init(new String [0], null); 108 109 org.omg.CORBA.Object rootobj = orb.resolve_initial_references("RootPOA"); 111 POA rootpoa = POAHelper.narrow(rootobj); 112 rootpoa.the_POAManager().activate(); 113 114 PingImpl servant = new PingImpl(orb); 116 org.omg.CORBA.Object obj = rootpoa.servant_to_reference(servant); 117 118 String ior = orb.object_to_string(obj); 120 IORServer iorServer = new IORServer(ior); 121 iorServer.listen(); 122 123 System.out.println( "The CORBA server is running ..." ); 125 orb.run(); 126 }catch(Exception ex){ 127 ex.printStackTrace(); 128 } 129 } 130 131 136 public static void main(String [] args) 137 { 138 Server serv = new Server(); 139 serv.run(); 140 } 141 } 142 | Popular Tags |