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 [] args ) 12 { 13 try 14 { 15 16 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); 17 org.omg.PortableServer.POA 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 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 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 e ){ 60 e.printStackTrace(); 61 System.exit(0); 62 } 63 } 64 }; 65 66 | Popular Tags |