[jboss-cvs] JBossAS SVN: r86955 - in projects/bootstrap/trunk: spi and 18 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 8 07:42:24 EDT 2009
Author: ALRubinger
Date: 2009-04-08 07:42:24 -0400 (Wed, 08 Apr 2009)
New Revision: 86955
Added:
projects/bootstrap/trunk/spi/src/main/java/org/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/
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/InvalidConfigurationException.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ServerConfig.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/lifecycle/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/lifecycle/LifecycleState.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/
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/server/Server.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java
projects/bootstrap/trunk/spi/src/test/java/org/
projects/bootstrap/trunk/spi/src/test/java/org/jboss/
projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/
projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/
projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/
projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/ConfigValidationAndInitTestCase.java
projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/TestServerConfig.java
projects/bootstrap/trunk/spi/src/test/resources/log4j.xml
Modified:
projects/bootstrap/trunk/build/pom.xml
projects/bootstrap/trunk/spi/.settings/org.eclipse.jdt.core.prefs
projects/bootstrap/trunk/spi/pom.xml
Log:
[JBBOOT-21] Add beginnings of new bootstrap SPI prototype and some basic tests
Modified: projects/bootstrap/trunk/build/pom.xml
===================================================================
--- projects/bootstrap/trunk/build/pom.xml 2009-04-08 10:41:20 UTC (rev 86954)
+++ projects/bootstrap/trunk/build/pom.xml 2009-04-08 11:42:24 UTC (rev 86955)
@@ -29,6 +29,8 @@
<!-- Versioning -->
<version.org.jboss.logging_jboss.logging.log4j>2.0.6.GA</version.org.jboss.logging_jboss.logging.log4j>
<version.org.jboss.logging_jboss.logging.spi>2.0.5.GA</version.org.jboss.logging_jboss.logging.spi>
+ <version.org.jboss.microcontainer_jboss.kernel>2.0.4.GA</version.org.jboss.microcontainer_jboss.kernel>
+ <version.org.jboss_jbossxb>2.0.0.GA</version.org.jboss_jbossxb>
<version.junit_junit>4.5</version.junit_junit>
</properties>
@@ -119,6 +121,12 @@
</dependency>
<dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossxb</artifactId>
+ <version>${version.org.jboss_jbossxb}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-log4j</artifactId>
<version>${version.org.jboss.logging_jboss.logging.log4j}</version>
@@ -129,6 +137,12 @@
<artifactId>jboss-logging-spi</artifactId>
<version>${version.org.jboss.logging_jboss.logging.spi}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.org.jboss.microcontainer_jboss.kernel}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: projects/bootstrap/trunk/spi/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/bootstrap/trunk/spi/.settings/org.eclipse.jdt.core.prefs 2009-04-08 10:41:20 UTC (rev 86954)
+++ projects/bootstrap/trunk/spi/.settings/org.eclipse.jdt.core.prefs 2009-04-08 11:42:24 UTC (rev 86955)
@@ -1,4 +1,4 @@
-#Fri Apr 03 06:40:15 GMT-05:00 2009
+#Wed Apr 08 06:41:05 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
Modified: projects/bootstrap/trunk/spi/pom.xml
===================================================================
--- projects/bootstrap/trunk/spi/pom.xml 2009-04-08 10:41:20 UTC (rev 86954)
+++ projects/bootstrap/trunk/spi/pom.xml 2009-04-08 11:42:24 UTC (rev 86955)
@@ -35,6 +35,26 @@
<!-- 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>
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/AbstractBasicServerConfig.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,372 @@
+/*
+ * 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.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+
+/**
+ * BasicServerConfig
+ *
+ * Base for simple Object-backed implementations of a Server Configuration
+ *
+ * @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);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private Class<T> actualClass;
+
+ private URL bootstrapUrl;
+
+ private URL bootstrapConfLocation;
+
+ private URL bootstrapHome;
+
+ private URL bootstrapLibLocation;
+
+ private String bootstrapName;
+
+ private Map<String, String> properties;
+
+ private boolean 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();
+ Map<String, String> properties = new HashMap<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;
+ this.actualClass = actualClass;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapConfLocation()
+ */
+ public URL getBootstrapConfLocation()
+ {
+ return this.bootstrapConfLocation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapHome()
+ */
+ public URL getBootstrapHome()
+ {
+ return this.bootstrapHome;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapLibLocation()
+ */
+ public URL getBootstrapLibLocation()
+ {
+ return this.bootstrapLibLocation;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapName()
+ */
+ public String getBootstrapName()
+ {
+ return this.bootstrapName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapUrl()
+ */
+ public URL getBootstrapUrl()
+ {
+ return this.bootstrapUrl;
+ }
+
+ /* (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 T setBootstrapConfLocation(final URL confLocation) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_CONF_URL, confLocation);
+
+ // Set URL
+ this.bootstrapConfLocation = confLocation;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapHome(java.net.URL)
+ */
+ public T setBootstrapHome(final URL bootstrapHome) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_HOME_URL, bootstrapHome);
+
+ // Set URL
+ this.bootstrapHome = bootstrapHome;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapLibLocation(java.net.URL)
+ */
+ public T setBootstrapLibLocation(final URL libLocation) throws IllegalArgumentException
+ {
+ // Precondition check
+ this.checkMutable();
+
+ // Set property
+ this.setPropertyForUrl(PROP_KEY_BOOTSTRAP_LIB_URL, libLocation);
+
+ // Set URL
+ this.bootstrapLibLocation = libLocation;
+
+ // Return
+ return this.covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#setBootstrapName(java.lang.String)
+ */
+ public T setBootstrapName(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 T setBootstrapUrl(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#setProperty(java.lang.String, java.lang.String)
+ */
+ public T setProperty(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 = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#isFrozen()
+ */
+ public boolean isFrozen()
+ {
+ return this.frozen;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // 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;
+ properties.put(propertyName, value);
+ if (log.isTraceEnabled())
+ {
+ log.trace(("Set property \"" + propertyName + "\" to: ") + (value != null ? "\"" + value + "\"" : "[NULL]"));
+ }
+ }
+
+ /**
+ * 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");
+ }
+ }
+
+ /**
+ * 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 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);
+ }
+ }
+}
Added: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/InvalidConfigurationException.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/InvalidConfigurationException.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/InvalidConfigurationException.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+/**
+ * InvalidConfigurationException
+ *
+ * Indicates that a particular configuration is not
+ * valid for a Server
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class InvalidConfigurationException extends Exception
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public InvalidConfigurationException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public InvalidConfigurationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public InvalidConfigurationException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public InvalidConfigurationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+}
Added: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ServerConfig.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ServerConfig.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ServerConfig.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,199 @@
+/*
+ * 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.util.Map;
+
+/**
+ * ServerConfig
+ *
+ * Configuration used in Server creation and initialization
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ServerConfig<T extends ServerConfig<?>>
+{
+ //-------------------------------------------------------------------------------------||
+ // Properties -------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Property denoting the URL pointing to the home of
+ * the bootstrap (from which other properties may be defaulted)
+ */
+ String PROP_KEY_BOOTSTRAP_HOME_URL = "jboss.bootstrap.home.url";
+
+ /**
+ * Property denoting the URL of the configuration home
+ */
+ String PROP_KEY_BOOTSTRAP_CONF_URL = "jboss.bootstrap.conf.url";
+
+ /**
+ * Property denoting the URL of the lib directory
+ */
+ String PROP_KEY_BOOTSTRAP_LIB_URL = "jboss.bootstrap.lib.url";
+
+ /**
+ * Property denoting the name of the bootstrap configuration
+ */
+ String PROP_KEY_BOOTSTRAP_NAME = "jboss.bootstrap.name";
+
+ /**
+ * Property denoting the URL of the bootstrap configuration
+ */
+ String PROP_KEY_BOOTSTRAP_URL = "jboss.bootstrap.url";
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the location of the bootstrap directory. This will mirror the value
+ * of {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapHome();
+
+ /**
+ * Sets the location of the bootstrap directory. Will additionally set
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
+ *
+ * @param bootstrapHome
+ * @return This configuration
+ * @throws IllegalArgumentException If the bootstrap home location was not specified
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setBootstrapHome(URL bootstrapHome) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the location of the bootstrap file. This will mirror the
+ * value of {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapUrl();
+
+ /**
+ * Sets the location of the bootstrap file. Will additionally set
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
+ *
+ * @param bootstrapLocation
+ * @return This configuration
+ * @throws IllegalArgumentException If the location was not specified
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setBootstrapUrl(URL bootstrapLocation) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the name of the bootstrap configuration. This will
+ * mirror the value of {@link ServerConfig#PROP_KEY_BOOTSTRAP_NAME}.
+ *
+ * @return
+ */
+ String getBootstrapName();
+
+ /**
+ * Sets the name of the bootstrap configuration file. Will additionally set
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_NAME}.
+ *
+ * @param name
+ * @return This configuration
+ * @throws IllegalArgumentException If the name was not specified
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setBootstrapName(String name) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the location of the bootstrap configuration location. This will mirror the
+ * value of {@link ServerConfig#PROP_KEY_BOOTSTRAP_CONF_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapConfLocation();
+
+ /**
+ * Sets the name of the bootstrap configuration location. Will additionally set
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_CONF_URL}.
+ *
+ * @param confLocation
+ * @return This configuration
+ * @throws IllegalArgumentException If the location was not specified
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setBootstrapConfLocation(URL confLocation) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the location of the bootstrap library location. This will mirror the
+ * value of {@link ServerConfig#PROP_KEY_BOOTSTRAP_LIB_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapLibLocation();
+
+ /**
+ * Sets the name of the bootstrap library location. Will additionally set
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_LIB_URL}.
+ *
+ * @param libLocation
+ * @return This configuration
+ * @throws IllegalArgumentException If the location was not specified
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setBootstrapLibLocation(URL libLocation) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Returns an immutable copy of the properties used in configuring the server
+ *
+ * @return
+ */
+ Map<String, String> getProperties();
+
+ /**
+ * Sets the property with the specified key to the specified value
+ *
+ * @param key
+ * @param value
+ * @return This configuration
+ * @throws IllegalArgumentException If the key was not supplied
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ ServerConfig<T> setProperty(String key, String value) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Freezes the configuration, marking it as immutable. Will typically
+ * be invoked by a server during the start lifecycle.
+ *
+ * @throws IllegalStateException
+ */
+ void freeze() throws IllegalStateException;
+
+ /**
+ * Returns whether or not this configuration is frozen and immutable
+ *
+ * @return
+ */
+ boolean isFrozen();
+}
Added: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/lifecycle/LifecycleState.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/lifecycle/LifecycleState.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/lifecycle/LifecycleState.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,40 @@
+/*
+ * 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.lifecycle;
+
+/**
+ * LifecycleState
+ *
+ * Describes current state of the Server lifecycle
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public enum LifecycleState {
+
+ /*
+ * Lifecycle States for Servers
+ */
+
+ IDLE, STARTING, STARTED, STOPPING
+}
Copied: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java (from rev 86846, projects/bootstrap/trunk/legacy/src/main/java/org/jboss/bootstrap/BootstrapMetaData.java)
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap.spi.metadata;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * BootstrapMetaData.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapMetaData implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7850412833463503239L;
+
+ /** The bootstrap urls */
+ private List<String> bootstrapURLs;
+
+ /**
+ * Get the bootstrapURLs.
+ *
+ * @return the bootstrapURLs.
+ */
+ public List<String> getBootstrapURLs()
+ {
+ return bootstrapURLs;
+ }
+
+ /**
+ * Set the bootstrapURLs.
+ *
+ * @param bootstrapURLs the bootstrapURLs.
+ */
+ public void setBootstrapURLs(List<String> bootstrapURLs)
+ {
+ this.bootstrapURLs = bootstrapURLs;
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "{" + bootstrapURLs + "}";
+ }
+}
Property changes on: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/AbstractServer.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,389 @@
+/*
+ * 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.MalformedURLException;
+import java.net.URL;
+
+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<T extends ServerConfig<?>> implements Server<T>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractServer.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Current state of the server
+ */
+ private LifecycleState state;
+
+ /**
+ * Underlying configuration
+ */
+ private T configuration;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * Requires a server configuration in place
+ */
+ protected AbstractServer(T configuration) throws IllegalArgumentException, InvalidConfigurationException
+ {
+ // Check for valid config and set
+ this.setConfiguration(configuration);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getConfiguration()
+ */
+ public final T getConfiguration()
+ {
+ // TODO Auto-generated method stub
+ return this.configuration;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#getState()
+ */
+ public final LifecycleState getState()
+ {
+ // TODO Auto-generated method stub
+ return this.state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#shutdown()
+ */
+ public void shutdown() throws IllegalStateException, Exception
+ {
+ // Ensure running
+ LifecycleState required = LifecycleState.STARTED;
+ LifecycleState actual = this.getState();
+ this.checkState(required, actual);
+
+ // Initiate shutdown sequence
+ log.info("Stopping: " + this);
+ this.setLifecycleState(LifecycleState.STOPPING);
+
+ // Shutdown
+ this.doShutdown();
+
+ // Done
+ log.info("Stopped: " + this);
+ this.setLifecycleState(LifecycleState.IDLE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.Server#start()
+ */
+ public void start() throws IllegalStateException, Exception
+ {
+ // Ensure idle
+ final LifecycleState required = LifecycleState.IDLE;
+ final LifecycleState actual = this.getState();
+ this.checkState(required, actual);
+
+ // Initiate shutdown sequence
+ log.info("Starting: " + this);
+ this.setLifecycleState(LifecycleState.STARTING);
+
+ // Start
+ this.doStart();
+
+ // Done
+ log.info("Started: " + this);
+ this.setLifecycleState(LifecycleState.STARTED);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // 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 -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Validates the specified configuration for:
+ *
+ * 1) Either bootstrapURL or both bootstrapHome+bootstrapName
+ * 2) bootstrapLib!=null
+ * 3) bootstrapConf!=null
+ *
+ * Subclasses may impose further restrictions.
+ *
+ * @param configuration
+ * @throws InvalidConfigurationException If the configuration is not valid
+ * @throws IllegalArgumentException If the configuration is not specified
+ */
+ protected void validate(T configuration) throws InvalidConfigurationException, IllegalArgumentException
+ {
+ // Precondition check
+ if (configuration == null)
+ {
+ throw new IllegalArgumentException("Configuration is required, but was not supplied");
+ }
+
+ // Get properties
+ String name = configuration.getBootstrapName();
+ URL home = configuration.getBootstrapHome();
+ URL direct = configuration.getBootstrapUrl();
+ URL lib = configuration.getBootstrapLibLocation();
+ URL conf = configuration.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 lib
+ if (lib == null)
+ {
+ throw new InvalidConfigurationException("Bootstrap library location must be specified");
+ }
+
+ // If no conf
+ if (conf == null)
+ {
+ throw new InvalidConfigurationException("Bootstrap configuration location must be specified");
+ }
+ }
+
+ /**
+ * Initializes the bootstrap configuration by
+ * setting appropriate defaults, setting system properties.
+ *
+ * Subclasses may define further rules.
+ *
+ * @param configuration
+ * @throws InvalidConfigurationException If the configuration is not able to be
+ * initialized due to faulty state
+ */
+ protected void initialize(T configuration) throws InvalidConfigurationException
+ {
+ /*
+ * If bootstrapURL is not directly defined, construct it from
+ * home+name
+ */
+ URL bootstrapUrl = configuration.getBootstrapUrl();
+ if (bootstrapUrl == null)
+ {
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("No bootstrap URL defined, constructing it from home and name...");
+ }
+
+ // Construct
+ URL home = configuration.getBootstrapHome();
+ String name = configuration.getBootstrapName();
+ assert home != null : "Bootstrap home should not be null, and should have failed validation if so";
+ assert name != null : "Bootstrap name should not be null, and should have failed validation if so";
+ try
+ {
+ bootstrapUrl = new URL(home, name);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new InvalidConfigurationException("Cannot construct bootstrapURL from home and name", e);
+ }
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("New bootstrap URL: " + bootstrapUrl.toExternalForm());
+ }
+
+ // Set
+ configuration.setBootstrapUrl(bootstrapUrl);
+ }
+
+ // Set System Properties
+ this.setSystemProperties(configuration);
+ }
+
+ /**
+ * Sets system properties from the specified configuration
+ *
+ * @param The configuration
+ */
+ protected void setSystemProperties(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_LIB_URL, configuration.getBootstrapLibLocation());
+ this.setSystemProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, configuration.getBootstrapName());
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets the specified system property key to the specified value
+ *
+ * @param key The non-null key
+ * @param value
+ */
+ private void setSystemProperty(String key, String value)
+ {
+ // Precondition check
+ assert key != null : "Key for system property was null";
+
+ // Set
+ SecurityActions.setSystemProperty(key, value);
+
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace(("Set system property \"" + key + "\" to: ") + (value != null ? "\"" + value + "\"" : "[NULL]"));
+ }
+ }
+
+ /**
+ * Sets the specified URL's external form as a system property with the specified key
+ *
+ * @param key
+ * @param value
+ */
+ private void setSystemProperty(String key, URL value)
+ {
+ String urlString = value.toExternalForm();
+ this.setSystemProperty(key, urlString == null ? null : urlString);
+ }
+
+ /**
+ * 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
+ + " for shutdown; is instead: " + actual);
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Accessors / Mutators ---------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets the current lifecycle state such that it may be easily reported
+ */
+ protected void setLifecycleState(LifecycleState state)
+ {
+ // Log and set
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting " + LifecycleState.class.getSimpleName() + " to: " + state);
+ }
+ this.state = state;
+ }
+
+ /**
+ * Sets the specified configuration:
+ *
+ * 1) Checks specified
+ * 2) Validates
+ * 3) Initializes
+ * 4) Freezes to immutable
+ * 5) Sets
+ *
+ * @param configuration
+ * @throws IllegalArgumentException If the configuration was not specified
+ * @throws InvalidConfigurationException In the configuration was not valid
+ */
+ void setConfiguration(T configuration) throws IllegalArgumentException, InvalidConfigurationException
+ {
+ // Validate
+ this.validate(configuration);
+
+ // Initialize
+ this.initialize(configuration);
+
+ // Freeze
+ configuration.freeze();
+
+ // Log and set
+ if (log.isTraceEnabled())
+ {
+ log.trace("Set configuration: " + configuration);
+ }
+ this.configuration = configuration;
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/SecurityActions.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+/**
+ * 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 --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * 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
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Key for System Property was not specified");
+ }
+
+ // Set
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+
+ public Void run()
+ {
+ System.setProperty(key, value);
+
+ // Return
+ return null;
+ }
+
+ });
+ }
+}
Added: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/Server.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/Server.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/server/Server.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,72 @@
+/*
+ * 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 org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
+
+/**
+ * Server
+ *
+ * Contract for generic Server implementations
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface Server<T extends ServerConfig<?>>
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Start lifecycle of the Server
+ *
+ * @throws IllegalStateException If the Server is already started
+ * @throws Exception
+ */
+ void start() throws IllegalStateException, Exception;
+
+ /**
+ * Stop lifecycle of the Server
+ *
+ * @throws IllegalStateException If the Server is not started
+ * @throws Exception
+ */
+ void shutdown() throws IllegalStateException, Exception;
+
+ /**
+ * Returns the current state of the Server lifecycle
+ *
+ * @return true if started, false otherwise
+ */
+ LifecycleState getState();
+
+ /**
+ * Returns the frozen (immutable) underlying server configuration
+ *
+ * @return
+ */
+ T getConfiguration();
+}
Copied: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java (from rev 86846, projects/bootstrap/trunk/legacy/src/main/java/org/jboss/bootstrap/xml/BootstrapParser.java)
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap.spi.xml;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.metadata.BootstrapMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/**
+ * BootstrapParser.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapParser
+{
+ /**
+ * Parse bootstrap metadata from the given url
+ *
+ * @param url the url
+ * @return the bootstrap metadata
+ */
+ public static BootstrapMetaData parse(URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("Null url");
+
+ UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ try
+ {
+ BootstrapMetaData result = (BootstrapMetaData) unmarshaller.unmarshal(url.toString(),
+ new BootstrapSchemaBinding());
+ if (result == null)
+ throw new IllegalStateException("The bootsrap xml " + url + " is not well formed");
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Error unmarshalling " + url, e);
+ }
+ }
+}
Property changes on: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapParser.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java (from rev 86846, projects/bootstrap/trunk/legacy/src/main/java/org/jboss/bootstrap/xml/BootstrapSchemaBinding.java)
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap.spi.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.bootstrap.spi.metadata.BootstrapMetaData;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.AllBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * SchemaBinding for the bootstrap
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 71554 $
+ */
+public class BootstrapSchemaBinding extends SchemaBinding
+{
+ /** The bootstrap namespace */
+ public static final String NAMESPACE = "urn:jboss:bootstrap:1.0";
+
+ /**
+ * Create a new BootstrapSchemaBinding.
+ */
+ public BootstrapSchemaBinding()
+ {
+ TypeBinding stringType = getType(SimpleTypeBindings.typeQName(String.class));
+
+ setNamespaces(Collections.singleton(NAMESPACE));
+ setIgnoreLowLine(true);
+ setIgnoreUnresolvedFieldOrClass(false);
+ setReplacePropertyRefs(true);
+ setStrictSchema(true);
+
+ // The bootstrap type
+ TypeBinding bootstrapType = new TypeBinding(new QName(NAMESPACE, "bootstrapType"));
+ bootstrapType.setSimple(false);
+ AllBinding bootstrapModel = new AllBinding(this);
+ ParticleBinding bootstrapParticle = new ParticleBinding(bootstrapModel, 1, 1, false);
+ bootstrapType.setParticle(bootstrapParticle);
+ ClassMetaData bootstrapClassMetaData = new ClassMetaData();
+ bootstrapClassMetaData.setImpl(BootstrapMetaData.class.getName());
+ bootstrapType.setClassMetaData(bootstrapClassMetaData);
+
+ // Bootstrap can take some urls
+ ElementBinding urlElement = new ElementBinding(this, new QName(NAMESPACE, "url"), stringType);
+ ParticleBinding urlParticle = new ParticleBinding(urlElement, 0, 1, true);
+ bootstrapModel.addParticle(urlParticle);
+ bootstrapType.pushInterceptor(urlElement.getQName(), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ BootstrapMetaData bootstrap = (BootstrapMetaData) parent;
+ String url = (String) child;
+ List<String> bootstrapURLs = bootstrap.getBootstrapURLs();
+ if (bootstrapURLs == null)
+ {
+ bootstrapURLs = new ArrayList<String>();
+ bootstrap.setBootstrapURLs(bootstrapURLs);
+ }
+ bootstrapURLs.add(url);
+ }
+ });
+
+ // The bootstrap root element
+ addElement(new ElementBinding(this, new QName(NAMESPACE, "bootstrap"), bootstrapType));
+ }
+}
Property changes on: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/xml/BootstrapSchemaBinding.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/ConfigValidationAndInitTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/ConfigValidationAndInitTestCase.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/ConfigValidationAndInitTestCase.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,379 @@
+/*
+ * 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.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+import org.jboss.logging.Logger;
+import org.junit.Test;
+
+/**
+ * ConfigValidationAndInitTestCase
+ *
+ * Ensures that the server will correctly initialize and
+ * validate configurations as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ConfigValidationAndInitTestCase extends AbstractServer<ServerConfig<?>>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ConfigValidationAndInitTestCase.class);
+
+ private static final String NAME_CONF = "conf";
+
+ private static final String NAME_LIB = "lib";
+
+ private static final String NAME_BOOTSTRAP = "bootstrap.xml";
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Explicit constructor, passing a null config in
+ * (which will be allowed in this test)
+ *
+ * @throws IllegalArgumentException
+ * @throws InvalidConfigurationException
+ */
+ public ConfigValidationAndInitTestCase() throws IllegalArgumentException, InvalidConfigurationException
+ {
+ super(null);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that a fully-populated config is valid
+ */
+ @Test
+ public void testValidationPopulatedBootstrap() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Validate
+ try
+ {
+ this.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ TestCase.fail("Configuration fully-populated should be valid, but instead got " + ice.getMessage());
+ }
+
+ // OK
+ return;
+ }
+
+ /**
+ * Ensures that an explicit bootstrapURL with no name or home set passes validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationExplicitBootstrapUrlWithNoHomeOrName() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Remove home and name
+ configuration.setBootstrapHome(null).setBootstrapName(null);
+
+ // Validate
+ try
+ {
+ this.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ TestCase.fail("Configuration with bootstrapURL but no home or name should be valid, but instead got "
+ + ice.getMessage());
+ }
+
+ // OK
+ return;
+ }
+
+ /**
+ * Ensures that a configuration with no home, bootstrapURL, or name set fails validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationNoBootstrapUrlWithNoHomeOrName() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Remove home, name, bootstrapURL
+ configuration.setBootstrapHome(null).setBootstrapName(null).setBootstrapUrl(null);
+
+ // Validate
+ boolean validationFailed = false;
+ try
+ {
+ this.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ // Expected
+ validationFailed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Configuration with no home, name or bootstrapURL must fail validation", validationFailed);
+ }
+
+ /**
+ * Ensures that the lib is required by validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationNoBootstrapLib() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Remove lib
+ configuration.setBootstrapLibLocation(null);
+
+ // Validate
+ boolean validationFailed = false;
+ try
+ {
+ this.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ // Expected
+ validationFailed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Configuration with no lib must fail validation", validationFailed);
+ }
+
+ /**
+ * Ensures that the conf is required by validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationNoBootstrapConf() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Remove conf
+ configuration.setBootstrapConfLocation(null);
+
+ // Validate
+ boolean validationFailed = false;
+ try
+ {
+ this.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ // Expected
+ validationFailed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Configuration with no conf must fail validation", validationFailed);
+ }
+
+ /**
+ * Ensures that setting a configuration results in proper defaulting
+ * of the bootstrap URL if it's not been explicitly specified
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapUrlDefaultedInInitialization() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Remove bootstrapURL
+ configuration.setBootstrapUrl(null);
+
+ // Set, using the super implementation (which will validate and initialize)
+ super.setConfiguration(configuration);
+
+ // Create the expected URL
+ URL home = configuration.getBootstrapHome();
+ String name = configuration.getBootstrapName();
+ URL expectedBootstrapURL = null;
+ expectedBootstrapURL = new URL(home, name);
+
+ // Get the actual URL
+ URL bootstrapUrl = this.getConfiguration().getBootstrapUrl();
+
+ // Test
+ TestCase.assertNotNull("Bootstrap URL was not initialized", bootstrapUrl);
+ TestCase.assertEquals("Initialized bootstrap is to incorrect location", expectedBootstrapURL, bootstrapUrl);
+ }
+
+ /**
+ * Ensures that the properties backing the configuration are set
+ * both on the configuration itself and in the System props
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testProperties() throws Throwable
+ {
+ // Get a populated config
+ TestServerConfig configuration = this.getPopulatedServerConfig();
+
+ // Set, using the super implementation (which will validate and initialize)
+ super.setConfiguration(configuration);
+
+ // Get Properties from Configuration
+ String homeFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
+ String bootstrapURLFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_URL);
+ String libFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_LIB_URL);
+ String confFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL);
+ String nameFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_NAME);
+
+ // Get Properties from System
+ String homeFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
+ String bootstrapURLFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_URL);
+ String libFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_LIB_URL);
+ String confFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_CONF_URL);
+ String nameFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME);
+
+ // Get Expected Values
+ String home = configuration.getBootstrapHome().toExternalForm();
+ String bootstrapURL = configuration.getBootstrapUrl().toExternalForm();
+ String lib = configuration.getBootstrapLibLocation().toExternalForm();
+ String conf = configuration.getBootstrapConfLocation().toExternalForm();
+ String name = configuration.getBootstrapName();
+
+ // Ensure all equal
+ TestCase.assertEquals("home in configuration must match the config property", home, homeFromConfigProp);
+ TestCase.assertEquals("home in configuration must match the system property", home, homeFromSystem);
+ TestCase.assertEquals("bootstrapURL in configuration must match the config property", bootstrapURL,
+ bootstrapURLFromConfigProp);
+ TestCase.assertEquals("bootstrapURL in configuration must match the system property", bootstrapURL,
+ bootstrapURLFromSystem);
+ TestCase.assertEquals("lib in configuration must match the config property", lib, libFromConfigProp);
+ TestCase.assertEquals("lib in configuration must match the system property", lib, libFromSystem);
+ TestCase.assertEquals("conf in configuration must match the config property", conf, confFromConfigProp);
+ TestCase.assertEquals("conf in configuration must match the system property", conf, confFromSystem);
+ TestCase.assertEquals("name in configuration must match the config property", name, nameFromConfigProp);
+ TestCase.assertEquals("name in configuration must match the system property", name, nameFromSystem);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains a server configuration populated with all URLs and name
+ */
+ private TestServerConfig getPopulatedServerConfig()
+ {
+ // Create a configuration
+ TestServerConfig config = new TestServerConfig();
+
+ // Get the home
+ URL home = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+
+ // Construct URLs
+ URL conf = null;
+ URL lib = null;
+ URL bootstrap = null;
+ try
+ {
+ conf = new URL(home, NAME_CONF);
+ lib = new URL(home, NAME_LIB);
+ bootstrap = new URL(home, NAME_BOOTSTRAP);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Error in URL (improper test setup)", e);
+ }
+
+ // Populate and return
+ return config.setBootstrapHome(home).setBootstrapConfLocation(conf).setBootstrapLibLocation(lib).setBootstrapUrl(
+ bootstrap).setBootstrapName(NAME_BOOTSTRAP);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /*
+ * NO-OP on all
+ */
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractServer#doShutdown()
+ */
+ @Override
+ protected void doShutdown() throws Exception
+ {
+ //NOOP
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractServer#doStart()
+ */
+ @Override
+ protected void doStart() throws Exception
+ {
+ //NOOP
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractServer#setConfiguration(org.jboss.bootstrap.spi.config.ServerConfig)
+ */
+ @Override
+ void setConfiguration(ServerConfig<?> configuration) throws IllegalArgumentException, InvalidConfigurationException
+ {
+ /*
+ * NOOP, allow a null config to be passed in
+ */
+ log.trace("Ignoring request to set configuration for test - NOOP");
+ }
+}
Added: projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/TestServerConfig.java
===================================================================
--- projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/TestServerConfig.java (rev 0)
+++ projects/bootstrap/trunk/spi/src/test/java/org/jboss/bootstrap/spi/server/TestServerConfig.java 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,45 @@
+/*
+ * 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 org.jboss.bootstrap.spi.config.AbstractBasicServerConfig;
+import org.jboss.bootstrap.spi.config.ServerConfig;
+
+/**
+ * TestServerConfig
+ *
+ * Simple server configuration used in testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class TestServerConfig extends AbstractBasicServerConfig<TestServerConfig>
+ implements
+ ServerConfig<TestServerConfig>
+{
+ public TestServerConfig()
+ {
+ super(TestServerConfig.class);
+ }
+
+}
Added: projects/bootstrap/trunk/spi/src/test/resources/log4j.xml
===================================================================
--- projects/bootstrap/trunk/spi/src/test/resources/log4j.xml (rev 0)
+++ projects/bootstrap/trunk/spi/src/test/resources/log4j.xml 2009-04-08 11:42:24 UTC (rev 86955)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jnp">
+ <priority value="INFO"/>
+ </category>
+
+ <category name="org.jboss.bootstrap">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
More information about the jboss-cvs-commits
mailing list