1 package demo.bank.transaction.explicit; 2 3 4 5 import org.omg.CORBA.*; 6 7 import org.omg.CORBA.ORBPackage.*; 8 9 import org.omg.CosTransactions.*; 10 11 import org.omg.CosNaming.*; 12 13 import java.io.*; 14 15 16 17 public class Server 18 19 { 20 21 public static void main( String [] args ) 22 23 { 24 25 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); 26 27 try 28 29 { 30 31 org.omg.PortableServer.POA poa = 32 33 org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 34 35 36 37 poa.the_POAManager().activate(); 38 39 40 41 org.omg.CORBA.Object o = poa.servant_to_reference(new BankImpl(orb,poa)); 42 43 44 45 if( args.length == 1 ) 46 47 { 48 49 51 52 53 PrintWriter ps = new PrintWriter(new FileOutputStream(new File( args[0] ))); 54 55 ps.println( orb.object_to_string( o ) ); 56 57 ps.close(); 58 59 } 60 61 else 62 63 { 64 65 NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); 66 67 NameComponent [] name = new NameComponent[1]; 68 69 name[0] = new NameComponent( "DigiBank", "server"); 70 71 nc.bind(name, o); 72 73 } 74 75 } 76 77 catch ( Exception e ) 78 79 { 80 81 e.printStackTrace(); 82 83 } 84 85 orb.run(); 86 87 } 88 89 90 91 92 93 } 94 95 96 97 | Popular Tags |