[jboss-cvs] JBossAS SVN: r87707 - 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 02:32:52 EDT 2009


Author: ALRubinger
Date: 2009-04-23 02:32:52 -0400 (Thu, 23 Apr 2009)
New Revision: 87707

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] impl-as support for jboss.lib.url init, validation, tests

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -68,6 +68,11 @@
     */
    private String serverName;
 
+   /**
+    * The AS Boot Library Location
+    */
+   private URL bootLibraryLocation;
+
    //-------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -147,11 +152,15 @@
       // Set
       this.jbossHome = jbossHome;
 
-      // If we're not clearing the value
-      if (jbossHome != null)
+      // Set properties
+      this.setPropertyForUrl(PROP_KEY_JBOSSAS_HOME_URL, jbossHome);
+      if (jbossHome == null)
       {
-         // Set properties
-         this.setPropertyForUrl(PROP_KEY_JBOSSAS_HOME_URL, jbossHome);
+         this.setPropertyForString(PROP_KEY_JBOSSAS_HOME, null);
+         this.setPropertyForString(PROP_KEY_JBOSSAS_HOME_DIR, null);
+      }
+      else
+      {
          URI jbossHomeUri;
          try
          {
@@ -194,4 +203,54 @@
       return this.jbossHome;
    }
 
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bootLibraryLocation(java.lang.String)
+    */
+   public JBossASServerConfig bootLibraryLocation(String bootLibraryLocation) throws IllegalArgumentException
+   {
+      // If null, just pass along
+      if (bootLibraryLocation == null)
+      {
+         return this.bootLibraryLocation((URL) null);
+      }
+
+      // Convert this String into a URL via File
+      final File file = new File(bootLibraryLocation);
+      URL url = null;
+      try
+      {
+         url = file.toURI().toURL();
+      }
+      catch (MalformedURLException e)
+      {
+         throw new IllegalArgumentException("Cannot construct URL given: " + bootLibraryLocation, e);
+      }
+
+      // Return
+      return this.bootLibraryLocation(url);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bootLibraryLocation(java.net.URL)
+    */
+   public JBossASServerConfig bootLibraryLocation(URL bootLibraryLocation)
+   {
+      // Set
+      this.bootLibraryLocation = bootLibraryLocation;
+
+      // Set properties
+      this.setPropertyForUrl(PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL, bootLibraryLocation);
+
+      // Return
+      return this.covarientReturn();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getBootLibraryLocation()
+    */
+   public URL getBootLibraryLocation()
+   {
+      return this.bootLibraryLocation;
+   }
+
 }

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -62,4 +62,10 @@
     * is not defined
     */
    String DEFAULT_VALUE_SERVER_NAME = "default";
+
+   /**
+    * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL},
+    * {@link #PROP_KEY_JBOSSAS_COMMON_LIBRARY_URL} and {@link #PROP_KEY_JBOSSAS_SERVER_LIBRARY_URL}.
+    */
+   String DEFAULT_VALUE_LIBRARY_URL_SUFFIX = "lib/";
 }

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -23,6 +23,7 @@
 package org.jboss.bootstrap.impl.as.config;
 
 import java.io.File;
+import java.net.URL;
 import java.util.Map;
 
 import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer;
@@ -52,7 +53,7 @@
     * File denoting the present working directory, used in
     * defaulting $JBOSS_HOME
     */
-   private static final File FILE_PRESENT_WORKING_DIRECTORY = new File(".");
+   private static final File FILE_PRESENT_WORKING_DIRECTORY = new File("");
 
    //-------------------------------------------------------------------------------||
    // Required Implementations -----------------------------------------------------||
@@ -75,7 +76,7 @@
       final Map<String, String> configProps = config.getProperties();
 
       // $JBOSS_HOME
-      final String pwd = FILE_PRESENT_WORKING_DIRECTORY.getAbsolutePath();
+      final String pwd = FILE_PRESENT_WORKING_DIRECTORY.getAbsolutePath() + "/";
       final String currentJBossHome = config.getJBossHome() != null ? config.getJBossHome().toExternalForm() : null;
       final String jbossHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME,
             JBossASServerConfig.ENV_VAR_JBOSSAS_HOME, currentJBossHome, pwd, configProps);
@@ -91,6 +92,14 @@
             .getServerName(), JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME, configProps);
       config.serverName(serverName);
 
