Author: mturk
Date: Tue Apr  7 13:23:42 2009
New Revision: 762765

URL: http://svn.apache.org/viewvc?rev=762765&view=rev
Log:
OS class. Majority of this info is available by using various system properties,
but things like WOW64 are not withouth some serious hacking. This class makes 
sure the returned info matches the running OS

Added:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java  
 (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr.h

Added: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java?rev=762765&view=auto
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java 
(added)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java 
Tue Apr  7 13:23:42 2009
@@ -0,0 +1,111 @@
+/*
+ *  SIGHT - System information gathering hybrid tool
+ *
+ *  Copyright(c) 2007 Red Hat Middleware, LLC,
+ *  and individual contributors as indicated by the @authors tag.
+ *  See the copyright.txt in the distribution for a
+ *  full listing of individual contributors.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library in the file COPYING.LIB;
+ *  if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ */
+package org.jboss.sight;
+
+/** OS
+ *
+ * @author Mladen Turk
+ *
+ */
+public final class OS {
+
+    /* OS Enums */
+    private static final int WINDOWS       = 0x1000;
+    private static final int WIN64         = 0x1001;
+    private static final int WOW64         = 0x1002;
+    private static final int UNIX          = 0x2000;
+    private static final int LINUX         = 0x2001;
+    private static final int SOLARIS       = 0x2002;
+    private static final int DARWIN        = 0x2004;
+    private static final int HPUX          = 0x2008;
+
+    /**
+     * Check for OS type.
+     * @param type OS type to test.
+     */
+    private static native boolean is(int type);
+
+    /**
+     * True if the operating system is unix family
+     * operating system.
+     */
+    public static final boolean IS_UNIX    = is(UNIX);
+    /**
+     * True if the operating system is Microsoft Windows family
+     * operating system.
+     */
+    public static final boolean IS_WINDOWS = is(WINDOWS);
+    /**
+     * True if the operating system is Microsoft Windows 64.
+     */
+    public static final boolean IS_WIN64   = is(WIN64);
+    /**
+     * True if the operating system is Microsoft Windows 64
+     * running 32-bit JVM.
+     */
+    public static final boolean IS_WOW64   = is(WOW64);
+    /**
+     * True if the operating system is Linux.
+     */
+    public static final boolean IS_LINUX   = is(LINUX);
+    /**
+     * True if the operating system is Sun Solaris.
+     */
+    public static final boolean IS_SOLARIS = is(SOLARIS);
+    /**
+     * True if the operating system is Mac OS X.
+     */
+    public static final boolean IS_DARWIN  = is(DARWIN);
+    /**
+     * True if the operating system is HP-UX.
+     */
+    public static final boolean IS_HPUX    = is(HPUX);
+
+    /**
+     * Name of the operating system implementation.
+     */
+    public static native String getSysname();
+
+    /**
+     * Network name of this machine.
+     */
+    public static native String getNodename();
+
+    /**
+     * Release level of the operating system.
+     */
+    public static native String getRelease();
+
+    /**
+     * Version level of the operating system.
+     */
+    public static native String getVersion();
+
+    /**
+     * Machine hardware platform.
+     */
+    public static native String getMachine();
+
+}

Propchange: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/OS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=762765&r1=762764&r2=762765&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Tue Apr  7 
13:23:42 2009
@@ -231,7 +231,7 @@
 
 #define ACR_OS_WINDOWS                    0x1000
 #define ACR_OS_WIN64                      0x1001
-#define ACR_OS_WIN64                      0x1002
+#define ACR_OS_WOW64                      0x1002
 #define ACR_OS_UNIX                       0x2000
 #define ACR_OS_LINUX                      0x2001
 #define ACR_OS_SOLARIS                    0x2002


Reply via email to