01: package demo.value.idl;
02:
03: import java.io.*;
04:
05: import org.omg.CORBA.*;
06: import org.omg.PortableServer.*;
07:
08: public class Server {
09: public static void main(String[] args) {
10: if (args.length != 1) {
11: System.out
12: .println("Usage: java demo.value.idl.Server <ior_file>");
13: System.exit(1);
14: }
15:
16: try {
17: //init ORB
18: ORB orb = ORB.init(args, null);
19:
20: //init POA
21: POA poa = POAHelper.narrow(orb
22: .resolve_initial_references("RootPOA"));
23:
24: poa.the_POAManager().activate();
25:
26: ValueServerImpl s = new ValueServerImpl();
27:
28: // create the object reference
29: org.omg.CORBA.Object obj = poa.servant_to_reference(s);
30:
31: PrintWriter pw = new PrintWriter(new FileWriter(args[0]));
32:
33: // print stringified object reference to file
34: pw.println(orb.object_to_string(obj));
35:
36: pw.flush();
37: pw.close();
38:
39: // wait for requests
40: orb.run();
41: } catch (Exception e) {
42: System.out.println(e);
43: }
44: }
45: }
|