1 7 8 18 19 20 package javax.rmi.CORBA; 21 22 import java.io.IOException ; 23 import java.io.File ; 24 import java.io.FileInputStream ; 25 26 import java.security.AccessController ; 27 import java.security.PrivilegedAction ; 28 import sun.security.action.GetPropertyAction; 29 import java.util.Properties ; 30 31 class GetORBPropertiesFileAction implements PrivilegedAction { 32 private boolean debug = false ; 33 34 public GetORBPropertiesFileAction () { 35 } 36 37 private String getSystemProperty(final String name) { 38 String propValue = (String ) AccessController.doPrivileged( 41 new PrivilegedAction () { 42 public java.lang.Object run() { 43 return System.getProperty(name); 44 } 45 } 46 ); 47 48 return propValue; 49 } 50 51 private void getPropertiesFromFile( Properties props, String fileName ) 52 { 53 try { 54 File file = new File ( fileName ) ; 55 if (!file.exists()) 56 return ; 57 58 FileInputStream in = new FileInputStream ( file ) ; 59 60 try { 61 props.load( in ) ; 62 } finally { 63 in.close() ; 64 } 65 } catch (Exception exc) { 66 if (debug) 67 System.out.println( "ORB properties file " + fileName + 68 " not found: " + exc) ; 69 } 70 } 71 72 public Object run() 73 { 74 Properties defaults = new Properties () ; 75 76 String javaHome = getSystemProperty( "java.home" ) ; 77 String fileName = javaHome + File.separator + "lib" + File.separator + 78 "orb.properties" ; 79 80 getPropertiesFromFile( defaults, fileName ) ; 81 82 Properties results = new Properties ( defaults ) ; 83 84 String userHome = getSystemProperty( "user.home" ) ; 85 fileName = userHome + File.separator + "orb.properties" ; 86 87 getPropertiesFromFile( results, fileName ) ; 88 return results ; 89 } 90 } 91 | Popular Tags |