+      // ${jboss.lib.url}
+      final URL bootLibLocation = config.getBootLibraryLocation();
+      final String bootLibDefault = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_LIBRARY_URL_SUFFIX;
+      final String currentBootLibLocation = bootLibLocation != null ? bootLibLocation.toExternalForm() : null;
+      final String resolvedbootLibLocation = this.resolvePropertyValue(
+            JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL, currentBootLibLocation, bootLibDefault, configProps);
+      config.bootLibraryLocation(resolvedbootLibLocation);
+
    }
 
    //-------------------------------------------------------------------------------||

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -79,6 +79,8 @@
       this.require(config.getBindAddress(), JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS);
       // jboss.server.name
       this.require(config.getServerName(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME);
+      // jboss.lib.url
+      this.require(config.getBootLibraryLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -79,6 +79,13 @@
     */
    String PROP_KEY_JBOSSAS_HOME_URL = "jboss.home.url";
 
+   /**
+    * Constant that holds the name of the environment property
+    * for specifying the URL where JBoss will read library files
+    * from.
+    */
+   String PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL = "jboss.lib.url";
+
    //-------------------------------------------------------------------------------||
    // Contracts --------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -141,4 +148,32 @@
     * @return This configuration
     */
    JBossASServerConfig jbossHome(URL jbossHome);
+
+   /**
+    * Obtains the location of the JBossAS
+    * Boot Libraries
+    * 
+    * @return
+    */
+   URL getBootLibraryLocation();
+
+   /**
+    * Sets the location of the JBossAS
+    * Boot Libraries
+    * 
+    * @param bootLibraryLocation
+    * @return
+    */
+   JBossASServerConfig bootLibraryLocation(URL bootLibraryLocation);
+
+   /**
+    * Sets the location of the JBossAS
+    * Boot Libraries
+    * 
+    * @param bootLibraryLocation
+    * @return
+    * @throws IllegalArgumentException If the specified argument 
+    *    is non-null and cannot be constructed into a URL
+    */
+   JBossASServerConfig bootLibraryLocation(String bootLibraryLocation) 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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -41,7 +41,6 @@
 public interface JBossASServerConfigLegacy extends MCBasedServerConfig<JBossASServerConfigLegacy>
 {
 
-
    //-------------------------------------------------------------------------------||
    // LEGACY -----------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -71,15 +70,6 @@
 
    /**
     * Constant that holds the name of the environment property
-    * for specifying the URL where JBoss will read library files
-    * from.
-    *
-    * <p>Defaults to <tt><em>HOME_URL</em>/lib</tt>/
-    */
-   String PROP_KEY_JBOSSAS_LIBRARY_URL = "jboss.lib.url";
-
-   /**
-    * Constant that holds the name of the environment property
     * for specifying the URL where JBoss will read patch library files
     * from.
     *
@@ -234,12 +224,6 @@
    /////////////////////////////////////////////////////////////////////////
 
    /**
-    * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_LIBRARY_URL},
-    * {@link #PROP_KEY_JBOSSAS_COMMON_LIBRARY_URL} and {@link #PROP_KEY_JBOSSAS_SERVER_LIBRARY_URL}.
-    */
-   String DEFAULT_VALUE_LIBRARY_URL_SUFFIX = "lib/";
-
-   /**
     * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_COMMON_BASE_URL}
     */
    String DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX = "common/";
@@ -278,7 +262,6 @@
    // Contracts --------------------------------------------------------------------||
    //-------------------------------------------------------------------------------||
 
-
    /**
     * Sets the location of the server configuration home
     * 

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -100,6 +100,8 @@
       }
       final File jbossHomeFile = new File(jbossHomeUri);
       final String jbossHomeDir = jbossHomeFile.getAbsolutePath();
+      final URL bootLibraryUrl = configuration.getBootLibraryLocation();
+      final String bootLibraryString = bootLibraryUrl == null ? null : bootLibraryUrl.toExternalForm();
 
       // Set our system properties
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME, jbossHomeDir);
@@ -107,6 +109,7 @@
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL, jbossHome);
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, configuration.getBindAddress());
       this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME, configuration.getServerName());
+      this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL, bootLibraryString);
    }
 
 }

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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -148,10 +148,11 @@
       final String bindAddress = config.getBindAddress();
 
       // Get expected value
-      final String expectedBindAddress = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
+      final String expected = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
 
       // Test
-      TestCase.assertEquals("Bind address was not defaulted as expected", expectedBindAddress, bindAddress);
+      TestCase.assertEquals("Bind address was not defaulted as expected", expected, bindAddress);
+      log.info("Got expected: " + expected);
    }
 
    /**
@@ -171,12 +172,38 @@
       final String serverName = config.getServerName();
 
       // Get expected value
-      final String expectedServerName = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
+      final String expected = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
 
       // Test
-      TestCase.assertEquals("Server name was not defaulted as expected", expectedServerName, serverName);
+      TestCase.assertEquals("Server name was not defaulted as expected", expected, serverName);
+      log.info("Got expected: " + expected);
    }
 
+   /**
+    * Ensures that jboss.lib.url defaults to $JBOSS_HOME/lib
+    * @throws Throwable
+    */
+   @Test
+   public void testBootLibDefault() throws Throwable
+   {
+      // Log
+      log.info("testBootLibDefault");
+
+      // Initialize the blank config
+      initializer.initialize(config);
+
+      // Get out the boot library location
+      final String actual = config.getBootLibraryLocation().toExternalForm();
+
+      // Get expected value
+      final String expected = this.getDefaultJBossHome()
+            + JBossASConfigurationInitializer.DEFAULT_VALUE_LIBRARY_URL_SUFFIX;
+
+      // Test
+      TestCase.assertEquals("Boot library 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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -278,6 +278,39 @@
       TestCase.assertTrue("Validation on no server name should have failed", failed);
    }
 
+   /**
+    * Ensures that an empty/null Boot Lib fails
+    */
+   @Test
+   public void testNoBootLibFails()
+   {
+      // Log
+      log.info("testNoBootLibFails");
+
+      // Initialize
+      boolean failed = false;
+
+      // Get config
+      final JBossASServerConfig config = this.config;
+
+      // Clear out 
+      config.bootLibraryLocation((URL) null);
+
+      // Validate
+      try
+      {
+         validator.validate(config);
+
+      }
+      catch (InvalidConfigurationException ice)
+      {
+         failed = true;
+      }
+
+      // Test
+      TestCase.assertTrue("Validation on no boot library location should have failed", failed);
+   }
+
    //-------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------||
    //-------------------------------------------------------------------------------||
@@ -294,15 +327,16 @@
       final JBossASServerConfig config = new BasicJBossASServerConfig();
 
       // Get properties
-      final String jbossHome = this.getJBossHome().getAbsolutePath();
+      final String jbossHome = this.getJBossHome().getAbsolutePath() + "/";
       final URL bootstrapHome = this.getBootstrapHome();
       final String bootstrapName = BOOTSTRAP_NAME;
       final String bindAddress = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
       final String serverName = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
+      final String bootLib = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_LIBRARY_URL_SUFFIX;
 
       // Populate
       config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bindAddress(bindAddress)
-            .serverName(serverName);
+            .serverName(serverName).bootLibraryLocation(bootLib);
 
       // 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 06:16:39 UTC (rev 87706)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java	2009-04-23 06:32:52 UTC (rev 87707)
@@ -115,6 +115,7 @@
       final String jbossHomeUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL;
       final String bindAddressPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS;
       final String serverNamePropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME;
+      final String bootLibPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL;
 
       // Get Properties from Configuration
       final Map<String, String> properties = configuration.getProperties();
@@ -123,6 +124,7 @@
       final String jbossHomeUrlFromConfProp = properties.get(jbossHomeUrlPropKey);
       final String bindAddressFromConfProp = properties.get(bindAddressPropKey);
       final String serverNameFromConfProp = properties.get(serverNamePropKey);
+      final String bootLibFromConfProp = properties.get(bootLibPropKey);
 
       // Get Properties from System
       final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
@@ -130,6 +132,7 @@
       final String jbossHomeUrlFromSystem = System.getProperty(jbossHomeUrlPropKey);
       final String bindAddressFromSystem = System.getProperty(bindAddressPropKey);
       final String serverNameFromSystem = System.getProperty(serverNamePropKey);
+      final String bootLibFromSystem = System.getProperty(bootLibPropKey);
 
       // Get Expected Values
       final URL jbossHomeFromConf = configuration.getJBossHome();
@@ -138,6 +141,7 @@
       final String jbossHomeUrlFromConf = jbossHomeFromConf.toExternalForm();
       final String bindAddressFromConf = configuration.getBindAddress();
       final String serverNameFromConf = configuration.getServerName();
+      final String bootLibFromConf = configuration.getBootLibraryLocation().toExternalForm();
 
       // Ensure all equal
       TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeDirFromConf,
@@ -160,6 +164,10 @@
             serverNameFromConfProp);
       TestCase.assertEquals("Server name in configuration must match the system property", serverNameFromConf,
             serverNameFromSystem);
+      TestCase.assertEquals("Boot library location in configuration must match the config property", bootLibFromConf,
+            bootLibFromConfProp);
+      TestCase.assertEquals("Boot library location in configuration must match the system property", bootLibFromConf,
+            bootLibFromSystem);
 
       // Cleanup
       server.shutdown();




More information about the jboss-cvs-commits mailing list