[jboss-cvs] JBossAS SVN: r88666 - in branches/Branch_5_x_BootstrapLegacyRemoval: main/src/resources and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 11 15:10:12 EDT 2009


Author: ALRubinger
Date: 2009-05-11 15:10:12 -0400 (Mon, 11 May 2009)
New Revision: 88666

Modified:
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-debug.properties
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-trace.properties
   branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j.properties
   branches/Branch_5_x_BootstrapLegacyRemoval/system-jmx/src/main/org/jboss/system/server/ServerConfigImpl.java
   branches/Branch_5_x_BootstrapLegacyRemoval/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java
Log:
[JBAS-6856] Update Main to pass all properties to the server before initialization, properly configure boot.log

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java	2009-05-11 19:10:12 UTC (rev 88666)
@@ -34,9 +34,11 @@
 import java.net.URLClassLoader;
 import java.net.URLDecoder;
 import java.net.UnknownHostException;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
@@ -137,7 +139,7 @@
     * information to get the server up and running. Use System
     * properties for defaults.
     */
-   private Properties props = new Properties(System.getProperties());
+   private Map<String,String> props = new HashMap<String, String>();
 
    /** 
     * The booted server instance. 
@@ -155,6 +157,11 @@
     * The FQN of the default server implementation class to create
     */
    private static final String DEFAULT_AS_SERVER_IMPL_CLASS_NAME = "org.jboss.bootstrap.impl.as.server.JBossASServerImpl";
+   
+   /**
+    * The name of the system property denoting where the boot.log will be placed
+    */
+   private static final String SYS_PROP_BOOT_LOG_DIR_NAME = "jboss.boot.server.log.dir";
 
    /**
     * Explicit constructor.
@@ -162,6 +169,15 @@
    public Main()
    {
       super();
+      
+      // Set default properties
+      final Properties sysProps = System.getProperties();
+      for (final Object propName : sysProps.keySet())
+      {
+         final String propNameString = (String) propName;
+         final String propValue = (String) sysProps.get(propNameString);
+         props.put(propNameString, propValue);
+      }
    }
 
    /**
@@ -189,12 +205,12 @@
       String name = System.getProperty("java.util.logging.manager");
       if (name == null)
       {
-         System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
+         SecurityActions.setSystemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
       }
 
       // Get JBOSS_HOME appropriately  
-      final String homeUrl = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL);
-      final String homeDir = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR);
+      final String homeUrl = props.get(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL);
+      final String homeDir = props.get(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR);
       URL jbossHome = null;
       // We've been given home URL
       if (homeUrl != null)
@@ -228,7 +244,7 @@
       }
       
       // Get Library URL
-      String libUrlFromProp = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL);
+      String libUrlFromProp = props.get(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL);
       URL libUrl = null;
       if (libUrlFromProp != null)
       {
@@ -239,6 +255,28 @@
          libUrl = new URL(jbossHome, JBossASConfigurationInitializer.VALUE_LIBRARY_URL_SUFFIX_DEFAULT);
       }
       
+      /*
+       * Set boot log directory
+       */
+      final String sysPropBootLogDir = SYS_PROP_BOOT_LOG_DIR_NAME;
+      final String sysPropLogDir = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_LOG_DIR;
+      final String serverName = props.get(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME);
+      final String manualBootLogDir = props.get(sysPropBootLogDir);
+      final String manualLogDir = props.get(sysPropLogDir);
+      // If nothing's been explicitly specified
+      if (manualBootLogDir == null && manualLogDir == null)
+      {
+         // We default it
+         final URL serverLog = new URL(jbossHome, "server/" + serverName + "/log/");
+         final File serverLogFile = new File(serverLog.toURI());
+         final String serverLogString = serverLogFile.getAbsolutePath();
+         SecurityActions.setSystemProperty(sysPropBootLogDir, serverLogString);
+      }
+      // If we've got a manual log dir, use it
+      else if (manualLogDir != null)
+      {
+         SecurityActions.setSystemProperty(sysPropBootLogDir, manualLogDir);
+      }
       
       // Get TCCL
       final ClassLoader tccl = SecurityActions.getThreadContextClassLoader();
@@ -331,8 +369,8 @@
       // Get out the default configuration
       JBossASServerConfig config = (JBossASServerConfig) server.getConfiguration();
       
