01: package demo.arrays;
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 serverImpl());
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: // register server with naming context
27: NamingContextExt nc = NamingContextExtHelper.narrow(orb
28: .resolve_initial_references("NameService"));
29:
30: nc.bind(nc.to_name("arrayServer.example"), o);
31: }
32: } catch (Exception e) {
33: e.printStackTrace();
34: }
35: orb.run();
36: }
37: }
|