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