01: package demo.interceptors;
02:
03: import java.io.*;
04: import org.omg.CosNaming.*;
05:
06: public class Server2 {
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: poa.the_POAManager().activate();
14:
15: org.omg.CORBA.Object o = poa
16: .servant_to_reference(new gridImpl());
17:
18: if (args.length == 1) {
19: // write the object reference to args[0]
20:
21: PrintWriter ps = new PrintWriter(new FileOutputStream(
22: new File(args[0])));
23: ps.println(orb.object_to_string(o));
24: ps.close();
25: } else {
26: NamingContextExt nc = NamingContextExtHelper.narrow(orb
27: .resolve_initial_references("NameService"));
28: nc.bind(nc.to_name("grid2.example"), o);
29: }
30: } catch (Exception e) {
31: e.printStackTrace();
32: }
33: orb.run();
34: }
35: }
|