01: package demo.grid;
02:
03: import java.io.*;
04: import org.omg.CosNaming.*;
05:
06: public class TieServer {
07: public static void main(String[] args) {
08: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
09: try {
10: org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
11: .narrow(orb.resolve_initial_references("RootPOA"));
12:
13: org.omg.CORBA.Object o = poa
14: .servant_to_reference(new MyServerPOATie(
15: new gridOperationsImpl()));
16:
17: poa.the_POAManager().activate();
18:
19: if (args.length == 1) {
20: // write the object reference to args[0]
21:
22: PrintWriter ps = new PrintWriter(new FileOutputStream(
23: new File(args[0])));
24: ps.println(orb.object_to_string(o));
25: ps.close();
26: } else {
27: NamingContextExt nc = NamingContextExtHelper.narrow(orb
28: .resolve_initial_references("NameService"));
29: NameComponent[] name = new NameComponent[1];
30: name[0] = new NameComponent("grid", "example");
31: nc.bind(name, o);
32: }
33: } catch (Exception e) {
34: e.printStackTrace();
35: }
36: orb.run();
37: }
38: }
|