01: package demo.hello;
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: jaco demo.hello.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: // create a GoodDay object
27: GoodDayImpl goodDayImpl = new GoodDayImpl("Somewhere");
28:
29: // create the object reference
30: org.omg.CORBA.Object obj = poa
31: .servant_to_reference(goodDayImpl);
32:
33: PrintWriter pw = new PrintWriter(new FileWriter(args[0]));
34:
35: // print stringified object reference to file
36: pw.println(orb.object_to_string(obj));
37:
38: pw.flush();
39: pw.close();
40:
41: // wait for requests
42: orb.run();
43: } catch (Exception e) {
44: System.out.println(e);
45: }
46: }
47: }
|