[jboss-cvs] JBossAS SVN: r87656 - in projects/bootstrap/trunk: impl-as and 25 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 22 01:32:07 EDT 2009
Author: ALRubinger
Date: 2009-04-22 01:32:06 -0400 (Wed, 22 Apr 2009)
New Revision: 87656
Added:
projects/bootstrap/trunk/impl-as/
projects/bootstrap/trunk/impl-as/.classpath
projects/bootstrap/trunk/impl-as/.project
projects/bootstrap/trunk/impl-as/.settings/
projects/bootstrap/trunk/impl-as/.settings/org.eclipse.jdt.core.prefs
projects/bootstrap/trunk/impl-as/.settings/org.maven.ide.eclipse.prefs
projects/bootstrap/trunk/impl-as/pom.xml
projects/bootstrap/trunk/impl-as/src/
projects/bootstrap/trunk/impl-as/src/main/
projects/bootstrap/trunk/impl-as/src/main/java/
projects/bootstrap/trunk/impl-as/src/main/java/org/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/
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/config/SecurityActions.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
projects/bootstrap/trunk/impl-as/src/test/
projects/bootstrap/trunk/impl-as/src/test/java/
projects/bootstrap/trunk/impl-as/src/test/java/org/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/
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/PropertyValueResolutionTestCase.java
projects/bootstrap/trunk/impl-as/src/test/resources/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/bin/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/client/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/common/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/common/lib/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/lib/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/conf/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/data/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deploy/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deployers/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/lib/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/log/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/log/work/
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/tmp/
projects/bootstrap/trunk/impl-as/src/test/resources/log4j.xml
Modified:
projects/bootstrap/trunk/pom.xml
Log:
[JBBOOT-31] Start of jboss-bootstrap-impl-as w/ some basic config tests
Property changes on: projects/bootstrap/trunk/impl-as
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
Added: projects/bootstrap/trunk/impl-as/.classpath
===================================================================
--- projects/bootstrap/trunk/impl-as/.classpath (rev 0)
+++ projects/bootstrap/trunk/impl-as/.classpath 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/tests-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/tests-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: projects/bootstrap/trunk/impl-as/.project
===================================================================
--- projects/bootstrap/trunk/impl-as/.project (rev 0)
+++ projects/bootstrap/trunk/impl-as/.project 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,17 @@
+<projectDescription>
+ <name>jboss-bootstrap-impl-as</name>
+ <comment>Application Server Implementation of JBoss Bootstrap</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/bootstrap/trunk/impl-as/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/bootstrap/trunk/impl-as/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/bootstrap/trunk/impl-as/.settings/org.eclipse.jdt.core.prefs 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,5 @@
+#Sat Apr 11 17:46:59 GMT-05:00 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/bootstrap/trunk/impl-as/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/bootstrap/trunk/impl-as/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/bootstrap/trunk/impl-as/.settings/org.maven.ide.eclipse.prefs 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,8 @@
+#Fri Apr 10 13:43:36 GMT-05:00 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+version=1
Added: projects/bootstrap/trunk/impl-as/pom.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/pom.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/pom.xml 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ vi:ts=2:sw=2:expandtab:
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap-build</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <artifactId>jboss-bootstrap-impl-as</artifactId>
+ <name>JBoss Bootstrap AS Implementation</name>
+ <description>Application Server Implementation of JBoss Bootstrap</description>
+
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versions -->
+ <version.org.jboss.bootstrap_jboss.bootstrap.impl.mc>0.1.2-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.impl.mc>
+
+ </properties>
+
+ <!-- Build -->
+ <build>
+
+ </build>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap-impl-mc</artifactId>
+ <version>${version.org.jboss.bootstrap_jboss.bootstrap.impl.mc}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,132 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import org.jboss.bootstrap.impl.base.config.AbstractBasicServerConfig;
+
+/**
+ * BasicJBossASServerConfig
+ *
+ * Basic object-backed implementation of the {@link JBossASServerConfig}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BasicJBossASServerConfig extends AbstractBasicServerConfig<JBossASServerConfig>
+ implements
+ JBossASServerConfig
+{
+
+ //-------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Bind address for the server
+ */
+ private String bindAddress;
+
+ /**
+ * $JBOSS_HOME, root of the AS installation
+ */
+ private String jbossHome;
+
+ /**
+ * The server configuration name
+ */
+ private String serverName;
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ public BasicJBossASServerConfig()
+ {
+ super(JBossASServerConfig.class);
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bindAddress(java.lang.String)
+ */
+ public JBossASServerConfig bindAddress(final String bindAddress) throws IllegalArgumentException
+ {
+ // Set
+ this.bindAddress = bindAddress;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getBindAddress()
+ */
+ public String getBindAddress()
+ {
+ return this.bindAddress;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerName()
+ */
+ public String getServerName()
+ {
+ return this.serverName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#jbossHome(java.lang.String)
+ */
+ public JBossASServerConfig jbossHome(final String jbossHome)
+ {
+ // Set
+ this.jbossHome = jbossHome;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverName(java.lang.String)
+ */
+ public JBossASServerConfig serverName(final String serverName)
+ {
+ // Set
+ this.serverName = serverName;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getJBossHome()
+ */
+ public String getJBossHome()
+ {
+ return this.jbossHome;
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+
+/**
+ * JBossASConfigurationInitializer
+ *
+ * Contract for a JBossAS Configuration Initializer
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ * @see {@link ServerInitializer}
+ */
+public interface JBossASConfigurationInitializer extends ConfigurationInitializer<JBossASServerConfig>
+{
+ //-------------------------------------------------------------------------------||
+ // Constants --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /*
+ * The following denote default values in the case
+ * a property is not explicitly-specified
+ */
+
+ /**
+ * Default address which will be set
+ * if {@link JBossASServerConfig#getBindAddress()} or
+ * system or configuration property
+ * {@link JBossASServerConfig#PROP_KEY_BIND_ADDRESS}
+ * is not defined
+ */
+ String DEFAULT_VALUE_BIND_ADDRESS = "127.0.0.1";
+
+ /**
+ * Default server name which will be set if
+ * {@link JBossASServerConfig#getBindAddress()} or
+ * system or configuration property
+ * {@link JBossASServerConfig#PROP_KEY_JBOSSAS_SERVER_NAME}
+ * is not defined
+ */
+ String DEFAULT_VALUE_SERVER_NAME = "default";
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,210 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.io.File;
+import java.util.Map;
+
+import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.logging.Logger;
+
+/**
+ * JBossASConfigurationInitializerImpl
+ *
+ * Configuration Initializer for JBossAS
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASConfigurationInitializerImpl extends AbstractBasicConfigurationInitializer<JBossASServerConfig>
+ implements
+ JBossASConfigurationInitializer
+{
+
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASConfigurationInitializerImpl.class);
+
+ /**
+ * File denoting the present working directory, used in
+ * defaulting $JBOSS_HOME
+ */
+ private static final File FILE_PRESENT_WORKING_DIRECTORY = new File(".");
+
+ //-------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.AbstractBasicConfigurationInitializer#initialize(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ @Override
+ public void initialize(JBossASServerConfig config) throws InvalidConfigurationException, IllegalArgumentException,
+ IllegalStateException
+ {
+ // Log
+ log.debug("Initializing: " + config);
+
+ // Init the super config
+ super.initialize(config);
+
+ // Get the configuration properties
+ final Map<String, String> configProps = config.getProperties();
+
+ // $JBOSS_HOME
+ final String pwd = FILE_PRESENT_WORKING_DIRECTORY.getAbsolutePath();
+ final String jbossHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSS_HOME,
+ JBossASServerConfig.ENV_VAR_JBOSS_HOME, config.getJBossHome(), pwd, configProps);
+ config.jbossHome(jbossHome);
+
+ // ${jboss.bind.address}
+ final String bindAddress = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_BIND_ADDRESS, config
+ .getBindAddress(), JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS, configProps);
+ config.bindAddress(bindAddress);
+
+ // ${jboss.server.name}
+ final String serverName = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME, config
+ .getServerName(), JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME, configProps);
+ config.serverName(serverName);
+
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Applies the following preference in resolving a property's value:
+ *
+ * 1) Config Property (which is originated from sys props)
+ * 2) Object Model (Current Value)
+ * 3) Default Value
+ *
+ * Lower numbers above denote higher priority.
+ *
+ * @param propertyName The name of the system/configuration property
+ * @param currentValue The value of the property within the object model
+ * @param defaultValue The value of the default if none others are specified
+ * @param properties The configuration properties
+ *
+ * @throws IllegalArgumentException If propertyName is null/empty or
+ * properties are null
+ */
+ private String resolvePropertyValue(final String propertyName, final String currentValue, final String defaultValue,
+ final Map<String, String> properties) throws IllegalArgumentException
+ {
+ // Pass along, using null env var
+ return this.resolvePropertyValue(propertyName, null, currentValue, defaultValue, properties);
+ }
+
+ /**
+ * Applies the following preference in resolving a property's value:
+ *
+ * 1) Config Property (which is originated from sys props)
+ * 2) Object Model (Current Value)
+ * 3) Environment Variable
+ * 4) Default Value
+ *
+ * Lower numbers above denote higher priority. This method is package-private
+ * for direct unit testing.
+ *
+ * @param propertyName The name of the system/configuration property
+ * @param envVarName The name of the environment variable, or null if not used
+ * @param currentValue The value of the property within the object model
+ * @param defaultValue The value of the default if none others are specified
+ * @param properties The configuration properties
+ *
+ * @throws IllegalArgumentException If propertyName is null/empty or
+ * properties are null
+ */
+ String resolvePropertyValue(final String propertyName, final String envVarName, final String currentValue,
+ final String defaultValue, final Map<String, String> properties) throws IllegalArgumentException
+ {
+ // Precondition checks
+ if (propertyName == null || propertyName.length() == 0)
+ {
+ throw new IllegalArgumentException("Property name is a required argument");
+ }
+ if (properties == null)
+ {
+ throw new IllegalArgumentException("Properties is a required argument");
+ }
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Determining true value for property: " + propertyName);
+ }
+
+ // Start at the default value
+ String returnValue = defaultValue;
+ if (log.isTraceEnabled())
+ {
+ log.trace("Default value of \"" + propertyName + "\" is: " + defaultValue);
+ }
+
+ // If the environment variable is defined, this overrides the default
+ if (envVarName != null)
+ {
+ final String envVarValue = SecurityActions.getEnvironmentVariable(envVarName);
+ if (envVarValue != null)
+ {
+ returnValue = envVarValue;
+ // Log at debug
+ log.debug("Found environment variable \"" + envVarName + "\", so using value as override: " + envVarValue);
+ }
+ }
+
+ // If the object model value is specified, use it
+ if (currentValue != null && currentValue.length() > 0)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Object model has specified value for \"" + propertyName + "\": " + currentValue);
+ }
+ returnValue = currentValue;
+ }
+
+ // Get the override value
+ final String override = properties.get(propertyName);
+
+ // If the override value is specified, use it
+ if (override != null && override.length() > 0)
+ {
+ // Log as debug here as property-based override may be from command-line,
+ // so give the user a greater hint of what's going on
+ log.debug("Got configuration property " + propertyName + ", so using as override: " + override);
+ returnValue = override;
+ }
+
+ // Return
+ log.debug("Resolved property: " + propertyName + " with currentValue = " + currentValue
+ + ", environment variable name = " + envVarName + ", and defaultValue = " + defaultValue + " to: "
+ + returnValue);
+ return returnValue;
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationValidator;
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+
+/**
+ * JBossASConfigurationValidator
+ *
+ * Validator for JBossAS Configurations
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASConfigurationValidator extends AbstractBasicConfigurationValidator<JBossASServerConfig>
+ implements
+ ConfigurationValidator<JBossASServerConfig>
+{
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.AbstractBasicConfigurationValidator#validate(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ @Override
+ public void validate(JBossASServerConfig config) throws InvalidConfigurationException
+ {
+ // Validate the generic configuration
+ super.validate(config);
+
+ /*
+ * Impl-specific
+ */
+
+ /*
+ * Rules for JBOSS_HOME:
+ * 1) Set from environment variable "JBOSS_HOME" if present
+ * 2) Set from system property "jboss.home" (overrides environment variable)
+ * if present
+ * 3) Use config if present
+ * 4) Throw InvalidConfigurationException
+ */
+
+ // Ensure JBOSS_HOME
+ // String jbossHome = config.getJBossHome();
+ // if(jbossHome)
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import org.jboss.bootstrap.spi.mc.config.MCBasedServerConfig;
+
+/**
+ * JBossASServerConfig
+ *
+ * User configuration for the JBoss Application Server.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface JBossASServerConfig extends MCBasedServerConfig<JBossASServerConfig>
+{
+ //-------------------------------------------------------------------------------||
+ // Constants --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Constant that holds the name of the system or
+ * configuration property
+ */
+ String PROP_KEY_BIND_ADDRESS = "jboss.bind.address";
+
+ /**
+ * Constant that holds the name of the system or configuration
+ * property which specifies the name of the server which will be used to
+ * calculate the servers home directory and url.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_NAME = "jboss.server.name";
+
+ /**
+ * Constant that holds the name of the environment
+ * variable which specifies the root of the AS
+ * installation
+ */
+ String ENV_VAR_JBOSS_HOME = "JBOSS_HOME";
+
+ /**
+ * Constant that holds the name of the system or configuration
+ * property which specifies the root of the AS
+ * installation
+ */
+ String PROP_KEY_JBOSS_HOME = "jboss.home";
+
+ /**
+ * Constant that holds the name of the system property
+ * which specifies the home directory for JBossAS.
+ */
+ String PROP_KEY_JBOSSAS_HOME_DIR = "jboss.home.dir";
+
+ /**
+ * Constant that holds the name of the system property
+ * which specifies the home URL for JBossAS.
+ *
+ * <p>If not set then the value of HOME_DIR will converted into a URL.
+ */
+ String PROP_KEY_JBOSSAS_HOME_URL = "jboss.home.url";
+
+ //-------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the bind address to be used for the Server.
+ *
+ * @return
+ */
+ String getBindAddress();
+
+ /**
+ * Sets the bind address for the server
+ *
+ * @param bindAddress
+ * @return
+ */
+ JBossASServerConfig bindAddress(String bindAddress);
+
+ /**
+ * Obtains the name of the server configuration.
+ *
+ * @return
+ */
+ String getServerName();
+
+ /**
+ * Sets the name of the server configuration
+ *
+ * @param serverName
+ * @return
+ */
+ JBossASServerConfig serverName(String serverName);
+
+ /**
+ * Obtains the $JBOSS_HOME, the path to the
+ * root location of the JBossAS
+ * installation.
+ *
+ * @return
+ */
+ String getJBossHome();
+
+ /**
+ * Sets $JBOSS_HOME, the path to the root location
+ * of the JBossAS installation.
+ *
+ * @param jbossHome The location to $JBOSS_HOME
+ * @return This configuration
+ */
+ JBossASServerConfig jbossHome(String jbossHome);
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfigLegacy.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,333 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.net.InetAddress;
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.mc.config.MCBasedServerConfig;
+
+/**
+ * JBossASServerConfig
+ *
+ * Placeholder for properties which need to be moved out
+ * into the real config
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ * @deprecated To be replaced by a completed {@link JBossASServerConfig} implementation
+ */
+ at Deprecated
+public interface JBossASServerConfigLegacy extends MCBasedServerConfig<JBossASServerConfigLegacy>
+{
+
+
+ //-------------------------------------------------------------------------------||
+ // LEGACY -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+ //TODO Everything to be moved out of here
+
+ /*
+ * STUFF BELOW HERE has not been addressed/documented/reintegrated
+ */
+
+ /** The default partition name */
+ String DEFAULT_VALUE_PARITION_NAME = "DefaultPartition";
+
+ /** The partition name property */
+ String PROP_KEY_JBOSSAS_PARTITION_NAME_PROPERTY = "jboss.partition.name";
+
+ /** The udp address property */
+ String PROP_KEY_JBOSSAS_PARTITION_UDP_PROPERTY = "jboss.partition.udpGroup";
+
+ /** The udp port property */
+ String PROP_KEY_JBOSSAS_PARTITION_UDP_PORT_PROPERTY = "jboss.jgroups.udp.mcast_port";
+
+ /** Whether to load native libraries */
+ String PROP_KEY_JBOSSAS_NATIVE_LOAD_PROPERTY = "jboss.native.load";
+
+ /** The location of native libraries property */
+ String PROP_KEY_JBOSSAS_NATIVE_DIR_PROPERTY = "jboss.native.dir";
+
+ /**
+ * 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.
+ *
+ * <p>If this value is a <tt>file</tt> URL, then all .zip and .jar files
+ * inside will be prepended to the classpath. Otherwise the URL will be
+ * added to the classpath. If not set then the no patch files will be
+ * loaded.
+ */
+ String PROP_KEY_JBOSSAS_PATCH_URL = "jboss.patch.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the base directory for calculating server
+ * home directories.
+ *
+ * <p>Defaults to <tt><em>HOME_DIR</em>/server</tt>.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_BASE_DIR = "jboss.server.base.dir";
+
+ /**
+ * 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>.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_LOG_DIR = "jboss.server.log.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the directory which JBoss will use for
+ * temporary file storage.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/tmp</tt> .
+ */
+ String PROP_KEY_JBOSSAS_SERVER_TEMP_DIR = "jboss.server.temp.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the directory which JBoss will use for
+ * persistent data file storage.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/data</tt>.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_DATA_DIR = "jboss.server.data.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the base URL for calculating server
+ * home URLs.
+ *
+ * <p>Defaults to <tt><em>HOME_URL</em>/server</tt>.
+ */
+ String PROP_KEY_JBOSSAS_SERVER_BASE_URL = "jboss.server.base.url";
+
+ /**
+ * 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> .
+ */
+ 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.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/lib</tt>/
+ */
+ String PROP_KEY_JBOSSAS_SERVER_LIBRARY_URL = "jboss.server.lib.url";
+
+ /**
+ * 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.
+ *
+ * <p>Defaults to <tt><em>COMMON_BASE_URL</em>/lib/</tt>
+ */
+ String PROP_KEY_JBOSSAS_COMMON_LIBRARY_URL = "jboss.common.lib.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying whether or not the server should exit the
+ * JVM on shutdown.
+ *
+ * <p>If not set then the server will default to exiting on shutdown.
+ */
+ String EXIT_ON_SHUTDOWN = "jboss.server.exitonshutdown";
+
+ /**
+ * Constant that holds the name of the environment property for
+ * specifying whether or not the server should shutdown
+ * synchronously (true) or asynchronously (false).
+ *
+ * <p>If not set then the server will default to asynchronous shutdown.
+ */
+ String BLOCKING_SHUTDOWN = "jboss.server.blockingshutdown";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying whether or not to install the lifethread
+ *
+ * <p>If not set then the server will default to installing the lifethread.
+ */
+ String INSTALL_LIFE_THREAD = "jboss.server.lifethread";
+
+ /**
+ * Constant that holds the name of the environment property for
+ * specifying whether or not the server should log and ignore
+ * exceptions when setting the URLStreamHandlerFactory.
+ *
+ * <p>If not set then the server will default to asynchronous shutdown.
+ */
+ String REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY = "jboss.server.requirejbossurlstreamhandlerfactory";
+
+ /**
+ * Constant that holds the name of the environment property for specifying
+ * whether or not to use as the main jboss server the MBeanServer returned
+ * from ManagementFactory.getPlatformMBeanServer(), when running under jdk1.5+
+ *
+ * <p>If not set then jboss will instantiate its own MBeanServer
+ */
+ String PLATFORM_MBEANSERVER = "jboss.platform.mbeanserver";
+
+ /////////////////////////////////////////////////////////////////////////
+ // Path Suffixes //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * 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/";
+
+ /**
+ * 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_BASE_DIR}.
+ */
+ String DEFAULT_VALUE_SERVER_BASE_DIR_SUFFIX = "server";
+
+ /**
+ * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_BASE_URL}.
+ */
+ String DEFAULT_VALUE_SERVER_BASE_URL_SUFFIX = "server/";
+
+ /**
+ * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_DATA_DIR}.
+ */
+ String DEFAULT_VALUE_SERVER_DATA_DIR_SUFFIX = "data";
+
+ /**
+ * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_LOG_DIR}.
+ */
+ String DEFAULT_VALUE_SERVER_LOG_DIR_SUFFIX = "log";
+
+ /**
+ * The suffix used when generating the default value for {@link #PROP_KEY_JBOSSAS_SERVER_TEMP_DIR}.
+ */
+ 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);
+
+}
Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/SecurityActions.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/SecurityActions.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/SecurityActions.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.logging.Logger;
+
+/**
+ * SecurityActions
+ *
+ * Utility class for security actions, so as to provide
+ * some centralization without leaking privileged actions
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SecurityActions.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * In place to prevent instanciation
+ */
+ private SecurityActions()
+ {
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Utility Methods --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Environment Variable of specified key, or null
+ * if not found
+ *
+ * @throws IllegalArgumentException If the key was not specified
+ */
+ static String getEnvironmentVariable(final String key) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (key == null || key.length() == 0)
+ {
+ throw new IllegalArgumentException("Key is a required argument");
+ }
+
+ // Get
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+
+ public String run()
+ {
+ final String value = System.getenv(key);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Obtained Environment Variable with key \"" + key + "\": " + value);
+ }
+ return value;
+ }
+
+ });
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import java.util.Date;
+
+import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.spi.mc.server.MCBasedServer;
+
+/**
+ * JBossASServer
+ *
+ * Contract of a JBossAS Server
+ *
+ * @author Jason Dillon
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface JBossASServer extends MCBasedServer<JBossASServer, JBossASServerConfig>
+{
+ /** The JMX notification event type sent on end of server startup */
+ public final String START_NOTIFICATION_TYPE = "org.jboss.system.server.started";
+
+ /** The JMX notification event type sent on begin of the server shutdown */
+ public final String STOP_NOTIFICATION_TYPE = "org.jboss.system.server.stopped";
+
+ /** @return The server start date */
+ Date getStartDate();
+
+ /** @return The server version */
+ String getVersion();
+
+ /** @return The server version code name */
+ String getVersionName();
+
+ /** @return The full server version number */
+ String getVersionNumber();
+
+ /** @return The date the server was build (compiled) */
+ String getBuildNumber();
+
+ /** @return The JVM used to build the server */
+ String getBuildJVM();
+
+ /** @return The Operating System used to build the server */
+ String getBuildOS();
+
+ /** @return The build id */
+ String getBuildID();
+
+ /** @return The date the server was build */
+ String getBuildDate();
+}
Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import java.util.Date;
+
+import org.jboss.bootstrap.impl.as.config.BasicJBossASServerConfig;
+import org.jboss.bootstrap.impl.as.config.JBossASConfigurationInitializer;
+import org.jboss.bootstrap.impl.as.config.JBossASConfigurationInitializerImpl;
+import org.jboss.bootstrap.impl.as.config.JBossASConfigurationValidator;
+import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase;
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+
+/**
+ * JBossASServerImpl
+ *
+ * Implementation of a JBossAS Server
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASServerImpl extends AbstractMCServerBase<JBossASServer, JBossASServerConfig>
+ implements
+ JBossASServer
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * The validator instance
+ */
+ private static final ConfigurationValidator<JBossASServerConfig> VALIDATOR;
+
+ /**
+ * The server initializer instance
+ */
+ private static final JBossASServerInitializer SERVER_INITIALIZER;
+
+ /**
+ * The config validator instance
+ */
+ private static final JBossASConfigurationInitializer CONFIG_INITIALIZER;
+
+ /*
+ * Initialize constants
+ */
+ static
+ {
+ VALIDATOR = new JBossASConfigurationValidator();
+ SERVER_INITIALIZER = new JBossASServerInitializer();
+ CONFIG_INITIALIZER = new JBossASConfigurationInitializerImpl();
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * Constructs a new JBossAS Server with the specified underlying configuration
+ *
+ * @param config
+ */
+ public JBossASServerImpl(final JBossASServerConfig config) throws IllegalArgumentException
+ {
+ // Invoke super
+ super(config);
+
+ // Set properties
+ this.setServerInitializer(SERVER_INITIALIZER);
+ this.setConfigInitializer(CONFIG_INITIALIZER);
+ this.setValidator(VALIDATOR);
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Required Implement--ations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.base.server.AbstractServer#getDefaultServerConfigClass()
+ */
+ @Override
+ protected Class<? extends JBossASServerConfig> getDefaultServerConfigClass()
+ {
+ return BasicJBossASServerConfig.class;
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * EVERYTHING BELOW THIS LINE IS TODO
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doShutdown()
+ */
+ @Override
+ protected void doShutdown() throws Exception
+ {
+ // TODO Auto-generated method stub
+ super.doShutdown();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doStart()
+ */
+ @Override
+ protected void doStart() throws Exception
+ {
+ // TODO Auto-generated method stub
+ super.doStart();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractServer#start()
+ */
+ @Override
+ public void start() throws IllegalStateException, Exception
+ {
+ // TODO Auto-generated method stub
+ super.start();
+
+ //TODO
+ // // Send a notification that the startup is complete
+ // KernelEventManager eventMgr = this.getKernel().getEventManager();
+ // KernelEvent startEvent = new AbstractEvent(eventMgr, START_NOTIFICATION_TYPE, 0, System.currentTimeMillis(),
+ // new Long(watch.getLapTime()));
+ // eventMgr.fireKernelEvent(startEvent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildDate()
+ */
+ public String getBuildDate()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildID()
+ */
+ public String getBuildID()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildJVM()
+ */
+ public String getBuildJVM()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildNumber()
+ */
+ public String getBuildNumber()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildOS()
+ */
+ public String getBuildOS()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getStartDate()
+ */
+ public Date getStartDate()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersion()
+ */
+ public String getVersion()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersionName()
+ */
+ public String getVersionName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersionNumber()
+ */
+ public String getVersionNumber()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.impl.base.server.AbstractBasicServerInitializer;
+import org.jboss.bootstrap.spi.server.Server;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+import org.jboss.logging.Logger;
+
+/**
+ * JBossASServerInitializer
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASServerInitializer extends AbstractBasicServerInitializer<JBossASServer, JBossASServerConfig>
+ implements
+ ServerInitializer<JBossASServer, JBossASServerConfig>
+{
+
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASServerInitializer.class);
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractBasicServerInitializer#initialize(org.jboss.bootstrap.spi.server.Server)
+ */
+ @Override
+ public void initialize(Server<JBossASServer, JBossASServerConfig> server) throws IllegalArgumentException,
+ IllegalStateException
+ {
+ // TODO Auto-generated method stub
+ super.initialize(server);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractBasicServerInitializer#setSystemProperties(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ @Override
+ protected void setSystemProperties(JBossASServerConfig configuration)
+ {
+ // Set
+ //TODO
+
+ // Invoke super implementation
+ super.setSystemProperties(configuration);
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JBossASConfigurationInitializationTestCase
+ *
+ * Test Cases to assert that the default configuration
+ * initializer implementation is functioning as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASConfigurationInitializationTestCase
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(JBossASConfigurationInitializationTestCase.class);
+
+ /**
+ * The initializer implementation to test
+ */
+ private static JBossASConfigurationInitializer initializer;
+
+ //-------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * The configuration
+ */
+ private static JBossASServerConfig config;
+
+ //-------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Performs initialization before any tests run
+ */
+ @BeforeClass
+ public static void init()
+ {
+ initializer = new JBossASConfigurationInitializerImpl();
+ }
+
+ /**
+ * Creates and sets a new config
+ */
+ @Before
+ public void preTest()
+ {
+ config = new BasicJBossASServerConfig();
+ }
+
+ /**
+ * Cleans up the config used in testing such that state
+ * is not carried (leaked) from test to test
+ */
+ @After
+ public void cleanup()
+ {
+ config = null;
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Test Cases -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that jboss.bind.address defaults to loopback
+ * @throws Throwable
+ */
+ @Test
+ public void testBindAddressDefaultsToLocalhost() throws Throwable
+ {
+ // Log
+ log.info("testBindAddressDefaultsToLocalhost");
+
+ // Initialize the blank config
+ initializer.initialize(config);
+
+ // Get out the bind address
+ final String bindAddress = config.getBindAddress();
+
+ // Get expected value
+ final String expectedBindAddress = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
+
+ // Test
+ TestCase.assertEquals("Bind address was not defaulted as expected", expectedBindAddress, bindAddress);
+ }
+
+ /**
+ * Ensures that jboss.server.name defaults to "default"
+ * @throws Throwable
+ */
+ @Test
+ public void testServerNameDefaultsToDefault() throws Throwable
+ {
+ // Log
+ log.info("testServerNameDefaultsToDefault");
+
+ // Initialize the blank config
+ initializer.initialize(config);
+
+ // Get out the server name
+ final String serverName = config.getServerName();
+
+ // Get expected value
+ final String expectedServerName = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
+
+ // Test
+ TestCase.assertEquals("Server name was not defaulted as expected", expectedServerName, serverName);
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/PropertyValueResolutionTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/PropertyValueResolutionTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/PropertyValueResolutionTestCase.java 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * PropertyValueResolutionTestCase
+ *
+ * Test Cases to validate that the {@link JBossASConfigurationInitializerImpl}
+ * has proper resolution logic such that priority in resolving properties is:
+ *
+ * 1) System Property / Configuration Property
+ * 2) Current Value
+ * 3) Environment Variable
+ * 4) Default
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class PropertyValueResolutionTestCase
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(PropertyValueResolutionTestCase.class);
+
+ /**
+ * null value String
+ */
+ private static final String NULL = null;
+
+ /**
+ * Mock default value
+ */
+ private static final String DEFAULT = "Default";
+
+ /**
+ * Mock current value
+ */
+ private static final String CURRENT = "Current";
+
+ /**
+ * Simple fake property name
+ */
+ private static final String PROP_NAME_FAKE = "fake";
+
+ /**
+ * Common environment variable name
+ */
+ private static final String ENV_VAR_NAME = "PATH";
+
+ /**
+ * Empty properties
+ */
+ private static final Map<String, String> PROPS_EMPTY = Collections.emptyMap();
+
+ /**
+ * The initializer implementation to test
+ */
+ private static JBossASConfigurationInitializerImpl initializer;
+
+ //-------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Performs initialization before any tests run
+ */
+ @BeforeClass
+ public static void init()
+ {
+ initializer = new JBossASConfigurationInitializerImpl();
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Test Cases -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that given no current value or overrides, the default
+ * value takes precedence
+ */
+ @Test
+ public void testResolutionToDefaultIfEverythingElseNull()
+ {
+ // Log
+ log.info("testResolutionToDefaultIfEverythingElseNull");
+
+ // Define default
+ final String defaultValue = DEFAULT;
+
+ // Resolve
+ final String resolvedValue = initializer.resolvePropertyValue(PROP_NAME_FAKE, NULL, NULL, defaultValue,
+ PROPS_EMPTY);
+
+ // Test
+ TestCase.assertEquals("The resolution to default in the case that no other value was specified failed",
+ defaultValue, resolvedValue);
+ }
+
+ /**
+ * Ensures that given no current value or overrides, the
+ * environment variable takes precedence over the default
+ */
+ @Test
+ public void testResolutionToEnvVarOverDefault()
+ {
+ // Log
+ log.info("testResolutionToEnvVarOverDefault");
+
+ // Define default
+ final String defaultValue = DEFAULT;
+
+ // Get the environment variable
+ final String envVarName = ENV_VAR_NAME;
+ final String envVarValue = System.getenv(envVarName);
+ TestCase.assertNotNull("Environment Variable \"" + envVarName + "\" must be set for this test", envVarValue);
+
+ // Resolve
+ final String resolvedValue = initializer.resolvePropertyValue(PROP_NAME_FAKE, envVarName, NULL, defaultValue,
+ PROPS_EMPTY);
+
+ // Test
+ TestCase.assertEquals(
+ "The resolution to environment variable in the case that no other value was specified failed", envVarValue,
+ resolvedValue);
+ }
+
+ /**
+ * Ensures that the current object value is given
+ * precedence over the default (which should be used
+ * only when no existing or override values are found)
+ * and the environment variable
+ */
+ @Test
+ public void testResolutionToCurrentValueOverDefaultAndEnvVar()
+ {
+ // Log
+ log.info("testResolutionToCurrentValueOverDefaultAndEnvVar");
+
+ // Define default
+ final String defaultValue = DEFAULT;
+
+ // Define the environment variable name
+ final String envVarName = ENV_VAR_NAME;
+
+ // Define current (presumably from the object model)
+ final String currentValue = CURRENT;
+
+ // Resolve
+ final String resolvedValue = initializer.resolvePropertyValue(PROP_NAME_FAKE, envVarName, currentValue,
+ defaultValue, PROPS_EMPTY);
+
+ // Test
+ TestCase.assertEquals("The resolution to current over a default value with no overrides failed", currentValue,
+ resolvedValue);
+ }
+
+ /**
+ * Ensures that the property value overrides take precedence
+ * over the current value, default value, and environment
+ * variable
+ */
+ @Test
+ public void testResolutionToPropOverCurrentEnvVarAndDefault()
+ {
+ // Log
+ log.info("testResolutionToPropOverCurrentEnvVarAndDefault");
+
+ // Define default
+ final String defaultValue = DEFAULT;
+
+ // Define the environment variable name
+ final String envVarName = ENV_VAR_NAME;
+
+ // Define current (presumably from the object model)
+ final String currentValue = CURRENT;
+
+ // Make configuration properties
+ final Map<String, String> props = new HashMap<String, String>();
+ final String propKey = PROP_NAME_FAKE;
+ final String propValue = "Override Value";
+ props.put(propKey, propValue);
+
+ // Resolve
+ final String resolvedValue = initializer.resolvePropertyValue(PROP_NAME_FAKE, envVarName, currentValue,
+ defaultValue, props);
+
+ // Test
+ TestCase.assertEquals("The resolution to property overrides over current, default, and env var failed",
+ propValue, resolvedValue);
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/test/resources/log4j.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/log4j.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/log4j.xml 2009-04-22 05:32:06 UTC (rev 87656)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jnp">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.bootstrap">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Modified: projects/bootstrap/trunk/pom.xml
===================================================================
--- projects/bootstrap/trunk/pom.xml 2009-04-22 04:59:26 UTC (rev 87655)
+++ projects/bootstrap/trunk/pom.xml 2009-04-22 05:32:06 UTC (rev 87656)
@@ -32,6 +32,7 @@
<!-- Aggregate Modules -->
<modules>
<module>build</module>
+ <module>impl-as</module>
<module>impl-base</module>
<module>impl-mc</module>
<module>legacy</module>
More information about the jboss-cvs-commits
mailing list