[jboss-cvs] JBossAS SVN: r87742 - in projects/bootstrap/trunk/impl-as/src: main/java/org/jboss/bootstrap/impl/as/server and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 23 20:02:17 EDT 2009


Author: ALRubinger
Date: 2009-04-23 20:02:17 -0400 (Thu, 23 Apr 2009)
New Revision: 87742

Modified:
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
Log:
[JBBOOT-31] Added support for jboss.server.conf.url

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -94,6 +94,11 @@
     */
    private URL serverLogLocation;
 
+   /**
+    * Location in which the server configuration resides
+    */
+   private URL serverConfigLocation;
+
    //-------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -473,6 +478,56 @@
       return this.covarientReturn();
    }
 
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerConfigLocation()
+    */
+   public URL getServerConfLocation()
+   {
+      return this.serverConfigLocation;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverConfigLocation(java.lang.String)
+    */
+   public JBossASServerConfig serverConfLocation(String serverConfigLocation) throws IllegalArgumentException
+   {
+      // If null, just pass along
+      if (serverConfigLocation == null)
+      {
+         return this.serverConfigLocation((URL) null);
+      }
+
+      // Convert this String into a URL via File
+      final File file = new File(serverConfigLocation);
+      URL url = null;
+      try
+      {
+         url = file.toURI().toURL();
+      }
+      catch (MalformedURLException e)
+      {
+         throw new IllegalArgumentException("Cannot construct URL given: " + serverConfigLocation, e);
+      }
+
+      // Return
+      return this.serverConfigLocation(url);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverConfigLocation(java.net.URL)
+    */
+   public JBossASServerConfig serverConfigLocation(URL serverConfigLocation)
+   {
+      // Set
+      this.serverConfigLocation = serverConfigLocation;
+
+      // Set properties
+      this.setPropertyForUrl(PROP_KEY_JBOSSAS_SERVER_CONF_URL, serverConfigLocation);
+
+      // Return
+      return this.covarientReturn();
+   }
+
    //-------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------||
    //-------------------------------------------------------------------------------||

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -88,4 +88,10 @@
     * {@link JBossASServerConfig#PROP_KEY_JBOSSAS_SERVER_LOG_DIR}.
     */
    String DEFAULT_VALUE_SERVER_LOG_DIR_SUFFIX = "log/";
+
+   /**
+    * The suffix used when generating the default value for 
+    * {@link JBossASServerConfig#PROP_KEY_JBOSSAS_SERVER_CONF_URL}.
+    */
+   String DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX = "conf/";
 }

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -147,6 +147,17 @@
       resolvedServerLogLocation = this.adjustToTrailingSlash(resolvedServerLogLocation);
       config.serverLogLocation(resolvedServerLogLocation);
 
+      // ${jboss.server.conf.url}
+      final URL serverConfLocation = config.getServerConfLocation();
+      final String serverConfDefault = resolvedServerHomeLocation
+            + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX;
+      final String currentServerConfLocation = serverConfLocation != null ? serverConfLocation.toExternalForm() : null;
+      String resolvedServerConfLocation = this.resolvePropertyValue(
+            JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL, currentServerConfLocation, serverConfDefault,
+            configProps);
+      resolvedServerConfLocation = this.adjustToTrailingSlash(resolvedServerConfLocation);
+      config.serverConfLocation(resolvedServerConfLocation);
+
    }
 
    //-------------------------------------------------------------------------------||

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -89,6 +89,8 @@
       this.require(config.getCommonBaseLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL);
       // jboss.server.log.dir
       this.require(config.getServerLogLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_LOG_DIR);
+      // jboss.server.conf.dir
+      this.require(config.getServerConfLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL);
 
       // Log
       log.debug("Configuration is valid: " + config);

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -125,6 +125,12 @@
     */
    String PROP_KEY_JBOSSAS_SERVER_LOG_DIR = "jboss.server.log.dir";
 
+   /**
+    * Constant that holds the name of the system property
+    * for specifying the server configuration URL.
+    */
+   String PROP_KEY_JBOSSAS_SERVER_CONF_URL = "jboss.server.config.url";
+
    //-------------------------------------------------------------------------------||
    // Contracts --------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -320,4 +326,29 @@
     *    is non-null and cannot be constructed into a URL
     */
    JBossASServerConfig serverLogLocation(String serverLogLocation) throws IllegalArgumentException;
+
+   /**
+    * Obtains the location in which the server configuration resides
+    * 
+    * @return
+    */
+   URL getServerConfLocation();
+
+   /**
+    * Sets the location in which the server configuration resides
+    * 
+    * @param serverConfigLocation
+    * @return
+    */
+   JBossASServerConfig serverConfigLocation(URL serverConfigLocation);
+
+   /**
+    * Sets the location in which the server configuration resides
+    * 
+    * @param serverConfigLocation
+    * @return
+    * @throws IllegalArgumentException If the specified argument 
+    *    is non-null and cannot be constructed into a URL
+    */
+   JBossASServerConfig serverConfLocation(String serverConfigLocation) throws IllegalArgumentException;
 }

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -97,14 +97,6 @@
 
    /**
     * Constant that holds the name of the environment property
-    * for specifying the server configuration URL.
-    *
-    * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/conf</tt> .
-    */
-   String PROP_KEY_JBOSSAS_SERVER_CONFIG_URL = "jboss.server.config.url";
-
-   /**
-    * Constant that holds the name of the environment property
     * for specifying the URL where JBoss will read server specific
     * library files from.
     *
@@ -170,11 +162,6 @@
    /////////////////////////////////////////////////////////////////////////
 
    /**
-    * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_CONFIG_URL}.
-    */
-   String DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX = "conf/";
-
-   /**
     * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_DATA_DIR}.
     */
    String DEFAULT_VALUE_SERVER_DATA_DIR_SUFFIX = "data";

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -97,6 +97,7 @@
       final String serverHomeDir = this.getAbsoluteLocationOfUrl(serverHomeUrl);
       final URL commonBaseUrl = configuration.getCommonBaseLocation();
       final String serverLogDir = this.getAbsoluteLocationOfUrl(configuration.getServerLogLocation());
