[jboss-cvs] JBossAS SVN: r87740 - in projects/bootstrap/trunk/impl-as/src: main/java/org/jboss/bootstrap/impl/as/server and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 23 17:47:20 EDT 2009
Author: ALRubinger
Date: 2009-04-23 17:47:20 -0400 (Thu, 23 Apr 2009)
New Revision: 87740
Added:
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/data/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/deploy/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/deployers/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/lib/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/log/work/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/tmp/EMPTY
Removed:
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/
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] Account for jboss.common.base.url, jboss.server.home.url and jboss.server.home.dir
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -47,6 +47,7 @@
// Class Members ----------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(BasicJBossASServerConfig.class);
//-------------------------------------------------------------------------------||
@@ -78,6 +79,16 @@
*/
private URL serverBaseLocation;
+ /**
+ * The location of the server home
+ */
+ private URL serverHomeLocation;
+
+ /**
+ * The location of the common base
+ */
+ private URL commonBaseLocation;
+
//-------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -289,6 +300,107 @@
return this.covarientReturn();
}
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverHomeLocation()
+ */
+ public URL getServerHomeLocation()
+ {
+ return this.serverHomeLocation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverHomeLocation(java.lang.String)
+ */
+ public JBossASServerConfig serverHomeLocation(String serverHomeLocation) throws IllegalArgumentException
+ {
+ // If null, just pass along
+ if (serverHomeLocation == null)
+ {
+ return this.serverHomeLocation((URL) null);
+ }
+
+ // Convert this String into a URL via File
+ final File file = new File(serverHomeLocation);
+ URL url = null;
+ try
+ {
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Cannot construct URL given: " + serverHomeLocation, e);
+ }
+
+ // Return
+ return this.serverHomeLocation(url);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverHomeLocation(java.net.URL)
+ */
+ public JBossASServerConfig serverHomeLocation(URL serverHomeLocation)
+ {
+ // Set
+ this.serverHomeLocation = serverHomeLocation;
+
+ // Set properties
+ this.setPropertyForUrlAndDir(PROP_KEY_JBOSSAS_SERVER_HOME_URL, PROP_KEY_JBOSSAS_SERVER_HOME_DIR,
+ serverHomeLocation);
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#commonBaseLocation(java.lang.String)
+ */
+ public JBossASServerConfig commonBaseLocation(String commonBaseLocation) throws IllegalArgumentException
+ {
+ // If null, just pass along
+ if (commonBaseLocation == null)
+ {
+ return this.commonBaseLocation((URL) null);
+ }
+
+ // Convert this String into a URL via File
+ final File file = new File(commonBaseLocation);
+ URL url = null;
+ try
+ {
+ url = file.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Cannot construct URL given: " + commonBaseLocation, e);
+ }
+
+ // Return
+ return this.commonBaseLocation(url);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#commonBaseLocation(java.net.URL)
+ */
+ public JBossASServerConfig commonBaseLocation(URL commonBaseLocation)
+ {
+ // Set
+ this.commonBaseLocation = commonBaseLocation;
+
+ // Set properties
+ this.setPropertyForUrl(PROP_KEY_JBOSSAS_COMMON_BASE_URL, commonBaseLocation);
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getCommonBaseLocation()
+ */
+ public URL getCommonBaseLocation()
+ {
+ return this.commonBaseLocation;
+ }
+
//-------------------------------------------------------------------------------||
// 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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -76,4 +76,10 @@
* {@link JBossASServerConfig#PROP_KEY_JBOSSAS_SERVER_BASE_URL}.
*/
String DEFAULT_VALUE_SERVER_BASE_URL_SUFFIX = "server/";
+
+ /**
+ * The suffix used when generating the default value for
+ * {@link JBossASServerConfig#PROP_KEY_JBOSSAS_COMMON_BASE_URL}
+ */
+ String DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX = "common/";
}
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -55,6 +55,11 @@
*/
private static final File FILE_PRESENT_WORKING_DIRECTORY = new File("");
+ /**
+ * Represents a trailing slash
+ */
+ private static final String TRAILING_SLASH = "/";
+
//-------------------------------------------------------------------------------||
// Required Implementations -----------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -80,11 +85,7 @@
final String currentJBossHome = config.getJBossHome() != null ? config.getJBossHome().toExternalForm() : null;
String jbossHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME,
JBossASServerConfig.ENV_VAR_JBOSSAS_HOME, currentJBossHome, pwd, configProps);
- final String trailingSlash = "/";
- if (!jbossHome.endsWith(trailingSlash))
- {
- jbossHome = jbossHome + trailingSlash;
- }
+ jbossHome = this.adjustToTrailingSlash(jbossHome);
config.jbossHome(jbossHome);
// ${jboss.bind.address}
@@ -103,10 +104,7 @@
final String currentBootLibLocation = bootLibLocation != null ? bootLibLocation.toExternalForm() : null;
String resolvedBootLibLocation = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL,
currentBootLibLocation, bootLibDefault, configProps);
- if (!resolvedBootLibLocation.endsWith(trailingSlash))
- {
- resolvedBootLibLocation = resolvedBootLibLocation + trailingSlash;
- }
+ resolvedBootLibLocation = this.adjustToTrailingSlash(resolvedBootLibLocation);
config.bootLibraryLocation(resolvedBootLibLocation);
// ${jboss.server.base.url} / ${jboss.server.base.dir}
@@ -116,12 +114,29 @@
String resolvedServerBaseLocation = this.resolvePropertyValue(
JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_URL, currentServerBaseLocation, serverBaseDefault,
configProps);
- if (!resolvedServerBaseLocation.endsWith(trailingSlash))
- {
- resolvedServerBaseLocation = resolvedServerBaseLocation + trailingSlash;
- }
+ resolvedServerBaseLocation = this.adjustToTrailingSlash(resolvedServerBaseLocation);
config.serverBaseLocation(resolvedServerBaseLocation);
+ // ${jboss.server.home.url} / ${jboss.server.home.dir}
+ final URL serverHomeLocation = config.getServerHomeLocation();
+ final String serverHomeDefault = resolvedServerBaseLocation + serverName;
+ final String currentServerHomeLocation = serverHomeLocation != null ? serverHomeLocation.toExternalForm() : null;
+ String resolvedServerHomeLocation = this.resolvePropertyValue(
+ JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL, currentServerHomeLocation, serverHomeDefault,
+ configProps);
+ resolvedServerHomeLocation = this.adjustToTrailingSlash(resolvedServerHomeLocation);
+ config.serverHomeLocation(resolvedServerHomeLocation);
+
+ // ${jboss.common.base.url}
+ final URL commonBaseLocation = config.getCommonBaseLocation();
+ final String commonBaseDefault = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX;
+ final String currentCommonBaseLocation = commonBaseLocation != null ? commonBaseLocation.toExternalForm() : null;
+ String resolvedCommonBaseLocation = this.resolvePropertyValue(
+ JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL, currentCommonBaseLocation, commonBaseDefault,
+ configProps);
+ resolvedCommonBaseLocation = this.adjustToTrailingSlash(resolvedCommonBaseLocation);
+ config.commonBaseLocation(resolvedCommonBaseLocation);
+
}
//-------------------------------------------------------------------------------||
@@ -129,6 +144,28 @@
//-------------------------------------------------------------------------------||
/**
+ * Returns the value of the specified String, appending a trailing
+ * slash "/", if not found. Otherwise returns the argument.
+ *
+ * @param string The String to which we should optionally append a "/"
+ */
+ private String adjustToTrailingSlash(final String string)
+ {
+ // Init
+ String newString = string;
+
+ // If we need a trailing slash
+ if (!newString.endsWith(TRAILING_SLASH))
+ {
+ // Append it
+ newString = newString + TRAILING_SLASH;
+ }
+
+ // Return
+ return newString;
+ }
+
+ /**
* Applies the following preference in resolving a property's value:
*
* 1) Config Property (which is originated from sys props)
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -83,6 +83,10 @@
this.require(config.getBootLibraryLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL);
// jboss.server.base.url
this.require(config.getServerBaseLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_URL);
+ // jboss.server.home.url
+ this.require(config.getServerHomeLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL);
+ // jboss.common.base.url
+ this.require(config.getCommonBaseLocation(), JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -80,26 +80,45 @@
String PROP_KEY_JBOSSAS_HOME_URL = "jboss.home.url";
/**
- * Constant that holds the name of the environment property
+ * Constant that holds the name of the system property
* for specifying the URL where JBoss will read library files
* from.
*/
String PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL = "jboss.lib.url";
/**
- * Constant that holds the name of the environment property
+ * Constant that holds the name of the system property
* for specifying the base directory for calculating server
* home directories.
*/
String PROP_KEY_JBOSSAS_SERVER_BASE_DIR = "jboss.server.base.dir";
/**
- * Constant that holds the name of the environment property
+ * Constant that holds the name of the system property
* for specifying the base URL for calculating server
* home URLs.
*/
String PROP_KEY_JBOSSAS_SERVER_BASE_URL = "jboss.server.base.url";
+ /**
+ * Constant that holds the name of the system property
+ * for specifying the server home directory for JBoss.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_HOME_DIR = "jboss.server.home.dir";
+
+ /**
+ * Constant that holds the name of the system property
+ * for specifying the server home URL for JBoss.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_HOME_URL = "jboss.server.home.url";
+
+ /**
+ * Constant that holds the name of the system property
+ * for specifying the base URL for files and directories
+ * common to different server configurations
+ */
+ String PROP_KEY_JBOSSAS_COMMON_BASE_URL = "jboss.common.base.url";
+
//-------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -220,4 +239,54 @@
* is non-null and cannot be constructed into a URL
*/
JBossASServerConfig serverBaseLocation(String serverBaseLocation) throws IllegalArgumentException;
+
+ /**
+ * Obtains the location of the server home
+ *
+ * @return
+ */
+ URL getServerHomeLocation();
+
+ /**
+ * Sets the location of the server home
+ *
+ * @param serverBaseLocation
+ * @return
+ */
+ JBossASServerConfig serverHomeLocation(URL serverHomeLocation);
+
+ /**
+ * Sets the location of the server home
+ *
+ * @param serverHomeLocation
+ * @return
+ * @throws IllegalArgumentException If the specified argument
+ * is non-null and cannot be constructed into a URL
+ */
+ JBossASServerConfig serverHomeLocation(String serverHomeLocation) throws IllegalArgumentException;
+
+ /**
+ * Obtains the location of the common base
+ *
+ * @return
+ */
+ URL getCommonBaseLocation();
+
+ /**
+ * Sets the location of the common base
+ *
+ * @param serverBaseLocation
+ * @return
+ */
+ JBossASServerConfig commonBaseLocation(URL commonBaseLocation);
+
+ /**
+ * Sets the location of the common base
+ *
+ * @param commonBaseLocation
+ * @return
+ * @throws IllegalArgumentException If the specified argument
+ * is non-null and cannot be constructed into a URL
+ */
+ JBossASServerConfig commonBaseLocation(String commonBaseLocation) 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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -22,9 +22,6 @@
package org.jboss.bootstrap.impl.as.config;
-import java.net.InetAddress;
-import java.net.URL;
-
import org.jboss.bootstrap.spi.mc.config.MCBasedServerConfig;
/**
@@ -80,18 +77,8 @@
*/
String PROP_KEY_JBOSSAS_PATCH_URL = "jboss.patch.url";
-
-
/**
* Constant that holds the name of the environment property
- * for specifying the server home directory for JBoss.
- *
- * <p>Defaults to <tt><em>SERVER_BASE_DIR</em>/<em>SERVER_NAME</em></tt>.
- */
- String PROP_KEY_JBOSSAS_SERVER_HOME_DIR = "jboss.server.home.dir";
-
- /**
- * Constant that holds the name of the environment property
* for specifying the server log directory for JBoss.
*
* <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/<em>log</em></tt>.
@@ -118,14 +105,6 @@
/**
* Constant that holds the name of the environment property
- * for specifying the server home URL for JBoss.
- *
- * <p>Defaults to <tt><em>SERVER_BASE_URL</em>/<em>SERVER_NAME</em></tt>.
- */
- String PROP_KEY_JBOSSAS_SERVER_HOME_URL = "jboss.server.home.url";
-
- /**
- * 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> .
@@ -143,15 +122,6 @@
/**
* Constant that holds the name of the environment property
- * for specifying the base URL for files and directories
- * common to different server configurations
- *
- * <p>Defaults to <tt><em>HOME_URL</em>/common/</tt>
- */
- String PROP_KEY_JBOSSAS_COMMON_BASE_URL = "jboss.common.base.url";
-
- /**
- * Constant that holds the name of the environment property
* for specifying a library directory URL that points to libraries
* shared by the various server configurations.
*
@@ -208,11 +178,6 @@
/////////////////////////////////////////////////////////////////////////
/**
- * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_COMMON_BASE_URL}
- */
- String DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX = "common/";
-
- /**
* The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_CONFIG_URL}.
*/
String DEFAULT_VALUE_SERVER_CONFIG_URL_SUFFIX = "conf/";
@@ -232,59 +197,4 @@
*/
String DEFAULT_VALUE_SERVER_TEMP_DIR_SUFFIX = "tmp";
- //-------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Sets the location of the server configuration home
- *
- * @return
- */
- URL getServerHome();
-
- /**
- * Sets the location of the server configuration home
- *
- * @param serverHome
- * @return
- * @throws IllegalArgumentException If the specified server home be resolved
- * to a known host via {@link InetAddress#getAllByName(String)}
- */
- JBossASServerConfigLegacy serverHome(String serverHome) throws IllegalArgumentException;
-
- /**
- * Sets the location of the server configuration home
- *
- * @param serverHome
- * @return
- */
- JBossASServerConfigLegacy serverHome(URL serverHome);
-
- /**
- * Obtains the $JBOSS_HOME, the root location of the JBossAS
- * installation.
- *
- * @return
- */
- URL getJBossHome();
-
- /**
- * Sets $JBOSS_HOME, the root location of the JBossAS
- * installation.
- *
- * @param jbossHome The location to $JBOSS_HOME
- * @return This configuration
- */
- JBossASServerConfigLegacy jbossHome(String jbossHome);
-
- /**
- * Sets $JBOSS_HOME, the root location of the JBossAS
- * installation.
- *
- * @param jbossHome The URL to $JBOSS_HOME
- * @return This configuration
- */
- JBossASServerConfigLegacy jbossHome(URL jbossHome);
-
}
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -88,33 +88,14 @@
// Get values to set
final URL jbossHome = configuration.getJBossHome();
- URI jbossHomeUri = null;
- try
- {
- jbossHomeUri = jbossHome.toURI();
- }
- catch (URISyntaxException e1)
- {
- throw new RuntimeException("JBOSS_HOME could not be made into URI, formatting "
- + "error should have been caught by config validation", e1);
- }
- final File jbossHomeFile = new File(jbossHomeUri);
- final String jbossHomeDir = jbossHomeFile.getAbsolutePath();
+ final String jbossHomeDir = this.getAbsoluteLocationOfUrl(jbossHome);
final URL bootLibraryUrl = configuration.getBootLibraryLocation();
final String bootLibraryString = bootLibraryUrl == null ? null : bootLibraryUrl.toExternalForm();
final URL serverBaseUrl = configuration.getServerBaseLocation();
- URI serverBaseUri = null;
- try
- {
- serverBaseUri = serverBaseUrl.toURI();
- }
- catch (URISyntaxException e1)
- {
- throw new RuntimeException("Server Base could not be made into URI, formatting "
- + "error should have been caught by config validation", e1);
- }
- final File serverBaseFile = new File(serverBaseUri);
- final String serverBaseDir = serverBaseFile.getAbsolutePath();
+ final String serverBaseDir = this.getAbsoluteLocationOfUrl(serverBaseUrl);
+ final URL serverHomeUrl = configuration.getServerHomeLocation();
+ final String serverHomeDir = this.getAbsoluteLocationOfUrl(serverHomeUrl);
+ final URL commonBaseUrl = configuration.getCommonBaseLocation();
// Set our system properties
this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME, jbossHomeDir);
@@ -125,6 +106,44 @@
this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL, bootLibraryString);
this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_URL, serverBaseUrl);
this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_DIR, serverBaseDir);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL, serverHomeUrl);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_DIR, serverHomeDir);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL, commonBaseUrl);
}
+ //-------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Returns the absolute location of the given URL, stripping
+ * the protocol
+ *
+ * @param url
+ * @return
+ */
+ private String getAbsoluteLocationOfUrl(final URL url)
+ {
+ // Convert to URI
+ URI uri = null;
+ try
+ {
+ uri = url.toURI();
+ }
+ catch (URISyntaxException urise)
+ {
+ throw new RuntimeException("URL be made into URI, formatting "
+ + "error should have been caught by config validation", urise);
+ }
+
+ // Construct a File
+ final File file = new File(uri);
+
+ // Get the absolute path
+ final String location = file.getAbsolutePath();
+
+ // Return it
+ return location;
+ }
+
}
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -208,4 +208,48 @@
log.info("Got expected: " + expected);
}
+ /**
+ * Ensures that the server home defaults to $JBOSS_HOME/server/$serverName
+ * @throws Throwable
+ */
+ @Test
+ public void testServerHomeDefault() throws Throwable
+ {
+ // Log
+ log.info("testServerHomeDefault");
+
+ // Get out server base location
+ final String actual = config.getServerHomeLocation().toExternalForm();
+
+ // Get expected value
+ final String expected = JBOSS_HOME.toExternalForm()
+ + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_BASE_URL_SUFFIX
+ + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME + "/";
+
+ // Test
+ TestCase.assertEquals("Server home location was not defaulted as expected", expected, actual);
+ log.info("Got expected: " + expected);
+ }
+
+ /**
+ * Ensures that the common base defaults to $JBOSS_HOME/common/
+ * @throws Throwable
+ */
+ @Test
+ public void testCommonBaseDefault() throws Throwable
+ {
+ // Log
+ log.info("testCommonBaseDefault");
+
+ // Get out server base location
+ final String actual = config.getCommonBaseLocation().toExternalForm();
+
+ // Get expected value
+ final String expected = JBOSS_HOME.toExternalForm()
+ + JBossASConfigurationInitializer.DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX;
+
+ // Test
+ TestCase.assertEquals("Common base location was not defaulted as expected", expected, actual);
+ log.info("Got expected: " + expected);
+ }
}
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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -149,28 +149,12 @@
// Log
log.info("testNoJBossHomeFails");
- // Initialize
- boolean failed = false;
-
- // Get config
+ // Get config and clear out
final JBossASServerConfig config = this.config;
-
- // Clear out
config.jbossHome((URL) null);
- // Validate
- try
- {
- validator.validate(config);
-
- }
- catch (InvalidConfigurationException ice)
- {
- failed = true;
- }
-
// Test
- TestCase.assertTrue("Validation on no JBOSS_HOME should have failed", failed);
+ this.assertMissingValueFails(config, "JBOSS_HOME");
}
/**
@@ -221,28 +205,12 @@
// Log
log.info("testNoBindAddressFails");
- // Initialize
- boolean failed = false;
-
- // Get config
+ // Get config and clear out
final JBossASServerConfig config = this.config;
-
- // Clear out
config.bindAddress(null);
- // Validate
- try
- {
- validator.validate(config);
-
- }
- catch (InvalidConfigurationException ice)
- {
- failed = true;
- }
-
// Test
- TestCase.assertTrue("Validation on no bind address should have failed", failed);
+ this.assertMissingValueFails(config, "bind address");
}
/**
@@ -254,28 +222,12 @@
// Log
log.info("testNoServerNameFails");
- // Initialize
- boolean failed = false;
-
- // Get config
+ // Get config and clear out
final JBossASServerConfig config = this.config;
-
- // Clear out
config.serverName(null);
- // Validate
- try
- {
- validator.validate(config);
-
- }
- catch (InvalidConfigurationException ice)
- {
- failed = true;
- }
-
// Test
- TestCase.assertTrue("Validation on no server name should have failed", failed);
+ this.assertMissingValueFails(config, "server name");
}
/**
@@ -287,52 +239,85 @@
// Log
log.info("testNoBootLibFails");
- // Initialize
- boolean failed = false;
-
- // Get config
+ // Get config and clear out
final JBossASServerConfig config = this.config;
-
- // Clear out
config.bootLibraryLocation((URL) null);
- // Validate
- try
- {
- validator.validate(config);
+ // Test
+ this.assertMissingValueFails(config, "boot library location");
+ }
- }
- catch (InvalidConfigurationException ice)
- {
- failed = true;
- }
+ /**
+ * Ensures that an empty/null Server Base location fails
+ */
+ @Test
+ public void testNoServerBaseFails()
+ {
+ // Log
+ log.info("testNoServerBaseFails");
+ // Get config and clear out
+ final JBossASServerConfig config = this.config;
+ config.serverBaseLocation((URL) null);
+
// Test
- TestCase.assertTrue("Validation on no boot library location should have failed", failed);
+ this.assertMissingValueFails(config, "server base");
}
/**
- * Ensures that an empty/null Server Base location fails
+ * Ensures that an empty/null Server Home location fails
*/
@Test
- public void testServerBaseFails()
+ public void testNoServerHomeFails()
{
// Log
- log.info("testNoBootLibFails");
+ log.info("testNoServerHomeFails");
- // Initialize
- boolean failed = false;
+ // Get config and clear out
+ final JBossASServerConfig config = this.config;
+ config.serverHomeLocation((URL) null);
- // Get config
+ // Test
+ this.assertMissingValueFails(config, "server home");
+ }
+
+ /**
+ * Ensures that an empty/null Common Base location fails
+ */
+ @Test
+ public void testNoCommonBaseFails()
+ {
+ // Log
+ log.info("testNoCommonBaseFails");
+
+ // Get config and clear out
final JBossASServerConfig config = this.config;
+ config.commonBaseLocation((URL) null);
- // Clear out
- config.serverBaseLocation((URL) null);
+ // Test
+ this.assertMissingValueFails(config, "common base");
+ }
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that a config with a missing property fails
+ *
+ * @param configWithMisingValue The config, presumably with a missing value
+ * @param propertyName The name of the property that's missing, for
+ * use in the fail message (human-readable)
+ */
+ private void assertMissingValueFails(final JBossASServerConfig configWithMisingValue, final String propertyName)
+ {
+ // Initialize
+ boolean failed = false;
+
// Validate
try
{
- validator.validate(config);
+ validator.validate(configWithMisingValue);
}
catch (InvalidConfigurationException ice)
@@ -341,13 +326,9 @@
}
// Test
- TestCase.assertTrue("Validation on no server base location should have failed", failed);
+ TestCase.assertTrue("Validation on no " + propertyName + " should have failed", failed);
}
- //-------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
/**
* Creates a new configuration and fully populates it,
* returning the result
@@ -367,10 +348,13 @@
final String serverName = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
final String bootLib = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_LIBRARY_URL_SUFFIX;
final String serverBase = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_BASE_URL_SUFFIX;
+ final String serverHome = serverBase + serverName;
+ final String commonBase = jbossHome + JBossASConfigurationInitializer.DEFAULT_VALUE_COMMON_BASE_URL_SUFFIX;
// Populate
config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bindAddress(bindAddress)
- .serverName(serverName).bootLibraryLocation(bootLib).serverBaseLocation(serverBase);
+ .serverName(serverName).bootLibraryLocation(bootLib).serverBaseLocation(serverBase).serverHomeLocation(
+ serverHome).commonBaseLocation(commonBase);
// 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 21:17:56 UTC (rev 87739)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2009-04-23 21:47:20 UTC (rev 87740)
@@ -124,6 +124,9 @@
final String bootLibPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL;
final String serverBaseUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_URL;
final String serverBaseDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_BASE_DIR;
+ final String serverHomeUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL;
+ final String serverHomeDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_DIR;
+ final String commonBaseUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_COMMON_BASE_URL;
// Get Properties from Configuration
final Map<String, String> properties = configuration.getProperties();
@@ -135,6 +138,9 @@
final String bootLibFromConfProp = properties.get(bootLibPropKey);
final String serverBaseUrlFromConfProp = properties.get(serverBaseUrlPropKey);
final String serverBaseDirFromConfProp = properties.get(serverBaseDirPropKey);
+ final String serverHomeUrlFromConfProp = properties.get(serverHomeUrlPropKey);
+ final String serverHomeDirFromConfProp = properties.get(serverHomeDirPropKey);
+ final String commonBaseUrlFromConfProp = properties.get(commonBaseUrlPropKey);
// Get Properties from System
final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
@@ -145,6 +151,9 @@
final String bootLibFromSystem = System.getProperty(bootLibPropKey);
final String serverBaseUrlFromSystem = System.getProperty(serverBaseUrlPropKey);
final String serverBaseDirFromSystem = System.getProperty(serverBaseDirPropKey);
+ final String serverHomeUrlFromSystem = System.getProperty(serverHomeUrlPropKey);
+ final String serverHomeDirFromSystem = System.getProperty(serverHomeDirPropKey);
+ final String commonBaseUrlFromSystem = System.getProperty(commonBaseUrlPropKey);
// Get Expected Values
final URL jbossHomeFromConf = configuration.getJBossHome();
@@ -158,6 +167,11 @@
final File serverBaseFile = new File(serverBaseFromConf.toURI());
final String serverBaseUrlFromConf = serverBaseFromConf.toExternalForm();
final String serverBaseDirFromConf = serverBaseFile.getAbsolutePath();
+ final URL serverHomeFromConf = configuration.getServerHomeLocation();
+ final File serverHomeFile = new File(serverHomeFromConf.toURI());
+ final String serverHomeUrlFromConf = serverHomeFromConf.toExternalForm();
+ final String serverHomeDirFromConf = serverHomeFile.getAbsolutePath();
+ final String commonBaseUrlFromConf = configuration.getCommonBaseLocation().toExternalForm();
// Ensure all equal
TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeDirFromConf,
@@ -192,16 +206,47 @@
serverBaseUrlFromConfProp);
TestCase.assertEquals("Server Base URL in configuration must match the system property", serverBaseUrlFromConf,
serverBaseUrlFromSystem);
+ TestCase.assertEquals("Server Home Dir in configuration must match the config property", serverHomeDirFromConf,
+ serverHomeDirFromConfProp);
+ TestCase.assertEquals("Server Home Dir in configuration must match the system property", serverHomeDirFromConf,
+ serverHomeDirFromSystem);
+ TestCase.assertEquals("Server Home URL in configuration must match the config property", serverHomeUrlFromConf,
+ serverHomeUrlFromConfProp);
+ TestCase.assertEquals("Server Home URL in configuration must match the system property", serverHomeUrlFromConf,
+ serverHomeUrlFromSystem);
+ TestCase.assertEquals("Common Base URL in configuration must match the config property", commonBaseUrlFromConf,
+ commonBaseUrlFromConfProp);
+ TestCase.assertEquals("Common Base URL in configuration must match the system property", commonBaseUrlFromConf,
+ commonBaseUrlFromSystem);
// Cleanup
server.shutdown();
// Get Properties from System
final String jbossHomeFromSystemAfterCleanup = System.getProperty(jbossHomePropKey);
+ final String jbossHomeDirFromSystemAfterCleanup = System.getProperty(jbossHomeDirPropKey);
+ final String jbossHomeUrlFromSystemAfterCleanup = System.getProperty(jbossHomeUrlPropKey);
+ final String bindAddressFromSystemAfterCleanup = System.getProperty(bindAddressPropKey);
+ final String serverNameFromSystemAfterCleanup = System.getProperty(serverNamePropKey);
+ final String bootLibFromSystemAfterCleanup = System.getProperty(bootLibPropKey);
+ final String serverBaseUrlFromSystemAfterCleanup = System.getProperty(serverBaseUrlPropKey);
+ final String serverBaseDirFromSystemAfterCleanup = System.getProperty(serverBaseDirPropKey);
+ final String serverHomeUrlFromSystemAfterCleanup = System.getProperty(serverHomeUrlPropKey);
+ final String serverHomeDirFromSystemAfterCleanup = System.getProperty(serverHomeDirPropKey);
+ final String commonBaseUrlFromSystemAfterCleanup = System.getProperty(commonBaseUrlPropKey);
// Ensure all null
final String failMessage = "System property should be null after cleanup";
TestCase.assertNull(failMessage, jbossHomeFromSystemAfterCleanup);
-
+ TestCase.assertNull(failMessage, jbossHomeDirFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, jbossHomeUrlFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, bindAddressFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, serverNameFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, bootLibFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, serverBaseUrlFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, serverBaseDirFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, serverHomeUrlFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, serverHomeDirFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, commonBaseUrlFromSystemAfterCleanup);
}
}
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default (from rev 87656, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all)
Property changes on: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/conf/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/data/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/data/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/deploy/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deploy/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/deployers/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deployers/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/lib/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/lib/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/log/work/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/log/work/EMPTY)
===================================================================
Copied: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/tmp/EMPTY (from rev 87701, projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/tmp/EMPTY)
===================================================================
More information about the jboss-cvs-commits
mailing list