1 7 8 package com.sun.corba.se.impl.naming.pcosnaming; 9 10 import java.io.File ; 11 import java.util.Properties ; 12 13 import com.sun.corba.se.impl.orbutil.ORBConstants; 14 import com.sun.corba.se.impl.orbutil.CorbaResourceUtil; 15 import com.sun.corba.se.spi.orb.ORB; 16 import com.sun.corba.se.spi.activation.InitialNameService; 17 import com.sun.corba.se.spi.activation.InitialNameServiceHelper; 18 import org.omg.CosNaming.NamingContext ; 19 29 30 public class NameServer 31 { 32 private ORB orb; 33 34 private File dbDir; 36 private final static String dbName = "names.db"; 37 38 public static void main(String args[]) 39 { 40 NameServer ns = new NameServer(args); 41 ns.run(); 42 } 43 44 protected NameServer(String args[]) 45 { 46 java.util.Properties props = System.getProperties(); 48 props.put( ORBConstants.SERVER_ID_PROPERTY, "1000" ) ; 49 props.put("org.omg.CORBA.ORBClass", 50 "com.sun.corba.se.impl.orb.ORBImpl"); 51 orb = (ORB) org.omg.CORBA.ORB.init(args,props); 52 53 String dbDirName = props.getProperty( ORBConstants.DB_DIR_PROPERTY ) + 55 props.getProperty("file.separator") + dbName + 56 props.getProperty("file.separator"); 57 58 dbDir = new File (dbDirName); 59 if (!dbDir.exists()) dbDir.mkdir(); 60 } 61 62 protected void run() 63 { 64 try { 65 66 NameService ns = new NameService(orb, dbDir); 68 69 NamingContext rootContext = ns.initialNamingContext(); 71 InitialNameService ins = InitialNameServiceHelper.narrow( 72 orb.resolve_initial_references( 73 ORBConstants.INITIAL_NAME_SERVICE_NAME )); 74 ins.bind( "NameService", rootContext, true); 75 System.out.println(CorbaResourceUtil.getText("pnameserv.success")); 76 77 orb.run(); 79 80 } catch (Exception ex) { 81 82 ex.printStackTrace(System.err); 83 } 84 } 85 86 } 87 | Popular Tags |