+      final URL serverConfDir = configuration.getServerConfLocation();
 
       // Set our system properties
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME, jbossHomeDir);
@@ -111,6 +112,7 @@
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_DIR, serverHomeDir);
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL, commonBaseUrl);
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_LOG_DIR, serverLogDir);
+      this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL, serverConfDir);
    }
 
    //-------------------------------------------------------------------------------||

Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -275,6 +275,28 @@
       log.info("Got expected: " + expected);
    }
 
+   /**
+    * Ensures that the server log location defaults to $JBOSS_HOME/server/$serverName/conf
+    * @throws Throwable
+    */
+   @Test
+   public void testServerConfDefault() throws Throwable
+   {
+      // Log
+      log.info("testServerConfDefault");
+
+      // Get out server base location
+      final String actual = config.getServerConfLocation().toExternalForm();
+
+      // Get expected value
+      final String expected = this.getServerHomeLocation()
+            + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX;
+
+      // Test
+      TestCase.assertEquals("Server config location was not defaulted as expected", expected, actual);
+      log.info("Got expected: " + expected);
+   }
+
    //-------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------||
    //-------------------------------------------------------------------------------||

Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -315,6 +315,23 @@
       this.assertMissingValueFails(config, "server log location");
    }
 
+   /**
+    * Ensures that an empty/null Server Config location fails
+    */
+   @Test
+   public void testNoServerConfigLocationFails()
+   {
+      // Log
+      log.info("testNoServerConfigLocationFails");
+
+      // Get config and clear out
+      final JBossASServerConfig config = this.config;
+      config.serverConfigLocation((URL) null);
+
+      // Test
+      this.assertMissingValueFails(config, "server config location");
+   }
+
    //-------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -368,11 +385,13 @@
       final String serverHome = serverBase + serverName + "/";
       final String commonBase = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX;
       final String serverLog = serverHome + JBossASConfigurationInitializer.DEFAULT_VALUE_LIBRARY_URL_SUFFIX;
