1 package org.jacorb.test.notification; 2 3 23 24 import java.io.PrintWriter ; 25 import java.net.Socket ; 26 27 import org.omg.CORBA.ORB ; 28 import org.omg.PortableServer.POA ; 29 import org.omg.PortableServer.POAHelper ; 30 import org.omg.PortableServer.Servant ; 31 32 35 36 public class TestServer 37 { 38 public static void main(String [] args) throws Exception 39 { 40 String _servantClassName = args[0]; 41 int _portToSendIorTo = Integer.parseInt(args[1]); 42 43 try 44 { 45 ORB orb = ORB.init(args, null); 47 48 POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 50 poa.the_POAManager().activate(); 51 52 Class _servantClass = Class.forName(_servantClassName); 53 54 Servant _servant = (Servant ) _servantClass.newInstance(); 55 56 org.omg.CORBA.Object o = poa.servant_to_reference(_servant); 58 59 Socket _socket = new Socket ("localhost", _portToSendIorTo); 60 61 PrintWriter _out = new PrintWriter (_socket.getOutputStream(), true); 62 63 _out.println(orb.object_to_string(o)); 64 _out.flush(); 65 _out.close(); 66 _socket.close(); 67 68 orb.run(); 70 } catch (Throwable e) 71 { 72 } 74 } 75 } 76 | Popular Tags |