db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1371041 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
Date Thu, 09 Aug 2012 05:23:11 GMT
Author: mamta
Date: Thu Aug  9 05:23:11 2012
New Revision: 1371041

URL: http://svn.apache.org/viewvc?rev=1371041&view=rev
Log:
DERBY-5240 (Log Operating system information to derby.log on boot)

Adding following piece of information into derby.log for OS right after the existing info
about JVM
OS name=XXX 
OS architecture=YYY 
OS version=ZZZ 



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java?rev=1371041&r1=1371040&r2=1371041&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java
Thu Aug  9 05:23:11 2012
@@ -135,6 +135,8 @@ public class BaseDataFileFactory
 	
 	private     String          jvmVersion;
 	
+	private     String          osInfo;
+	
 	private     String          jarCPath;
 
 	private     RawStoreFactory	rawStoreFactory; // associated raw store factory
@@ -261,6 +263,8 @@ public class BaseDataFileFactory
 		
 		jvmVersion = buildJvmVersion();
 		
+		osInfo = buildOSinfo();
+		
 		jarCPath = jarClassPath(getClass());
 
 		dataDirectory = startParams.getProperty(PersistentService.ROOT);
@@ -368,6 +372,9 @@ public class BaseDataFileFactory
 		//Log the JVM version info
 		logMsg(jvmVersion);
 
+		//Log the OS info
+		logMsg(osInfo);
+
 		//Log derby.system.home It will have null value if user didn't set it
 		logMsg(Property.SYSTEM_HOME_PROPERTY+"=" + 
 				PropertyUtil.getSystemProperty(Property.SYSTEM_HOME_PROPERTY));
@@ -2154,6 +2161,32 @@ public class BaseDataFileFactory
         });
     }
     
+    /**
+     * Return values of system properties that identify the OS.
+     * Will catch SecurityExceptions and note them for displaying information.
+     * @return the Java system property value for the OS or a string capturing a
+     * security exception.
+     */
+    private static String buildOSinfo () {
+    	return (String)AccessController.doPrivileged(new PrivilegedAction(){
+    		public Object run() {
+    			String osInfo = "";
+    			try {
+    				String currentProp = PropertyUtil.getSystemProperty("os.name");
+    				if (currentProp != null)
+    					osInfo = "os.name="+currentProp+"\n";
+    				if ((currentProp = PropertyUtil.getSystemProperty("os.arch")) != null)
+    					osInfo += "os.arch="+currentProp+"\n";
+    				if ((currentProp = PropertyUtil.getSystemProperty("os.version")) != null)
+    					osInfo += "os.version="+currentProp;
+    			}
+    			catch(SecurityException se){
+    				return se.getMessage();
+    			}
+    			return osInfo;
+    		}
+    	});
+    }
     
     /**
      * Return values of system properties that identify the JVM. 



Mime
View raw message