[jboss-cvs] JBossAS SVN: r87278 - in projects/bootstrap/trunk: impl-mc and 32 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 14 08:28:22 EDT 2009
Author: ALRubinger
Date: 2009-04-14 08:28:22 -0400 (Tue, 14 Apr 2009)
New Revision: 87278
Added:
projects/bootstrap/trunk/spi-base/
projects/bootstrap/trunk/spi-base/.classpath
projects/bootstrap/trunk/spi-base/.project
projects/bootstrap/trunk/spi-base/.settings/
projects/bootstrap/trunk/spi-base/.settings/org.eclipse.jdt.core.prefs
projects/bootstrap/trunk/spi-base/.settings/org.maven.ide.eclipse.prefs
projects/bootstrap/trunk/spi-base/pom.xml
projects/bootstrap/trunk/spi-base/src/
projects/bootstrap/trunk/spi-base/src/main/
projects/bootstrap/trunk/spi-base/src/main/java/
projects/bootstrap/trunk/spi-base/src/main/java/org/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationInitializer.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationValidator.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicServerConfig.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/SecurityActions.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractBasicServerInitializer.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractServer.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/SecurityActions.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/
projects/bootstrap/trunk/spi-base/src/test/
projects/bootstrap/trunk/spi-base/src/test/java/
projects/bootstrap/trunk/spi-base/src/test/java/org/
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/
projects/bootstrap/trunk/spi-base/src/test/resources/
Removed:
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/config/
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/server/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationInitializer.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationValidator.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/SecurityActions.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractBasicServerInitializer.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/
projects/bootstrap/trunk/spi/src/test/java/org/
projects/bootstrap/trunk/spi/src/test/resources/
Modified:
projects/bootstrap/trunk/impl-mc/pom.xml
projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/BasicMCServerConfig.java
projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationInitializer.java
projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationValidator.java
projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java
projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCServerInitializer.java
projects/bootstrap/trunk/pom.xml
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapParser.java
projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapSchemaBinding.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/Counter.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingConfigurationValidator.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingServerInitializer.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigFactory.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationInitializer.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationValidator.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerConfig.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerInitializer.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/BasicConfigurationTestCase.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigInitializationTestCase.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigValidationTestCase.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/TestNoOpServer.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerInitializationTestCase.java
projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerLifecycleTestCase.java
projects/bootstrap/trunk/spi-mc/pom.xml
projects/bootstrap/trunk/spi/pom.xml
Log:
[JBBOOT-38] Split abstract base classes from bootstrap-spi into new bootstrap-spi-base
Modified: projects/bootstrap/trunk/impl-mc/pom.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/pom.xml 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/pom.xml 2009-04-14 12:28:22 UTC (rev 87278)
@@ -25,7 +25,8 @@
<!-- Properties -->
<properties>
- <version.org.jboss.bootstrap_jboss.bootstrap.spi.mc>0.1.0</version.org.jboss.bootstrap_jboss.bootstrap.spi.mc>
+ <version.org.jboss.bootstrap_jboss.bootstrap.spi.base>0.1.1-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.spi.base>
+ <version.org.jboss.bootstrap_jboss.bootstrap.spi.mc>0.1.1-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.spi.mc>
<version.org.jboss.man_jboss.managed>2.0.0.GA</version.org.jboss.man_jboss.managed>
</properties>
@@ -44,6 +45,13 @@
<artifactId>junit</artifactId>
</dependency>
+ <!-- org.jboss.bootstrap:jboss-bootstrap-spi-base -->
+ <dependency>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap-spi-base</artifactId>
+ <version>${version.org.jboss.bootstrap_jboss.bootstrap.spi.base}</version>
+ </dependency>
+
<!-- org.jboss.bootstrap:jboss-bootstrap-spi-mc -->
<dependency>
<groupId>org.jboss.bootstrap</groupId>
Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/BasicMCServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/BasicMCServerConfig.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/BasicMCServerConfig.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -24,7 +24,7 @@
import java.util.Map;
-import org.jboss.bootstrap.spi.config.AbstractBasicServerConfig;
+import org.jboss.bootstrap.spi.base.config.AbstractBasicServerConfig;
import org.jboss.bootstrap.spi.mc.config.MCServerConfig;
import org.jboss.logging.Logger;
Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationInitializer.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -22,7 +22,7 @@
package org.jboss.bootstrap.impl.mc.config;
-import org.jboss.bootstrap.spi.config.AbstractBasicConfigurationInitializer;
+import org.jboss.bootstrap.spi.base.config.AbstractBasicConfigurationInitializer;
import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
import org.jboss.bootstrap.spi.mc.config.MCServerConfig;
Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationValidator.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/config/MCConfigurationValidator.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -22,7 +22,7 @@
package org.jboss.bootstrap.impl.mc.config;
-import org.jboss.bootstrap.spi.config.AbstractBasicConfigurationValidator;
+import org.jboss.bootstrap.spi.base.config.AbstractBasicConfigurationValidator;
import org.jboss.bootstrap.spi.config.ConfigurationValidator;
import org.jboss.bootstrap.spi.mc.config.MCServerConfig;
Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -28,11 +28,11 @@
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.bootstrap.impl.mc.deployer.TempBasicXMLDeployer;
+import org.jboss.bootstrap.spi.base.server.AbstractServer;
+import org.jboss.bootstrap.spi.base.xml.BootstrapParser;
import org.jboss.bootstrap.spi.mc.config.MCBasedServerConfig;
import org.jboss.bootstrap.spi.mc.server.MCBasedServer;
import org.jboss.bootstrap.spi.metadata.BootstrapMetaData;
-import org.jboss.bootstrap.spi.server.AbstractServer;
-import org.jboss.bootstrap.spi.xml.BootstrapParser;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.spi.dependency.KernelController;
Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCServerInitializer.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCServerInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -22,9 +22,9 @@
package org.jboss.bootstrap.impl.mc.server;
+import org.jboss.bootstrap.spi.base.server.AbstractBasicServerInitializer;
import org.jboss.bootstrap.spi.mc.config.MCServerConfig;
import org.jboss.bootstrap.spi.mc.server.MCServer;
-import org.jboss.bootstrap.spi.server.AbstractBasicServerInitializer;
import org.jboss.bootstrap.spi.server.ServerInitializer;
/**
Modified: projects/bootstrap/trunk/pom.xml
===================================================================
--- projects/bootstrap/trunk/pom.xml 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/pom.xml 2009-04-14 12:28:22 UTC (rev 87278)
@@ -35,6 +35,7 @@
<module>impl-mc</module>
<module>legacy</module>
<module>spi</module>
+ <module>spi-base</module>
<module>spi-mc</module>
</modules>
Modified: projects/bootstrap/trunk/spi/pom.xml
===================================================================
--- projects/bootstrap/trunk/spi/pom.xml 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/pom.xml 2009-04-14 12:28:22 UTC (rev 87278)
@@ -2,7 +2,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">
+<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>
@@ -35,25 +36,5 @@
<!-- Dependencies -->
<dependencies>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jbossxb</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </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>
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationInitializer.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,266 +0,0 @@
-/*
- * 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.spi.config;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-
-/**
- * AbstractBasicConfigurationInitializer
- *
- * Base for initializing a configuration before
- * its validated and used to run a server
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class AbstractBasicConfigurationInitializer<T extends ServerConfig<T>>
- implements
- ConfigurationInitializer<T>
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractBasicConfigurationInitializer.class);
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ConfigurationInitializer#initialize(org.jboss.bootstrap.spi.config.ServerConfig)
- */
- public void initialize(T config) throws InvalidConfigurationException, IllegalArgumentException,
- IllegalStateException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Initializing: " + config);
- }
-
- // Apply overrides
- this.applySystemPropertyOverrides(config);
-
- /*
- * Default the config
- */
-
- final URL bootstrapUrl = config.getBootstrapUrl();
- final URL home = config.getBootstrapHome();
- final URL conf = config.getBootstrapConfLocation();
- final String name = config.getBootstrapName();
-
- /*
- * If bootstrapURL is not directly defined, construct it from
- * home+name (assuming they both *are* defined)
- */
-
- if (bootstrapUrl == null && (home != null && name != null))
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("No bootstrap URL defined, constructing it from home and name...");
- }
-
- // Construct
- URL newBootstrapUrl = null;
- try
- {
- newBootstrapUrl = new URL(home, name);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException(new InvalidConfigurationException(
- "Cannot construct bootstrapURL from home and name", e));
- }
-
- // Log
- log.debug("New bootstrap URL: " + newBootstrapUrl.toExternalForm());
-
- // Set
- config.bootstrapUrl(newBootstrapUrl);
- }
-
- /*
- * If bootstrapConf was not initialized, set it from either home or URL base
- */
-
- if (conf == null)
- {
- // Make a new conf
- URL newConf = null;
-
- // If we've got a home
- if (home != null)
- {
- try
- {
- String homeExternal = home.toExternalForm();
- newConf = new URL(homeExternal);
- log.debug("Defaulted bootstrapConf from bootstrap home: " + homeExternal);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not default the conf from home", e);
- }
- }
- // If we've got a bootstrapURL
- else if (bootstrapUrl != null)
- {
- try
- {
- final String bootstrapUrlString = bootstrapUrl.toExternalForm();
- final String bootstrapUrlBase = bootstrapUrlString.substring(0, bootstrapUrlString.lastIndexOf("/") + 1);
- newConf = new URL(bootstrapUrlBase);
- log.debug("Defaulted bootstrapConf from bootstrapURL's base: " + bootstrapUrlBase);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not default the conf from bootstrapURL base", e);
- }
- }
-
- // Set
- if (newConf != null)
- {
- config.bootstrapConfLocation(newConf);
- }
- }
-
- // If there's no name, default it, then run this config again to
- // default other properties if necessary
- if (name == null || name.length() == 0)
- {
- config.bootstrapName(ConfigurationInitializer.DEFAULT_NAME);
- this.initialize(config);
- }
-
- // If there's no home, default it, then run this config again
- if (home == null)
- {
- final URL newHome = SecurityActions.getCodeSourceLocation(this.getClass());
- config.bootstrapHome(newHome);
- this.initialize(config);
- }
-
- }
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Sets the values of contracted system properties upon the supplied configuration
- *
- * @throws IllegalArgumentException If the config was not specified
- */
- protected void applySystemPropertyOverrides(final T config) throws IllegalArgumentException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Applying system property overrides...");
- }
-
- // Precondition check
- if (config == null)
- {
- throw new IllegalArgumentException("Supplied configuration is null");
- }
-
- // Get Properties
- final Map<String, String> properties = config.getProperties();
-
- /*
- * Apply overrides if present
- */
-
- // Home
- final String overrideHome = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, properties);
- if (overrideHome != null)
- {
- config.bootstrapHome(overrideHome);
- }
-
- // Conf
- final String overrideConf = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL, properties);
- if (overrideConf != null)
- {
- config.bootstrapConfLocation(overrideConf);
- }
-
- // URL
- final String overrideUrl = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_URL, properties);
- if (overrideUrl != null)
- {
- config.bootstrapUrl(overrideUrl);
- }
-
- // Name
- final String overrideName = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, properties);
- if (overrideName != null)
- {
- config.bootstrapName(overrideName);
- }
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Returns the override value for the specified property name in the specified
- * properties, additionally logging if found. If not found, null will be returned.
- *
- * @throws IllegalArgumentException If either argument is null
- */
- private String getOverrideValue(final String propertyName, final Map<String, String> properties)
- throws IllegalArgumentException
- {
- // Get the override value
- String override = properties.get(propertyName);
-
- // Adjust to null if empty
- if (override != null && override.length() == 0)
- {
- override = null;
- }
-
- // Log if we'll use it
- if (override != null && override.length() > 0)
- {
- log.debug("Got system property " + propertyName + ", so using as override: " + override);
- }
-
- // Return
- return override;
- }
-
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationValidator.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationValidator.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,102 +0,0 @@
-/*
- * 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.spi.config;
-
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-
-/**
- * AbstractBasicConfigurationValidator
- *
- * Base for validating a server configuration to assert that
- * it's valid for defining a server
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class AbstractBasicConfigurationValidator<T extends ServerConfig<T>>
- implements
- ConfigurationValidator<T>
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractBasicConfigurationValidator.class);
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ConfigurationValidator#validate(org.jboss.bootstrap.spi.config.ServerConfig)
- */
- public void validate(final T config) throws InvalidConfigurationException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Validating configuration: " + config);
- }
-
- // Precondition check
- if (config == null)
- {
- throw new IllegalArgumentException("Configuration is required, but was not supplied");
- }
-
- // Get properties
- final String name = config.getBootstrapName();
- final URL home = config.getBootstrapHome();
- final URL direct = config.getBootstrapUrl();
- final URL conf = config.getBootstrapConfLocation();
-
- // If no direct bootstrap URL
- if (direct == null)
- {
- // Ensure we may construct this via home+name
- if (home == null || (name == null || name.length() == 0))
- {
- throw new InvalidConfigurationException(
- "If the bootstrap URL is not specified, both the bootstrap home and name must be.");
- }
- }
-
- // If no conf
- if (conf == null)
- {
- // Ensure we may construct this from home
- if (home == null)
- {
- throw new InvalidConfigurationException("Bootstrap configuration location must be specified explicity, "
- + "or a home must be provided such that it may be constructed");
- }
- }
-
- // Log
- log.debug("Configuration passed on: " + config);
- }
-
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,543 +0,0 @@
-/*
- * 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.spi.config;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.jboss.logging.Logger;
-
-/**
- * BasicServerConfig
- *
- * Base for simple Object-backed implementations of a Server
- * Configuration. As this is exported from the Server, this
- * is Thread-safe.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class AbstractBasicServerConfig<T extends ServerConfig<T>> implements ServerConfig<T>
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractBasicServerConfig.class);
-
- private static final String TRAILING_SLASH = "/";
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Actual class used in casting for covarient return in
- * method chaining. Synchronized on "this".
- */
- private Class<T> actualClass;
-
- /**
- * URL of the bootstrap to run. Synchronized on
- * "this". Must
- * not be exported (so copy on return).
- */
- private URL bootstrapUrl;
-
- /**
- * Bootstrap configuration home (URLs referenced in the
- * main bootstrap are relative to this URL).
- * Synchronized on "this". Must
- * not be exported (so copy on return).
- */
- private URL bootstrapConfLocation;
-
- /**
- * Bootstrap home, used in defaulting/construction
- * of other properties. Synchronized on "this". Must
- * not be exported (so copy on return).
- */
- private URL bootstrapHome;
-
- /**
- * Name of the bootstrap file. Synchronized on
- * "this".
- */
- private String bootstrapName;
-
- /**
- * Properties for this configuration. Must be backed
- * by a Thread-safe impl.
- */
- private ConcurrentMap<String, String> properties;
-
- /**
- * Whether or not this configuration is frozen
- */
- private AtomicBoolean frozen;
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Constructor
- *
- * @param actualClass The actual class of this Server Configuration
- * to be used in casting for covarient return types
- */
- public AbstractBasicServerConfig(final Class<T> actualClass)
- {
- // Use no override properties
- this(actualClass, null);
- }
-
- /**
- * Constructor
- *
- * @param actualClass The actual class of this Server Configuration
- * to be used in casting for covarient return types
- * @param overrideProperties A Map of properties to override those found
- * in System Properties
- */
- public AbstractBasicServerConfig(final Class<T> actualClass, final Map<String, String> overrideProperties)
- {
- /*
- * Initialize properties
- */
- Properties sysProps = System.getProperties();
- ConcurrentMap<String, String> properties = new ConcurrentHashMap<String, String>();
- Set<Object> sysPropKeys = sysProps.keySet();
- for (Object sysPropKey : sysPropKeys)
- {
- // Cast, all Property keys are Strings
- String sysPropKeyString = (String) sysPropKey;
- String value = sysProps.getProperty(sysPropKeyString);
- properties.put(sysPropKeyString, value);
- }
-
- /*
- * Override properties
- */
- if (overrideProperties != null)
- {
- properties.putAll(overrideProperties);
- }
-
- /*
- * Set properties
- */
- this.properties = properties;
- synchronized (this)
- {
- this.actualClass = actualClass;
- }
- this.frozen = new AtomicBoolean(false);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapConfLocation()
- */
- public URL getBootstrapConfLocation()
- {
- URL url = null;
- synchronized (this)
- {
- url = this.bootstrapConfLocation;
- }
- return this.copyURL(url);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapHome()
- */
- public URL getBootstrapHome()
- {
- URL url = null;
- synchronized (this)
- {
- url = this.bootstrapHome;
- }
- return this.copyURL(url);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapName()
- */
- public synchronized String getBootstrapName()
- {
- return this.bootstrapName;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapUrl()
- */
- public URL getBootstrapUrl()
- {
- URL url = null;
- synchronized (this)
- {
- url = this.bootstrapUrl;
- }
- return this.copyURL(url);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getProperties()
- */
- public Map<String, String> getProperties()
- {
- return Collections.unmodifiableMap(this.properties);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapConfLocation(java.net.URL)
- */
- public synchronized T bootstrapConfLocation(final URL confLocation) throws IllegalArgumentException
- {
- // Precondition check
- this.checkMutable();
-
- // Adjust
- final URL newUrl = this.adjustToDirectory(confLocation);
-
- // Set property
- this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_CONF_URL, newUrl);
-
- // Set URL
- this.bootstrapConfLocation = newUrl;
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapHome(java.net.URL)
- */
- public synchronized T bootstrapHome(final URL bootstrapHome) throws IllegalArgumentException
- {
- // Precondition check
- this.checkMutable();
-
- // Adjust
- final URL newUrl = this.adjustToDirectory(bootstrapHome);
-
- // Set property
- this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_HOME_URL, newUrl);
-
- // Set URL
- this.bootstrapHome = newUrl;
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapName(java.lang.String)
- */
- public synchronized T bootstrapName(final String name) throws IllegalArgumentException
- {
- // Precondition check
- this.checkMutable();
-
- // Set property
- this.setPropertyForString(PROP_KEY_BOOTSTRAP_NAME, name);
-
- // Set URL
- this.bootstrapName = name;
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapUrl(java.net.URL)
- */
- public synchronized T bootstrapUrl(final URL bootstrapLocation) throws IllegalArgumentException
- {
- // Precondition check
- this.checkMutable();
-
- // Set property
- this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_URL, bootstrapLocation);
-
- // Set URL
- this.bootstrapUrl = bootstrapLocation;
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#property(java.lang.String, java.lang.String)
- */
- public T property(final String key, final String value) throws IllegalArgumentException
- {
- // Precondition check
- this.checkMutable();
-
- // Set property
- this.setPropertyForString(key, value);
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#freeze()
- */
- public void freeze() throws IllegalStateException
- {
- this.frozen.set(true);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#isFrozen()
- */
- public boolean isFrozen()
- {
- return this.frozen.get();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapConfLocation(java.lang.String)
- */
- public T bootstrapConfLocation(String confLocation) throws IllegalArgumentException, IllegalStateException
- {
- // Set
- this.bootstrapConfLocation(this.urlFromString(confLocation));
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapHome(java.lang.String)
- */
- public T bootstrapHome(String bootstrapHome) throws IllegalArgumentException, IllegalStateException
- {
- // Set
- this.bootstrapHome(this.urlFromString(bootstrapHome));
-
- // Return
- return this.covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapUrl(java.lang.String)
- */
- public T bootstrapUrl(String bootstrapUrl) throws IllegalArgumentException, IllegalStateException
- {
- // Set
- this.bootstrapUrl(this.urlFromString(bootstrapUrl));
-
- // Return
- return this.covarientReturn();
- }
-
- //-------------------------------------------------------------------------------------||
- // Helper Methods ---------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Sets both the configuration property and System property with the
- * specified key and the external form of the specified URL
- */
- protected void setPropertyForUrl(final String propertyName, final URL url)
- {
- String urlString = url != null ? url.toExternalForm() : null;
- this.setPropertyForString(propertyName, urlString);
- }
-
- /**
- * Sets both the configuration property and System property with the
- * specified key and specified value
- */
- protected void setPropertyForString(final String propertyName, final String value)
- {
- Map<String, String> properties = this.properties;
- String valueToSet = value;
- if (valueToSet == null)
- {
- valueToSet = "";
- }
- properties.put(propertyName, valueToSet);
- if (log.isTraceEnabled())
- {
- log.trace(("Set property \"" + propertyName + "\" to: ") + (value != null ? "\"" + value + "\"" : "[EMPTY]"));
- }
- }
-
- /**
- * Throws IllegalStateException if this configuration is frozen
- *
- * @throws IllegalStateException
- */
- protected void checkMutable() throws IllegalStateException
- {
- if (this.isFrozen())
- {
- throw new IllegalStateException("Cannot mutate state of the configuration after it has been frozen");
- }
- }
-
- /**
- * If the specified URL denotes a directory (ie. trailing slash),
- * will return the argument. Nulls are ignored and returned as-is.
- *
- * @param url
- * @return
- */
- protected URL adjustToDirectory(final URL url)
- {
- // Do nothing to nulls
- if (url == null)
- {
- return null;
- }
-
- // Check
- final String externalForm = url.toExternalForm();
- if (externalForm.endsWith(TRAILING_SLASH))
- {
- // Return per normal
- return url;
- }
-
- // Otherwise make a new URL
- final String newLocation = externalForm + TRAILING_SLASH;
- URL newUrl = null;
- try
- {
- // Construct
- newUrl = new URL(newLocation);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not create new URL to point to directory", e);
- }
-
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Appended trailing slash to " + url + " to point to directory: " + newUrl);
- }
-
- // Return it
- return newUrl;
- }
-
- /**
- * Returns the actual types of this configuration, used in
- * covarient return of the mutator methods
- *
- * @return
- */
- protected Class<T> getActualClass()
- {
- return this.actualClass;
- }
-
- /**
- * Casts this configuration to the requisite type, using
- * the actual implementation class. This is in place to
- * avoid unchecked casting (ie. (T)this)) and the resultant compiler
- * warnings
- *
- * @return
- */
- protected final T covarientReturn() throws ClassCastException
- {
- try
- {
- return this.getActualClass().cast(this);
- }
- catch (ClassCastException cce)
- {
- throw new RuntimeException(
- "Could not return the expected type; ensure that this configuration was constructed with the correct actual class",
- cce);
- }
- }
-
- /**
- * Copies and returns the specified URL. Used
- * to ensure we don't export mutable URLs (thread safety)
- *
- * @param url
- * @return
- */
- protected final URL copyURL(final URL url)
- {
- // If null, return
- if (url == null)
- {
- return url;
- }
-
- try
- {
- // Copy
- return new URL(url.toExternalForm());
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Error in copying URL", e);
- }
- }
-
- /**
- * Constructs a URL from the specified String, throwing
- * {@link IllegalArgumentException} to wrap the
- * {@link MalformedURLException} if unable to do so. Null arguments
- * will be ignored.
- *
- * @param url
- * @return
- * @throws IllegalArgumentException
- */
- protected final URL urlFromString(String url) throws IllegalArgumentException
- {
- try
- {
- return url != null ? new URL(url) : null;
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Could not construct " + URL.class.getSimpleName()
- + " from the supplied argument: " + url, e);
- }
- }
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/SecurityActions.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/SecurityActions.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/SecurityActions.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,80 +0,0 @@
-/*
- * 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.spi.config;
-
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * 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
-{
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * In place to prevent instanciation
- */
- private SecurityActions()
- {
- }
-
- //-------------------------------------------------------------------------------------||
- // Utility Methods --------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the URL codesource location of the given class
- *
- * @param clazz
- * @throws IllegalArgumentException If the class was not specified
- */
- static URL getCodeSourceLocation(final Class<?> clazz) throws IllegalArgumentException
- {
- // Precondition check
- if (clazz == null)
- {
- throw new IllegalArgumentException("Class for code source is required");
- }
-
- // Return codesource location
- return AccessController.doPrivileged(new PrivilegedAction<URL>()
- {
-
- public URL run()
- {
- return clazz.getProtectionDomain().getCodeSource().getLocation();
- }
-
- });
- }
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractBasicServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractBasicServerInitializer.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractBasicServerInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,185 +0,0 @@
-/*
- * 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.spi.server;
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.bootstrap.spi.config.ServerConfig;
-import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
-import org.jboss.logging.Logger;
-
-/**
- * AbstractBasicServerInitializer
- *
- * Simple server initializer which will default the configuration
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class AbstractBasicServerInitializer<K extends Server<K, T>, T extends ServerConfig<T>>
- implements
- ServerInitializer<K, T>
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractBasicServerInitializer.class);
-
- /**
- * Set of all system properties added during initialization. Synchronized on "this",
- * must not be exported.
- */
- private static final Set<String> SYS_PROPS_ADDED = new HashSet<String>();
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.ServerInitializer#initialize(org.jboss.bootstrap.spi.server.Server)
- */
- public synchronized void initialize(final Server<K, T> server) throws IllegalArgumentException,
- IllegalStateException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Request to initialize " + server + " using: " + this);
- }
-
- // Precondition checks
- if (server == null)
- {
- throw new IllegalArgumentException("Server must be specified");
- }
-
- final LifecycleState state = server.getState();
- final LifecycleState required = LifecycleState.PRE_INIT;
- if (!state.equals(required))
- {
- throw new IllegalStateException(this + " may only be invoked when " + LifecycleState.class.getSimpleName()
- + " is " + required + ", was: " + state);
- }
-
- // Obtain config
- final T config = server.getConfiguration();
-
- // Set System Properties
- if (log.isTraceEnabled())
- {
- log.trace("Setting system properties for " + server);
- }
- this.setSystemProperties(config);
-
- // Log
- log.debug("Initialized " + server + ": " + this);
-
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.ServerInitializer#cleanup(org.jboss.bootstrap.spi.server.Server)
- */
- public synchronized void cleanup(final Server<K, T> server) throws IllegalArgumentException, IllegalStateException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Preparing for shutdown...");
- }
-
- // Clear all system properties set
- log.debug("Clearing all system properties set in initialization...");
- for (final String sysProp : SYS_PROPS_ADDED)
- {
- SecurityActions.clearSystemProperty(sysProp);
- }
-
- }
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Sets system properties from the current configuration; may be overridden to set
- * more properties
- */
- protected void setSystemProperties(final T configuration)
- {
- // Set Properties from Config
- this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, configuration.getBootstrapHome());
- this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_URL, configuration.getBootstrapUrl());
- this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL, configuration.getBootstrapConfLocation());
- this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, configuration.getBootstrapName());
- }
-
- /**
- * Sets the specified URL's external form as a system property with the specified key
- *
- * @param key
- * @param value
- */
- protected final void setSystemProperty(final String key, final URL value)
- {
- String urlString = value != null ? value.toExternalForm() : "";
- this.setSystemProperty(key, urlString == null ? null : urlString);
- }
-
- /**
- * Sets the specified system property key to the specified value
- *
- * @param key The non-null key
- * @param value
- */
- protected final void setSystemProperty(final String key, final String value)
- {
- // Precondition check
- assert key != null : "Key for system property was null";
-
- // Adjust for null
- String valueToSet = value;
- if (valueToSet == null)
- {
- valueToSet = "";
- }
-
- // Set
- SecurityActions.setSystemProperty(key, valueToSet);
-
- // Add to Set
- synchronized (this)
- {
- SYS_PROPS_ADDED.add(key);
- }
-
- // Log
- if (log.isTraceEnabled())
- {
- log.trace(("Set system property \"" + key + "\" to: ")
- + (value != null ? "\"" + valueToSet + "\"" : "[EMPTY]"));
- }
- }
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,574 +0,0 @@
-/*
- * 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.spi.server;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.bootstrap.spi.Bootstrap;
-import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
-import org.jboss.bootstrap.spi.config.ConfigurationValidator;
-import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
-import org.jboss.bootstrap.spi.config.ServerConfig;
-import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
-import org.jboss.logging.Logger;
-
-/**
- * AbstractServer
- *
- * Generic support for
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public abstract class AbstractServer<K extends Server<K, T>, T extends ServerConfig<T>> implements Server<K, T>
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractServer.class);
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Current state of the server. Synchronized on "this".
- */
- private LifecycleState state;
-
- /**
- * Underlying configuration. Must be a Thread-safe implementation
- * as it's exported
- */
- private T configuration;
-
- /**
- * Validator for the configuration. Synchronized on "this". Requires
- * Thread-safe impl (as it's exported)
- */
- private ConfigurationValidator<T> validator;
-
- /**
- * Initializer for the configuration. Synchronized on "this". Requires
- * Thread-safe impl (as it's exported)
- */
- private ConfigurationInitializer<T> configInitializer;
-
- /**
- * Server initializer. Synchronized on "this". Requires
- * Thread-safe impl (as it's exported)
- */
- private ServerInitializer<K, T> serverInitializer;
-
- /**
- * The list of bootstraps to run upon start, requires Thread-safe impl.
- */
- private final List<Bootstrap> bootstraps = new CopyOnWriteArrayList<Bootstrap>();
-
- /**
- * The bootstraps that have been started, requires Thread-safe impl.
- */
- private final List<Bootstrap> startedBootstraps = new CopyOnWriteArrayList<Bootstrap>();
-
- //-------------------------------------------------------------------------------------||
- // Constructors -----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Constructor
- */
- protected AbstractServer()
- {
- this(null);
- }
-
- /**
- * Constructor
- *
- * @param configuration The configuration to set
- */
- protected AbstractServer(final T configuration)
- {
- // Check for valid config and set
- this.setConfiguration(configuration);
-
- // Set properties
- this.setState(LifecycleState.PRE_INIT);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#getConfiguration()
- */
- public final T getConfiguration()
- {
- return this.configuration;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#setConfiguration(org.jboss.bootstrap.spi.config.ServerConfig)
- */
- public void setConfiguration(final T configuration)
- {
- // Log and set
- if (log.isTraceEnabled())
- {
- log.trace("Set configuration: " + configuration);
- }
- this.configuration = configuration;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#getState()
- */
- public final synchronized LifecycleState getState()
- {
- LifecycleState state = this.state;
- if (state == null)
- {
- throw new IllegalStateException("null state");
- }
- return state;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#shutdown()
- */
- public void shutdown() throws IllegalStateException, Exception
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Received request to shutdown");
- }
-
- // Ensure running
- LifecycleState required = LifecycleState.STARTED;
- LifecycleState actual = this.getState();
- this.checkState(required, actual);
-
- // Initiate shutdown sequence
- log.info("Stopping: " + this);
- this.setState(LifecycleState.STOPPING);
-
- // Shutdown the Bootstraps
- if (log.isTraceEnabled())
- {
- log.trace("Shutting down bootstraps");
- }
- this.shutdownBootstraps();
-
- // Shutdown
- if (log.isTraceEnabled())
- {
- log.trace("Calling implementation class shutdown...");
- }
- this.doShutdown();
-
- // Let the initializer clean up
- final ServerInitializer<K, T> serverInitializer = this.getServerInitializer();
- if (serverInitializer != null)
- {
- if (log.isTraceEnabled())
- {
- log.trace("Calling to clean up for shutdown: " + serverInitializer);
- }
- serverInitializer.cleanup(this);
- }
-
- // Done
- log.info("Stopped: " + this);
- this.setState(LifecycleState.IDLE);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#start()
- */
- public void start() throws IllegalStateException, Exception
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Received request to start");
- }
-
- // Invoke init() if necessary
- if (this.getState().equals(LifecycleState.PRE_INIT))
- {
- log.debug("Invoking implicit initialization from start()");
- this.initialize();
- }
-
- // Ensure idle
- final LifecycleState required = LifecycleState.IDLE;
- final LifecycleState actual = this.getState();
- this.checkState(required, actual);
-
- // Initiate shutdown sequence
- log.info("Starting: " + this);
- this.setState(LifecycleState.STARTING);
-
- // Start
- if (log.isTraceEnabled())
- {
- log.trace("Entering implementation class start...");
- }
- this.doStart();
-
- // Run the bootstraps
- if (log.isTraceEnabled())
- {
- log.trace("Starting bootstraps...");
- }
- this.startBootstraps();
-
- // Done
- log.info("Started: " + this);
- this.setState(LifecycleState.STARTED);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#addBootstrap(org.jboss.bootstrap.spi.Bootstrap)
- */
- public void addBootstrap(final Bootstrap bootstrap) throws IllegalStateException, IllegalArgumentException
- {
- // Precondition check
- if (bootstrap == null)
- {
- throw new IllegalArgumentException("Supplied bootstrap was null");
- }
-
- // Add
- this.getBootstraps().add(bootstrap);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#removeBootstrap(org.jboss.bootstrap.spi.Bootstrap)
- */
- public void removeBootstrap(final Bootstrap bootstrap) throws IllegalStateException, IllegalArgumentException
- {
- // Remove
- boolean removed = bootstraps.remove(bootstrap);
-
- // Postcondition check
- if (!removed)
- {
- throw new IllegalArgumentException(
- "Specified bootstrap could not be removed because it is not present in the list");
- }
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#getValidator()
- */
- public ConfigurationValidator<T> getValidator()
- {
- return this.validator;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#initialize()
- */
- public synchronized void initialize() throws IllegalStateException, InvalidConfigurationException
- {
- // Log
- log.debug("Initializing server: " + this);
-
- /*
- * Precondition checks
- */
-
- // State must be pre-initialized
- final LifecycleState state = this.getState();
- if (!state.equals(LifecycleState.PRE_INIT))
- {
- throw new IllegalStateException("Cannot initialize an already initialized server, state is: " + state);
- }
-
- // Config must be in place
- final T config = this.getConfiguration();
- if (config == null)
- {
- throw new IllegalStateException("Configuration must be supplied before server is initialized");
- }
-
- // If there's a configuration initializer, use it
- final ConfigurationInitializer<T> configInitializer = this.getConfigInitializer();
- if (configInitializer != null)
- {
- if (log.isTraceEnabled())
- {
- log.trace("Performing configuration initialization...");
- }
- configInitializer.initialize(config);
- }
- else
- {
- if (log.isTraceEnabled())
- {
- log.trace("No configuration initializer supplied, skipping");
- }
- }
-
- // Validate
- if (log.isTraceEnabled())
- {
- log.trace("Validating config...");
- }
- this.validate(config);
-
- /*
- * If there's an initializer, use it
- */
- final ServerInitializer<K, T> serverInitializer = this.getServerInitializer();
- if (serverInitializer != null)
- {
- serverInitializer.initialize(this);
- }
- else
- {
- log.debug("No initializer defined, skipping initialization of " + this);
- }
-
- // Freeze config
- config.freeze();
-
- // Set state
- this.setState(LifecycleState.IDLE);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#getInitializer()
- */
- public synchronized final ServerInitializer<K, T> getServerInitializer()
- {
- return this.serverInitializer;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#setInitializer(org.jboss.bootstrap.spi.server.ServerInitializer)
- */
- public synchronized final void setServerInitializer(final ServerInitializer<K, T> serverInitializer)
- throws IllegalStateException
- {
- // Precondition check
- this.checkState(LifecycleState.PRE_INIT, this.getState());
-
- this.serverInitializer = serverInitializer;
- log.debug("Set server initializer to " + serverInitializer);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#getConfigInitializer()
- */
- public synchronized final ConfigurationInitializer<T> getConfigInitializer()
- {
- return this.configInitializer;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#setConfigInitializer(org.jboss.bootstrap.spi.config.ConfigurationInitializer)
- */
- public synchronized final void setConfigInitializer(ConfigurationInitializer<T> configInitializer)
- {
- // Precondition check
- this.checkState(LifecycleState.PRE_INIT, this.getState());
-
- this.configInitializer = configInitializer;
- log.debug("Set config initializer to " + configInitializer);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.Server#setConfigurationValidator(org.jboss.bootstrap.spi.config.ConfigurationValidator)
- */
- public synchronized final void setValidator(final ConfigurationValidator<T> validator)
- {
- // Precondition check
- this.checkState(LifecycleState.PRE_INIT, this.getState());
-
- log.debug("Setting validator to: " + validator);
- this.validator = validator;
- }
-
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
- /**
- * Implementation-specific start hook
- *
- * @throws Exception
- */
- protected abstract void doStart() throws Exception;
-
- /**
- * Implementation-specific shutdown hook
- *
- * @throws Exception
- */
- protected abstract void doShutdown() throws Exception;
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Starts the bootstraps
- *
- * @throws Exception
- */
- protected void startBootstraps() throws Exception
- {
- // Run the bootstraps
- for (Bootstrap bootstrap : this.getBootstraps())
- {
- // Add in reverse order
- this.getStartedBootstraps().add(0, bootstrap);
-
- // Start
- bootstrap.start(this);
- }
- }
-
- /**
- * Shuts down the bootstraps that have been started
- */
- protected void shutdownBootstraps()
- {
- // Initialize
- final List<Bootstrap> startedBootstraps = this.getStartedBootstraps();
-
- // Signal
- for (Bootstrap bootstrap : startedBootstraps)
- {
- bootstrap.prepareShutdown(this);
- }
-
- // Do the bootstraps in reverse order
- for (Bootstrap bootstrap : startedBootstraps)
- {
- try
- {
- bootstrap.shutdown(this);
- }
- catch (Throwable t)
- {
- log.warn("Error shutting down bootstrap: " + bootstrap, t);
- }
- }
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures the actual state matches the required, throwing {@link IllegalStateException}
- * if not
- *
- * @throws IllegalStateException If the actual state does not match required
- */
- private void checkState(final LifecycleState required, final LifecycleState actual) throws IllegalStateException
- {
- // Check State
- if (required != actual)
- {
- throw new IllegalStateException("Server must be in " + LifecycleState.class.getSimpleName() + " " + required
- + "; is instead: " + actual);
- }
- }
-
- /**
- * If {@link Server#getValidator()} is non-null, will
- * assert the configuration is valid using the supplied
- * validator
- *
- * @param configuration
- * @throws InvalidConfigurationException If the configuration is invalid
- * @throws IllegalArgumentException If the confirguation has not been set
- */
- private void validate(T configuration) throws InvalidConfigurationException, IllegalArgumentException
- {
- // Precondition check
- if (configuration == null)
- {
- throw new IllegalArgumentException("Configuration was not specified");
- }
-
- // Get the validator
- ConfigurationValidator<T> validator = this.getValidator();
-
- // Is specified, validate
- if (validator != null)
- {
- log.debug("Validating configuration using: " + validator);
- validator.validate(this.getConfiguration());
- }
- else
- {
- if (log.isTraceEnabled())
- {
- log.trace("No validator defined, skipping validation upon configuration");
- }
- }
- }
-
- //-------------------------------------------------------------------------------------||
- // Accessors / Mutators ---------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * @return the bootstraps
- */
- private List<Bootstrap> getBootstraps()
- {
- return bootstraps;
- }
-
- /**
- * @return the startedBootstraps
- */
- private List<Bootstrap> getStartedBootstraps()
- {
- return startedBootstraps;
- }
-
- /**
- * @param state the state to set
- */
- private synchronized final void setState(final LifecycleState state)
- {
- // Log and set
- if (log.isTraceEnabled())
- {
- log.trace("Setting " + LifecycleState.class.getSimpleName() + " to: " + state);
- }
- this.state = state;
- }
-
-}
Deleted: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -1,142 +0,0 @@
-/*
- * 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.spi.server;
-
-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 --------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Sets a system property with specified key and value
- *
- * @throws IllegalArgumentException If the key was not specified
- */
- static void setSystemProperty(final String key, final String value) throws IllegalArgumentException
- {
- // Precondition check
- ensureSysPropKeySpecified(key);
-
- // Set
- AccessController.doPrivileged(new PrivilegedAction<Void>()
- {
-
- public Void run()
- {
- // Set
- System.setProperty(key, value);
-
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Set system property \"" + key + "\" > " + value);
- }
-
- // Return
- return null;
- }
-
- });
- }
-
- /**
- * Clears the specified System Property
- *
- * @throws IllegalArgumentException If the key was not specified
- */
- static void clearSystemProperty(final String key) throws IllegalArgumentException
- {
- // Precondition check
- ensureSysPropKeySpecified(key);
-
- // Set
- AccessController.doPrivileged(new PrivilegedAction<Void>()
- {
-
- public Void run()
- {
- // Clear
- String previousValue = System.clearProperty(key);
-
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Removed system property \"" + key + "\" which had previous value: " + previousValue);
- }
-
- // Return
- return null;
- }
-
- });
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that the specified key is not null
- *
- * @throws IllegalArgumentException If the specified key was null
- */
- private static void ensureSysPropKeySpecified(String key) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("Key for System Property was not specified");
- }
- }
-}
Property changes on: projects/bootstrap/trunk/spi-base
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
Added: projects/bootstrap/trunk/spi-base/.classpath
===================================================================
--- projects/bootstrap/trunk/spi-base/.classpath (rev 0)
+++ projects/bootstrap/trunk/spi-base/.classpath 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,7 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java" output="eclipse-target/tests-classes"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+</classpath>
\ No newline at end of file
Added: projects/bootstrap/trunk/spi-base/.project
===================================================================
--- projects/bootstrap/trunk/spi-base/.project (rev 0)
+++ projects/bootstrap/trunk/spi-base/.project 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,17 @@
+<projectDescription>
+ <name>jboss-bootstrap-spi-base</name>
+ <comment>Service Provider Abstract Base for 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/spi-base/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/bootstrap/trunk/spi-base/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/bootstrap/trunk/spi-base/.settings/org.eclipse.jdt.core.prefs 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,5 @@
+#Mon Apr 13 20:50:02 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/spi-base/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/bootstrap/trunk/spi-base/.settings/org.maven.ide.eclipse.prefs (rev 0)
+++ projects/bootstrap/trunk/spi-base/.settings/org.maven.ide.eclipse.prefs 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,8 @@
+#Mon Apr 13 20:47:09 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/spi-base/pom.xml
===================================================================
--- projects/bootstrap/trunk/spi-base/pom.xml (rev 0)
+++ projects/bootstrap/trunk/spi-base/pom.xml 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,68 @@
+<?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</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <artifactId>jboss-bootstrap-spi-base</artifactId>
+ <name>JBoss Bootstrap SPI Base</name>
+ <version>0.1.1-SNAPSHOT</version>
+ <description>Service Provider Abstract Base for JBoss Bootstrap</description>
+
+
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versioning -->
+ <version.org.jboss.bootstrap_jboss.bootstrap.spi>0.1.1-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.spi>
+
+ </properties>
+
+ <!-- Build -->
+ <build>
+
+ </build>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap-spi</artifactId>
+ <version>${version.org.jboss.bootstrap_jboss.bootstrap.spi}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </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>
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationInitializer.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationInitializer.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationInitializer.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,270 @@
+/*
+ * 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.spi.base.config;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.logging.Logger;
+
+
+/**
+ * AbstractBasicConfigurationInitializer
+ *
+ * Base for initializing a configuration before
+ * its validated and used to run a server
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractBasicConfigurationInitializer<T extends ServerConfig<T>>
+ implements
+ ConfigurationInitializer<T>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractBasicConfigurationInitializer.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ConfigurationInitializer#initialize(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ public void initialize(T config) throws InvalidConfigurationException, IllegalArgumentException,
+ IllegalStateException
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Initializing: " + config);
+ }
+
+ // Apply overrides
+ this.applySystemPropertyOverrides(config);
+
+ /*
+ * Default the config
+ */
+
+ final URL bootstrapUrl = config.getBootstrapUrl();
+ final URL home = config.getBootstrapHome();
+ final URL conf = config.getBootstrapConfLocation();
+ final String name = config.getBootstrapName();
+
+ /*
+ * If bootstrapURL is not directly defined, construct it from
+ * home+name (assuming they both *are* defined)
+ */
+
+ if (bootstrapUrl == null && (home != null && name != null))
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("No bootstrap URL defined, constructing it from home and name...");
+ }
+
+ // Construct
+ URL newBootstrapUrl = null;
+ try
+ {
+ newBootstrapUrl = new URL(home, name);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException(new InvalidConfigurationException(
+ "Cannot construct bootstrapURL from home and name", e));
+ }
+
+ // Log
+ log.debug("New bootstrap URL: " + newBootstrapUrl.toExternalForm());
+
+ // Set
+ config.bootstrapUrl(newBootstrapUrl);
+ }
+
+ /*
+ * If bootstrapConf was not initialized, set it from either home or URL base
+ */
+
+ if (conf == null)
+ {
+ // Make a new conf
+ URL newConf = null;
+
+ // If we've got a home
+ if (home != null)
+ {
+ try
+ {
+ String homeExternal = home.toExternalForm();
+ newConf = new URL(homeExternal);
+ log.debug("Defaulted bootstrapConf from bootstrap home: " + homeExternal);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not default the conf from home", e);
+ }
+ }
+ // If we've got a bootstrapURL
+ else if (bootstrapUrl != null)
+ {
+ try
+ {
+ final String bootstrapUrlString = bootstrapUrl.toExternalForm();
+ final String bootstrapUrlBase = bootstrapUrlString.substring(0, bootstrapUrlString.lastIndexOf("/") + 1);
+ newConf = new URL(bootstrapUrlBase);
+ log.debug("Defaulted bootstrapConf from bootstrapURL's base: " + bootstrapUrlBase);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not default the conf from bootstrapURL base", e);
+ }
+ }
+
+ // Set
+ if (newConf != null)
+ {
+ config.bootstrapConfLocation(newConf);
+ }
+ }
+
+ // If there's no name, default it, then run this config again to
+ // default other properties if necessary
+ if (name == null || name.length() == 0)
+ {
+ config.bootstrapName(ConfigurationInitializer.DEFAULT_NAME);
+ this.initialize(config);
+ }
+
+ // If there's no home, default it, then run this config again
+ if (home == null)
+ {
+ final URL newHome = SecurityActions.getCodeSourceLocation(this.getClass());
+ config.bootstrapHome(newHome);
+ this.initialize(config);
+ }
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets the values of contracted system properties upon the supplied configuration
+ *
+ * @throws IllegalArgumentException If the config was not specified
+ */
+ protected void applySystemPropertyOverrides(final T config) throws IllegalArgumentException
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Applying system property overrides...");
+ }
+
+ // Precondition check
+ if (config == null)
+ {
+ throw new IllegalArgumentException("Supplied configuration is null");
+ }
+
+ // Get Properties
+ final Map<String, String> properties = config.getProperties();
+
+ /*
+ * Apply overrides if present
+ */
+
+ // Home
+ final String overrideHome = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, properties);
+ if (overrideHome != null)
+ {
+ config.bootstrapHome(overrideHome);
+ }
+
+ // Conf
+ final String overrideConf = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL, properties);
+ if (overrideConf != null)
+ {
+ config.bootstrapConfLocation(overrideConf);
+ }
+
+ // URL
+ final String overrideUrl = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_URL, properties);
+ if (overrideUrl != null)
+ {
+ config.bootstrapUrl(overrideUrl);
+ }
+
+ // Name
+ final String overrideName = this.getOverrideValue(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, properties);
+ if (overrideName != null)
+ {
+ config.bootstrapName(overrideName);
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns the override value for the specified property name in the specified
+ * properties, additionally logging if found. If not found, null will be returned.
+ *
+ * @throws IllegalArgumentException If either argument is null
+ */
+ private String getOverrideValue(final String propertyName, final Map<String, String> properties)
+ throws IllegalArgumentException
+ {
+ // Get the override value
+ String override = properties.get(propertyName);
+
+ // Adjust to null if empty
+ if (override != null && override.length() == 0)
+ {
+ override = null;
+ }
+
+ // Log if we'll use it
+ if (override != null && override.length() > 0)
+ {
+ log.debug("Got system property " + propertyName + ", so using as override: " + override);
+ }
+
+ // Return
+ return override;
+ }
+
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationInitializer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationValidator.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicConfigurationValidator.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationValidator.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationValidator.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,106 @@
+/*
+ * 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.spi.base.config;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.logging.Logger;
+
+
+/**
+ * AbstractBasicConfigurationValidator
+ *
+ * Base for validating a server configuration to assert that
+ * it's valid for defining a server
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractBasicConfigurationValidator<T extends ServerConfig<T>>
+ implements
+ ConfigurationValidator<T>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractBasicConfigurationValidator.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ConfigurationValidator#validate(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ public void validate(final T config) throws InvalidConfigurationException
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Validating configuration: " + config);
+ }
+
+ // Precondition check
+ if (config == null)
+ {
+ throw new IllegalArgumentException("Configuration is required, but was not supplied");
+ }
+
+ // Get properties
+ final String name = config.getBootstrapName();
+ final URL home = config.getBootstrapHome();
+ final URL direct = config.getBootstrapUrl();
+ final URL conf = config.getBootstrapConfLocation();
+
+ // If no direct bootstrap URL
+ if (direct == null)
+ {
+ // Ensure we may construct this via home+name
+ if (home == null || (name == null || name.length() == 0))
+ {
+ throw new InvalidConfigurationException(
+ "If the bootstrap URL is not specified, both the bootstrap home and name must be.");
+ }
+ }
+
+ // If no conf
+ if (conf == null)
+ {
+ // Ensure we may construct this from home
+ if (home == null)
+ {
+ throw new InvalidConfigurationException("Bootstrap configuration location must be specified explicity, "
+ + "or a home must be provided such that it may be constructed");
+ }
+ }
+
+ // Log
+ log.debug("Configuration passed on: " + config);
+ }
+
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicConfigurationValidator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicServerConfig.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicServerConfig.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicServerConfig.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,545 @@
+/*
+ * 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.spi.base.config;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.logging.Logger;
+
+
+/**
+ * BasicServerConfig
+ *
+ * Base for simple Object-backed implementations of a Server
+ * Configuration. As this is exported from the Server, this
+ * is Thread-safe.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractBasicServerConfig<T extends ServerConfig<T>> implements ServerConfig<T>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractBasicServerConfig.class);
+
+ private static final String TRAILING_SLASH = "/";
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Actual class used in casting for covarient return in
+ * method chaining. Synchronized on "this".
+ */
+ private Class<T> actualClass;
+
+ /**
+ * URL of the bootstrap to run. Synchronized on
+ * "this". Must
+ * not be exported (so copy on return).
+ */
+ private URL bootstrapUrl;
+
+ /**
+ * Bootstrap configuration home (URLs referenced in the
+ * main bootstrap are relative to this URL).
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
+ */
+ private URL bootstrapConfLocation;
+
+ /**
+ * Bootstrap home, used in defaulting/construction
+ * of other properties. Synchronized on "this". Must
+ * not be exported (so copy on return).
+ */
+ private URL bootstrapHome;
+
+ /**
+ * Name of the bootstrap file. Synchronized on
+ * "this".
+ */
+ private String bootstrapName;
+
+ /**
+ * Properties for this configuration. Must be backed
+ * by a Thread-safe impl.
+ */
+ private ConcurrentMap<String, String> properties;
+
+ /**
+ * Whether or not this configuration is frozen
+ */
+ private AtomicBoolean frozen;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param actualClass The actual class of this Server Configuration
+ * to be used in casting for covarient return types
+ */
+ public AbstractBasicServerConfig(final Class<T> actualClass)
+ {
+ // Use no override properties
+ this(actualClass, null);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param actualClass The actual class of this Server Configuration
+ * to be used in casting for covarient return types
+ * @param overrideProperties A Map of properties to override those found
+ * in System Properties
+ */
+ public AbstractBasicServerConfig(final Class<T> actualClass, final Map<String, String> overrideProperties)
+ {
+ /*
+ * Initialize properties
+ */
+ Properties sysProps = System.getProperties();
+ ConcurrentMap<String, String> properties = new ConcurrentHashMap<String, String>();
+ Set<Object> sysPropKeys = sysProps.keySet();
+ for (Object sysPropKey : sysPropKeys)
+ {
+ // Cast, all Property keys are Strings
+ String sysPropKeyString = (String) sysPropKey;
+ String value = sysProps.getProperty(sysPropKeyString);
+ properties.put(sysPropKeyString, value);
+ }
+
+ /*
+ * Override properties
+ */
+ if (overrideProperties != null)
+ {
+ properties.putAll(overrideProperties);
+ }
+
+ /*
+ * Set properties
+ */
+ this.properties = properties;
+ synchronized (this)
+ {
+ this.actualClass = actualClass;
+ }
+ this.frozen = new AtomicBoolean(false);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapConfLocation()
+ */
+ public URL getBootstrapConfLocation()
+ {
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootstrapConfLocation;
+ }
+ return this.copyURL(url);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapHome()
+ */
+ public URL getBootstrapHome()
+ {
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootstrapHome;
+ }
+ return this.copyURL(url);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapName()
+ */
+ public synchronized String getBootstrapName()
+ {
+ return this.bootstrapName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapUrl()
+ */
+ public URL getBootstrapUrl()
+ {
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootstrapUrl;
+ }
+ return this.copyURL(url);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getProperties()
+ */
+ public Map<String, String> getProperties()
+ {
+ return Collections.unmodifiableMap(this.properties);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapConfLocation(java.net.URL)
+ */
+ public synchronized T bootstrapConfLocation(final URL confLocation) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Adjust
+ final URL newUrl = this.adjustToDirectory(confLocation);
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_CONF_URL, newUrl);
+
+ // Set URL
+ this.bootstrapConfLocation = newUrl;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapHome(java.net.URL)
+ */
+ public synchronized T bootstrapHome(final URL bootstrapHome) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Adjust
+ final URL newUrl = this.adjustToDirectory(bootstrapHome);
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_HOME_URL, newUrl);
+
+ // Set URL
+ this.bootstrapHome = newUrl;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapName(java.lang.String)
+ */
+ public synchronized T bootstrapName(final String name) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForString(PROP_KEY_BOOTSTRAP_NAME, name);
+
+ // Set URL
+ this.bootstrapName = name;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapUrl(java.net.URL)
+ */
+ public synchronized T bootstrapUrl(final URL bootstrapLocation) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_URL, bootstrapLocation);
+
+ // Set URL
+ this.bootstrapUrl = bootstrapLocation;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#property(java.lang.String, java.lang.String)
+ */
+ public T property(final String key, final String value) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForString(key, value);
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#freeze()
+ */
+ public void freeze() throws IllegalStateException
+ {
+ this.frozen.set(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#isFrozen()
+ */
+ public boolean isFrozen()
+ {
+ return this.frozen.get();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapConfLocation(java.lang.String)
+ */
+ public T bootstrapConfLocation(String confLocation) throws IllegalArgumentException, IllegalStateException
+ {
+ // Set
+ this.bootstrapConfLocation(this.urlFromString(confLocation));
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapHome(java.lang.String)
+ */
+ public T bootstrapHome(String bootstrapHome) throws IllegalArgumentException, IllegalStateException
+ {
+ // Set
+ this.bootstrapHome(this.urlFromString(bootstrapHome));
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#bootstrapUrl(java.lang.String)
+ */
+ public T bootstrapUrl(String bootstrapUrl) throws IllegalArgumentException, IllegalStateException
+ {
+ // Set
+ this.bootstrapUrl(this.urlFromString(bootstrapUrl));
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Helper Methods ---------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets both the configuration property and System property with the
+ * specified key and the external form of the specified URL
+ */
+ protected void setPropertyForUrl(final String propertyName, final URL url)
+ {
+ String urlString = url != null ? url.toExternalForm() : null;
+ this.setPropertyForString(propertyName, urlString);
+ }
+
+ /**
+ * Sets both the configuration property and System property with the
+ * specified key and specified value
+ */
+ protected void setPropertyForString(final String propertyName, final String value)
+ {
+ Map<String, String> properties = this.properties;
+ String valueToSet = value;
+ if (valueToSet == null)
+ {
+ valueToSet = "";
+ }
+ properties.put(propertyName, valueToSet);
+ if (log.isTraceEnabled())
+ {
+ log.trace(("Set property \"" + propertyName + "\" to: ") + (value != null ? "\"" + value + "\"" : "[EMPTY]"));
+ }
+ }
+
+ /**
+ * Throws IllegalStateException if this configuration is frozen
+ *
+ * @throws IllegalStateException
+ */
+ protected void checkMutable() throws IllegalStateException
+ {
+ if (this.isFrozen())
+ {
+ throw new IllegalStateException("Cannot mutate state of the configuration after it has been frozen");
+ }
+ }
+
+ /**
+ * If the specified URL denotes a directory (ie. trailing slash),
+ * will return the argument. Nulls are ignored and returned as-is.
+ *
+ * @param url
+ * @return
+ */
+ protected URL adjustToDirectory(final URL url)
+ {
+ // Do nothing to nulls
+ if (url == null)
+ {
+ return null;
+ }
+
+ // Check
+ final String externalForm = url.toExternalForm();
+ if (externalForm.endsWith(TRAILING_SLASH))
+ {
+ // Return per normal
+ return url;
+ }
+
+ // Otherwise make a new URL
+ final String newLocation = externalForm + TRAILING_SLASH;
+ URL newUrl = null;
+ try
+ {
+ // Construct
+ newUrl = new URL(newLocation);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not create new URL to point to directory", e);
+ }
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Appended trailing slash to " + url + " to point to directory: " + newUrl);
+ }
+
+ // Return it
+ return newUrl;
+ }
+
+ /**
+ * Returns the actual types of this configuration, used in
+ * covarient return of the mutator methods
+ *
+ * @return
+ */
+ protected Class<T> getActualClass()
+ {
+ return this.actualClass;
+ }
+
+ /**
+ * Casts this configuration to the requisite type, using
+ * the actual implementation class. This is in place to
+ * avoid unchecked casting (ie. (T)this)) and the resultant compiler
+ * warnings
+ *
+ * @return
+ */
+ protected final T covarientReturn() throws ClassCastException
+ {
+ try
+ {
+ return this.getActualClass().cast(this);
+ }
+ catch (ClassCastException cce)
+ {
+ throw new RuntimeException(
+ "Could not return the expected type; ensure that this configuration was constructed with the correct actual class",
+ cce);
+ }
+ }
+
+ /**
+ * Copies and returns the specified URL. Used
+ * to ensure we don't export mutable URLs (thread safety)
+ *
+ * @param url
+ * @return
+ */
+ protected final URL copyURL(final URL url)
+ {
+ // If null, return
+ if (url == null)
+ {
+ return url;
+ }
+
+ try
+ {
+ // Copy
+ return new URL(url.toExternalForm());
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Error in copying URL", e);
+ }
+ }
+
+ /**
+ * Constructs a URL from the specified String, throwing
+ * {@link IllegalArgumentException} to wrap the
+ * {@link MalformedURLException} if unable to do so. Null arguments
+ * will be ignored.
+ *
+ * @param url
+ * @return
+ * @throws IllegalArgumentException
+ */
+ protected final URL urlFromString(String url) throws IllegalArgumentException
+ {
+ try
+ {
+ return url != null ? new URL(url) : null;
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Could not construct " + URL.class.getSimpleName()
+ + " from the supplied argument: " + url, e);
+ }
+ }
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/AbstractBasicServerConfig.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/SecurityActions.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/SecurityActions.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/SecurityActions.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/SecurityActions.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.base.config;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * 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
+{
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * In place to prevent instanciation
+ */
+ private SecurityActions()
+ {
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Utility Methods --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the URL codesource location of the given class
+ *
+ * @param clazz
+ * @throws IllegalArgumentException If the class was not specified
+ */
+ static URL getCodeSourceLocation(final Class<?> clazz) throws IllegalArgumentException
+ {
+ // Precondition check
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("Class for code source is required");
+ }
+
+ // Return codesource location
+ return AccessController.doPrivileged(new PrivilegedAction<URL>()
+ {
+
+ public URL run()
+ {
+ return clazz.getProtectionDomain().getCodeSource().getLocation();
+ }
+
+ });
+ }
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/config/SecurityActions.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractBasicServerInitializer.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractBasicServerInitializer.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractBasicServerInitializer.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractBasicServerInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,188 @@
+/*
+ * 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.spi.base.server;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
+import org.jboss.bootstrap.spi.server.Server;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+import org.jboss.logging.Logger;
+
+
+/**
+ * AbstractBasicServerInitializer
+ *
+ * Simple server initializer which will default the configuration
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractBasicServerInitializer<K extends Server<K, T>, T extends ServerConfig<T>>
+ implements
+ ServerInitializer<K, T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractBasicServerInitializer.class);
+
+ /**
+ * Set of all system properties added during initialization. Synchronized on "this",
+ * must not be exported.
+ */
+ private static final Set<String> SYS_PROPS_ADDED = new HashSet<String>();
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.ServerInitializer#initialize(org.jboss.bootstrap.spi.server.Server)
+ */
+ public synchronized void initialize(final Server<K, T> server) throws IllegalArgumentException,
+ IllegalStateException
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Request to initialize " + server + " using: " + this);
+ }
+
+ // Precondition checks
+ if (server == null)
+ {
+ throw new IllegalArgumentException("Server must be specified");
+ }
+
+ final LifecycleState state = server.getState();
+ final LifecycleState required = LifecycleState.PRE_INIT;
+ if (!state.equals(required))
+ {
+ throw new IllegalStateException(this + " may only be invoked when " + LifecycleState.class.getSimpleName()
+ + " is " + required + ", was: " + state);
+ }
+
+ // Obtain config
+ final T config = server.getConfiguration();
+
+ // Set System Properties
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting system properties for " + server);
+ }
+ this.setSystemProperties(config);
+
+ // Log
+ log.debug("Initialized " + server + ": " + this);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.ServerInitializer#cleanup(org.jboss.bootstrap.spi.server.Server)
+ */
+ public synchronized void cleanup(final Server<K, T> server) throws IllegalArgumentException, IllegalStateException
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Preparing for shutdown...");
+ }
+
+ // Clear all system properties set
+ log.debug("Clearing all system properties set in initialization...");
+ for (final String sysProp : SYS_PROPS_ADDED)
+ {
+ SecurityActions.clearSystemProperty(sysProp);
+ }
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets system properties from the current configuration; may be overridden to set
+ * more properties
+ */
+ protected void setSystemProperties(final T configuration)
+ {
+ // Set Properties from Config
+ this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, configuration.getBootstrapHome());
+ this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_URL, configuration.getBootstrapUrl());
+ this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL, configuration.getBootstrapConfLocation());
+ this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, configuration.getBootstrapName());
+ }
+
+ /**
+ * Sets the specified URL's external form as a system property with the specified key
+ *
+ * @param key
+ * @param value
+ */
+ protected final void setSystemProperty(final String key, final URL value)
+ {
+ String urlString = value != null ? value.toExternalForm() : "";
+ this.setSystemProperty(key, urlString == null ? null : urlString);
+ }
+
+ /**
+ * Sets the specified system property key to the specified value
+ *
+ * @param key The non-null key
+ * @param value
+ */
+ protected final void setSystemProperty(final String key, final String value)
+ {
+ // Precondition check
+ assert key != null : "Key for system property was null";
+
+ // Adjust for null
+ String valueToSet = value;
+ if (valueToSet == null)
+ {
+ valueToSet = "";
+ }
+
+ // Set
+ SecurityActions.setSystemProperty(key, valueToSet);
+
+ // Add to Set
+ synchronized (this)
+ {
+ SYS_PROPS_ADDED.add(key);
+ }
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace(("Set system property \"" + key + "\" to: ")
+ + (value != null ? "\"" + valueToSet + "\"" : "[EMPTY]"));
+ }
+ }
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractBasicServerInitializer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractServer.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractServer.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractServer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,576 @@
+/*
+ * 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.spi.base.server;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.bootstrap.spi.Bootstrap;
+import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
+import org.jboss.bootstrap.spi.server.Server;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+import org.jboss.logging.Logger;
+
+/**
+ * AbstractServer
+ *
+ * Generic support for
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractServer<K extends Server<K, T>, T extends ServerConfig<T>> implements Server<K, T>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractServer.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Current state of the server. Synchronized on "this".
+ */
+ private LifecycleState state;
+
+ /**
+ * Underlying configuration. Must be a Thread-safe implementation
+ * as it's exported
+ */
+ private T configuration;
+
+ /**
+ * Validator for the configuration. Synchronized on "this". Requires
+ * Thread-safe impl (as it's exported)
+ */
+ private ConfigurationValidator<T> validator;
+
+ /**
+ * Initializer for the configuration. Synchronized on "this". Requires
+ * Thread-safe impl (as it's exported)
+ */
+ private ConfigurationInitializer<T> configInitializer;
+
+ /**
+ * Server initializer. Synchronized on "this". Requires
+ * Thread-safe impl (as it's exported)
+ */
+ private ServerInitializer<K, T> serverInitializer;
+
+ /**
+ * The list of bootstraps to run upon start, requires Thread-safe impl.
+ */
+ private final List<Bootstrap> bootstraps = new CopyOnWriteArrayList<Bootstrap>();
+
+ /**
+ * The bootstraps that have been started, requires Thread-safe impl.
+ */
+ private final List<Bootstrap> startedBootstraps = new CopyOnWriteArrayList<Bootstrap>();
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ */
+ protected AbstractServer()
+ {
+ this(null);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param configuration The configuration to set
+ */
+ protected AbstractServer(final T configuration)
+ {
+ // Check for valid config and set
+ this.setConfiguration(configuration);
+
+ // Set properties
+ this.setState(LifecycleState.PRE_INIT);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getConfiguration()
+ */
+ public final T getConfiguration()
+ {
+ return this.configuration;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#setConfiguration(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ public void setConfiguration(final T configuration)
+ {
+ // Log and set
+ if (log.isTraceEnabled())
+ {
+ log.trace("Set configuration: " + configuration);
+ }
+ this.configuration = configuration;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getState()
+ */
+ public final synchronized LifecycleState getState()
+ {
+ LifecycleState state = this.state;
+ if (state == null)
+ {
+ throw new IllegalStateException("null state");
+ }
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#shutdown()
+ */
+ public void shutdown() throws IllegalStateException, Exception
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Received request to shutdown");
+ }
+
+ // Ensure running
+ LifecycleState required = LifecycleState.STARTED;
+ LifecycleState actual = this.getState();
+ this.checkState(required, actual);
+
+ // Initiate shutdown sequence
+ log.info("Stopping: " + this);
+ this.setState(LifecycleState.STOPPING);
+
+ // Shutdown the Bootstraps
+ if (log.isTraceEnabled())
+ {
+ log.trace("Shutting down bootstraps");
+ }
+ this.shutdownBootstraps();
+
+ // Shutdown
+ if (log.isTraceEnabled())
+ {
+ log.trace("Calling implementation class shutdown...");
+ }
+ this.doShutdown();
+
+ // Let the initializer clean up
+ final ServerInitializer<K, T> serverInitializer = this.getServerInitializer();
+ if (serverInitializer != null)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Calling to clean up for shutdown: " + serverInitializer);
+ }
+ serverInitializer.cleanup(this);
+ }
+
+ // Done
+ log.info("Stopped: " + this);
+ this.setState(LifecycleState.IDLE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#start()
+ */
+ public void start() throws IllegalStateException, Exception
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Received request to start");
+ }
+
+ // Invoke init() if necessary
+ if (this.getState().equals(LifecycleState.PRE_INIT))
+ {
+ log.debug("Invoking implicit initialization from start()");
+ this.initialize();
+ }
+
+ // Ensure idle
+ final LifecycleState required = LifecycleState.IDLE;
+ final LifecycleState actual = this.getState();
+ this.checkState(required, actual);
+
+ // Initiate shutdown sequence
+ log.info("Starting: " + this);
+ this.setState(LifecycleState.STARTING);
+
+ // Start
+ if (log.isTraceEnabled())
+ {
+ log.trace("Entering implementation class start...");
+ }
+ this.doStart();
+
+ // Run the bootstraps
+ if (log.isTraceEnabled())
+ {
+ log.trace("Starting bootstraps...");
+ }
+ this.startBootstraps();
+
+ // Done
+ log.info("Started: " + this);
+ this.setState(LifecycleState.STARTED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#addBootstrap(org.jboss.bootstrap.spi.Bootstrap)
+ */
+ public void addBootstrap(final Bootstrap bootstrap) throws IllegalStateException, IllegalArgumentException
+ {
+ // Precondition check
+ if (bootstrap == null)
+ {
+ throw new IllegalArgumentException("Supplied bootstrap was null");
+ }
+
+ // Add
+ this.getBootstraps().add(bootstrap);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#removeBootstrap(org.jboss.bootstrap.spi.Bootstrap)
+ */
+ public void removeBootstrap(final Bootstrap bootstrap) throws IllegalStateException, IllegalArgumentException
+ {
+ // Remove
+ boolean removed = bootstraps.remove(bootstrap);
+
+ // Postcondition check
+ if (!removed)
+ {
+ throw new IllegalArgumentException(
+ "Specified bootstrap could not be removed because it is not present in the list");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getValidator()
+ */
+ public ConfigurationValidator<T> getValidator()
+ {
+ return this.validator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#initialize()
+ */
+ public synchronized void initialize() throws IllegalStateException, InvalidConfigurationException
+ {
+ // Log
+ log.debug("Initializing server: " + this);
+
+ /*
+ * Precondition checks
+ */
+
+ // State must be pre-initialized
+ final LifecycleState state = this.getState();
+ if (!state.equals(LifecycleState.PRE_INIT))
+ {
+ throw new IllegalStateException("Cannot initialize an already initialized server, state is: " + state);
+ }
+
+ // Config must be in place
+ final T config = this.getConfiguration();
+ if (config == null)
+ {
+ throw new IllegalStateException("Configuration must be supplied before server is initialized");
+ }
+
+ // If there's a configuration initializer, use it
+ final ConfigurationInitializer<T> configInitializer = this.getConfigInitializer();
+ if (configInitializer != null)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Performing configuration initialization...");
+ }
+ configInitializer.initialize(config);
+ }
+ else
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("No configuration initializer supplied, skipping");
+ }
+ }
+
+ // Validate
+ if (log.isTraceEnabled())
+ {
+ log.trace("Validating config...");
+ }
+ this.validate(config);
+
+ /*
+ * If there's an initializer, use it
+ */
+ final ServerInitializer<K, T> serverInitializer = this.getServerInitializer();
+ if (serverInitializer != null)
+ {
+ serverInitializer.initialize(this);
+ }
+ else
+ {
+ log.debug("No initializer defined, skipping initialization of " + this);
+ }
+
+ // Freeze config
+ config.freeze();
+
+ // Set state
+ this.setState(LifecycleState.IDLE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getInitializer()
+ */
+ public synchronized final ServerInitializer<K, T> getServerInitializer()
+ {
+ return this.serverInitializer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#setInitializer(org.jboss.bootstrap.spi.server.ServerInitializer)
+ */
+ public synchronized final void setServerInitializer(final ServerInitializer<K, T> serverInitializer)
+ throws IllegalStateException
+ {
+ // Precondition check
+ this.checkState(LifecycleState.PRE_INIT, this.getState());
+
+ this.serverInitializer = serverInitializer;
+ log.debug("Set server initializer to " + serverInitializer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getConfigInitializer()
+ */
+ public synchronized final ConfigurationInitializer<T> getConfigInitializer()
+ {
+ return this.configInitializer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#setConfigInitializer(org.jboss.bootstrap.spi.config.ConfigurationInitializer)
+ */
+ public synchronized final void setConfigInitializer(ConfigurationInitializer<T> configInitializer)
+ {
+ // Precondition check
+ this.checkState(LifecycleState.PRE_INIT, this.getState());
+
+ this.configInitializer = configInitializer;
+ log.debug("Set config initializer to " + configInitializer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#setConfigurationValidator(org.jboss.bootstrap.spi.config.ConfigurationValidator)
+ */
+ public synchronized final void setValidator(final ConfigurationValidator<T> validator)
+ {
+ // Precondition check
+ this.checkState(LifecycleState.PRE_INIT, this.getState());
+
+ log.debug("Setting validator to: " + validator);
+ this.validator = validator;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+ /**
+ * Implementation-specific start hook
+ *
+ * @throws Exception
+ */
+ protected abstract void doStart() throws Exception;
+
+ /**
+ * Implementation-specific shutdown hook
+ *
+ * @throws Exception
+ */
+ protected abstract void doShutdown() throws Exception;
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Starts the bootstraps
+ *
+ * @throws Exception
+ */
+ protected void startBootstraps() throws Exception
+ {
+ // Run the bootstraps
+ for (Bootstrap bootstrap : this.getBootstraps())
+ {
+ // Add in reverse order
+ this.getStartedBootstraps().add(0, bootstrap);
+
+ // Start
+ bootstrap.start(this);
+ }
+ }
+
+ /**
+ * Shuts down the bootstraps that have been started
+ */
+ protected void shutdownBootstraps()
+ {
+ // Initialize
+ final List<Bootstrap> startedBootstraps = this.getStartedBootstraps();
+
+ // Signal
+ for (Bootstrap bootstrap : startedBootstraps)
+ {
+ bootstrap.prepareShutdown(this);
+ }
+
+ // Do the bootstraps in reverse order
+ for (Bootstrap bootstrap : startedBootstraps)
+ {
+ try
+ {
+ bootstrap.shutdown(this);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error shutting down bootstrap: " + bootstrap, t);
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures the actual state matches the required, throwing {@link IllegalStateException}
+ * if not
+ *
+ * @throws IllegalStateException If the actual state does not match required
+ */
+ private void checkState(final LifecycleState required, final LifecycleState actual) throws IllegalStateException
+ {
+ // Check State
+ if (required != actual)
+ {
+ throw new IllegalStateException("Server must be in " + LifecycleState.class.getSimpleName() + " " + required
+ + "; is instead: " + actual);
+ }
+ }
+
+ /**
+ * If {@link Server#getValidator()} is non-null, will
+ * assert the configuration is valid using the supplied
+ * validator
+ *
+ * @param configuration
+ * @throws InvalidConfigurationException If the configuration is invalid
+ * @throws IllegalArgumentException If the confirguation has not been set
+ */
+ private void validate(T configuration) throws InvalidConfigurationException, IllegalArgumentException
+ {
+ // Precondition check
+ if (configuration == null)
+ {
+ throw new IllegalArgumentException("Configuration was not specified");
+ }
+
+ // Get the validator
+ ConfigurationValidator<T> validator = this.getValidator();
+
+ // Is specified, validate
+ if (validator != null)
+ {
+ log.debug("Validating configuration using: " + validator);
+ validator.validate(this.getConfiguration());
+ }
+ else
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("No validator defined, skipping validation upon configuration");
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Accessors / Mutators ---------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @return the bootstraps
+ */
+ private List<Bootstrap> getBootstraps()
+ {
+ return bootstraps;
+ }
+
+ /**
+ * @return the startedBootstraps
+ */
+ private List<Bootstrap> getStartedBootstraps()
+ {
+ return startedBootstraps;
+ }
+
+ /**
+ * @param state the state to set
+ */
+ private synchronized final void setState(final LifecycleState state)
+ {
+ // Log and set
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting " + LifecycleState.class.getSimpleName() + " to: " + state);
+ }
+ this.state = state;
+ }
+
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/AbstractServer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/SecurityActions.java (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java)
===================================================================
--- projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/SecurityActions.java (rev 0)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/SecurityActions.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -0,0 +1,143 @@
+/*
+ * 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.spi.base.server;
+
+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 --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets a system property with specified key and value
+ *
+ * @throws IllegalArgumentException If the key was not specified
+ */
+ static void setSystemProperty(final String key, final String value) throws IllegalArgumentException
+ {
+ // Precondition check
+ ensureSysPropKeySpecified(key);
+
+ // Set
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+
+ public Void run()
+ {
+ // Set
+ System.setProperty(key, value);
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Set system property \"" + key + "\" > " + value);
+ }
+
+ // Return
+ return null;
+ }
+
+ });
+ }
+
+ /**
+ * Clears the specified System Property
+ *
+ * @throws IllegalArgumentException If the key was not specified
+ */
+ static void clearSystemProperty(final String key) throws IllegalArgumentException
+ {
+ // Precondition check
+ ensureSysPropKeySpecified(key);
+
+ // Set
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+
+ public Void run()
+ {
+ // Clear
+ String previousValue = System.clearProperty(key);
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Removed system property \"" + key + "\" which had previous value: " + previousValue);
+ }
+
+ // Return
+ return null;
+ }
+
+ });
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the specified key is not null
+ *
+ * @throws IllegalArgumentException If the specified key was null
+ */
+ private static void ensureSysPropKeySpecified(String key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key for System Property was not specified");
+ }
+ }
+}
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/server/SecurityActions.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml (from rev 87231, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml)
Property changes on: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapParser.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapParser.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -19,7 +19,7 @@
* 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.spi.xml;
+package org.jboss.bootstrap.spi.base.xml;
import java.net.URL;
Modified: projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapSchemaBinding.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/main/java/org/jboss/bootstrap/spi/base/xml/BootstrapSchemaBinding.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -19,7 +19,7 @@
* 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.spi.xml;
+package org.jboss.bootstrap.spi.base.xml;
import java.util.ArrayList;
import java.util.Collections;
Copied: projects/bootstrap/trunk/spi-base/src/test/java/org (from rev 87231, projects/bootstrap/trunk/spi/src/test/java/org)
Property changes on: projects/bootstrap/trunk/spi-base/src/test/java/org
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config (from rev 87231, projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config)
Property changes on: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/Counter.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/Counter.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/Counter.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,8 +20,11 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+
/**
* Counter
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/CountingConfigurationValidator.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingConfigurationValidator.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,8 +20,11 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+
/**
* CountingConfigurationValidator
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/CountingServerInitializer.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/CountingServerInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,10 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
+import org.jboss.bootstrap.spi.base.server.TestNoOpServer;
import org.jboss.bootstrap.spi.server.ServerInitializer;
-import org.jboss.bootstrap.spi.server.TestNoOpServer;
/**
* CountingServerInitializer
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigFactory.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/TestConfigFactory.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigFactory.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
import java.net.MalformedURLException;
import java.net.URL;
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/TestConfigurationInitializer.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,8 +20,11 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
+import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
+
+
/**
* TestConfigurationInitializer
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/TestConfigurationValidator.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestConfigurationValidator.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,10 +20,12 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
import java.util.concurrent.atomic.AtomicInteger;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+
/**
* TestConfigurationValidator
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerConfig.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/TestServerConfig.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerConfig.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,8 +20,11 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+
+
/**
* TestServerConfig
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/TestServerInitializer.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/TestServerInitializer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,14 +20,15 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config;
+package org.jboss.bootstrap.spi.base.config;
import java.util.concurrent.atomic.AtomicInteger;
-import org.jboss.bootstrap.spi.server.AbstractBasicServerInitializer;
+import org.jboss.bootstrap.spi.base.server.AbstractBasicServerInitializer;
+import org.jboss.bootstrap.spi.base.server.TestNoOpServer;
import org.jboss.bootstrap.spi.server.Server;
-import org.jboss.bootstrap.spi.server.TestNoOpServer;
+
/**
* TestServerInitializer
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/BasicConfigurationTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/unit/BasicConfigurationTestCase.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/BasicConfigurationTestCase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,16 +20,17 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config.unit;
+package org.jboss.bootstrap.spi.base.config.unit;
import java.net.URL;
import junit.framework.TestCase;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
import org.jboss.logging.Logger;
import org.junit.Test;
+
/**
* BasicConfigurationTestCase
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/unit/ConfigInitializationTestCase.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigInitializationTestCase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,17 +20,17 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config.unit;
+package org.jboss.bootstrap.spi.base.config.unit;
import java.net.URL;
import junit.framework.TestCase;
+import org.jboss.bootstrap.spi.base.config.TestConfigFactory;
+import org.jboss.bootstrap.spi.base.config.TestConfigurationInitializer;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
import org.jboss.bootstrap.spi.config.ServerConfig;
-import org.jboss.bootstrap.spi.config.TestConfigFactory;
-import org.jboss.bootstrap.spi.config.TestConfigurationInitializer;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
import org.jboss.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigValidationTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/config/unit/ConfigValidationTestCase.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/config/unit/ConfigValidationTestCase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,15 +20,15 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.config.unit;
+package org.jboss.bootstrap.spi.base.config.unit;
import junit.framework.TestCase;
+import org.jboss.bootstrap.spi.base.config.TestConfigFactory;
+import org.jboss.bootstrap.spi.base.config.TestConfigurationValidator;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
import org.jboss.bootstrap.spi.config.ConfigurationValidator;
import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
-import org.jboss.bootstrap.spi.config.TestConfigFactory;
-import org.jboss.bootstrap.spi.config.TestConfigurationValidator;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
import org.jboss.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
Copied: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server (from rev 87231, projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server)
Property changes on: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/TestNoOpServer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/TestNoOpServer.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/TestNoOpServer.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,11 +20,13 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.server;
+package org.jboss.bootstrap.spi.base.server;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
+import org.jboss.bootstrap.spi.server.Server;
import org.jboss.logging.Logger;
+
/**
* TestServer
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/unit/ServerInitializationTestCase.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerInitializationTestCase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,23 +20,24 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.server.unit;
+package org.jboss.bootstrap.spi.base.server.unit;
import junit.framework.TestCase;
-import org.jboss.bootstrap.spi.config.CountingServerInitializer;
+import org.jboss.bootstrap.spi.base.config.CountingServerInitializer;
+import org.jboss.bootstrap.spi.base.config.TestConfigFactory;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
+import org.jboss.bootstrap.spi.base.config.TestServerInitializer;
+import org.jboss.bootstrap.spi.base.config.unit.ConfigValidationTestCase;
+import org.jboss.bootstrap.spi.base.server.TestNoOpServer;
import org.jboss.bootstrap.spi.config.ServerConfig;
-import org.jboss.bootstrap.spi.config.TestConfigFactory;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
-import org.jboss.bootstrap.spi.config.TestServerInitializer;
-import org.jboss.bootstrap.spi.config.unit.ConfigValidationTestCase;
-import org.jboss.bootstrap.spi.server.TestNoOpServer;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+
/**
* ConfigInitializationTestCase
*
Modified: projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerLifecycleTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/unit/ServerLifecycleTestCase.java 2009-04-14 01:56:49 UTC (rev 87231)
+++ projects/bootstrap/trunk/spi-base/src/test/java/org/jboss/bootstrap/spi/base/server/unit/ServerLifecycleTestCase.java 2009-04-14 12:28:22 UTC (rev 87278)
@@ -20,20 +20,20 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.bootstrap.spi.server.unit;
+package org.jboss.bootstrap.spi.base.server.unit;
import junit.framework.TestCase;
-import org.jboss.bootstrap.spi.config.CountingConfigurationValidator;
-import org.jboss.bootstrap.spi.config.CountingServerInitializer;
-import org.jboss.bootstrap.spi.config.TestConfigFactory;
-import org.jboss.bootstrap.spi.config.TestConfigurationInitializer;
-import org.jboss.bootstrap.spi.config.TestConfigurationValidator;
-import org.jboss.bootstrap.spi.config.TestServerConfig;
-import org.jboss.bootstrap.spi.config.TestServerInitializer;
-import org.jboss.bootstrap.spi.config.unit.ConfigValidationTestCase;
+import org.jboss.bootstrap.spi.base.config.CountingConfigurationValidator;
+import org.jboss.bootstrap.spi.base.config.CountingServerInitializer;
+import org.jboss.bootstrap.spi.base.config.TestConfigFactory;
+import org.jboss.bootstrap.spi.base.config.TestConfigurationInitializer;
+import org.jboss.bootstrap.spi.base.config.TestConfigurationValidator;
+import org.jboss.bootstrap.spi.base.config.TestServerConfig;
+import org.jboss.bootstrap.spi.base.config.TestServerInitializer;
+import org.jboss.bootstrap.spi.base.config.unit.ConfigValidationTestCase;
+import org.jboss.bootstrap.spi.base.server.TestNoOpServer;
import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
-import org.jboss.bootstrap.spi.server.TestNoOpServer;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Before;
Copied: projects/bootstrap/trunk/spi-base/src/test/resources (from rev 87231, projects/bootstrap/trunk/spi/src/test/resources)
Property changes on: projects/bootstrap/trunk/spi-base/src/test/resources
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/bootstrap/trunk/spi-mc/pom.xml
===================================================================
--- projects/bootstrap/trunk/spi-mc/pom.xml 2009-04-14 12:22:32 UTC (rev 87277)
+++ projects/bootstrap/trunk/spi-mc/pom.xml 2009-04-14 12:28:22 UTC (rev 87278)
@@ -25,7 +25,7 @@
<!-- Properties -->
<properties>
- <version.org.jboss.bootstrap_jboss.bootstrap.spi>0.1.0</version.org.jboss.bootstrap_jboss.bootstrap.spi>
+ <version.org.jboss.bootstrap_jboss.bootstrap.spi>0.1.1-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.spi>
</properties>
More information about the jboss-cvs-commits
mailing list