geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r639435 - in /geronimo/server/branches/2.1: framework/configs/offline-deployer/src/main/plan/ framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/ framework/modules/geronimo-system/src/main/java/org/apac...
Date Thu, 20 Mar 2008 20:09:04 GMT
Author: dwoods
Date: Thu Mar 20 13:09:03 2008
New Revision: 639435

URL: http://svn.apache.org/viewvc?rev=639435&view=rev
Log:
GERONIMO-3900 Add runtime support for non-Sun JVMs

Added:
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java
  (with props)
Modified:
    geronimo/server/branches/2.1/framework/configs/offline-deployer/src/main/plan/plan.xml
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
    geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/SystemProperties.java
    geronimo/server/branches/2.1/plugins/client/client/src/main/plan/plan.xml
    geronimo/server/branches/2.1/plugins/j2ee/j2ee-server/src/main/plan/plan.xml

Modified: geronimo/server/branches/2.1/framework/configs/offline-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/configs/offline-deployer/src/main/plan/plan.xml?rev=639435&r1=639434&r2=639435&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/configs/offline-deployer/src/main/plan/plan.xml
(original)
+++ geronimo/server/branches/2.1/framework/configs/offline-deployer/src/main/plan/plan.xml
Thu Mar 20 13:09:03 2008
@@ -31,7 +31,16 @@
     <!-- System Properties -->
     <gbean name="OfflineDeployerProperties" class="org.apache.geronimo.system.properties.SystemProperties">
         <attribute name="systemProperties">
-             org.apache.geronimo.deployment.util.DeploymentUtil.jarUrlRewrite=true
+           org.apache.geronimo.deployment.util.DeploymentUtil.jarUrlRewrite=true
         </attribute>
+         <attribute name="sunSystemProperties">
+             java.security.Provider=SUN
+         </attribute>
+         <attribute name="ibmSystemProperties">
+             java.security.Provider=IBMCertPath
+         </attribute>
+         <attribute name="apacheSystemProperties">
+             java.naming.factory.url.pkgs=org.apache.harmony.jndi.provider
+         </attribute>
     </gbean>
 </module>

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java?rev=639435&r1=639434&r2=639435&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
Thu Mar 20 13:09:03 2008
@@ -51,6 +51,7 @@
 import org.apache.geronimo.kernel.log.GeronimoLogFactory;
 import org.apache.geronimo.kernel.log.GeronimoLogging;
 import org.apache.geronimo.system.logging.SystemLog;
+import org.apache.geronimo.system.properties.JvmVendor;
 import org.apache.geronimo.system.serverinfo.DirectoryUtils;
 import org.apache.geronimo.system.serverinfo.ServerConstants;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -632,7 +633,11 @@
                     ", refreshPeriodSeconds=" + this.refreshPeriod);
           log.info("Runtime Information:");
           log.info("  Install Directory = " + DirectoryUtils.getGeronimoInstallDirectory().toString());
-          log.info("  JVM in use = " + System.getProperty("java.vendor") + " Java " + System.getProperty("java.version"));
+          if (JvmVendor.isIBMHybrid()) {
+              log.info("  JVM in use = IBM Hybrid Java " + System.getProperty("java.version"));
+          } else {
+              log.info("  JVM in use = " + System.getProperty("java.vendor") + " Java " +
System.getProperty("java.version"));
+          }
           log.info("Java Information:");
           log.info("  System property [java.runtime.name]  = " + System.getProperty("java.runtime.name"));
           log.info("  System property [java.runtime.version]  = " + System.getProperty("java.runtime.version"));

