01: package demo.bank.transaction.implicit;
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: java.util.Properties props = new java.util.Properties();
12: props
13: .put(
14: "org.omg.PortableInterceptor.ORBInitializerClass.TSClientInit",
15: "org.jacorb.transaction.TransactionInitializer");
16:
17: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
18: try {
19: org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
20: .narrow(orb.resolve_initial_references("RootPOA"));
21:
22: poa.the_POAManager().activate();
23:
24: org.omg.CORBA.Object o = poa
25: .servant_to_reference(new BankImpl(orb, poa));
26:
27: if (args.length == 1) {
28: // write the object reference to args[0]
29:
30: PrintWriter ps = new PrintWriter(new FileOutputStream(
31: new File(args[0])));
32: ps.println(orb.object_to_string(o));
33: ps.close();
34: } else {
35: NamingContextExt nc = NamingContextExtHelper.narrow(orb
36: .resolve_initial_references("NameService"));
37: NameComponent[] name = new NameComponent[1];
38: name[0] = new NameComponent("DigiBank", "server");
39: nc.rebind(name, o);
40: }
41: } catch (Exception e) {
42: e.printStackTrace();
43: }
44: orb.run();
45: }
46:
47: }
|