+      final String serverConfig = serverHome + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX;
 
       // Populate
       config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bindAddress(bindAddress)
             .serverName(serverName).bootLibraryLocation(bootLib).serverBaseLocation(serverBase).serverHomeLocation(
-                  serverHome).commonBaseLocation(commonBase).serverLogLocation(serverLog);
+                  serverHome).commonBaseLocation(commonBase).serverLogLocation(serverLog).serverConfLocation(
+                  serverConfig);
 
       // Return
       return config;

Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java	2009-04-23 23:36:11 UTC (rev 87741)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java	2009-04-24 00:02:17 UTC (rev 87742)
@@ -128,6 +128,7 @@
       final String serverHomeDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_DIR;
       final String commonBaseUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL;
       final String serverLogDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_LOG_DIR;
+      final String serverConfUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL;
 
       // Get Properties from Configuration
       final Map<String, String> properties = configuration.getProperties();
@@ -143,6 +144,7 @@
       final String serverHomeDirFromConfProp = properties.get(serverHomeDirPropKey);
       final String commonBaseUrlFromConfProp = properties.get(commonBaseUrlPropKey);
       final String serverLogDirFromConfProp = properties.get(serverLogDirPropKey);
+      final String serverConfUrlFromConfProp = properties.get(serverConfUrlPropKey);
 
       // Get Properties from System
       final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
@@ -157,6 +159,7 @@
       final String serverHomeDirFromSystem = System.getProperty(serverHomeDirPropKey);
       final String commonBaseUrlFromSystem = System.getProperty(commonBaseUrlPropKey);
       final String serverLogDirFromSystem = System.getProperty(serverLogDirPropKey);
+      final String serverConfUrlFromSystem = System.getProperty(serverConfUrlPropKey);
 
       // Get Expected Values
       final URL jbossHomeFromConf = configuration.getJBossHome();
@@ -178,6 +181,7 @@
       final URL serverLogFromConf = configuration.getServerLogLocation();
       final File serverLogFile = new File(serverLogFromConf.toURI());
       final String serverLogDirFromConf = serverLogFile.getAbsolutePath();
+      final String serverConfUrlFromConf = configuration.getServerConfLocation().toExternalForm();
 
       // Ensure all equal
       TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeDirFromConf,
@@ -228,6 +232,10 @@
             serverLogDirFromConfProp);
       TestCase.assertEquals("Server Log Dir in configuration must match the system property", serverLogDirFromConf,
             serverLogDirFromSystem);
+      TestCase.assertEquals("Server Conf URL in configuration must match the config property", serverConfUrlFromConf,
+            serverConfUrlFromConfProp);
+      TestCase.assertEquals("Server Conf URL in configuration must match the system property", serverConfUrlFromConf,
+            serverConfUrlFromSystem);
 
       // Cleanup
       server.shutdown();
@@ -245,6 +253,7 @@
       final String serverHomeDirFromSystemAfterCleanup = System.getProperty(serverHomeDirPropKey);
       final String commonBaseUrlFromSystemAfterCleanup = System.getProperty(commonBaseUrlPropKey);
       final String serverLogDirFromSystemAfterCleanup = System.getProperty(serverLogDirPropKey);
+      final String serverConfUrlFromSystemAfterCleanup = System.getProperty(serverConfUrlPropKey);
 
       // Ensure all null
       final String failMessage = "System property should be null after cleanup";
@@ -260,5 +269,6 @@
       TestCase.assertNull(failMessage, serverHomeDirFromSystemAfterCleanup);
       TestCase.assertNull(failMessage, commonBaseUrlFromSystemAfterCleanup);
       TestCase.assertNull(failMessage, serverLogDirFromSystemAfterCleanup);
+      TestCase.assertNull(failMessage, serverConfUrlFromSystemAfterCleanup);
    }
 }




More information about the jboss-cvs-commits mailing list