Added: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java?rev=639435&view=auto
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java
(added)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java
Thu Mar 20 13:09:03 2008
@@ -0,0 +1,147 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.system.properties;
+
+import java.security.Provider;
+import java.security.Security;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Rev: 5066 $ $Date: 2007-04-27 12:07:23 -0400 (Fri, 27 Apr 2007) $
+ */
+public class JvmVendor {
+
+    private static final Log log = LogFactory.getLog(JvmVendor.class);
+
+    private static final String JVM_VENDOR_PROPERTY_NAME = "java.vm.vendor";
+
+    private static final boolean sun;
+
+    private static final boolean ibm;
+
+    private static final boolean apache;
+    
+    private static final boolean ibmHybrid;
+
+    private JvmVendor () {
+    }
+
+    static {
+        String fullVendorName = getFullName();
+        boolean bApache = fullVendorName.substring(0, 6).equalsIgnoreCase("Apache");    //
aka. Apache Harmony
+        boolean bIBM = fullVendorName.substring(0, 3)equalsIgnoreCase("IBM");           //
aka. IBM, but not IBM Hybrid
+        boolean bSun = !bIBM && !bApache;                                       
       // default all others to Sun
+        boolean bHP = fullVendorName.substring(0, 7).equalsIgnoreCase("Hewlett");       //
aka. Hewlett-Packard Company
+        boolean bIBMHybrid = false;
+        
+        // Special code for IBM Hybrid SDK (Sun JVM with IBM extensions on Solaris and HP-UX)
+        if ( ((bSun == true) && (System.getProperty("os.name").equalsIgnoreCase("SunOS")
== true)) ||
+             ((bHP == true) && (System.getProperty("os.name").equalsIgnoreCase("HP-UX")
== true)) )
+        {
+            log.debug("Looking for the IBM Hybrid SDK Extensions");
+            // Check if provider IBMJSSE Provider is installed.
+            try {
+                if (Security.getProvider("com.ibm.jsse2.IBMJSSEProvider2") == null) {
+                    // IBMJSSE Provider is not installed, install it
+                    log.debug("Trying to load IBM JSSE2 Provider.");
+                    Class c = Class.forName("com.ibm.jsse2.IBMJSSEProvider2");
+                    Provider p = (Provider) c.newInstance();
+                    Security.addProvider(p);
+                    // Security.addProvider(new com.ibm.jsse2.IBMJSSEProvider2());
+                    log.debug("Loaded the IBM JSSE2 Provider");
+                } else {
+                    log.debug("Found the IBM JSSE2 Provider = " + Security.getProvider("com.ibm.jsse2.IBMJSSEProvider2"));
+                }
+                if (Security.getProvider("IBMCertPath") == null) {
+                    // If we found IBMJSSE but not this one, then the JAVA_OPTS are probably
messed up
+                    log.debug("No IBMCertPath provider found.");
+                    throw new RuntimeException("Could not find the IBMCertPath provider.");
+                } else {
+                    log.debug("Found the IBMCertPath Provider = " + Security.getProvider("IBMCertPath"));
+                }
+                if (Security.getProvider("IBMJCE") == null) {
+                    // If we found IBMJSSE but not this one, then the JAVA_OPTS are probably
messed up
+                    log.debug("No IBMJCE provider found.");
+                    throw new RuntimeException("Could not find the IBMJCE provider.");
+                } else {
+                    log.debug("Found the IBMJCE Provider" + Security.getProvider("IBMJCE"));
+                }
+                System.setProperty("java.protocol.handler.pkgs", "com.ibm.net.ssl.www2.protocol");
+                // All of the expected IBM Extensions were found, so we must be using the
IBM Hybrid JDK
+                bSun = false;
+                bApache = false;
+                bIBM = true;
+                bIBMHybrid = true;
+            } catch (ClassNotFoundException e) {
+                // Couldn't load the IBMJSSE Provider, so we must not be using the IBM Hybrid
SDK
+                log.debug("Caught Exception="+e.toString());
+                log.debug("Could not load the IBM JSSE Provider.  Must be using the OS provider's
Java.");
+            } catch (Throwable t) {
+                // Couldn't load the IBMJSSE Provider, so we must not be using the IBM Hybrid
SDK
+                log.debug("Caught Throwable="+t.toString());
+                log.debug("Assume we could not load the IBM JSSE Provider and that we are
using the OS provider's Java.");
+            }
+        }
+        // now, set our statics
+        apache = bApache;
+        ibm = bIBM;
+        ibmHybrid = bIBMHybrid;
+        sun = bSun;
+        // log what we found
+        if (ibmHybrid == true) {
+            if (System.getProperty("os.name").equalsIgnoreCase("SunOS") == true) {
+                log.info("IBM Hybrid SDK on SunOS detected");
+            } else if (System.getProperty("os.name").equalsIgnoreCase("HP-UX") == true) {
+                log.info("IBM Hybrid SDK on HP-UX detected");
+            } else {
+                log.error("Unknown IBM Hybrid SDK detected on " + System.getProperty("os.name"));
+            }
+        } else if (apache == true) {
+            log.info("Apache JVM detected - " + fullVendorName);
+        } else if (ibm == true) {
+            log.info("IBM JVM detected - " + fullVendorName);
+        } else if (sun == true) {
+            log.info("Sun JVM detected - " + fullVendorName);
+        } else {
+            // should never happen
+            log.warn("Unhandled JVM detected - " + getFullName());
+        }
+    }
+
+    public static String getFullName() {
+        return System.getProperty(JVM_VENDOR_PROPERTY_NAME);
+    }
+
+    public static boolean isSun() {
+        return sun;
+    }
+
+    public static boolean isIBM() {
+        return ibm;
+    }
+
+    public static boolean isIBMHybrid() {
+        return ibmHybrid;
+    }
+
+    public static boolean isApache() {
+        return apache;
+    }
+
+}

Propchange: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/JvmVendor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/SystemProperties.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/SystemProperties.java?rev=639435&r1=639434&r2=639435&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/SystemProperties.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/properties/SystemProperties.java
Thu Mar 20 13:09:03 2008
@@ -20,6 +20,8 @@
 import java.util.Properties;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -29,26 +31,48 @@
  */
 public class SystemProperties {
 
+    private final Log log = LogFactory.getLog(SystemProperties.class);
 
-    public SystemProperties(Properties properties, Properties pathProperties, ServerInfo
serverInfo) {
+    public SystemProperties(Properties systemProperties, Properties systemPathProperties,
ServerInfo serverInfo, Properties sunSystemProperties, Properties ibmSystemProperties, Properties
apacheSystemProperties) {
+        if (log.isDebugEnabled()) log.debug("Setting systemProperties");
+        setProperties(systemProperties, null);
+
+        if (JvmVendor.isIBM()) {
+            if (log.isDebugEnabled()) log.debug("Setting ibmSystemProperties for the IBM
JVM");
+            setProperties(ibmSystemProperties, null);
+        } else if (JvmVendor.isApache()) {
+            if (log.isDebugEnabled()) log.debug("Setting apacheSystemProperties for the Apache
Harmony JVM");
+            setProperties(apacheSystemProperties, null);
+        } else {
+            if (log.isDebugEnabled()) log.debug("Setting sunSystemProperties for the Sun
JVM");
+            setProperties(sunSystemProperties, null);
+        }
+
+        if (serverInfo != null) {
+            if (log.isDebugEnabled()) log.debug("Setting systemPathProperties");
+            setProperties(systemPathProperties, serverInfo);
+        }
+    }
+
+    private void setProperties(Properties properties, ServerInfo serverInfo) {
         if (properties != null) {
             for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();)
{
                 Map.Entry entry = (Map.Entry) iterator.next();
                 String propertyName = (String) entry.getKey();
                 String propertyValue = (String) entry.getValue();
-                if (System.getProperty(propertyName) == null) {
-                    System.setProperty(propertyName, propertyValue);
+                if (serverInfo != null) {
+                    propertyValue = serverInfo.resolvePath(propertyValue);
                 }
-            }
-        }
-        if (pathProperties != null && serverInfo != null) {
-            for (Iterator iterator = pathProperties.entrySet().iterator(); iterator.hasNext();)
{
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String propertyName = (String) entry.getKey();
-                String propertyValue = (String) entry.getValue();
-                propertyValue = serverInfo.resolveServerPath(propertyValue);
-                if (System.getProperty(propertyName) == null) {
+                String currentPropertyValue = System.getProperty(propertyName);
+                if (currentPropertyValue == null) {
                     System.setProperty(propertyName, propertyValue);
+                    log.info("Setting Property=" + propertyName + " to Value=" + propertyValue);
+                } else {
+                    if (currentPropertyValue.equals(propertyValue)) {
+                        log.warn("Existing Property=" + propertyName + " is already set to
Value=" + currentPropertyValue);
+                    } else {
+                        log.error("Not updating existing Property=" + propertyName + " to
Value=" + propertyValue + ".  Property is already set to " + currentPropertyValue);
+                    }
                 }
             }
         }
@@ -61,7 +85,10 @@
         infoBuilder.addAttribute("systemProperties", Properties.class, true, true);
         infoBuilder.addAttribute("systemPathProperties", Properties.class, true, true);
         infoBuilder.addReference("ServerInfo", ServerInfo.class, "GBean");
-        infoBuilder.setConstructor(new String[] {"systemProperties", "systemPathProperties",
"ServerInfo"});
+        infoBuilder.addAttribute("sunSystemProperties", Properties.class, true, true);
+        infoBuilder.addAttribute("ibmSystemProperties", Properties.class, true, true);
+        infoBuilder.addAttribute("apacheSystemProperties", Properties.class, true, true);
+        infoBuilder.setConstructor(new String[] { "systemProperties", "systemPathProperties",
"ServerInfo", "sunSystemProperties", "ibmSystemProperties", "apacheSystemProperties" });
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

Modified: geronimo/server/branches/2.1/plugins/client/client/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/client/client/src/main/plan/plan.xml?rev=639435&r1=639434&r2=639435&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/client/client/src/main/plan/plan.xml (original)
+++ geronimo/server/branches/2.1/plugins/client/client/src/main/plan/plan.xml Thu Mar 20 13:09:03
2008
@@ -103,8 +103,17 @@
            javax.xml.soap.SOAPFactory=org.apache.geronimo.webservices.saaj.GeronimoSOAPFactory
            javax.xml.soap.SOAPConnectionFactory=org.apache.geronimo.webservices.saaj.GeronimoSOAPConnectionFactory
            javax.xml.soap.MetaFactory=org.apache.geronimo.webservices.saaj.GeronimoMetaFactory
-
            org.apache.cxf.jaxws.checkPublishEndpointPermission=true
+           java.net.preferIPv4Stack=true
+         </attribute>
+         <attribute name="sunSystemProperties">
+             java.security.Provider=SUN
+         </attribute>
+         <attribute name="ibmSystemProperties">
+             java.security.Provider=IBMCertPath
+         </attribute>
+         <attribute name="apacheSystemProperties">
+             java.naming.factory.url.pkgs=org.apache.harmony.jndi.provider
          </attribute>
     </gbean>
 

Modified: geronimo/server/branches/2.1/plugins/j2ee/j2ee-server/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/j2ee/j2ee-server/src/main/plan/plan.xml?rev=639435&r1=639434&r2=639435&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/j2ee/j2ee-server/src/main/plan/plan.xml (original)
+++ geronimo/server/branches/2.1/plugins/j2ee/j2ee-server/src/main/plan/plan.xml Thu Mar 20
13:09:03 2008
@@ -90,6 +90,15 @@
            org.apache.cxf.jaxws.checkPublishEndpointPermission=true
            java.net.preferIPv4Stack=true
          </attribute>
+         <attribute name="sunSystemProperties">
+             java.security.Provider=SUN
+         </attribute>
+         <attribute name="ibmSystemProperties">
+             java.security.Provider=IBMCertPath
+         </attribute>
+         <attribute name="apacheSystemProperties">
+             java.naming.factory.url.pkgs=org.apache.harmony.jndi.provider
+         </attribute>
     </gbean>
 
 </module>



Mime
View raw message