-      // Set JBOSS_HOME
-      config.jbossHome(jbossHome);
+      // Set JBOSS_HOME and properties
+      config.properties(props).jbossHome(jbossHome);
 
       try
       {
@@ -437,7 +475,7 @@
       Getopt getopt = new Getopt(programName, args, sopts, lopts);
       int code;
       String arg;
-      props.setProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, "127.0.0.1");
+      props.put(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, "127.0.0.1");
       System.setProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, "127.0.0.1");
       while ((code = getopt.getopt()) != -1)
       {

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java	2009-05-11 19:10:12 UTC (rev 88666)
@@ -68,6 +68,31 @@
    }
 
    /**
+    * Obtains the system property with the specified key
+    * 
+    * @param key
+    * @return
+    * @throws IllegalArgumentException If the key is null
+    */
+   static String getSystemProperty(final String key) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (key == null)
+      {
+         throw new IllegalArgumentException("key was null");
+      }
+
+      // Get sysprop
+      return AccessController.doPrivileged(new PrivilegedAction<String>()
+      {
+         public String run()
+         {
+            return System.getProperty(key);
+         }
+      });
+   }
+
+   /**
     * Obtains the Thread Context ClassLoader
     */
    static ClassLoader getThreadContextClassLoader()

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-debug.properties
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-debug.properties	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-debug.properties	2009-05-11 19:10:12 UTC (rev 88666)
@@ -10,7 +10,7 @@
 
 ### A bootstrap file appender
 log4j.appender.FILE=org.jboss.logging.appender.FileAppender
-log4j.appender.FILE.File=${jboss.server.log.dir}/boot.log
+log4j.appender.FILE.File=${jboss.boot.server.log.dir}/boot.log
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
 log4j.appender.FILE.Append=false

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-trace.properties
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-trace.properties	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j-trace.properties	2009-05-11 19:10:12 UTC (rev 88666)
@@ -10,7 +10,7 @@
 
 ### A bootstrap file appender
 log4j.appender.FILE=org.jboss.logging.appender.FileAppender
-log4j.appender.FILE.File=${jboss.server.log.dir}/boot.log
+log4j.appender.FILE.File=${jboss.boot.server.log.dir}/boot.log
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
 log4j.appender.FILE.Append=false

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j.properties
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j.properties	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/resources/log4j.properties	2009-05-11 19:10:12 UTC (rev 88666)
@@ -10,7 +10,7 @@
 
 ### A bootstrap file appender
 log4j.appender.FILE=org.jboss.logging.appender.FileAppender
-log4j.appender.FILE.File=${jboss.server.log.dir}/boot.log
+log4j.appender.FILE.File=${jboss.boot.server.log.dir}/boot.log
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
 log4j.appender.FILE.Append=false

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/system/src/tests/org/jboss/test/server/profileservice/support/MockServerConfig.java	2009-05-11 19:10:12 UTC (rev 88666)
@@ -23,6 +23,7 @@
 
 import java.net.URL;
 import java.util.Map;
+import java.util.Properties;
 
 import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
 
@@ -426,6 +427,25 @@
       // TODO Auto-generated method stub
       return null;
    }
+
+   public String getProperty(String arg0) throws IllegalArgumentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public JBossASServerConfig properties(Map<String, String> arg0) throws IllegalArgumentException,
+         IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public JBossASServerConfig properties(Properties arg0) throws IllegalArgumentException, IllegalStateException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
    
   
 

Modified: branches/Branch_5_x_BootstrapLegacyRemoval/system-jmx/src/main/org/jboss/system/server/ServerConfigImpl.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/system-jmx/src/main/org/jboss/system/server/ServerConfigImpl.java	2009-05-11 18:52:32 UTC (rev 88665)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/system-jmx/src/main/org/jboss/system/server/ServerConfigImpl.java	2009-05-11 19:10:12 UTC (rev 88666)
@@ -23,6 +23,7 @@
 
 import java.net.URL;
 import java.util.Map;
+import java.util.Properties;
 
 import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
 
@@ -410,4 +411,22 @@
       return this;
    }
 
+   public String getProperty(String arg0) throws IllegalArgumentException
+   {
+      return config.getProperty(arg0);
+   }
+
+   public JBossASServerConfig properties(Map<String, String> arg0) throws IllegalArgumentException,
+         IllegalStateException
+   {
+      config.properties(arg0);
+      return this;
+   }
+
+   public JBossASServerConfig properties(Properties arg0) throws IllegalArgumentException, IllegalStateException
+   {
+      config.properties(arg0);
+      return this;
+   }
+
 }




More information about the jboss-cvs-commits mailing list