KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > concurrency > Server


1 package demo.concurrency;
2
3 import org.jacorb.concurrency.*;
4 import org.jacorb.transaction.*;
5 import org.omg.CosNaming.*;
6
7 import org.omg.CosConcurrencyControl.*;
8
9 public class Server
10 {
11     public static void main( String JavaDoc [] args )
12     {
13         try
14     {
15
16             org.omg.CORBA.ORB JavaDoc orb = org.omg.CORBA.ORB.init(args, null);
17             org.omg.PortableServer.POA JavaDoc poa =
18                 org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
19
20         poa.the_POAManager().activate();
21
22             TransactionService.start( poa, 100 );
23
24         // SessionService.start(poa, 5);
25
// org.omg.CosNaming.NamingContextExt nc = SessionService._get_naming();
26
NamingContextExt nc =
27                 NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
28             NameComponent [] name = new NameComponent[1];
29             name[0] =
30                 new NameComponent( "LogicLand", "transaction");
31
32             if( nc == null )
33             {
34                 System.out.println( "null" );
35                 System.exit(0);
36             };
37
38             nc.bind(name, TransactionService.get_reference());
39
40             LockSetFactoryImpl lsf = new LockSetFactoryImpl( poa );
41
42             name[0] = new NameComponent( "LogicLand", "lock");
43             nc.bind(name, poa.servant_to_reference( lsf ));
44
45             TransactionalLockSet ls = lsf.create_transactional();
46             name[0] = new NameComponent( "LogicLand", "lockset");
47             nc.bind(name, ls );
48         /*
49           Session ss = SessionService.get_reference();
50           ReferenceServer ref_server = new ReferenceServer(ss, 9000);
51           Thread refsrv_thr = new Thread(ref_server);
52           refsrv_thr.start();
53         */

54             System.out.println( "Server is ready" );
55             System.out.println( "Do with client program instructions." );
56             System.out.println( "Print result will displayed on this screen." );
57             orb.run();
58
59         } catch ( Exception JavaDoc e ){
60             e.printStackTrace();
61             System.exit(0);
62         }
63     }
64 };
65
66
Popular Tags