01: package demo.concurrency;
02:
03: import org.jacorb.concurrency.*;
04: import org.jacorb.transaction.*;
05: import org.omg.CosNaming.*;
06:
07: import org.omg.CosConcurrencyControl.*;
08:
09: public class Server {
10: public static void main(String[] args) {
11: try {
12:
13: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
14: org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
15: .narrow(orb.resolve_initial_references("RootPOA"));
16:
17: poa.the_POAManager().activate();
18:
19: TransactionService.start(poa, 100);
20:
21: // SessionService.start(poa, 5);
22: // org.omg.CosNaming.NamingContextExt nc = SessionService._get_naming();
23: NamingContextExt nc = NamingContextExtHelper.narrow(orb
24: .resolve_initial_references("NameService"));
25: NameComponent[] name = new NameComponent[1];
26: name[0] = new NameComponent("LogicLand", "transaction");
27:
28: if (nc == null) {
29: System.out.println("null");
30: System.exit(0);
31: }
32: ;
33:
34: nc.bind(name, TransactionService.get_reference());
35:
36: LockSetFactoryImpl lsf = new LockSetFactoryImpl(poa);
37:
38: name[0] = new NameComponent("LogicLand", "lock");
39: nc.bind(name, poa.servant_to_reference(lsf));
40:
41: TransactionalLockSet ls = lsf.create_transactional();
42: name[0] = new NameComponent("LogicLand", "lockset");
43: nc.bind(name, ls);
44: /*
45: Session ss = SessionService.get_reference();
46: ReferenceServer ref_server = new ReferenceServer(ss, 9000);
47: Thread refsrv_thr = new Thread(ref_server);
48: refsrv_thr.start();
49: */
50: System.out.println("Server is ready");
51: System.out.println("Do with client program instructions.");
52: System.out
53: .println("Print result will displayed on this screen.");
54: orb.run();
55:
56: } catch (Exception e) {
57: e.printStackTrace();
58: System.exit(0);
59: }
60: }
61: };
|