01: package demo.poa_monitor.root_poa;
02:
03: import demo.poa_monitor.foox.*;
04: import org.omg.CORBA.ORB;
05: import org.omg.PortableServer.*;
06: import org.omg.CosNaming.*;
07: import java.io.*;
08:
09: public class Server {
10: public static String description = "Root-POA only";
11:
12: public static void main(String[] args) {
13: try {
14: ORB orb = org.omg.CORBA.ORB.init(args, null);
15: POA rootPOA = POAHelper.narrow(orb
16: .resolve_initial_references("RootPOA"));
17: POAManager poaMgr = rootPOA.the_POAManager();
18:
19: FooFactoryImpl servant = new FooFactoryImpl();
20: FooFactory reference = servant._this (orb);
21:
22: /*
23: PrintWriter pw = new PrintWriter(new FileWriter("../fooFactory.ior"));
24: pw.println(orb.object_to_string(reference));
25: pw.close();
26: */
27: // CORBA compliant:
28: NamingContextExt nc = NamingContextExtHelper.narrow(orb
29: .resolve_initial_references("NameService"));
30: NameComponent[] name = new NameComponent[1];
31: name[0] = new NameComponent("FooFactory", "service");
32: nc.bind(name, reference);
33:
34: poaMgr.activate();
35: System.out.println("[ Server ready ]");
36: orb.run();
37:
38: } catch (Exception e) {
39: e.printStackTrace();
40: }
41: }
42: }
|