01: package demo.grid;
02:
03: import java.io.*;
04: import org.omg.CosNaming.*;
05:
06: public class Server {
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: // use the naming service
27:
28: NamingContextExt nc = NamingContextExtHelper.narrow(orb
29: .resolve_initial_references("NameService"));
30: nc.bind(nc.to_name("grid.example"), o);
31: }
32:
33: orb.run();
34: } catch (Exception e) {
35: e.printStackTrace();
36: }
37: }
38: }
|