[jboss-cvs] JBossAS SVN: r99509 - in projects/bootstrap/trunk: api/src/main/java/org/jboss/bootstrap/api/config and 33 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 17 19:23:46 EST 2010
Author: ALRubinger
Date: 2010-01-17 19:23:43 -0500 (Sun, 17 Jan 2010)
New Revision: 99509
Added:
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/BootstrapDescriptor.java
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/ClassLoaderResourceBootstrapDescriptor.java
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/FileBootstrapDescriptor.java
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/UrlBootstrapDescriptor.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapParser.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapSchemaBinding.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BasicConfigurationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapInitializationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapOnlyConfigurationInitializer.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/Pojo.java
projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-pojo.xml
projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-starting-slash.xml
projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-urls.xml
projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap.xml
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/bootstrap.xml
projects/bootstrap/trunk/impl-as/src/test/resources/pojo.xml
projects/bootstrap/trunk/impl-as/src/test/resources/pojo2.xml
projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/BootstrapMetaData.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASGenericServerProvider.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASServerProvider.java
projects/bootstrap/trunk/spi-as/src/main/resources/schema/
Removed:
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/EMPTY
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/xml/
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/BasicConfigurationTestCase.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigInitializationTestCase.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigValidationTestCase.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerInitializationTestCase.java
projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/Pojo.java
projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java
projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerBootstrapUrlTestCase.java
projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-pojo.xml
projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-starting-slash.xml
projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-urls.xml
projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap.xml
projects/bootstrap/trunk/impl-mc/src/test/resources/pojo2.xml
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASConfigurationInitializer.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASBasedServerProvider.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServerProvider.java
projects/bootstrap/trunk/spi-test/src/test/resources/bootstrap.xml
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java
projects/bootstrap/trunk/spi/src/main/resources/schema/
Modified:
projects/bootstrap/trunk/api-as/src/main/java/org/jboss/bootstrap/api/as/config/JBossASBasedServerConfig.java
projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/config/ServerConfig.java
projects/bootstrap/trunk/impl-as/pom.xml
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASBasedConfigurationValidator.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/AbstractKernelEventLifecycleEventHandler.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStartEventLifecycleEventHandler.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStopEventLifecycleEventHandler.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/KernelEventsTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MutableStartDateNoOpJBossASServer.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationInitializer.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationValidator.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigFactory.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigurationInitializer.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestServerInitializer.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerConcurrentStartShutdownTestCase.java
projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerLifecycleTestCase.java
projects/bootstrap/trunk/impl-mc/pom.xml
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/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerUnitTestCase.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASBasedConfigurationInitializer.java
projects/bootstrap/trunk/spi-test/src/test/java/org/jboss/bootstrap/spi/test/ClassLoadingTestCase.java
projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ConfigurationInitializer.java
Log:
[JBBOOT-118] Change the jboss-bootstrap API to accept "BootstrapDescriptor" types instead of a main bootstrap.xml; keep api-as and impl-as compatible with the older bootstrap URL mechanism
Modified: projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/config/ServerConfig.java
===================================================================
--- projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/config/ServerConfig.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/config/ServerConfig.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,11 +22,13 @@
package org.jboss.bootstrap.api.config;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+
/**
* ServerConfig
*
@@ -38,112 +40,18 @@
*/
public interface ServerConfig<T extends ServerConfig<?>>
{
- //-------------------------------------------------------------------------------------||
- // Constants --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
/**
- * 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 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. Corresponds to
- * {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
- *
+ * Obtains the ordered {@link BootstrapDescriptor}s used in
+ * the server start lifecycle. If {@link ServerConfig#isFrozen()}
+ * is false, this will be a mutable view, allowing the caller to
+ * adjust the available bootstraps. After the configuration is frozen,
+ * this will return an immutable view.
* @return
*/
- URL getBootstrapHome();
+ List<BootstrapDescriptor> getBootstrapDescriptors();
/**
- * Sets the location of the bootstrap directory. Corresponds to
- * {@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
- */
- T bootstrapHome(URL bootstrapHome) throws IllegalArgumentException, IllegalStateException;
-
- /**
- * Sets the location of the bootstrap directory. Corresponds to
- * {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
- *
- * @param bootstrapHome
- * @return This configuration
- * @throws IllegalArgumentException If the bootstrap home location was not specified,
- * or could not be assigned to a URL (ie. {@link MalformedURLException}
- * @throws IllegalStateException If the configuration has been frozen
- */
- T bootstrapHome(String bootstrapHome) throws IllegalArgumentException, IllegalStateException;
-
- /**
- * Obtains the location of the bootstrap file. Corresponds to
- * {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
- *
- * @return
- */
- URL getBootstrapUrl();
-
- /**
- * Sets the location of the bootstrap file. Corresponds to
- * {@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
- */
- T bootstrapUrl(URL bootstrapLocation) throws IllegalArgumentException, IllegalStateException;
-
- /**
- * Sets the location of the bootstrap file. Corresponds to
- * {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
- *
- * @param bootstrapUrl
- * @return This configuration
- * @throws IllegalArgumentException If the bootstrap URL location was not specified,
- * or could not be assigned to a URL (ie. {@link MalformedURLException}
- * @throws IllegalStateException If the configuration has been frozen
- */
- T bootstrapUrl(String bootstrapUrl) throws IllegalArgumentException, IllegalStateException;
-
- /**
- * Obtains the name of the bootstrap configuration. Corresponds to
- * {@link ServerConfig#PROP_KEY_BOOTSTRAP_NAME}.
- *
- * @return
- */
- String getBootstrapName();
-
- /**
- * Sets the name of the bootstrap configuration file. Corresponds to
- * {@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
- */
- T bootstrapName(String name) throws IllegalArgumentException, IllegalStateException;
-
- /**
* Returns an immutable copy of the properties used in configuring the server
*
* @return
@@ -196,7 +104,7 @@
/**
* Freezes the configuration, marking it as immutable. Will typically
- * be invoked by a server during the start lifecycle.
+ * be invoked by a server during the {@link LifecycleState#INITIALIZED} lifecycle.
*
* @throws IllegalStateException
*/
Added: projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/BootstrapDescriptor.java
===================================================================
--- projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/BootstrapDescriptor.java (rev 0)
+++ projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/BootstrapDescriptor.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.api.descriptor;
+
+import java.io.InputStream;
+
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.server.Server;
+
+/**
+ * Generic descriptor for components which should be installed
+ * into the {@link Server} during the {@link LifecycleState#STARTING}
+ * phase.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public interface BootstrapDescriptor
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the name of this {@link BootstrapDescriptor}
+ */
+ String getName();
+
+ /**
+ * Returns a new stream representing the content of this {@link BootstrapDescriptor}.
+ * Its form may be mandated by a specific {@link Server} implementation.
+ * @return
+ */
+ InputStream getContent();
+}
Added: projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/ClassLoaderResourceBootstrapDescriptor.java
===================================================================
--- projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/ClassLoaderResourceBootstrapDescriptor.java (rev 0)
+++ projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/ClassLoaderResourceBootstrapDescriptor.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.api.descriptor;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.logging.Logger;
+
+/**
+ * {@link BootstrapDescriptor} implementation backed by a named resource
+ * to be obtained via a {@link ClassLoader}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public class ClassLoaderResourceBootstrapDescriptor implements BootstrapDescriptor
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ClassLoaderResourceBootstrapDescriptor.class.getName());
+
+ /**
+ * {@link PrivilegedAction} to obtain the TCCL
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ private static enum GetTcclAction implements PrivilegedAction<ClassLoader> {
+ INSTANCE;
+
+ @Override
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ };
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Underlying handler
+ */
+ private final BootstrapDescriptor urlDescriptor;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance backed by a resource of the specified
+ * name located within (or accessible from) the Thread Context {@link ClassLoader}
+ * @param name
+ * @throws IllegalArgumentException If the name is not specified, or
+ * if a resource of the specified name could not be found from TCCL.
+ */
+ public ClassLoaderResourceBootstrapDescriptor(final String name) throws IllegalArgumentException
+ {
+ // Get TCCL
+ this(name, AccessController.doPrivileged(GetTcclAction.INSTANCE));
+ }
+
+ /**
+ * Creates a new instance backed by a resource of the specified
+ * name located within (or accessible from) the specified {@link ClassLoader}
+ * @param name
+ * @param cl
+ * @throws IllegalArgumentException If either the cl or name is not specified, or
+ * if a resource of the specified name could not be found from the specified cl.
+ */
+ public ClassLoaderResourceBootstrapDescriptor(final String name, final ClassLoader cl)
+ throws IllegalArgumentException
+ {
+ // Precondition checks
+ if (cl == null)
+ {
+ throw new IllegalArgumentException("cl must be specified");
+ }
+ if (name == null || name.length() == 0)
+ {
+ throw new IllegalArgumentException("name must be specified");
+ }
+
+ // Get the URL for this CL Resource
+ final URL url = cl.getResource(name);
+
+ // Ensure found
+ if (url == null)
+ {
+ throw new IllegalArgumentException("Could not find requested resource \"" + name + "\" in " + cl);
+ }
+
+ // Make a descriptor impl which can handle this type
+ final BootstrapDescriptor delegate = new UrlBootstrapDescriptor(url);
+
+ // Set
+ this.urlDescriptor = delegate;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return urlDescriptor.getName();
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getContent()
+ */
+ public InputStream getContent()
+ {
+ return urlDescriptor.getContent();
+ }
+}
Added: projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/FileBootstrapDescriptor.java
===================================================================
--- projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/FileBootstrapDescriptor.java (rev 0)
+++ projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/FileBootstrapDescriptor.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.api.descriptor;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Logger;
+
+/**
+ * {@link BootstrapDescriptor} implementation backed by a {@link File}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public class FileBootstrapDescriptor implements BootstrapDescriptor
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(FileBootstrapDescriptor.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Underlying handler
+ */
+ private final BootstrapDescriptor urlDescriptor;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance with the specified {@link File}
+ * @param file
+ * @throws IllegalArgumentException If the file is not specified, does not
+ * exist, or is a directory
+ */
+ public FileBootstrapDescriptor(final File file) throws IllegalArgumentException
+ {
+ // Precondition checks
+ if (file == null)
+ {
+ throw new IllegalArgumentException("file must be specified");
+ }
+ if (!file.exists())
+ {
+ throw new IllegalArgumentException("file must exist: " + file.getAbsolutePath());
+ }
+ if (file.isDirectory())
+ {
+ throw new IllegalArgumentException("file must not be a directory: " + file.getAbsolutePath());
+ }
+
+ // Get the URL for this File
+ final URL url;
+ try
+ {
+ url = file.toURI().toURL();
+ }
+ catch (final MalformedURLException e)
+ {
+ throw new RuntimeException("Error in obtaining URL for File: " + file.getAbsolutePath(), e);
+ }
+
+ // Make a descriptor impl which can handle this type
+ final BootstrapDescriptor delegate = new UrlBootstrapDescriptor(url);
+
+ // Set
+ this.urlDescriptor = delegate;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return urlDescriptor.getName();
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getContent()
+ */
+ public InputStream getContent()
+ {
+ return urlDescriptor.getContent();
+ }
+}
Added: projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/UrlBootstrapDescriptor.java
===================================================================
--- projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/UrlBootstrapDescriptor.java (rev 0)
+++ projects/bootstrap/trunk/api/src/main/java/org/jboss/bootstrap/api/descriptor/UrlBootstrapDescriptor.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.api.descriptor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.logging.Logger;
+
+/**
+ * {@link BootstrapDescriptor} implementation backed by a {@link URL}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public class UrlBootstrapDescriptor implements BootstrapDescriptor
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(UrlBootstrapDescriptor.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Underlying URL
+ */
+ private final URL url;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new instance with the specified {@link URL}
+ * @param url
+ * @throws IllegalArgumentException If either argument is not specified
+ */
+ public UrlBootstrapDescriptor(final URL url) throws IllegalArgumentException
+ {
+ // Precondition checks
+ if (url == null)
+ {
+ throw new IllegalArgumentException("url must be specified");
+ }
+
+ // Set
+ this.url = url;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns the name of the underlying {@link URL}
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return url.toExternalForm();
+ }
+
+ /**
+ * Obtains the contents of the underlying {@link URL}; equivalent to
+ * {@link URL#openStream()}
+ * @see org.jboss.bootstrap.api.descriptor.BootstrapDescriptor#getContent()
+ */
+ public InputStream getContent()
+ {
+ try
+ {
+ return this.url.openStream();
+ }
+ catch (final IOException e)
+ {
+ throw new RuntimeException("Could not obtain content stream from " + url.toExternalForm(), e);
+ }
+ }
+}
Modified: projects/bootstrap/trunk/api-as/src/main/java/org/jboss/bootstrap/api/as/config/JBossASBasedServerConfig.java
===================================================================
--- projects/bootstrap/trunk/api-as/src/main/java/org/jboss/bootstrap/api/as/config/JBossASBasedServerConfig.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/api-as/src/main/java/org/jboss/bootstrap/api/as/config/JBossASBasedServerConfig.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -21,6 +21,7 @@
*/
package org.jboss.bootstrap.api.as.config;
+import java.net.MalformedURLException;
import java.net.URL;
import org.jboss.bootstrap.api.config.ServerConfig;
@@ -39,8 +40,24 @@
//-------------------------------------------------------------------------------||
// Constants --------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+
+ /**
+ * 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 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";
+
+ /**
* Constant that holds the name of the system or
* configuration property
*/
@@ -200,8 +217,93 @@
//-------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
/**
+ * Obtains the location of the bootstrap directory. Corresponds to
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapHome();
+
+ /**
+ * Sets the location of the bootstrap directory. Corresponds to
+ * {@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
+ */
+ T bootstrapHome(URL bootstrapHome) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Sets the location of the bootstrap directory. Corresponds to
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_HOME_URL}.
+ *
+ * @param bootstrapHome
+ * @return This configuration
+ * @throws IllegalArgumentException If the bootstrap home location was not specified,
+ * or could not be assigned to a URL (ie. {@link MalformedURLException}
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ T bootstrapHome(String bootstrapHome) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the location of the bootstrap file. Corresponds to
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
+ *
+ * @return
+ */
+ URL getBootstrapUrl();
+
+ /**
+ * Sets the location of the bootstrap file. Corresponds to
+ * {@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
+ */
+ T bootstrapUrl(URL bootstrapLocation) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Sets the location of the bootstrap file. Corresponds to
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_URL}.
+ *
+ * @param bootstrapUrl
+ * @return This configuration
+ * @throws IllegalArgumentException If the bootstrap URL location was not specified,
+ * or could not be assigned to a URL (ie. {@link MalformedURLException}
+ * @throws IllegalStateException If the configuration has been frozen
+ */
+ T bootstrapUrl(String bootstrapUrl) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Obtains the name of the bootstrap configuration. Corresponds to
+ * {@link ServerConfig#PROP_KEY_BOOTSTRAP_NAME}.
+ *
+ * @return
+ */
+ String getBootstrapName();
+
+ /**
+ * Sets the name of the bootstrap configuration file. Corresponds to
+ * {@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
+ */
+ T bootstrapName(String name) throws IllegalArgumentException, IllegalStateException;
+
+ /**
* Obtains the bind address to be used for the Server.
*
* @return
Modified: projects/bootstrap/trunk/impl-as/pom.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/pom.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/pom.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -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>
@@ -26,6 +27,7 @@
<!-- Versions -->
<!-- REMOVE: JBBOOT-68 -->
<version.org.jboss_jboss.vfs>2.2.0.M4</version.org.jboss_jboss.vfs>
+ <version.jetty>6.1.16</version.jetty>
</properties>
@@ -63,7 +65,7 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
</dependency>
-
+
<!-- Remove: JBBOOT-68 -->
<dependency>
<groupId>org.jboss</groupId>
@@ -71,6 +73,14 @@
<version>${version.org.jboss_jboss.vfs}</version>
<scope>provided</scope>
</dependency>
+
+ <!-- org.mortbay.jetty:jetty -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${version.jetty}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -79,6 +79,25 @@
//-------------------------------------------------------------------------------||
/**
+ * URL of the bootstrap to run. Synchronized on
+ * "this". Must
+ * not be exported (so copy on return).
+ */
+ private URL bootstrapUrl;
+
+ /**
+ * 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;
+
+ /**
* Bind address for the server. Synchronized on
* "this". Volatile so we don't have to block
* when simply setting the value.
@@ -239,6 +258,121 @@
// Required Implementations -----------------------------------------------------||
//-------------------------------------------------------------------------------||
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#bootstrapHome(java.net.URL)
+ */
+ public synchronized JBossASServerConfig 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();
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#bootstrapHome(java.lang.String)
+ */
+ public JBossASServerConfig bootstrapHome(String bootstrapHome) throws IllegalArgumentException,
+ IllegalStateException
+ {
+ // If null, just pass along
+ if (bootstrapHome == null)
+ {
+ return this.bootstrapHome((URL) null);
+ }
+
+ // Convert this String into a URL via File
+ final URL url = this.getUrlFromString(bootstrapHome);
+
+ // Return
+ return this.bootstrapHome(url);
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#bootstrapUrl(java.lang.String)
+ */
+ public JBossASServerConfig bootstrapUrl(String bootstrapUrl) throws IllegalArgumentException, IllegalStateException
+ {
+ // If null, just pass along
+ if (bootstrapUrl == null)
+ {
+ return this.bootstrapUrl((URL) null);
+ }
+
+ // Convert this String into a URL via File
+ final URL url = this.getUrlFromString(bootstrapUrl);
+
+ // Return
+ return this.bootstrapUrl(url);
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#bootstrapName(java.lang.String)
+ */
+ public synchronized JBossASServerConfig 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();
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#bootstrapUrl(java.net.URL)
+ */
+ public synchronized JBossASServerConfig 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();
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#getBootstrapHome()
+ */
+ public URL getBootstrapHome()
+ {
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootstrapHome;
+ }
+ return this.copyURL(url);
+ }
+
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#getBootstrapName()
+ */
+ public synchronized String getBootstrapName()
+ {
+ return this.bootstrapName;
+ }
+
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bindAddress(java.lang.String)
*/
@@ -1066,14 +1200,19 @@
* JBBOOT-84
*/
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.base.config.AbstractBasicServerConfig#getBootstrapUrl()
+ /**
+ * @see org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig#getBootstrapUrl()
*/
@ManagementProperty(description = "the bootstrap url", readOnly = true, name = "bootstrapURL")
@Override
public URL getBootstrapUrl()
{
- return super.getBootstrapUrl();
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootstrapUrl;
+ }
+ return this.copyURL(url);
}
@ManagementProperty(description = "the local home directory which the server is running from", readOnly = true)
@@ -1246,6 +1385,55 @@
}
}
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * 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);
+ }
+ }
+
//-------------------------------------------------------------------------------||
// Inner Classes ----------------------------------------------------------------||
//-------------------------------------------------------------------------------||
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASBasedConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASBasedConfigurationValidator.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASBasedConfigurationValidator.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -55,12 +55,18 @@
// Overridden Implementations ---------------------------------------------------||
//-------------------------------------------------------------------------------||
- /* (non-Javadoc)
+ /**
* @see org.jboss.bootstrap.spi.config.AbstractBasicConfigurationValidator#validate(org.jboss.bootstrap.spi.config.ServerConfig)
*/
@Override
- public void validate(T config) throws InvalidConfigurationException
+ public void validate(final T config) throws InvalidConfigurationException
{
+ // Precondition check
+ if (config == null)
+ {
+ throw new IllegalArgumentException("Configuration is required, but was not supplied");
+ }
+
// Log
if (log.isTraceEnabled())
{
@@ -71,6 +77,24 @@
super.validate(config);
/*
+ * Validate bootstrap properties
+ */
+ final String name = config.getBootstrapName();
+ final URL home = config.getBootstrapHome();
+ final URL direct = config.getBootstrapUrl();
+
+ // 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.");
+ }
+ }
+
+ /*
* The following properties must be specified
*/
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -23,6 +23,7 @@
package org.jboss.bootstrap.impl.as.config;
import java.io.File;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
@@ -30,6 +31,7 @@
import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
import org.jboss.bootstrap.api.config.InvalidConfigurationException;
import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer;
+import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
import org.jboss.bootstrap.spi.as.config.JBossASBasedConfigurationInitializer;
import org.jboss.logging.Logger;
@@ -208,16 +210,22 @@
resolvedServerTempLocation = this.adjustToTrailingSlash(resolvedServerTempLocation);
config.serverTempLocation(resolvedServerTempLocation);
- // Bootstrap Home for AS
- final String bootstrapName = config.getBootstrapName();
- assert bootstrapName != null && bootstrapName.length() > 0 : "Bootstrap name is not supplied, perhaps the super impl was not yet initialized?";
- final String bootstrapHomeDefault = resolvedServerConfLocation + bootstrapName;
- // Resolve, ignoring the current value
- String resolvedBootstrapHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, null,
+ // Bootstrap Name and Home for AS
+ final String resolvedBootstrapName = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_BOOTSTRAP_NAME, null,
+ JBossASBasedConfigurationInitializer.VALUE_BOOTSTRAP_NAME_DEFAULT, configProps);
+ config.bootstrapName(resolvedBootstrapName);
+ final String bootstrapHomeDefault = resolvedServerConfLocation;
+ // Resolve
+ final URL bootstrapHome = config.getBootstrapHome();
+ final String currentBootstrapHome = bootstrapHome == null ? null : bootstrapHome.toExternalForm();
+ String resolvedBootstrapHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, currentBootstrapHome,
bootstrapHomeDefault, configProps);
resolvedBootstrapHome = this.adjustToTrailingSlash(resolvedBootstrapHome);
config.bootstrapHome(resolvedBootstrapHome);
+ // Initialize the bootstrap URL
+ this.initializeBootstrapUrl(config);
+
// ${jboss.partition.name}
final String partitionName = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_PARTITION_NAME,
config.getPartitionName(), JBossASBasedConfigurationInitializer.VALUE_PARTITION_NAME_DEFAULT, configProps);
@@ -285,16 +293,6 @@
// Functional Methods -----------------------------------------------------------||
//-------------------------------------------------------------------------------||
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer#getDefaultBootstrapHome()
- */
- @Override
- protected URL getDefaultBootstrapHome(T config)
- {
- // For AS, the bootstrap home is the server conf location
- return config.getServerConfLocation();
- }
-
/**
* Returns the value of the specified String, appending a trailing
* slash "/", if not found. Otherwise returns the argument.
@@ -428,4 +426,162 @@
return returnValue;
}
+ /**
+ * @see org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer#applyPropertyOverrides(org.jboss.bootstrap.api.config.ServerConfig)
+ */
+ @Override
+ protected void applyPropertyOverrides(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(T.PROP_KEY_BOOTSTRAP_HOME_URL, properties);
+ if (overrideHome != null)
+ {
+ config.bootstrapHome(overrideHome);
+ }
+
+ // URL
+ final String overrideUrl = this.getOverrideValue(T.PROP_KEY_BOOTSTRAP_URL, properties);
+ if (overrideUrl != null)
+ {
+ config.bootstrapUrl(overrideUrl);
+ }
+
+ // Name
+ final String overrideName = this.getOverrideValue(T.PROP_KEY_BOOTSTRAP_NAME, properties);
+ if (overrideName != null)
+ {
+ config.bootstrapName(overrideName);
+ }
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Initializes the bootstrap URL from bootstrapHome+bootstrapName (if specified),
+ * or directly from the bootstrapURL property (if specified this takes priority).
+ * @param config
+ */
+ void initializeBootstrapUrl(final T config)
+ {
+ /*
+ * Default the config
+ */
+
+ final URL bootstrapUrl = config.getBootstrapUrl();
+ final URL home = config.getBootstrapHome();
+ 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...");
+ }
+
+ // Bootstrap name should not start with a slash when being treated as a relative URL
+ // to the bootstrap home.
+ if (name.startsWith(TRAILING_SLASH))
+ {
+ throw new InvalidBootstrapURLException("Invalid bootstrap name: " + name
+ + ". Bootstrap name can not start with '" + TRAILING_SLASH + "'.");
+ }
+
+ // 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
+ */
+
+ final URL defaultBootstrapHome = config.getServerConfLocation();
+
+ // If there's no name, default it, then run this config again to
+ // default other properties if necessary
+ if (name == null || name.length() == 0)
+ {
+ final String defaultBootstrapName = JBossASBasedConfigurationInitializer.VALUE_BOOTSTRAP_NAME_DEFAULT;
+ config.bootstrapName(defaultBootstrapName);
+ this.initializeBootstrapUrl(config);
+ }
+
+ // If there's no home, default it, then run this config again
+ if (home == null)
+ {
+ final URL newHome = defaultBootstrapHome;
+ config.bootstrapHome(newHome);
+ this.initializeBootstrapUrl(config);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
}
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/AbstractKernelEventLifecycleEventHandler.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/AbstractKernelEventLifecycleEventHandler.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/AbstractKernelEventLifecycleEventHandler.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -25,8 +25,8 @@
import org.jboss.bootstrap.api.lifecycle.LifecycleEventException;
import org.jboss.bootstrap.api.lifecycle.LifecycleEventHandler;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.server.MCBasedServer;
import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.plugins.event.AbstractEvent;
import org.jboss.kernel.spi.event.KernelEvent;
import org.jboss.kernel.spi.event.KernelEventManager;
@@ -55,9 +55,9 @@
//-------------------------------------------------------------------------------------||
/**
- * The bootstrap, whose kernel we'll use to fire events
+ * The server whose kernel we'll use to fire events
*/
- private BasicBootstrap bootstrap;
+ private MCBasedServer<?, ?> server;
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
@@ -66,18 +66,18 @@
/**
* Constructor
*
- * @throws IllegalArgumentException If the bootstrap was not specified
+ * @throws IllegalArgumentException If the server was not specified
*/
- public AbstractKernelEventLifecycleEventHandler(final BasicBootstrap bootstrap) throws IllegalArgumentException
+ public AbstractKernelEventLifecycleEventHandler(final MCBasedServer<?, ?> server) throws IllegalArgumentException
{
// Precondition check
- if (bootstrap == null)
+ if (server == null)
{
- throw new IllegalArgumentException("Bootstrap is required");
+ throw new IllegalArgumentException("server is required");
}
// Set
- this.setBootstrap(bootstrap);
+ this.server = server;
}
//-------------------------------------------------------------------------------------||
@@ -96,7 +96,7 @@
}
// Get the Kernel
- final Kernel kernel = this.getBootstrap().getKernel();
+ final Kernel kernel = this.server.getKernel();
// Send a notification
final KernelEventManager eventMgr = kernel.getEventManager();
@@ -118,24 +118,4 @@
*/
protected abstract String getNotificationType();
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * @return the bootstrap
- */
- private BasicBootstrap getBootstrap()
- {
- return bootstrap;
- }
-
- /**
- * @param bootstrap the bootstrap to set
- */
- private void setBootstrap(final BasicBootstrap bootstrap)
- {
- this.bootstrap = bootstrap;
- }
-
}
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStartEventLifecycleEventHandler.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStartEventLifecycleEventHandler.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStartEventLifecycleEventHandler.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,8 +22,8 @@
package org.jboss.bootstrap.impl.as.lifecycle;
+import org.jboss.bootstrap.api.mc.server.MCBasedServer;
import org.jboss.bootstrap.spi.server.ServerProvider;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
/**
* KernelStartEventLifecycleEventHandler
@@ -40,9 +40,9 @@
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- public KernelStartEventLifecycleEventHandler(final BasicBootstrap bootstrap)
+ public KernelStartEventLifecycleEventHandler(final MCBasedServer<?, ?> server)
{
- super(bootstrap);
+ super(server);
}
//-------------------------------------------------------------------------------------||
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStopEventLifecycleEventHandler.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStopEventLifecycleEventHandler.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/KernelStopEventLifecycleEventHandler.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,8 +22,8 @@
package org.jboss.bootstrap.impl.as.lifecycle;
+import org.jboss.bootstrap.api.mc.server.MCBasedServer;
import org.jboss.bootstrap.spi.server.ServerProvider;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
/**
* KernelStopEventLifecycleEventHandler
@@ -40,9 +40,9 @@
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- public KernelStopEventLifecycleEventHandler(final BasicBootstrap bootstrap)
+ public KernelStopEventLifecycleEventHandler(final MCBasedServer<?, ?> server)
{
- super(bootstrap);
+ super(server);
}
//-------------------------------------------------------------------------------------||
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -23,9 +23,11 @@
package org.jboss.bootstrap.impl.as.server;
import java.io.File;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -33,6 +35,8 @@
import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
import org.jboss.bootstrap.api.as.server.JBossASBasedServer;
import org.jboss.bootstrap.api.config.InvalidConfigurationException;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.descriptor.UrlBootstrapDescriptor;
import org.jboss.bootstrap.api.lifecycle.LifecycleEventException;
import org.jboss.bootstrap.api.lifecycle.LifecycleEventHandler;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
@@ -41,9 +45,11 @@
import org.jboss.bootstrap.impl.as.lifecycle.KernelStartEventLifecycleEventHandler;
import org.jboss.bootstrap.impl.as.lifecycle.KernelStopEventLifecycleEventHandler;
import org.jboss.bootstrap.impl.as.lifecycle.VfsInitializingLifecycleEventHandler;
+import org.jboss.bootstrap.impl.as.xml.BootstrapParser;
+import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
import org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase;
-import org.jboss.bootstrap.spi.as.server.JBossASBasedServerProvider;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.bootstrap.spi.as.metadata.BootstrapMetaData;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASGenericServerProvider;
import org.jboss.logging.Logger;
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
@@ -61,7 +67,7 @@
@ManagementObject(name = AbstractJBossASServerBase.NAME_MANAGEMENT_OBJECT, isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "the MCServer bootstrap view", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
public abstract class AbstractJBossASServerBase<K extends JBossASBasedServer<K, T>, T extends JBossASBasedServerConfig<T>>
extends
- AbstractMCServerBase<K, T> implements JBossASBasedServerProvider<K, T>
+ AbstractMCServerBase<K, T> implements MCBasedJBossASGenericServerProvider<K, T>
{
//-------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------||
@@ -92,6 +98,11 @@
*/
private static final char CHAR_TAB = '\t';
+ /**
+ * Slash string
+ */
+ private static final String SLASH = "/";
+
//-------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -273,6 +284,9 @@
// Call Super
super.doInitialize();
+ // Set up the bootstrap descriptors
+ this.setupBootstrapDescriptorsFromBootstrapUrl();
+
// JBBOOT-68
//TODO Remove once VFS is init'd from something else
// Register an event handler to init VFS alongside server start
@@ -281,9 +295,8 @@
this.registerEventHandler(initVfsHandler, LifecycleState.INITIALIZED);
// Create and Register handlers
- final BasicBootstrap bootstrap = this.getBootstrap();
- final LifecycleEventHandler startHandler = new KernelStartEventLifecycleEventHandler(bootstrap);
- final LifecycleEventHandler stopHandler = new KernelStopEventLifecycleEventHandler(bootstrap);
+ final LifecycleEventHandler startHandler = new KernelStartEventLifecycleEventHandler(this);
+ final LifecycleEventHandler stopHandler = new KernelStopEventLifecycleEventHandler(this);
this.registerEventHandler(startHandler, LifecycleState.STARTED);
this.registerEventHandler(stopHandler, LifecycleState.STOPPING);
@@ -402,4 +415,52 @@
return sb.toString();
}
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Sets up the bootstrap descriptors based upon the main bootstrap XML referents
+ * @throws Exception
+ */
+ protected void setupBootstrapDescriptorsFromBootstrapUrl()
+ {
+ // Set up the bootstrap descriptors
+ final URL bootstrapUrl = this.getConfiguration().getBootstrapUrl();
+ if (bootstrapUrl == null)
+ {
+ throw new IllegalStateException("Bootstrap URL should have been initialized");
+ }
+ final BootstrapMetaData bmd = BootstrapParser.parse(bootstrapUrl);
+ final List<String> urlStrings = bmd.getBootstrapURLs();
+ final URL bootstrapHome = this.getConfiguration().getBootstrapHome();
+ final List<BootstrapDescriptor> descriptors = this.getConfiguration().getBootstrapDescriptors();
+ for (final String urlString : urlStrings)
+ {
+
+ // Condition checks on the URL Strings format as specified by the user
+ if (urlString.startsWith(SLASH))
+ {
+ throw new InvalidBootstrapURLException("Specified URL starts with a \"" + SLASH + "\": " + urlString);
+ }
+
+ final URL url;
+ try
+ {
+ url = new URL(bootstrapHome, urlString);
+ }
+ catch (final MalformedURLException e)
+ {
+ throw new RuntimeException("Could not construct URL from parent " + bootstrapHome + " and name "
+ + urlString, e);
+ }
+ final BootstrapDescriptor descriptor = new UrlBootstrapDescriptor(url);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Adding bootstrap descriptor: " + descriptor);
+ }
+ descriptors.add(descriptor);
+ }
+ }
+
}
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -24,7 +24,7 @@
import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
import org.jboss.bootstrap.api.as.server.JBossASServer;
import org.jboss.bootstrap.impl.as.config.BasicJBossASServerConfig;
-import org.jboss.bootstrap.spi.as.server.JBossASServerProvider;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
/**
* JBossASServerImpl
@@ -36,7 +36,7 @@
*/
public class JBossASServerImpl extends AbstractJBossASServerBase<JBossASServer, JBossASServerConfig>
implements
- JBossASServerProvider
+ MCBasedJBossASServerProvider
{
//-------------------------------------------------------------------------------------||
// Constructors -----------------------------------------------------------------------||
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -71,8 +71,8 @@
super.initialize(server);
}
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.AbstractBasicServerInitializer#setSystemProperties(org.jboss.bootstrap.spi.config.ServerConfig)
+ /**
+ * @see org.jboss.bootstrap.impl.base.server.AbstractBasicServerInitializer#setSystemProperties(org.jboss.bootstrap.api.config.ServerConfig)
*/
@Override
protected void setSystemProperties(T configuration)
@@ -83,8 +83,10 @@
log.trace("Setting system properties for " + this + " ...");
}
- // Super
- super.setSystemProperties(configuration);
+ // Set Properties from Config
+ this.setSystemProperty(T.PROP_KEY_BOOTSTRAP_HOME_URL, configuration.getBootstrapHome());
+ this.setSystemProperty(T.PROP_KEY_BOOTSTRAP_URL, configuration.getBootstrapUrl());
+ this.setSystemProperty(T.PROP_KEY_BOOTSTRAP_NAME, configuration.getBootstrapName());
// Get values to set
final URL jbossHome = configuration.getJBossHome();
Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapParser.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapParser.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapParser.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -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.impl.as.xml;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.as.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/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapParser.java
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapSchemaBinding.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapSchemaBinding.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapSchemaBinding.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -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.impl.as.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.bootstrap.spi.as.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 $
+ */
+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/impl-as/src/main/java/org/jboss/bootstrap/impl/as/xml/BootstrapSchemaBinding.java
___________________________________________________________________
Name: svn:executable
+ *
Copied: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BasicConfigurationTestCase.java (from rev 99507, projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/BasicConfigurationTestCase.java)
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BasicConfigurationTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BasicConfigurationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.logging.Logger;
+import org.junit.Test;
+
+/**
+ * BasicConfigurationTestCase
+ *
+ * Test Cases to assert the basic abstract configuration is working
+ * as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BasicConfigurationTestCase
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(BasicConfigurationTestCase.class);
+
+ private static final String TRAILING_SLASH = "/";
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the supplied home location is a directory
+ *
+ * JBBOOT-36
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationHomeIsDirectory() throws Throwable
+ {
+ // Log
+ log.info("testValidationHomeIsDirectory");
+
+ // Make a config
+ final JBossASServerConfig configuration = new BasicJBossASServerConfig();
+
+ // Make some URL to a non-directory
+ final URL url = new URL("http://manual");
+ final String externalForm = url.toExternalForm();
+ TestCase
+ .assertTrue("Test should not start by looking for trailing slash", !externalForm.endsWith(TRAILING_SLASH));
+
+ // Set
+ configuration.bootstrapHome(url);
+
+ // Test
+ final URL newUrl = configuration.getBootstrapHome();
+ TestCase.assertTrue("Home location should have been adjusted to have a trailing slash", newUrl.toExternalForm()
+ .endsWith(TRAILING_SLASH));
+ }
+
+ @Test
+ public void testPropertiesSet() throws Throwable
+ {
+ // Log
+ log.info("testPropertiesSet");
+
+ // Make a config
+ final JBossASServerConfig configuration = new BasicJBossASServerConfig();
+
+ // Set a bunch of properties at once
+ final String key1 = "key1";
+ final String key2 = "key2";
+ final String value1 = "value1";
+ final String value2 = "value2";
+ final Map<String, String> properties = new HashMap<String, String>();
+ properties.put(key1, value1);
+ properties.put(key2, value2);
+ configuration.properties(properties);
+
+ // Get out the props
+ final String actualValue1 = configuration.getProperty(key1);
+ final String actualValue2 = configuration.getProperty(key2);
+
+ // Test
+ final String failMessage = "Obtained wrong property from that expected";
+ TestCase.assertEquals(failMessage, value1, actualValue1);
+ TestCase.assertEquals(failMessage, value2, actualValue2);
+ }
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapInitializationTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapInitializationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,299 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.config;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.impl.as.common.TestUtils;
+import org.jboss.bootstrap.spi.as.config.JBossASBasedConfigurationInitializer;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Cases to assert that the default configuration
+ * initializer implementation handles the bootstrap
+ * properties as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class BootstrapInitializationTestCase
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(BootstrapInitializationTestCase.class);
+
+ /**
+ * The initializer implementation to test
+ */
+ private static JBossASBasedConfigurationInitializer<JBossASServerConfig> initializer;
+
+ /**
+ * JBOSS_HOME for our tests
+ */
+ private static final URL JBOSS_HOME;
+ static
+ {
+ try
+ {
+ JBOSS_HOME = TestUtils.getJBossHome();
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error in test setup creating JBOSS_HOME", t);
+ }
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * The configuration
+ */
+ private static JBossASServerConfig config;
+
+ //-------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Performs initialization before any tests run
+ */
+ @BeforeClass
+ public static void init()
+ {
+ initializer = new JBossASConfigurationInitializerImpl<JBossASServerConfig>();
+ }
+
+ /**
+ * Creates and sets a new config
+ */
+ @Before
+ public void preTest() throws Throwable
+ {
+ // Create new config
+ config = new BasicJBossASServerConfig();
+ }
+
+ /**
+ * Cleans up the config used in testing such that state
+ * is not carried (leaked) from test to test
+ */
+ @After
+ public void cleanup()
+ {
+ config = null;
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Test Cases -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that 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
+ final JBossASServerConfig configuration = config;
+
+ // Remove bootstrapURL
+ configuration.bootstrapUrl((String) null);
+
+ // Initialize
+ initializer.initialize(configuration);
+
+ // Create the expected URL
+ final URL home = configuration.getBootstrapHome();
+ final String name = configuration.getBootstrapName();
+ final URL expectedBootstrapURL = new URL(home, name);
+
+ // Get the actual URL
+ final URL bootstrapUrl = configuration.getBootstrapUrl();
+
+ // Test
+ TestCase.assertNotNull("Bootstrap URL was not initialized", bootstrapUrl);
+ TestCase.assertEquals("Initialized bootstrap is to incorrect location", expectedBootstrapURL, bootstrapUrl);
+ }
+
+ /**
+ * Ensures that setting a configuration results in proper defaulting
+ * of the bootstrap name if it's not been explicitly specified and
+ * there's no bootstrapUrl
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapNameDefaultedInInitialization() throws Throwable
+ {
+ // Get a populated config
+ final JBossASServerConfig configuration = config;
+
+ // Remove bootstrapURL and name
+ configuration.bootstrapUrl((String) null).bootstrapName(null);
+
+ // Initialize
+ initializer.initialize(configuration);
+
+ // Create the expected name
+ final String expectedName = JBossASBasedConfigurationInitializer.VALUE_BOOTSTRAP_NAME_DEFAULT;
+
+ // Get the actual name
+ final String actualname = configuration.getBootstrapName();
+
+ // Test
+ TestCase.assertNotNull("Bootstrap name was not initialized", actualname);
+ TestCase.assertEquals("Initialized bootstrap is to incorrect name", expectedName, actualname);
+ }
+
+ /**
+ * Ensures that a completely empty configuration may be initialized
+ * to default values
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testEverythingDefaulted() throws Throwable
+ {
+ // Log
+ log.info("testEverythingDefaulted");
+
+ // Get an empty config
+ final JBossASServerConfig configuration = new BasicJBossASServerConfig();
+ final String serverName = "myserver";
+ configuration.jbossHome(JBOSS_HOME).serverName(serverName);
+
+ // Create the expected values
+ final URL expectedHome = new URL(JBOSS_HOME, "server/" + serverName + "/conf/");
+
+ // Test
+ this.assertBootstrapProperties(expectedHome, configuration);
+ }
+
+ /**
+ * Ensures that specifying a bootstrap home will lead to defaulting
+ * all other properties
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testHomeOnlyDefaultsEverythingElse() throws Throwable
+ {
+ // Log
+ log.info("testHomeOnlyDefaultsEverythingElse");
+
+ // Get an empty config
+ final JBossASServerConfig configuration = config;
+
+ // Make an explicit home and set it
+ final URL explicitHome = new URL("file://myhome/");
+ configuration.bootstrapHome(explicitHome);
+
+ // Test
+ this.assertBootstrapProperties(explicitHome, configuration);
+ }
+
+ /**
+ * Ensures that each configuration value may be overridden
+ * by using the corresponding system property
+ */
+ @Test
+ public void testSystemPropertyOverrides() throws Throwable
+ {
+ // Log
+ log.info("testSystemPropertyOverrides");
+
+ // Get a populated config
+ final JBossASServerConfig configuration = config;
+
+ // Define some property values
+ final String expectedBootstrapName = "overrideBootstrapName";
+ final String expectedBootstrapHome = "file://overrideBootstrapHome/";
+ final String expectedBootstrapUrl = "file://overrideBootstrapUrl";
+
+ // Set as overrides
+ configuration.property(JBossASServerConfig.PROP_KEY_BOOTSTRAP_NAME, expectedBootstrapName).property(
+ JBossASServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, expectedBootstrapHome).property(
+ JBossASServerConfig.PROP_KEY_BOOTSTRAP_URL, expectedBootstrapUrl);
+
+ // Initialize
+ initializer.initialize(configuration);
+
+ // Test
+ final String failMessage = "Override was not honored";
+ TestCase.assertEquals(failMessage, expectedBootstrapName, configuration.getBootstrapName());
+ TestCase.assertEquals(failMessage, expectedBootstrapHome, configuration.getBootstrapHome().toExternalForm());
+ TestCase.assertEquals(failMessage, expectedBootstrapUrl, configuration.getBootstrapUrl().toExternalForm());
+
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that all properties of the specified configuration
+ * are defaulted as expected, given the specified home
+ *
+ * @param home
+ * @param configuration
+ * @throws Throwable
+ */
+ private void assertBootstrapProperties(final URL home, final JBossASServerConfig configuration) throws Throwable
+ {
+ // Initialize
+ initializer.initialize(configuration);
+
+ // Create the expected values
+ final URL expectedHome = home;
+ final String defaultName = JBossASBasedConfigurationInitializer.VALUE_BOOTSTRAP_NAME_DEFAULT;
+ final URL expectedUrl = new URL(expectedHome, defaultName);
+ final String expectedName = defaultName;
+
+ // Get the actual name
+ final URL actualHome = configuration.getBootstrapHome();
+ final URL actualUrl = configuration.getBootstrapUrl();
+ final String actualname = configuration.getBootstrapName();
+
+ // Test
+ TestCase.assertEquals("Initialized bootstrap is to incorrect home", expectedHome, actualHome);
+ TestCase.assertEquals("Initialized bootstrap is to incorrect URL", expectedUrl, actualUrl);
+ TestCase.assertEquals("Initialized bootstrap is to incorrect name", expectedName, actualname);
+ }
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapOnlyConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapOnlyConfigurationInitializer.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/BootstrapOnlyConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap.impl.as.config;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.api.config.InvalidConfigurationException;
+
+/**
+ * A configuration initializer used in testing which is responsible for
+ * initializing the bootstrap properties only
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+public class BootstrapOnlyConfigurationInitializer extends JBossASConfigurationInitializerImpl<JBossASServerConfig>
+{
+ /**
+ * @see org.jboss.bootstrap.impl.as.config.JBossASConfigurationInitializerImpl#initialize(org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig)
+ */
+ @Override
+ public void initialize(JBossASServerConfig config) throws InvalidConfigurationException, IllegalArgumentException,
+ IllegalStateException
+ {
+ // Set up server conf if required
+ final URL serverConf = config.getServerConfLocation();
+ if (serverConf == null)
+ {
+ config.serverConfLocation(getServerConfDefault());
+ }
+
+ // Init the bootstrap URL
+ this.initializeBootstrapUrl(config);
+ }
+
+ /**
+ * Dummy implementation to fake a server conf directory if not already
+ * specified by the configuration; just points to an existing URL
+ * @return
+ */
+ private static final URL getServerConfDefault()
+ {
+ return BootstrapOnlyConfigurationInitializer.class.getProtectionDomain().getCodeSource().getLocation();
+ }
+}
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -28,7 +28,6 @@
import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
import org.jboss.bootstrap.impl.as.common.TestUtils;
-import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationInitializer;
import org.jboss.bootstrap.spi.as.config.JBossASBasedConfigurationInitializer;
import org.jboss.logging.Logger;
import org.junit.After;
@@ -37,8 +36,6 @@
import org.junit.Test;
/**
- * JBossASConfigurationInitializationTestCase
- *
* Test Cases to assert that the default configuration
* initializer implementation is functioning as contracted
*
@@ -429,7 +426,7 @@
// Get expected value
final String expected = this.getBootstrapHome()
- + AbstractBasicConfigurationInitializer.DEFAULT_VALUE_BOOTSTRAP_NAME;
+ + JBossASBasedConfigurationInitializer.VALUE_BOOTSTRAP_NAME_DEFAULT;
// Test
TestCase.assertEquals("Bootstrap URL for AS was not defaulted as expected", expected, actual);
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -469,6 +469,116 @@
this.assertMissingValueFails(config, "use platform MBean Server");
}
+ /**
+ * Ensures that a fully-populated config is returned from
+ * the factory (as a control)
+ */
+ @Test
+ public void testControlOnBootstrapProperties() throws Throwable
+ {
+ // Log
+ log.info("testControlOnBootstrapProperties");
+
+ // Get a populated config
+ final JBossASServerConfig configuration = this.config;
+
+ // Test
+ TestCase.assertNotNull("home was not populated", configuration.getBootstrapHome());
+ TestCase.assertNotNull("name was not populated", configuration.getBootstrapName());
+ TestCase.assertNotNull("URL was not populated", configuration.getBootstrapUrl());
+ }
+
+ /**
+ * Ensures that a fully-populated config is valid
+ */
+ @Test
+ public void testValidationPopulatedBootstrap() throws Throwable
+ {
+ // Log
+ log.info("testValidationPopulatedBootstrap");
+
+ // Get a populated config
+ final JBossASServerConfig configuration = this.config;
+
+ // Validate (should pass)
+ try
+ {
+ validator.validate(configuration);
+ }
+ catch (final InvalidConfigurationException ice)
+ {
+ TestCase.fail("Validation should have succeeded for populated bootstrap");
+ }
+
+ }
+
+ /**
+ * Ensures that an explicit bootstrapURL with no name or home set passes validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationExplicitBootstrapUrlWithNoHomeOrName() throws Throwable
+ {
+ // Log
+ log.info("testValidationExplicitBootstrapUrlWithNoHomeOrName");
+
+ // Get a populated config
+ final JBossASServerConfig configuration = this.config;
+
+ // Remove home and name
+ configuration.bootstrapHome((String) null).bootstrapName((String) null);
+
+ // Validate
+ boolean validationFailed = false;
+ try
+ {
+ validator.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ // Expected
+ validationFailed = true;
+ }
+
+ // Test
+ TestCase.assertFalse("Configuration with no home or name, but a valid or bootstrapURL, must pass validation",
+ validationFailed);
+ }
+
+ /**
+ * Ensures that a configuration with no home, bootstrapURL, or name set fails validation
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testValidationNoBootstrapUrlWithNoHomeOrName() throws Throwable
+ {
+ // Log
+ log.info("testValidationNoBootstrapUrlWithNoHomeOrName");
+
+ // Get a populated config
+ final JBossASServerConfig configuration = this.config;
+
+ // Remove home, name, bootstrapURL
+ configuration.bootstrapHome((String) null).bootstrapName((String) null).bootstrapUrl((String) null);
+
+ // Validate
+ boolean validationFailed = false;
+ try
+ {
+ validator.validate(configuration);
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ // Expected
+ validationFailed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Configuration with no home, name or bootstrapURL must fail validation", validationFailed);
+ }
+
//-------------------------------------------------------------------------------||
// Internal Helper Methods ------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -491,9 +601,10 @@
validator.validate(configWithMisingValue);
}
- catch (InvalidConfigurationException ice)
+ catch (final InvalidConfigurationException ice)
{
failed = true;
+ log.debug("Failed with: " + ice.getMessage());
}
// Test
@@ -515,6 +626,7 @@
final String jbossHome = this.getJBossHome().getAbsolutePath() + "/";
final URL bootstrapHome = this.getBootstrapHome();
final String bootstrapName = BOOTSTRAP_NAME;
+ final URL bootstrapUrl = new URL(bootstrapHome, bootstrapName);
final String bindAddress = JBossASBasedConfigurationInitializer.VALUE_BIND_ADDRESS_DEFAULT;
final String serverName = JBossASBasedConfigurationInitializer.VALUE_SERVER_NAME_DEFAULT;
final String bootLib = jbossHome + JBossASBasedConfigurationInitializer.VALUE_LIBRARY_URL_SUFFIX_DEFAULT;
@@ -536,12 +648,13 @@
final Boolean usePlatformMBeanServer = JBossASBasedConfigurationInitializer.VALUE_PLATFORM_MBEAN_SERVER_DEFAULT;
// Populate
- config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bindAddress(bindAddress)
- .serverName(serverName).bootLibraryLocation(bootLib).serverBaseLocation(serverBase).serverHomeLocation(
- serverHome).commonBaseLocation(commonBase).commonLibLocation(commonLib).serverLogLocation(serverLog)
- .serverConfLocation(serverConfig).serverLibLocation(serverLib).serverDataLocation(serverData)
- .serverTempLocation(serverTemp).partitionName(partitionName).loadNative(nativeLoad).nativeLibraryLocation(
- nativeLibLocation).usePlatformMBeanServer(usePlatformMBeanServer);
+ config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bootstrapUrl(bootstrapUrl)
+ .bindAddress(bindAddress).serverName(serverName).bootLibraryLocation(bootLib)
+ .serverBaseLocation(serverBase).serverHomeLocation(serverHome).commonBaseLocation(commonBase)
+ .commonLibLocation(commonLib).serverLogLocation(serverLog).serverConfLocation(serverConfig)
+ .serverLibLocation(serverLib).serverDataLocation(serverData).serverTempLocation(serverTemp).partitionName(
+ partitionName).loadNative(nativeLoad).nativeLibraryLocation(nativeLibLocation)
+ .usePlatformMBeanServer(usePlatformMBeanServer);
// Return
return config;
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/AbstractMCServerTest.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.impl.as.config.BasicJBossASServerConfig;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
+import org.jboss.bootstrap.spi.server.ServerInitializer;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * AbstractMCServerTest
+ *
+ * Abstract test class used to setup basic functionality for MCServer testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class AbstractMCServerTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractMCServerTest.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * The server to test
+ */
+ private JBossASServer server;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates the server
+ */
+ @Before
+ public void createServer() throws Throwable
+ {
+ // Create the server
+ final JBossASServerConfig config = createServerConfig();
+ this.server = new NoOpJBossASServer();
+ this.server.setConfiguration(config);
+ log.info("Created: " + this.server);
+ }
+
+ /**
+ * If started, shuts down the server
+ * @throws Throwable
+ */
+ @After
+ public void shutdownServerAndClear() throws Throwable
+ {
+ final JBossASServer server = this.server;
+ if (server.getState().equals(LifecycleState.STARTED))
+ {
+ server.shutdown();
+ }
+ // Server didn't start up cleanly, so manually run init cleanup
+ else
+ {
+ final MCBasedJBossASServerProvider provider = (MCBasedJBossASServerProvider) server;
+ final ServerInitializer<JBossASServer, JBossASServerConfig> initializer = provider.getServerInitializer();
+ if (initializer != null)
+ {
+ initializer.cleanup(provider);
+ }
+ }
+
+ // Clear the server
+ this.server = null;
+ log.info("Server cleared");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Return the configured {@link JBossASServer}
+ * @return The server
+ */
+ protected JBossASServer getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Obtains a server configuration populated with all URLs and name
+ */
+ private JBossASServerConfig createServerConfig()
+ {
+ // Get the home
+ final URL home = this.getHome();
+
+ // Populate and return
+ return new BasicJBossASServerConfig().bootstrapHome(home);
+ }
+
+ /**
+ * Obtains the home relative to this test location
+ * @return
+ */
+ protected URL getHome()
+ {
+ return this.getClass().getProtectionDomain().getCodeSource().getLocation();
+ }
+
+ /**
+ * Installs a POJO into the specified server
+ *
+ * @param server
+ * @throws Throwable
+ */
+ protected void installPojo(final MCBasedJBossASServerProvider server, final String mcBindName) throws Throwable
+ {
+ // Construct BeanMetaData
+ final Pojo pojo = new Pojo();
+ final BeanMetaData beanMD = BeanMetaDataBuilder.createBuilder(mcBindName, pojo.getClass().getName())
+ .getBeanMetaData();
+
+ // Get the controller and install
+ log.info("Installing test POJO under name " + mcBindName + " into " + server + "...");
+ server.getKernel().getController().install(beanMD, pojo);
+ }
+
+ /**
+ * Ensures that the POJO is installed at {@link AbstractMCServerTest#BIND_NAME_POJO}
+ * and has no expected value
+ *
+ * @param mcBindName
+ * @throws Throwable
+ */
+ protected void assertPojo(final String mcBindName) throws Throwable
+ {
+ this.assertPojo(mcBindName, null);
+ }
+
+ /**
+ * Ensures that the POJO is installed in the provided bind name
+ * and has the expected value
+ *
+ * @param mcBindName
+ * @param expectedValue
+ * @throws Throwable
+ */
+ protected void assertPojo(final String mcBindName, final String expectedValue) throws Throwable
+ {
+ // Log
+ log.trace("Asserting POJO installed as expected...");
+
+ // Get the underlying bean context
+ final KernelController controller = ((MCBasedJBossASServerProvider) this.server).getKernel().getController();
+ final ControllerContext beanContext = controller.getContext(mcBindName, null);
+ TestCase.assertNotNull("beanContext from " + mcBindName + " is null", beanContext);
+ final ControllerState beanState = beanContext.getState();
+ TestCase.assertEquals("POJO did not properly install, error was: " + beanContext.getError(),
+ ControllerState.INSTALLED, beanState);
+
+ // Get Pojo
+ final Object target = beanContext.getTarget();
+ TestCase.assertNotNull("POJO could not be found in MC at: " + mcBindName, target);
+ Pojo pojo = null;
+ try
+ {
+ pojo = Pojo.class.cast(target);
+ }
+ catch (ClassCastException cce)
+ {
+ TestCase.fail("Test pojo was not expected type: " + cce);
+ }
+
+ // Test Lifecycle was invoked by MC
+ final boolean pojoStarted = pojo.isStarted();
+ TestCase.assertTrue("Start lifecycle was not called upon the POJO", pojoStarted);
+
+ // Test expected value
+ final String actualvalue = pojo.getValue();
+ TestCase.assertEquals("POJO did not have expected value", expectedValue, actualvalue);
+
+ // Log
+ log.info("POJO installed as expected with value: " + actualvalue);
+ }
+}
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -173,6 +173,9 @@
final String nativeLoadPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_NATIVE_LOAD;
final String nativeLibLocationPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_NATIVE_DIR;
final String platformMBeanServerPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_PLATFORM_MBEANSERVER;
+ final String bootstrapHomeUrlPropKey = JBossASServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL;
+ final String bootstrapUrlPropKey = JBossASServerConfig.PROP_KEY_BOOTSTRAP_URL;
+ final String bootstrapNamePropKey = JBossASServerConfig.PROP_KEY_BOOTSTRAP_NAME;
// Get Properties from Configuration
final Map<String, String> properties = configuration.getProperties();
@@ -199,6 +202,9 @@
final String nativeLoadFromConfProp = properties.get(nativeLoadPropKey);
final String nativeLibLocationFromConfProp = properties.get(nativeLibLocationPropKey);
final String platformMBeanServerFromConfProp = properties.get(platformMBeanServerPropKey);
+ final String bootstrapHomeFromConfigProp = configuration.getProperties().get(bootstrapHomeUrlPropKey);
+ final String bootstrapURLFromConfigProp = configuration.getProperties().get(bootstrapUrlPropKey);
+ final String bootstrapNameFromConfigProp = configuration.getProperties().get(bootstrapNamePropKey);
// Get Properties from System
final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
@@ -224,6 +230,9 @@
final String nativeLoadFromSystem = System.getProperty(nativeLoadPropKey);
final String nativeLibLocationFromSystem = System.getProperty(nativeLibLocationPropKey);
final String platformMBeanServerFromSystem = System.getProperty(platformMBeanServerPropKey);
+ final String bootstrapHomeFromSystem = System.getProperty(bootstrapHomeUrlPropKey);
+ final String bootstrapURLFromSystem = System.getProperty(bootstrapUrlPropKey);
+ final String bootstrapNameFromSystem = System.getProperty(bootstrapNamePropKey);
// Get Expected Values
final URL jbossHomeFromConf = configuration.getJBossHome();
@@ -262,6 +271,9 @@
final File nativeLibFile = new File(nativeLibFromConf.toURI());
final String nativeLibDirFromConf = nativeLibFile.getAbsolutePath();
final String platformMBeanServerFromConf = configuration.isUsePlatformMBeanServer().toString();
+ final String bootstrapHomeFromConf = configuration.getBootstrapHome().toExternalForm();
+ final String bootstrapURLFromConf = configuration.getBootstrapUrl().toExternalForm();
+ final String bootstrapNameFromConf = configuration.getBootstrapName();
// Ensure all equal
TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeDirFromConf,
@@ -356,6 +368,14 @@
platformMBeanServerFromConf, platformMBeanServerFromConfProp);
TestCase.assertEquals("Platform MBean Server in configuration must match the system property",
platformMBeanServerFromConf, platformMBeanServerFromSystem);
+ TestCase.assertEquals("home in configuration must match the config property", bootstrapHomeFromConf, bootstrapHomeFromConfigProp);
+ TestCase.assertEquals("home in configuration must match the system property", bootstrapHomeFromConf, bootstrapHomeFromSystem);
+ TestCase.assertEquals("bootstrapURL in configuration must match the config property", bootstrapURLFromConf,
+ bootstrapURLFromConfigProp);
+ TestCase.assertEquals("bootstrapURL in configuration must match the system property", bootstrapURLFromConf,
+ bootstrapURLFromSystem);
+ TestCase.assertEquals("name in configuration must match the config property", bootstrapNameFromConf, bootstrapNameFromConfigProp);
+ TestCase.assertEquals("name in configuration must match the system property", bootstrapNameFromConf, bootstrapNameFromSystem);
// Push through lifecycle start/stop
server.start();
@@ -385,6 +405,9 @@
final String nativeLoadFromSystemAfterCleanup = System.getProperty(nativeLoadPropKey);
final String nativeLibFromSystemAfterCleanup = System.getProperty(nativeLibLocationPropKey);
final String platformMBeanServerFromSystemAfterCleanup = System.getProperty(platformMBeanServerPropKey);
+ final String bootstrapHomeFromSystemAfterCleanup = System.getProperty(JBossASServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
+ final String bootstrapURLFromSystemAfterCleanup = System.getProperty(JBossASServerConfig.PROP_KEY_BOOTSTRAP_URL);
+ final String bootstrapNameFromSystemAfterCleanup = System.getProperty(JBossASServerConfig.PROP_KEY_BOOTSTRAP_NAME);
// Ensure all null
final String failMessage = "System property should be null after cleanup";
@@ -411,5 +434,8 @@
TestCase.assertNull(failMessage, nativeLoadFromSystemAfterCleanup);
TestCase.assertNull(failMessage, nativeLibFromSystemAfterCleanup);
TestCase.assertNull(failMessage, platformMBeanServerFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, bootstrapHomeFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, bootstrapURLFromSystemAfterCleanup);
+ TestCase.assertNull(failMessage, bootstrapNameFromSystemAfterCleanup);
}
}
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -29,7 +29,7 @@
import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
import org.jboss.bootstrap.api.as.server.JBossASServer;
import org.jboss.bootstrap.impl.as.common.TestUtils;
-import org.jboss.bootstrap.spi.as.server.JBossASServerProvider;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Before;
@@ -108,7 +108,7 @@
log.info("testIsStarted");
// Cast to get the SPI View
- final JBossASServerProvider serverProviderSpiView = (JBossASServerProvider) server;
+ final MCBasedJBossASServerProvider serverProviderSpiView = (MCBasedJBossASServerProvider) server;
// Test not started
final boolean startedBefore = serverProviderSpiView.isStarted();
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -25,7 +25,7 @@
import junit.framework.TestCase;
import org.jboss.bootstrap.spi.as.config.JBossASServerConfigProvider;
-import org.jboss.bootstrap.spi.as.server.JBossASServerProvider;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
import org.jboss.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -50,7 +50,7 @@
/**
* The server to test; use the SPI view, not the client view
*/
- private static JBossASServerProvider server;
+ private static MCBasedJBossASServerProvider server;
/*
* Test expected values; these must match the contents of the test
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/KernelEventsTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/KernelEventsTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/KernelEventsTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -24,8 +24,10 @@
import junit.framework.TestCase;
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-import org.jboss.bootstrap.spi.as.server.JBossASServerProvider;
+import org.jboss.bootstrap.api.lifecycle.LifecycleEventException;
+import org.jboss.bootstrap.api.lifecycle.LifecycleEventHandler;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
import org.jboss.bootstrap.spi.server.ServerProvider;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.event.KernelEvent;
@@ -60,7 +62,7 @@
/**
* The Server; use the SPI view and not the client view to get at getKernel()
*/
- private JBossASServerProvider server;
+ private MCBasedJBossASServerProvider server;
/**
* Whether or not we got the start event
@@ -84,7 +86,7 @@
public void init() throws Throwable
{
// Make and set the test server
- final JBossASServerProvider server = new NoOpJBossASServer();
+ final MCBasedJBossASServerProvider server = new NoOpJBossASServer();
this.server = server;
// Initialize
@@ -94,10 +96,7 @@
@After
public void cleanup() throws Throwable
{
- // Reset everything
- this.gotStartEvent = false;
- this.gotStopEvent = false;
- this.server = null;
+
}
//-------------------------------------------------------------------------------------||
@@ -115,7 +114,7 @@
log.info("testKernelEvents");
// Get the server
- final JBossASServer server = this.server;
+ final MCBasedJBossASServerProvider server = this.server;
// Test integrity
this.ensureIntegrity();
@@ -147,7 +146,7 @@
log.info("testKernelEventsOnServerRestart");
// Get the server
- final JBossASServer server = this.server;
+ final MCBasedJBossASServerProvider server = this.server;
// Test integrity
this.ensureIntegrity();
@@ -156,12 +155,29 @@
server.start();
server.shutdown();
+ // Register event listeners (do this when the Kernel is back up)
+ server.registerEventHandler(LifecycleState.STARTING, new LifecycleEventHandler()
+ {
+
+ @Override
+ public void handleEvent(final LifecycleState state) throws LifecycleEventException
+ {
+ try
+ {
+ log.info("\n\n\n\n\n\nALR!!!\n\n\n\n");
+ registerEventListeners();
+ }
+ catch (final Throwable t)
+ {
+ throw new LifecycleEventException(t);
+ }
+
+ }
+ });
+
// Test integrity again
this.ensureIntegrity();
- // Register event listeners
- this.registerEventListeners();
-
// Start the server
server.start();
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerBootstrapUrlTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,355 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
+import org.jboss.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.AbstractHandler;
+
+/**
+ * MCServerBootstrapUrlTestCase
+ *
+ * Test Cases to ensure that the MC Server Implementation handles the bootstrapUrl correctly.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class MCServerBootstrapUrlTestCase extends AbstractMCServerTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(MCServerBootstrapUrlTestCase.class);
+
+ private static final String NAME_BOOTSTRAP_POJO = "bootstrap-pojo.xml";
+
+ private static final String NAME_BOOTSTRAP_URLS = "bootstrap-urls.xml";
+
+ private static final String NAME_BOOTSTRAP_SLASH = "bootstrap-starting-slash.xml";
+
+ private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
+
+ private static final String BIND_NAME_POJO_TWO = "org.jboss.bootstrap.test.POJO_2";
+
+ private static final int HTTP_TEST_BIND_PORT = 12345;
+
+ private static final String CONTENT_TYPE_XML = "text/xml";
+
+ private static final String TEST_HTTP_ROOT = "http://localhost:" + HTTP_TEST_BIND_PORT;
+
+ private static final String TEST_HTTP_PATH_BASE = "/path/";
+
+ private static final String TEST_HTTP_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_POJO;
+
+ private static final String TEST_HTTP_MULTI_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_URLS;
+
+ private static Server httpServer;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Starts up an embedded HTTP Server to serve out the Mock
+ *
+ * file:/ URLs)
+ */
+ @BeforeClass
+ public static void startHttpServer()
+ {
+ // Start an Embedded HTTP Server
+ final Handler handler = new StaticFileHandler();
+ httpServer = new Server(HTTP_TEST_BIND_PORT);
+ httpServer.setHandler(handler);
+ try
+ {
+ httpServer.start();
+ }
+ catch (final Exception e)
+ {
+ throw new RuntimeException("Could not start server");
+ }
+ log.info("HTTP Server Started: " + httpServer);
+ }
+
+ /**
+ * Shuts down and clears the Embedded HTTP Server
+ */
+ @AfterClass
+ public static void shutdownHttpServer()
+ {
+ if (httpServer != null)
+ {
+ try
+ {
+ httpServer.stop();
+ }
+ catch (final Exception e)
+ {
+ // Swallow
+ log.error("Could not stop HTTP Server cleanly", e);
+ }
+ log.info("HTTP Server Stopped: " + httpServer);
+ httpServer = null;
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that any valid http:// URL can be processed as a bootstrapUrl.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapHttpUrl() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapHttpUrl");
+
+ final JBossASServer server = getServer();
+
+ // Initialize
+ server.getConfiguration().bootstrapUrl(TEST_HTTP_URL);
+
+ // Start the server
+ server.start();
+
+ assertPojo(BIND_NAME_POJO);
+ }
+
+ /**
+ * Ensures that <url> elements support both relative and fully qualified format
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapHttpUrlMultiNested() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapHttpUrlMultiNested");
+
+ final JBossASServer server = getServer();
+
+ // Initialize
+ server.getConfiguration().bootstrapUrl(TEST_HTTP_MULTI_URL);
+
+ // Start the server
+ server.start();
+
+ assertPojo(BIND_NAME_POJO);
+ assertPojo(BIND_NAME_POJO_TWO);
+ }
+
+ /**
+ * Ensures that any valid file:// URL can be processed as a bootstrapUrl.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapFileUrl() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapFileUrl");
+
+ final JBossASServer server = getServer();
+
+ URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_POJO);
+
+ // Initialize
+ server.getConfiguration().bootstrapUrl(bootstrapUrl);
+
+ // Start the server
+ server.start();
+
+ assertPojo(BIND_NAME_POJO);
+ }
+
+ /**
+ * Ensures that any valid file:// URL can be processed as a bootstrapUrl and will
+ * correctly handle both relative and fully qualified <url> elements.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapFileUrlMultiNested() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapFileUrlMultiNested");
+
+ final JBossASServer server = getServer();
+
+ URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_URLS);
+
+ // Initialize
+ server.getConfiguration().bootstrapUrl(bootstrapUrl);
+
+ // Start the server
+ server.start();
+
+ assertPojo(BIND_NAME_POJO);
+ assertPojo(BIND_NAME_POJO_TWO);
+ }
+
+ /**
+ * Ensures a bootstrapUrl created by the bootstrapHome property functions correctly for both
+ * relative and fully qualified <url> elements
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapUrlFromBootstrapHome() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapUrlFromBootstrapHome");
+
+ final JBossASServer server = getServer();
+
+ // Set name to deploy a test POJO via XML
+ server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_URLS);
+
+ // Start the server
+ server.start();
+
+ assertPojo(BIND_NAME_POJO);
+ assertPojo(BIND_NAME_POJO_TWO);
+ }
+
+ /**
+ * Test to show relative URL will not function with a starting slash in the bootstrapUrl.
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapUrlStartsWithSlash() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapUrlStartsWithSlash");
+
+ final JBossASServer server = getServer();
+
+ server.getConfiguration().bootstrapName("/" + NAME_BOOTSTRAP_POJO);
+
+ try
+ {
+ // Start the server
+ server.start();
+ fail("Should have thrown InvalidBootstrapUrlFormatException");
+ }
+ catch (final InvalidBootstrapURLException expectedException)
+ {
+ // Ignore expected InvalidBootstrapUrlFormatException
+ }
+ }
+
+ /**
+ * Test to show relative URL will not function with a starting slash in a <url> element
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testNestedUrlStartsWithSlash() throws Throwable
+ {
+ // Log
+ log.info("testNestedUrlStartsWithSlash");
+
+ final JBossASServer server = getServer();
+
+ server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_SLASH);
+
+ try
+ {
+ // Start the server
+ server.start();
+ fail("Should have thrown InvalidBootstrapUrlFormatException");
+ }
+ catch (final InvalidBootstrapURLException iburle)
+ {
+ // Good
+ }
+
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Classes--------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Jetty Handler to serve a file contents over HTTP
+ */
+ private static class StaticFileHandler extends AbstractHandler implements Handler
+ {
+ /*
+ * (non-Javadoc)
+ * @see org.mortbay.jetty.Handler#handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
+ */
+ public void handle(final String target, final HttpServletRequest request, final HttpServletResponse response,
+ final int dispatch) throws IOException, ServletException
+ {
+ // Set content type and status before we write anything to the stream
+ response.setContentType(CONTENT_TYPE_XML);
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ // Get local path (removed /path from the target)
+ final String localPath = target.replace(TEST_HTTP_PATH_BASE, "/");
+
+ // Get local stream
+ final InputStream stream = this.getClass().getResourceAsStream(localPath);
+
+ // Write out each line
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ final PrintWriter writer = response.getWriter();
+ String line = null;
+ while ((line = reader.readLine()) != null)
+ {
+ writer.println(line);
+ }
+ writer.flush();
+ reader.close();
+ writer.close();
+ }
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MCServerUnitTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.descriptor.ClassLoaderResourceBootstrapDescriptor;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.bootstrap.spi.as.server.MCBasedJBossASServerProvider;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.junit.Test;
+
+/**
+ * MCServerUnitTestCase
+ *
+ * Test Cases to ensure that the MC Server Implementation is
+ * working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class MCServerUnitTestCase extends AbstractMCServerTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(MCServerUnitTestCase.class);
+
+ private static final String NAME_BOOTSTRAP_POJO = "pojo.xml";
+
+ private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the server starts and that a simple bean
+ * may be installed into the underlying KernelController
+ *
+ * Uses standard MC APIs via the MCServer interface
+ */
+ @Test
+ public void testMcIntegration() throws Throwable
+ {
+ // Log
+ log.info("testMcIntegration");
+
+ // Initialize
+ final JBossASServer server = getServer();
+
+ // Precondition check
+ LifecycleState state = server.getState();
+ TestCase.assertTrue("Server should not yet be started", !state.equals(LifecycleState.STARTED));
+
+ // Start
+ server.start();
+
+ // Get state
+ state = server.getState();
+
+ // Ensure reports as started
+ TestCase.assertTrue("Server should report as started", state.equals(LifecycleState.STARTED));
+
+ // Get the internals/SPI view
+ final MCBasedJBossASServerProvider provider = (MCBasedJBossASServerProvider) server;
+
+ /*
+ * Install a test MC bean into the Server, ensure MC takes
+ * over and lifecycle is invoked
+ */
+ this.installPojo(provider, BIND_NAME_POJO);
+ this.assertPojo(BIND_NAME_POJO);
+ }
+
+ /**
+ * Ensures that a deployed bean is available via
+ * {@link MCServer#getDeployments()}
+ */
+ @Test
+ public void testKernelDeployments() throws Throwable
+ {
+ // Log
+ log.info("testKernelDeployments");
+
+ // Initialize
+ final JBossASServer server = getServer();
+
+ // Set name to deploy a test POJO via XML
+ final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
+ server.getConfiguration().getBootstrapDescriptors().add(descriptor);
+
+ // Start
+ server.start();
+
+ // Get the internals/SPI view
+ final MCBasedJBossASServerProvider provider = (MCBasedJBossASServerProvider) server;
+
+ // Get the Deployment
+ final Map<String, KernelDeployment> deployments = provider.getDeployments();
+
+ // Ensure the deployment is there
+ TestCase.assertEquals("Wrong number of expected kernel deployments", 1, deployments.size());
+ }
+
+ /**
+ * Ensures that deployment from a bootstrap.xml succeeds as expected
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testBootstrapDeployment() throws Throwable
+ {
+ // Log
+ log.info("testBootstrapDeployment");
+
+ // Initialize
+ final JBossASServer server = getServer();
+
+ // Set name to deploy a test POJO via XML
+ final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
+ server.getConfiguration().getBootstrapDescriptors().add(descriptor);
+
+ // Start the server
+ server.start();
+
+ // Test the POJO
+ this.assertPojo(BIND_NAME_POJO);
+ }
+
+ /**
+ * Ensures that the MC Server may restart
+ *
+ * JBBOOT-74
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testRestart() throws Throwable
+ {
+ // Log
+ log.info("testRestart");
+
+ // Initialize
+ final JBossASServer server = getServer();
+
+ // Start the server
+ server.start();
+
+ // Stop the server
+ server.shutdown();
+
+ // Restart
+ boolean restartedOk = true;
+ try
+ {
+ server.start();
+ }
+ catch (final Exception e)
+ {
+ log.error("Server could not restart, exception was:", e);
+ restartedOk = false;
+ }
+
+ // Test that restart was OK
+ TestCase.assertTrue("The server did not restart as expected", restartedOk);
+ }
+
+}
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MutableStartDateNoOpJBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MutableStartDateNoOpJBossASServer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/MutableStartDateNoOpJBossASServer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -24,6 +24,7 @@
import java.util.Date;
+
/**
* MutableStartDateNoOpJBossASServer
*
Deleted: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,97 +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.impl.as.server;
-
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-import org.jboss.logging.Logger;
-
-/**
- * NoOpJBossASServer
- *
- * An implementation of an AS Server which doesn't truly start,
- * but performs all other lifecycle activities
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class NoOpJBossASServer extends JBossASServerImpl implements JBossASServer
-{
- //-------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(NoOpJBossASServer.class);
-
- //-------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /**
- * Constructor to clear all initializers and validators
- */
- public NoOpJBossASServer()
- {
- this(false);
- }
-
- /**
- * Constructor to optionally clear all initializers and validators
- */
- public NoOpJBossASServer(final boolean useInitializersAndValidators)
- {
- super();
-
- // Clear our initializers and validators if specified
- if (!useInitializersAndValidators)
- {
- this.setConfigInitializer(null);
- this.setServerInitializer(null);
- this.setValidator(null);
- }
- }
-
- //-------------------------------------------------------------------------------||
- // Overridden Implementations ---------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doShutdown()
- */
- @Override
- protected void doShutdown() throws Exception
- {
- // NOOP
- log.info("NOOP Shutdown");
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doStart()
- */
- @Override
- protected void doStart() throws Exception
- {
- // NOOP
- log.info("NOOP Startup");
- }
-
-}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+import org.jboss.bootstrap.impl.as.config.BootstrapOnlyConfigurationInitializer;
+import org.jboss.logging.Logger;
+
+/**
+ * NoOpJBossASServer
+ *
+ * An implementation of an AS Server which doesn't truly start,
+ * but performs all other lifecycle activities
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class NoOpJBossASServer extends JBossASServerImpl implements JBossASServer
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(NoOpJBossASServer.class);
+
+ //-------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Constructor to clear all initializers and validators
+ */
+ public NoOpJBossASServer()
+ {
+ this(false);
+ }
+
+ /**
+ * Constructor to optionally clear all initializers and validators
+ */
+ public NoOpJBossASServer(final boolean useInitializersAndValidators)
+ {
+ super();
+
+ // Clear our initializers and validators if specified
+ if (!useInitializersAndValidators)
+ {
+ this.setConfigInitializer(new BootstrapOnlyConfigurationInitializer());
+ this.setServerInitializer(null);
+ this.setValidator(null);
+ }
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doShutdown()
+ */
+ @Override
+ protected void doShutdown() throws Exception
+ {
+ // NOOP
+ log.info("NOOP Shutdown");
+ this.shutdownKernelAndDeployer();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doStart()
+ */
+ @Override
+ protected void doStart() throws Exception
+ {
+ // NOOP
+ log.info("NOOP Startup");
+
+ // Just carry out the MC bits, not starting a full AS
+ this.bootstrapMcAndDescriptors();
+ }
+
+}
Property changes on: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
___________________________________________________________________
Name: svn:executable
+ *
Copied: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/Pojo.java (from rev 99507, projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/Pojo.java)
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/Pojo.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/Pojo.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.server;
+
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.logging.Logger;
+
+/**
+ * Simple test POJO
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class Pojo
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(Pojo.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private boolean started = false;
+
+ private String value;
+
+ //-------------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Start lifecycle (called by MC upon install)
+ */
+ @Start
+ public void start() throws Throwable
+ {
+ log.info("Start lifecycle called: " + this);
+ this.started = true;
+ }
+
+ /**
+ * Returns whether or not the Service was started
+ * @return
+ */
+ public boolean isStarted()
+ {
+ return this.started;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Accessors / Mutators ---------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @return the value
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+}
Added: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-pojo.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-pojo.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-pojo.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>pojo.xml</url>
+
+</bootstrap>
+
Property changes on: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-pojo.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-starting-slash.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-starting-slash.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-starting-slash.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>/pojo.xml</url>
+
+</bootstrap>
+
Added: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-urls.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-urls.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap-urls.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>http://localhost:12345/pojo.xml</url>
+ <url>pojo2.xml</url>
+
+</bootstrap>
+
Added: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+
+ <!--
+ Dummy file for testing, would ordinarily contain:
+
+ <url>something.xml</url>
+ -->
+
+</bootstrap>
\ No newline at end of file
Property changes on: projects/bootstrap/trunk/impl-as/src/test/resources/bootstrap.xml
___________________________________________________________________
Name: svn:executable
+ *
Deleted: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/bootstrap.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/bootstrap.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/bootstrap.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+
+ <!--
+ Dummy file for testing, would ordinarily contain:
+
+ <url>something.xml</url>
+ -->
+
+</bootstrap>
\ No newline at end of file
Property changes on: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/default/conf/bootstrap.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/bootstrap/trunk/impl-as/src/test/resources/pojo.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/pojo.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/pojo.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Test POJO
+
+ Deploys a POJO with no value
+
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="org.jboss.bootstrap.test.POJO" class="org.jboss.bootstrap.impl.as.server.Pojo" />
+
+</deployment>
Property changes on: projects/bootstrap/trunk/impl-as/src/test/resources/pojo.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: projects/bootstrap/trunk/impl-as/src/test/resources/pojo2.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/pojo2.xml (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/pojo2.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Test POJO
+
+ Deploys a POJO with no value
+
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="org.jboss.bootstrap.test.POJO_2" class="org.jboss.bootstrap.impl.as.server.Pojo" />
+
+</deployment>
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,10 +22,6 @@
package org.jboss.bootstrap.impl.base.config;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
import org.jboss.bootstrap.api.config.InvalidConfigurationException;
import org.jboss.bootstrap.api.config.ServerConfig;
import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
@@ -51,218 +47,32 @@
private static final Logger log = Logger.getLogger(AbstractBasicConfigurationInitializer.class);
- /**
- * Represents a slash
- */
- private static final String SLASH = "/";
-
//-------------------------------------------------------------------------------------||
// 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
{
- // Internally initialize to prevent recursion leaking into subclass implementations
- this._initialize(config);
- }
-
- /**
- * Internal implementation of initialize so as to not invoke subclass
- * implementations upon recursion
- *
- * @param config
- * @throws InvalidConfigurationException
- * @throws IllegalArgumentException
- * @throws IllegalStateException
- * @see org.jboss.bootstrap.api.config.ConfigurationInitializer#initialize(org.jboss.bootstrap.api.config.ServerConfig)
- */
- private void _initialize(T config) throws InvalidConfigurationException, IllegalArgumentException,
- IllegalStateException
- {
- // Log
- if (log.isTraceEnabled())
- {
- log.trace("Initializing: " + config);
- }
-
// Apply overrides
this.applyPropertyOverrides(config);
-
- /*
- * Default the config
- */
-
- final URL bootstrapUrl = config.getBootstrapUrl();
- final URL home = config.getBootstrapHome();
- 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...");
- }
-
- // Bootstrap name should not start with a slash when being treated as a relative URL
- // to the bootstrap home.
- if (name.startsWith(SLASH))
- {
- throw new InvalidBootstrapURLException("Invalid bootstrap name: " + name
- + ". Bootstrap name can not start with '" + SLASH + "'.");
- }
-
- // 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 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(this.getDefaultBootstrapName(config));
- this._initialize(config);
- }
-
- // If there's no home, default it, then run this config again
- if (home == null)
- {
- final URL newHome = this.getDefaultBootstrapHome(config);
- config.bootstrapHome(newHome);
- this._initialize(config);
- }
}
//-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * Returns the default bootstrap name
- * @param config A configuration which may be used in determining the default value
- * @return
- */
- protected String getDefaultBootstrapName(final T config)
- {
- return ConfigurationInitializer.DEFAULT_VALUE_BOOTSTRAP_NAME;
- }
-
- /**
- * Returns the default bootstrap home
- * @param config A configuration which may be used in determining the default value
- * @return
- */
- protected URL getDefaultBootstrapHome(final T config)
- {
- return SecurityActions.getCodeSourceLocation(this.getClass());
- }
-
- /**
* Sets the values of contracted system/config properties upon the supplied configuration
*
* @throws IllegalArgumentException If the config was not specified
*/
protected void applyPropertyOverrides(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);
- }
-
- // 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);
- }
+ //NOOP
}
- //-------------------------------------------------------------------------------------||
- // 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;
- }
-
}
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationValidator.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicConfigurationValidator.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,16 +22,12 @@
package org.jboss.bootstrap.impl.base.config;
-import java.net.URL;
-
import org.jboss.bootstrap.api.config.InvalidConfigurationException;
import org.jboss.bootstrap.api.config.ServerConfig;
import org.jboss.bootstrap.spi.config.ConfigurationValidator;
import org.jboss.logging.Logger;
/**
- * AbstractBasicConfigurationValidator
- *
* Base for validating a server configuration to assert that
* it's valid for defining a server
*
@@ -59,34 +55,6 @@
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();
-
- // 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.");
- }
- }
-
- // Log
log.debug("Configuration passed on: " + config);
}
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -25,18 +25,19 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
+import java.util.List;
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.CopyOnWriteArrayList;
import org.jboss.bootstrap.api.config.ServerConfig;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
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.
@@ -66,25 +67,6 @@
private volatile Class<T> actualClass;
/**
- * URL of the bootstrap to run. Synchronized on
- * "this". Must
- * not be exported (so copy on return).
- */
- private URL bootstrapUrl;
-
- /**
- * 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.
*/
@@ -95,6 +77,11 @@
*/
private volatile boolean frozen;
+ /**
+ * Bootstrap descriptors
+ */
+ private final List<BootstrapDescriptor> bootstrapDescriptors;
+
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -149,6 +136,7 @@
this.properties = properties;
this.actualClass = actualClass;
this.frozen = false;
+ this.bootstrapDescriptors = new CopyOnWriteArrayList<BootstrapDescriptor>();
}
//-------------------------------------------------------------------------------------||
@@ -156,48 +144,30 @@
//-------------------------------------------------------------------------------------||
/* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapHome()
+ * @see org.jboss.bootstrap.spi.config.ServerConfig#getProperties()
*/
- public URL getBootstrapHome()
+ public Map<String, String> getProperties()
{
- URL url = null;
- synchronized (this)
- {
- url = this.bootstrapHome;
- }
- return this.copyURL(url);
+ return Collections.unmodifiableMap(this.properties);
}
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapName()
+ /**
+ * @see org.jboss.bootstrap.api.config.ServerConfig#getBootstrapDescriptors()
*/
- public synchronized String getBootstrapName()
+ public List<BootstrapDescriptor> getBootstrapDescriptors()
{
- return this.bootstrapName;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.config.ServerConfig#getBootstrapUrl()
- */
- public URL getBootstrapUrl()
- {
- URL url = null;
- synchronized (this)
+ // If frozen, don't expose a mutable view
+ if (this.isFrozen())
{
- url = this.bootstrapUrl;
+ return Collections.unmodifiableList(this.bootstrapDescriptors);
}
- return this.copyURL(url);
+ else
+ {
+ return this.bootstrapDescriptors;
+ }
}
/* (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#getProperty(java.lang.String)
*/
public String getProperty(final String key) throws IllegalArgumentException
@@ -216,63 +186,6 @@
}
/* (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
@@ -378,30 +291,6 @@
return this.frozen;
}
- /* (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 ---------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -547,52 +436,4 @@
}
}
- /**
- * 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);
- }
- }
}
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractBasicServerInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -131,10 +131,7 @@
*/
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_NAME, configuration.getBootstrapName());
+ // NOOP
}
/**
Modified: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigFactory.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigFactory.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigFactory.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,7 +22,6 @@
package org.jboss.bootstrap.impl.base.config;
-import java.net.MalformedURLException;
import java.net.URL;
/**
@@ -62,22 +61,8 @@
// Create a configuration
final TestServerConfig config = new TestServerConfig();
- // Get the home
- final URL home = getResourcesBase();
-
- // Construct URLs
- URL bootstrap = null;
- try
- {
- bootstrap = new URL(home, NAME_BOOTSTRAP);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Error in URL (improper setup)", e);
- }
-
- // Populate and return
- return config.bootstrapHome(home).bootstrapUrl(bootstrap).bootstrapName(NAME_BOOTSTRAP);
+ // Return
+ return config;
}
/**
Modified: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigurationInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -24,7 +24,6 @@
import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
-
/**
* TestConfigurationInitializer
*
@@ -35,5 +34,11 @@
implements
ConfigurationInitializer<TestServerConfig>
{
- // Impl in superclass
+
+ @Override
+ protected void applyPropertyOverrides(TestServerConfig config) throws IllegalArgumentException
+ {
+ // NOOP
+
+ }
}
Modified: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestServerInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/TestServerInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -77,4 +77,11 @@
super.initialize(server);
}
+ @Override
+ protected void setSystemProperties(final TestServerConfig configuration)
+ {
+ // NOOP
+
+ }
+
}
Deleted: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/BasicConfigurationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/BasicConfigurationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/BasicConfigurationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,121 +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.impl.base.config.unit;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.impl.base.config.TestServerConfig;
-import org.jboss.logging.Logger;
-import org.junit.Test;
-
-/**
- * BasicConfigurationTestCase
- *
- * Test Cases to assert the basic abstract configuration is working
- * as expected
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class BasicConfigurationTestCase
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(BasicConfigurationTestCase.class);
-
- private static final String TRAILING_SLASH = "/";
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that the supplied home location is a directory
- *
- * JBBOOT-36
- *
- * @throws Throwable
- */
- @Test
- public void testValidationHomeIsDirectory() throws Throwable
- {
- // Log
- log.info("testValidationHomeIsDirectory");
-
- // Make a config
- final TestServerConfig configuration = new TestServerConfig();
-
- // Make some URL to a non-directory
- final URL url = new URL("http://manual");
- final String externalForm = url.toExternalForm();
- TestCase
- .assertTrue("Test should not start by looking for trailing slash", !externalForm.endsWith(TRAILING_SLASH));
-
- // Set
- configuration.bootstrapHome(url);
-
- // Test
- final URL newUrl = configuration.getBootstrapHome();
- TestCase.assertTrue("Home location should have been adjusted to have a trailing slash", newUrl.toExternalForm()
- .endsWith(TRAILING_SLASH));
- }
-
- @Test
- public void testPropertiesSet() throws Throwable
- {
- // Log
- log.info("testPropertiesSet");
-
- // Make a config
- final TestServerConfig configuration = new TestServerConfig();
-
- // Set a bunch of properties at once
- final String key1 = "key1";
- final String key2 = "key2";
- final String value1 = "value1";
- final String value2 = "value2";
- final Map<String, String> properties = new HashMap<String, String>();
- properties.put(key1, value1);
- properties.put(key2, value2);
- configuration.properties(properties);
-
- // Get out the props
- final String actualValue1 = configuration.getProperty(key1);
- final String actualValue2 = configuration.getProperty(key2);
-
- // Test
- final String failMessage = "Obtained wrong property from that expected";
- TestCase.assertEquals(failMessage, value1, actualValue1);
- TestCase.assertEquals(failMessage, value2, actualValue2);
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-}
Deleted: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigInitializationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigInitializationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,248 +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.impl.base.config.unit;
-
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.api.config.ServerConfig;
-import org.jboss.bootstrap.impl.base.config.TestConfigFactory;
-import org.jboss.bootstrap.impl.base.config.TestConfigurationInitializer;
-import org.jboss.bootstrap.impl.base.config.TestServerConfig;
-import org.jboss.bootstrap.spi.config.ConfigurationInitializer;
-import org.jboss.logging.Logger;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * ConfigInitializationTestCase
- *
- * Ensures that the base configuration initialization is correct
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ConfigInitializationTestCase
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(ConfigValidationTestCase.class);
-
- private static TestConfigurationInitializer configurationInitializer;
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- @BeforeClass
- public static void createInitializer() throws Throwable
- {
- configurationInitializer = new TestConfigurationInitializer();
- log.info("Created: " + configurationInitializer);
- }
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * 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
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Remove bootstrapURL
- configuration.bootstrapUrl((String) null);
-
- // Initialize
- configurationInitializer.initialize(configuration);
-
- // Create the expected URL
- final URL home = configuration.getBootstrapHome();
- final String name = configuration.getBootstrapName();
- final URL expectedBootstrapURL = new URL(home, name);
-
- // Get the actual URL
- final URL bootstrapUrl = configuration.getBootstrapUrl();
-
- // Test
- TestCase.assertNotNull("Bootstrap URL was not initialized", bootstrapUrl);
- TestCase.assertEquals("Initialized bootstrap is to incorrect location", expectedBootstrapURL, bootstrapUrl);
- }
-
- /**
- * Ensures that setting a configuration results in proper defaulting
- * of the bootstrap name if it's not been explicitly specified and
- * there's no bootstrapUrl
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapNameDefaultedInInitialization() throws Throwable
- {
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Remove bootstrapURL and name
- configuration.bootstrapUrl((String) null).bootstrapName(null);
-
- // Initialize
- configurationInitializer.initialize(configuration);
-
- // Create the expected name
- final String expectedName = ConfigurationInitializer.DEFAULT_VALUE_BOOTSTRAP_NAME;
-
- // Get the actual name
- final String actualname = configuration.getBootstrapName();
-
- // Test
- TestCase.assertNotNull("Bootstrap name was not initialized", actualname);
- TestCase.assertEquals("Initialized bootstrap is to incorrect name", expectedName, actualname);
- }
-
- /**
- * Ensures that a completely empty configuration may be initialized
- * to default values
- *
- * @throws Throwable
- */
- @Test
- public void testEverythingDefaulted() throws Throwable
- {
- // Log
- log.info("testEverythingDefaulted");
-
- // Get an empty config
- final TestServerConfig configuration = new TestServerConfig();
-
- // Create the expected values
- final URL expectedHome = TestServerConfig.class.getProtectionDomain().getCodeSource().getLocation();
-
- // Test
- this.assertAllProperties(expectedHome, configuration);
- }
-
- /**
- * Ensures that specifying a bootstrap home will lead to defaulting
- * all other properties
- *
- * @throws Throwable
- */
- @Test
- public void testHomeOnlyDefaultsEverythingElse() throws Throwable
- {
- // Log
- log.info("testHomeOnlyDefaultsEverythingElse");
-
- // Get an empty config
- final TestServerConfig configuration = new TestServerConfig();
-
- // Make an explicit home and set it
- final URL explicitHome = new URL("file://myhome/");
- configuration.bootstrapHome(explicitHome);
-
- // Test
- this.assertAllProperties(explicitHome, configuration);
- }
-
- /**
- * Ensures that each configuration value may be overridden
- * by using the corresponding system property
- */
- @Test
- public void testSystemPropertyOverrides() throws Throwable
- {
- // Log
- log.info("testSystemPropertyOverrides");
-
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Define some property values
- final String expectedBootstrapName = "overrideBootstrapName";
- final String expectedBootstrapHome = "file://overrideBootstrapHome/";
- final String expectedBootstrapUrl = "file://overrideBootstrapUrl";
-
- // Set as overrides
- configuration.property(ServerConfig.PROP_KEY_BOOTSTRAP_NAME, expectedBootstrapName).property(
- ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL, expectedBootstrapHome).property(
- ServerConfig.PROP_KEY_BOOTSTRAP_URL, expectedBootstrapUrl);
-
- // Initialize
- configurationInitializer.initialize(configuration);
-
- // Test
- final String failMessage = "Override was not honored";
- TestCase.assertEquals(failMessage, expectedBootstrapName, configuration.getBootstrapName());
- TestCase.assertEquals(failMessage, expectedBootstrapHome, configuration.getBootstrapHome().toExternalForm());
- TestCase.assertEquals(failMessage, expectedBootstrapUrl, configuration.getBootstrapUrl().toExternalForm());
-
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that all properties of the specified configuration
- * are defaulted as expected, given the specified home
- *
- * @param home
- * @param configuration
- * @throws Throwable
- */
- private void assertAllProperties(final URL home, final TestServerConfig configuration) throws Throwable
- {
- // Initialize
- configurationInitializer.initialize(configuration);
-
- // Create the expected values
- final URL expectedHome = home;
- final String defaultName = ConfigurationInitializer.DEFAULT_VALUE_BOOTSTRAP_NAME;
- final URL expectedUrl = new URL(expectedHome, defaultName);
- final String expectedName = defaultName;
-
- // Get the actual name
- final URL actualHome = configuration.getBootstrapHome();
- final URL actualUrl = configuration.getBootstrapUrl();
- final String actualname = configuration.getBootstrapName();
-
- // Test
- TestCase.assertEquals("Initialized bootstrap is to incorrect home", expectedHome, actualHome);
- TestCase.assertEquals("Initialized bootstrap is to incorrect URL", expectedUrl, actualUrl);
- TestCase.assertEquals("Initialized bootstrap is to incorrect name", expectedName, actualname);
- }
-}
Deleted: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigValidationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigValidationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/config/unit/ConfigValidationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,178 +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.impl.base.config.unit;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.api.config.InvalidConfigurationException;
-import org.jboss.bootstrap.impl.base.config.TestConfigFactory;
-import org.jboss.bootstrap.impl.base.config.TestConfigurationValidator;
-import org.jboss.bootstrap.impl.base.config.TestServerConfig;
-import org.jboss.bootstrap.spi.config.ConfigurationValidator;
-import org.jboss.logging.Logger;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * ConfigValidationTestCase
- *
- * Ensures that the base configuration validation is correct
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ConfigValidationTestCase
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(ConfigValidationTestCase.class);
-
- private static ConfigurationValidator<TestServerConfig> validator;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- @BeforeClass
- public static void createValidator() throws Throwable
- {
- validator = new TestConfigurationValidator();
- }
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that a fully-populated config is returned from
- * the factory (as a control)
- */
- @Test
- public void testControl() throws Throwable
- {
- // Log
- log.info("testControl");
-
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Test
- TestCase.assertNotNull("home was not populated", configuration.getBootstrapHome());
- TestCase.assertNotNull("name was not populated", configuration.getBootstrapName());
- TestCase.assertNotNull("URL was not populated", configuration.getBootstrapUrl());
- }
-
- /**
- * Ensures that a fully-populated config is valid
- */
- @Test
- public void testValidationPopulatedBootstrap() throws Throwable
- {
- // Log
- log.info("testValidationPopulatedBootstrap");
-
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Validate
- try
- {
- validator.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
- {
- // Log
- log.info("testValidationExplicitBootstrapUrlWithNoHomeOrName");
-
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Remove home and name
- configuration.bootstrapHome((String) null).bootstrapName((String) null);
-
- // Validate
- try
- {
- validator.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
- {
- // Log
- log.info("testValidationNoBootstrapUrlWithNoHomeOrName");
-
- // Get a populated config
- final TestServerConfig configuration = TestConfigFactory.createConfiguration();
-
- // Remove home, name, bootstrapURL
- configuration.bootstrapHome((String) null).bootstrapName((String) null).bootstrapUrl((String) null);
-
- // Validate
- boolean validationFailed = false;
- try
- {
- validator.validate(configuration);
- }
- catch (InvalidConfigurationException ice)
- {
- // Expected
- validationFailed = true;
- }
-
- // Test
- TestCase.assertTrue("Configuration with no home, name or bootstrapURL must fail validation", validationFailed);
- }
-
-}
Modified: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerConcurrentStartShutdownTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerConcurrentStartShutdownTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerConcurrentStartShutdownTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.bootstrap.impl.base.config.unit.ConfigValidationTestCase;
import org.jboss.bootstrap.impl.base.server.InterruptibleStartupServer;
import org.jboss.bootstrap.impl.base.server.TestExceptionOnStartServer;
import org.jboss.bootstrap.impl.base.server.TestExceptionOnStartServer.StartException;
@@ -47,7 +46,7 @@
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- private static final Logger log = Logger.getLogger(ConfigValidationTestCase.class);
+ private static final Logger log = Logger.getLogger(ServerConcurrentStartShutdownTestCase.class);
//-------------------------------------------------------------------------------------||
// Tests ------------------------------------------------------------------------------||
Deleted: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerInitializationTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerInitializationTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,151 +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.impl.base.server.unit;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.api.config.ServerConfig;
-import org.jboss.bootstrap.impl.base.config.CountingServerInitializer;
-import org.jboss.bootstrap.impl.base.config.TestConfigFactory;
-import org.jboss.bootstrap.impl.base.config.TestServerConfig;
-import org.jboss.bootstrap.impl.base.config.TestServerInitializer;
-import org.jboss.bootstrap.impl.base.server.TestNoOpServer;
-import org.jboss.logging.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * ServerInitializationTestCase
- *
- * Ensures that the base server initialization is correct
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ServerInitializationTestCase
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(ServerInitializationTestCase.class);
-
- private static CountingServerInitializer serverInitializer;
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private TestNoOpServer server;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- @BeforeClass
- public static void createInitializer() throws Throwable
- {
- serverInitializer = new TestServerInitializer();
- log.info("Created: " + serverInitializer);
- }
-
- @Before
- public void createServer()
- {
- this.server = new TestNoOpServer();
- log.info("Created: " + this.server);
- }
-
- @After
- public void resetServer()
- {
- this.server = null;
- log.info("Cleaned up server to null");
- }
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that the properties backing the configuration are set
- * both on the configuration itself and in the System props. Upon
- * cleanup, these properties must be cleared.
- *
- * @throws Throwable
- */
- @Test
- public void testPropertiesInInitializationLifecycle() throws Throwable
- {
- // Get a populated config and server
- TestServerConfig configuration = TestConfigFactory.createConfiguration();
- final TestNoOpServer server = this.server;
- server.setConfiguration(configuration);
- server.setServerInitializer(serverInitializer);
-
- // Initialize
- server.initialize();
-
- // Get Properties from Configuration
- final String homeFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
- final String bootstrapURLFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_URL);
- final String nameFromConfigProp = configuration.getProperties().get(ServerConfig.PROP_KEY_BOOTSTRAP_NAME);
-
- // Get Properties from System
- final String homeFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
- final String bootstrapURLFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_URL);
- final String nameFromSystem = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME);
-
- // Get Expected Values
- final String home = configuration.getBootstrapHome().toExternalForm();
- final String bootstrapURL = configuration.getBootstrapUrl().toExternalForm();
- final 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("name in configuration must match the config property", name, nameFromConfigProp);
- TestCase.assertEquals("name in configuration must match the system property", name, nameFromSystem);
-
- // Cleanup
- serverInitializer.cleanup(server);
-
- // Get Properties from System
- final String homeFromSystemAfterCleanup = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_HOME_URL);
- final String bootstrapURLFromSystemAfterCleanup = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_URL);
- final String nameFromSystemAfterCleanup = System.getProperty(ServerConfig.PROP_KEY_BOOTSTRAP_NAME);
-
- // Ensure all null
- String failMessage = "System property should be null after cleanup";
- TestCase.assertNull(failMessage, homeFromSystemAfterCleanup);
- TestCase.assertNull(failMessage, bootstrapURLFromSystemAfterCleanup);
- TestCase.assertNull(failMessage, nameFromSystemAfterCleanup);
-
- }
-}
Modified: projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerLifecycleTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerLifecycleTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-base/src/test/java/org/jboss/bootstrap/impl/base/server/unit/ServerLifecycleTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -32,7 +32,6 @@
import org.jboss.bootstrap.impl.base.config.TestConfigurationValidator;
import org.jboss.bootstrap.impl.base.config.TestServerConfig;
import org.jboss.bootstrap.impl.base.config.TestServerInitializer;
-import org.jboss.bootstrap.impl.base.config.unit.ConfigValidationTestCase;
import org.jboss.bootstrap.impl.base.server.TestNoOpServer;
import org.jboss.logging.Logger;
import org.junit.After;
@@ -54,7 +53,7 @@
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- private static final Logger log = Logger.getLogger(ConfigValidationTestCase.class);
+ private static final Logger log = Logger.getLogger(ServerLifecycleTestCase.class);
private static CountingServerInitializer serverInitializer;
Modified: projects/bootstrap/trunk/impl-mc/pom.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/pom.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/pom.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -25,7 +25,6 @@
<properties>
<version.org.jboss.man_jboss.managed>2.1.0.SP1</version.org.jboss.man_jboss.managed>
- <version.jetty>6.1.16</version.jetty>
</properties>
@@ -43,14 +42,6 @@
<artifactId>junit</artifactId>
</dependency>
- <!-- org.mortbay.jetty:jetty -->
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>${version.jetty}</version>
- <scope>test</scope>
- </dependency>
-
<!-- org.jboss.bootstrap:jboss-bootstrap-impl-base -->
<dependency>
<groupId>org.jboss.bootstrap</groupId>
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 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -22,22 +22,19 @@
package org.jboss.bootstrap.impl.mc.server;
-import java.net.URL;
-import java.util.Collections;
+import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.bootstrap.api.config.InvalidConfigurationException;
import org.jboss.bootstrap.api.config.ServerConfig;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
import org.jboss.bootstrap.api.lifecycle.LifecycleEventException;
import org.jboss.bootstrap.api.server.Server;
-import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
import org.jboss.bootstrap.impl.base.server.AbstractServer;
-import org.jboss.bootstrap.impl.base.xml.BootstrapParser;
import org.jboss.bootstrap.impl.mc.deployer.TempBasicXMLDeployer;
import org.jboss.bootstrap.spi.mc.server.MCBasedServerProvider;
-import org.jboss.bootstrap.spi.metadata.BootstrapMetaData;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
import org.jboss.kernel.spi.dependency.KernelController;
@@ -67,11 +64,6 @@
private static final Logger log = Logger.getLogger(AbstractMCServerBase.class);
- /**
- * Represents a slash
- */
- private static final String SLASH = "/";
-
//-------------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -165,6 +157,16 @@
@Override
protected void doShutdown() throws Exception
{
+ this.shutdownKernelAndDeployer();
+ }
+
+ /**
+ * Externalized {@link AbstractMCServerBase#doShutdown()} so we may access directly
+ * from a test environment
+ * @throws Exception
+ */
+ protected void shutdownKernelAndDeployer() throws Exception
+ {
// Shutdown the deployer
try
{
@@ -189,7 +191,7 @@
tempKernelReference = bootstrap.getKernel();
}
- // Null out the Bootstrap
+ // Null out the bootstrap
bootstrap = null;
// If we had a kernel
@@ -204,7 +206,6 @@
{
log.warn("Error stopping " + KernelController.class.getName(), e);
}
-
}
/*
@@ -256,6 +257,16 @@
@Override
protected void doStart() throws Exception
{
+ this.bootstrapMcAndDescriptors();
+ }
+
+ /**
+ * Externalized {@link AbstractMCServerBase#doStart()} so we may access directly
+ * from a test environment
+ * @throws Exception
+ */
+ protected void bootstrapMcAndDescriptors() throws Exception
+ {
// Register the server implementation
final String mcServerBindName = "JBossServer";
final Kernel kernel = this.getKernel();
@@ -280,59 +291,45 @@
throw new Exception("Error in installing " + mcServerBindName + " during startup", t);
}
- // Determine the url for the bootstrap
+ // Get the bootstrap descriptors
final T config = this.getConfiguration();
- final URL homeUrl = config.getBootstrapHome();
- final URL bootstrapUrl = config.getBootstrapUrl();
- log.info("Starting Microcontainer, Main bootstrapURL=" + bootstrapUrl);
-
- // Parse the bootstrap metadata
- final BootstrapMetaData bootstrapMetaData = BootstrapParser.parse(bootstrapUrl);
- List<String> bootstrapURLs = bootstrapMetaData.getBootstrapURLs();
- if (bootstrapURLs == null)
+ final List<BootstrapDescriptor> bootstrapDescriptors = config.getBootstrapDescriptors();
+ if (bootstrapDescriptors.isEmpty())
{
- bootstrapURLs = Collections.emptyList();
+ log.warn("No bootstrap descriptors defined");
}
- if (bootstrapURLs.isEmpty())
- {
- log.warn("No bootstrap urls in " + bootstrapUrl);
- }
- log.debug("BootstrapURLs=" + bootstrapURLs);
- log.debug("Bootstrap URLs are relative to: " + homeUrl);
+ log.info("Starting Microcontainer, Bootstrap Descriptors: " + bootstrapDescriptors);
// Create an xml deployer
kernelDeployer = new TempBasicXMLDeployer(kernel);
try
{
- // Deploy the bootstrap urls
- for (String childBootstrapURL : bootstrapURLs)
+ // Deploy the bootstrap descriptor into MC
+ for (final BootstrapDescriptor bootstrapDescriptor : bootstrapDescriptors)
{
- // Check if child bootstrap URL is valid
- if (childBootstrapURL.startsWith(SLASH))
+ final String bootstrapDescriptorName = bootstrapDescriptor.getName();
+ final InputStream bootstrapDescriptorContent = bootstrapDescriptor.getContent();
+ if (log.isDebugEnabled())
{
- throw new InvalidBootstrapURLException("Invlaid bootstrap URL: " + childBootstrapURL
- + ". Bootstrap URLs can not start with a '" + SLASH + "'");
+ log.debug("Deploying bootstrap descriptor: " + bootstrapDescriptorName);
}
- final URL suburl = new URL(bootstrapUrl, childBootstrapURL);
- log.debug("Deploying bootstrap xml: " + suburl);
- kernelDeployer.deploy(suburl);
+ kernelDeployer.deploy(bootstrapDescriptorName, bootstrapDescriptorContent);
}
- // Check it is complete
+ // Check the deployer's completed OK with all bootstrap descriptors
kernelDeployer.validate();
}
- catch (Throwable t)
+ catch (final Throwable t)
{
try
{
kernelDeployer.shutdown();
}
- catch (Throwable ignored)
+ catch (final Throwable ignored)
{
}
throw new Exception("Encountered exception in server startup", t);
}
-
}
//-------------------------------------------------------------------------------------||
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 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCServerInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -39,5 +39,6 @@
implements
ServerInitializer<MCServer, MCServerConfig>
{
+
// Impl in superclass
}
Deleted: projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/Pojo.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/Pojo.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/Pojo.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,95 +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.impl.mc.server;
-
-import org.jboss.beans.metadata.api.annotations.Start;
-import org.jboss.logging.Logger;
-
-/**
- * Pojo
- *
- * Simple test POJO
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class Pojo
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(Pojo.class);
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private boolean started = false;
-
- private String value;
-
- //-------------------------------------------------------------------------------------||
- // Functional Methods -----------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Start lifecycle (called by MC upon install)
- */
- @Start
- public void start() throws Throwable
- {
- log.info("Start lifecycle called: " + this);
- this.started = true;
- }
-
- /**
- * Returns whether or not the Service was started
- * @return
- */
- public boolean isStarted()
- {
- return this.started;
- }
-
- //-------------------------------------------------------------------------------------||
- // Accessors / Mutators ---------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * @return the value
- */
- public String getValue()
- {
- return value;
- }
-
- /**
- * @param value the value to set
- */
- public void setValue(String value)
- {
- this.value = value;
- }
-}
Deleted: projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,220 +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.impl.mc.server.unit;
-
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.bootstrap.api.mc.config.MCServerConfig;
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.bootstrap.impl.mc.config.BasicMCServerConfig;
-import org.jboss.bootstrap.impl.mc.server.MCServerImpl;
-import org.jboss.bootstrap.impl.mc.server.Pojo;
-import org.jboss.bootstrap.spi.mc.server.MCServerProvider;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.logging.Logger;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * AbstractMCServerTest
- *
- * Abstract test class used to setup basic functionality for MCServer testing
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @version $Revision: $
- */
-public class AbstractMCServerTest
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(AbstractMCServerTest.class);
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * The server to test
- */
- private MCServer server;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Creates the server
- */
- @Before
- public void createServer() throws Throwable
- {
- // Create the server
- final MCServerConfig config = createServerConfig();
- this.server = new MCServerImpl(config);
- log.info("Created: " + this.server);
- }
-
- /**
- * If started, shuts down the server
- * @throws Throwable
- */
- @After
- public void shutdownServerAndClear() throws Throwable
- {
- final MCServer server = this.server;
- if (server.getState().equals(LifecycleState.STARTED))
- {
- server.shutdown();
- }
- // Server didn't start up cleanly, so manually run init cleanup
- else
- {
- final MCServerProvider provider = (MCServerProvider) server;
- provider.getServerInitializer().cleanup(provider);
- }
-
- // Clear the server
- this.server = null;
- log.info("Server cleared");
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Return the configured {@link MCServer}
- * @return MCServer
- */
- protected MCServer getServer()
- {
- return server;
- }
-
- /**
- * Obtains a server configuration populated with all URLs and name
- */
- private MCServerConfig createServerConfig()
- {
- // Get the home
- final URL home = this.getHome();
-
- // Populate and return
- return new BasicMCServerConfig().bootstrapHome(home);
- }
-
- /**
- * Obtains the home relative to this test location
- * @return
- */
- protected URL getHome()
- {
- return this.getClass().getProtectionDomain().getCodeSource().getLocation();
- }
-
- /**
- * Installs a POJO into the specified server
- *
- * @param server
- * @throws Throwable
- */
- protected void installPojo(final MCServer server, final String mcBindName) throws Throwable
- {
- // Construct BeanMetaData
- final Pojo pojo = new Pojo();
- final BeanMetaData beanMD = BeanMetaDataBuilder.createBuilder(mcBindName, pojo.getClass().getName())
- .getBeanMetaData();
-
- // Get the controller and install
- log.info("Installing test POJO under name " + mcBindName + " into " + server + "...");
- server.getKernel().getController().install(beanMD, pojo);
- }
-
- /**
- * Ensures that the POJO is installed at {@link AbstractMCServerTest#BIND_NAME_POJO}
- * and has no expected value
- *
- * @param mcBindName
- * @throws Throwable
- */
- protected void assertPojo(final String mcBindName) throws Throwable
- {
- this.assertPojo(mcBindName, null);
- }
-
- /**
- * Ensures that the POJO is installed in the provided bind name
- * and has the expected value
- *
- * @param mcBindName
- * @param expectedValue
- * @throws Throwable
- */
- protected void assertPojo(final String mcBindName, final String expectedValue) throws Throwable
- {
- // Log
- log.trace("Asserting POJO installed as expected...");
-
- // Get the underlying bean context
- final KernelController controller = this.server.getKernel().getController();
- final ControllerContext beanContext = controller.getContext(mcBindName, null);
- TestCase.assertNotNull("beanContext from " + mcBindName + " is null", beanContext);
- final ControllerState beanState = beanContext.getState();
- TestCase.assertEquals("POJO did not properly install, error was: " + beanContext.getError(),
- ControllerState.INSTALLED, beanState);
-
- // Get Pojo
- final Object target = beanContext.getTarget();
- TestCase.assertNotNull("POJO could not be found in MC at: " + mcBindName, target);
- Pojo pojo = null;
- try
- {
- pojo = Pojo.class.cast(target);
- }
- catch (ClassCastException cce)
- {
- TestCase.fail("Test pojo was not expected type: " + cce);
- }
-
- // Test Lifecycle was invoked by MC
- final boolean pojoStarted = pojo.isStarted();
- TestCase.assertTrue("Start lifecycle was not called upon the POJO", pojoStarted);
-
- // Test expected value
- final String actualvalue = pojo.getValue();
- TestCase.assertEquals("POJO did not have expected value", expectedValue, actualvalue);
-
- // Log
- log.info("POJO installed as expected with value: " + actualvalue);
- }
-}
Added: projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java (rev 0)
+++ projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/AbstractMCServerTest.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.mc.server.unit;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.config.MCServerConfig;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.bootstrap.impl.mc.config.BasicMCServerConfig;
+import org.jboss.bootstrap.impl.mc.server.MCServerImpl;
+import org.jboss.bootstrap.impl.mc.server.Pojo;
+import org.jboss.bootstrap.spi.mc.server.MCServerProvider;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * AbstractMCServerTest
+ *
+ * Abstract test class used to setup basic functionality for MCServer testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class AbstractMCServerTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(AbstractMCServerTest.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * The server to test
+ */
+ private MCServer server;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates the server
+ */
+ @Before
+ public void createServer() throws Throwable
+ {
+ // Create the server
+ final MCServerConfig config = createServerConfig();
+ this.server = new MCServerImpl(config);
+ log.info("Created: " + this.server);
+ }
+
+ /**
+ * If started, shuts down the server
+ * @throws Throwable
+ */
+ @After
+ public void shutdownServerAndClear() throws Throwable
+ {
+ final MCServer server = this.server;
+ if (server.getState().equals(LifecycleState.STARTED))
+ {
+ server.shutdown();
+ }
+ // Server didn't start up cleanly, so manually run init cleanup
+ else
+ {
+ final MCServerProvider provider = (MCServerProvider) server;
+ provider.getServerInitializer().cleanup(provider);
+ }
+
+ // Clear the server
+ this.server = null;
+ log.info("Server cleared");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Return the configured {@link MCServer}
+ * @return MCServer
+ */
+ protected MCServer getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Obtains a server configuration populated with all URLs and name
+ */
+ private MCServerConfig createServerConfig()
+ {
+ // Return
+ return new BasicMCServerConfig();
+ }
+
+ /**
+ * Obtains the home relative to this test location
+ * @return
+ */
+ protected URL getHome()
+ {
+ return this.getClass().getProtectionDomain().getCodeSource().getLocation();
+ }
+
+ /**
+ * Installs a POJO into the specified server
+ *
+ * @param server
+ * @throws Throwable
+ */
+ protected void installPojo(final MCServer server, final String mcBindName) throws Throwable
+ {
+ // Construct BeanMetaData
+ final Pojo pojo = new Pojo();
+ final BeanMetaData beanMD = BeanMetaDataBuilder.createBuilder(mcBindName, pojo.getClass().getName())
+ .getBeanMetaData();
+
+ // Get the controller and install
+ log.info("Installing test POJO under name " + mcBindName + " into " + server + "...");
+ server.getKernel().getController().install(beanMD, pojo);
+ }
+
+ /**
+ * Ensures that the POJO is installed at {@link AbstractMCServerTest#BIND_NAME_POJO}
+ * and has no expected value
+ *
+ * @param mcBindName
+ * @throws Throwable
+ */
+ protected void assertPojo(final String mcBindName) throws Throwable
+ {
+ this.assertPojo(mcBindName, null);
+ }
+
+ /**
+ * Ensures that the POJO is installed in the provided bind name
+ * and has the expected value
+ *
+ * @param mcBindName
+ * @param expectedValue
+ * @throws Throwable
+ */
+ protected void assertPojo(final String mcBindName, final String expectedValue) throws Throwable
+ {
+ // Log
+ log.trace("Asserting POJO installed as expected...");
+
+ // Get the underlying bean context
+ final KernelController controller = this.server.getKernel().getController();
+ final ControllerContext beanContext = controller.getContext(mcBindName, null);
+ TestCase.assertNotNull("beanContext from " + mcBindName + " is null", beanContext);
+ final ControllerState beanState = beanContext.getState();
+ TestCase.assertEquals("POJO did not properly install, error was: " + beanContext.getError(),
+ ControllerState.INSTALLED, beanState);
+
+ // Get Pojo
+ final Object target = beanContext.getTarget();
+ TestCase.assertNotNull("POJO could not be found in MC at: " + mcBindName, target);
+ Pojo pojo = null;
+ try
+ {
+ pojo = Pojo.class.cast(target);
+ }
+ catch (ClassCastException cce)
+ {
+ TestCase.fail("Test pojo was not expected type: " + cce);
+ }
+
+ // Test Lifecycle was invoked by MC
+ final boolean pojoStarted = pojo.isStarted();
+ TestCase.assertTrue("Start lifecycle was not called upon the POJO", pojoStarted);
+
+ // Test expected value
+ final String actualvalue = pojo.getValue();
+ TestCase.assertEquals("POJO did not have expected value", expectedValue, actualvalue);
+
+ // Log
+ log.info("POJO installed as expected with value: " + actualvalue);
+ }
+}
Deleted: projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerBootstrapUrlTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerBootstrapUrlTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerBootstrapUrlTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,356 +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.impl.mc.server.unit;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.URL;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.bootstrap.impl.base.config.InvalidBootstrapURLException;
-import org.jboss.logging.Logger;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-
-/**
- * MCServerBootstrapUrlTestCase
- *
- * Test Cases to ensure that the MC Server Implementation handles the bootstrapUrl correctly.
- *
- * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
- * @version $Revision: $
- */
-public class MCServerBootstrapUrlTestCase extends AbstractMCServerTest
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(MCServerBootstrapUrlTestCase.class);
-
- private static final String NAME_BOOTSTRAP_POJO = "bootstrap-pojo.xml";
-
- private static final String NAME_BOOTSTRAP_URLS = "bootstrap-urls.xml";
-
- private static final String NAME_BOOTSTRAP_SLASH = "bootstrap-starting-slash.xml";
-
- private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
-
- private static final String BIND_NAME_POJO_TWO = "org.jboss.bootstrap.test.POJO_2";
-
- private static final int HTTP_TEST_BIND_PORT = 12345;
-
- private static final String CONTENT_TYPE_XML = "text/xml";
-
- private static final String TEST_HTTP_ROOT = "http://localhost:" + HTTP_TEST_BIND_PORT;
-
- private static final String TEST_HTTP_PATH_BASE = "/path/";
-
- private static final String TEST_HTTP_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_POJO;
-
- private static final String TEST_HTTP_MULTI_URL = TEST_HTTP_ROOT + TEST_HTTP_PATH_BASE + NAME_BOOTSTRAP_URLS;
-
- private static Server httpServer;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Starts up an embedded HTTP Server to serve out the Mock
- *
- * file:/ URLs)
- */
- @BeforeClass
- public static void startHttpServer()
- {
- // Start an Embedded HTTP Server
- final Handler handler = new StaticFileHandler();
- httpServer = new Server(HTTP_TEST_BIND_PORT);
- httpServer.setHandler(handler);
- try
- {
- httpServer.start();
- }
- catch (final Exception e)
- {
- throw new RuntimeException("Could not start server");
- }
- log.info("HTTP Server Started: " + httpServer);
- }
-
- /**
- * Shuts down and clears the Embedded HTTP Server
- */
- @AfterClass
- public static void shutdownHttpServer()
- {
- if (httpServer != null)
- {
- try
- {
- httpServer.stop();
- }
- catch (final Exception e)
- {
- // Swallow
- log.error("Could not stop HTTP Server cleanly", e);
- }
- log.info("HTTP Server Stopped: " + httpServer);
- httpServer = null;
- }
- }
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures that any valid http:// URL can be processed as a bootstrapUrl.
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapHttpUrl() throws Throwable
- {
- // Log
- log.info("testBootstrapHttpUrl");
-
- final MCServer server = getServer();
-
- // Initialize
- server.getConfiguration().bootstrapUrl(TEST_HTTP_URL);
-
- // Start the server
- server.start();
-
- assertPojo(BIND_NAME_POJO);
- }
-
- /**
- * Ensures that <url> elements support both relative and fully qualified format
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapHttpUrlMultiNested() throws Throwable
- {
- // Log
- log.info("testBootstrapHttpUrlMultiNested");
-
- final MCServer server = getServer();
-
- // Initialize
- server.getConfiguration().bootstrapUrl(TEST_HTTP_MULTI_URL);
-
- // Start the server
- server.start();
-
- assertPojo(BIND_NAME_POJO);
- assertPojo(BIND_NAME_POJO_TWO);
- }
-
- /**
- * Ensures that any valid file:// URL can be processed as a bootstrapUrl.
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapFileUrl() throws Throwable
- {
- // Log
- log.info("testBootstrapFileUrl");
-
- final MCServer server = getServer();
-
- URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_POJO);
-
- // Initialize
- server.getConfiguration().bootstrapUrl(bootstrapUrl);
-
- // Start the server
- server.start();
-
- assertPojo(BIND_NAME_POJO);
- }
-
- /**
- * Ensures that any valid file:// URL can be processed as a bootstrapUrl and will
- * correctly handle both relative and fully qualified <url> elements.
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapFileUrlMultiNested() throws Throwable
- {
- // Log
- log.info("testBootstrapFileUrlMultiNested");
-
- final MCServer server = getServer();
-
- URL bootstrapUrl = new URL(getHome(), NAME_BOOTSTRAP_URLS);
-
- // Initialize
- server.getConfiguration().bootstrapUrl(bootstrapUrl);
-
- // Start the server
- server.start();
-
- assertPojo(BIND_NAME_POJO);
- assertPojo(BIND_NAME_POJO_TWO);
- }
-
- /**
- * Ensures a bootstrapUrl created by the bootstrapHome property functions correctly for both
- * relative and fully qualified <url> elements
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapUrlFromBootstrapHome() throws Throwable
- {
- // Log
- log.info("testBootstrapUrlFromBootstrapHome");
-
- final MCServer server = getServer();
-
- // Set name to deploy a test POJO via XML
- server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_URLS);
-
- // Start the server
- server.start();
-
- assertPojo(BIND_NAME_POJO);
- assertPojo(BIND_NAME_POJO_TWO);
- }
-
- /**
- * Test to show relative URL will not function with a starting slash in the bootstrapUrl.
- *
- * @throws Throwable
- */
- @Test
- public void testBootstrapUrlStartsWithSlash() throws Throwable
- {
- // Log
- log.info("testBootstrapUrlStartsWithSlash");
-
- MCServer server = getServer();
-
- server.getConfiguration().bootstrapName("/" + NAME_BOOTSTRAP_POJO);
-
- try
- {
- // Start the server
- server.start();
- fail("Should have thrown InvalidBootstrapUrlFormatException");
- }
- catch (InvalidBootstrapURLException expectedException)
- {
- // Ignore expected InvalidBootstrapUrlFormatException
- }
- }
-
- /**
- * Test to show relative URL will not function with a starting slash in a <url> element
- *
- * @throws Throwable
- */
- @Test
- public void testNestedUrlStartsWithSlash() throws Throwable
- {
- // Log
- log.info("testNestedUrlStartsWithSlash");
-
- final MCServer server = getServer();
-
- server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_SLASH);
-
- try
- {
- // Start the server
- server.start();
- fail("Should have thrown InvalidBootstrapUrlFormatException");
- }
- catch (Exception expectedException)
- {
- assertTrue(expectedException.getCause() instanceof InvalidBootstrapURLException);
- }
-
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Classes--------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Jetty Handler to serve a file contents over HTTP
- */
- private static class StaticFileHandler extends AbstractHandler implements Handler
- {
- /*
- * (non-Javadoc)
- * @see org.mortbay.jetty.Handler#handle(java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int)
- */
- public void handle(final String target, final HttpServletRequest request, final HttpServletResponse response,
- final int dispatch) throws IOException, ServletException
- {
- // Set content type and status before we write anything to the stream
- response.setContentType(CONTENT_TYPE_XML);
- response.setStatus(HttpServletResponse.SC_OK);
-
- // Get local path (removed /path from the target)
- final String localPath = target.replace(TEST_HTTP_PATH_BASE, "/");
-
- // Get local stream
- final InputStream stream = this.getClass().getResourceAsStream(localPath);
-
- // Write out each line
- final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- final PrintWriter writer = response.getWriter();
- String line = null;
- while ((line = reader.readLine()) != null)
- {
- writer.println(line);
- }
- writer.flush();
- reader.close();
- writer.close();
- }
- }
-
-}
Modified: projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerUnitTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerUnitTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/java/org/jboss/bootstrap/impl/mc/server/unit/MCServerUnitTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -26,6 +26,8 @@
import junit.framework.TestCase;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.descriptor.ClassLoaderResourceBootstrapDescriptor;
import org.jboss.bootstrap.api.lifecycle.LifecycleState;
import org.jboss.bootstrap.api.mc.server.MCServer;
import org.jboss.bootstrap.spi.mc.server.MCServerProvider;
@@ -50,7 +52,7 @@
private static final Logger log = Logger.getLogger(MCServerUnitTestCase.class);
- private static final String NAME_BOOTSTRAP_POJO = "bootstrap-pojo.xml";
+ private static final String NAME_BOOTSTRAP_POJO = "pojo.xml";
private static final String BIND_NAME_POJO = "org.jboss.bootstrap.test.POJO";
@@ -108,7 +110,8 @@
final MCServer server = getServer();
// Set name to deploy a test POJO via XML
- server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_POJO);
+ final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
+ server.getConfiguration().getBootstrapDescriptors().add(descriptor);
// Start
server.start();
@@ -138,7 +141,8 @@
final MCServer server = getServer();
// Set name to deploy a test POJO via XML
- server.getConfiguration().bootstrapName(NAME_BOOTSTRAP_POJO);
+ final BootstrapDescriptor descriptor = new ClassLoaderResourceBootstrapDescriptor(NAME_BOOTSTRAP_POJO);
+ server.getConfiguration().getBootstrapDescriptors().add(descriptor);
// Start the server
server.start();
Deleted: projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-pojo.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-pojo.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-pojo.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
- <url>pojo.xml</url>
-
-</bootstrap>
-
Deleted: projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-starting-slash.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-starting-slash.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-starting-slash.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
- <url>/pojo.xml</url>
-
-</bootstrap>
-
Deleted: projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-urls.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-urls.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap-urls.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
- <url>http://localhost:12345/pojo.xml</url>
- <url>pojo2.xml</url>
-
-</bootstrap>
-
Deleted: projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/bootstrap.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
-
- <!--
- Dummy file for testing, would ordinarily contain:
-
- <url>something.xml</url>
- -->
-
-</bootstrap>
\ No newline at end of file
Deleted: projects/bootstrap/trunk/impl-mc/src/test/resources/pojo2.xml
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/pojo2.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/pojo2.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
- Test POJO
-
- Deploys a POJO with no value
-
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <bean name="org.jboss.bootstrap.test.POJO_2" class="org.jboss.bootstrap.impl.mc.server.Pojo" />
-
-</deployment>
Modified: projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ConfigurationInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/config/ConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -38,15 +38,6 @@
public interface ConfigurationInitializer<T extends ServerConfig<?>>
{
//-------------------------------------------------------------------------------------||
- // Constants --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * The default value of the name of the bootstrap file
- */
- String DEFAULT_VALUE_BOOTSTRAP_NAME = "bootstrap.xml";
-
- //-------------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
Deleted: 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/metadata/BootstrapMetaData.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,66 +0,0 @@
-/*
- * 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(final List<String> bootstrapURLs)
- {
- this.bootstrapURLs = bootstrapURLs;
- }
-
- @Override
- public String toString()
- {
- return super.toString() + "{" + bootstrapURLs + "}";
- }
-}
Modified: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASBasedConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASBasedConfigurationInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASBasedConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -47,6 +47,11 @@
* The following denote default values in the case
* a property is not explicitly-specified
*/
+
+ /**
+ * The default value of the name of the bootstrap file
+ */
+ String VALUE_BOOTSTRAP_NAME_DEFAULT = "bootstrap.xml";
/**
* Default address which will be set
Deleted: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASConfigurationInitializer.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/config/JBossASConfigurationInitializer.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,37 +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.as.config;
-
-import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
-
-/**
- * JBossASSConfigurationInitializer
- *
- * Contract for a JBossAS Configuration Initializer
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface JBossASConfigurationInitializer extends JBossASBasedConfigurationInitializer<JBossASServerConfig>
-{
-
-}
Copied: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/BootstrapMetaData.java (from rev 99507, projects/bootstrap/trunk/spi/src/main/java/org/jboss/bootstrap/spi/metadata/BootstrapMetaData.java)
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/BootstrapMetaData.java (rev 0)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/BootstrapMetaData.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,67 @@
+/*
+ * 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.as.metadata;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+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 = new ArrayList<String>();
+
+ /**
+ * Get the bootstrapURLs.
+ *
+ * @return the bootstrapURLs.
+ */
+ public List<String> getBootstrapURLs()
+ {
+ return bootstrapURLs;
+ }
+
+ /**
+ * Set the bootstrapURLs.
+ *
+ * @param bootstrapURLs the bootstrapURLs.
+ */
+ public void setBootstrapURLs(final List<String> bootstrapURLs)
+ {
+ this.bootstrapURLs = bootstrapURLs;
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "{" + bootstrapURLs + "}";
+ }
+}
Property changes on: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/metadata/BootstrapMetaData.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASBasedServerProvider.java
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASBasedServerProvider.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASBasedServerProvider.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,95 +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.as.server;
-
-import java.util.Date;
-import java.util.Map;
-
-import org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig;
-import org.jboss.bootstrap.api.as.server.JBossASBasedServer;
-import org.jboss.bootstrap.api.server.Server;
-import org.jboss.bootstrap.spi.mc.server.MCBasedServerProvider;
-
-/**
- * JBossASBasedServerProvider
- *
- * Contract for implementations of JBoss Application Servers
- * and extensions thereof
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface JBossASBasedServerProvider<K extends JBossASBasedServer<K, T>, T extends JBossASBasedServerConfig<T>>
- extends
- MCBasedServerProvider<K, T>,
- JBossASBasedServer<K, T>
-{
- //-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /** @return The server start date */
- Date getStartDate();
-
- /** @return The server version, the underlying version expressed as a String */
- String getVersion();
-
- /** @return The server version code name */
- String getVersionName();
-
- /** @return The full server version number */
- String getVersionNumber();
-
- /** @return The date the server was build (compiled) */
- String getBuildNumber();
-
- /** @return The JVM used to build the server */
- String getBuildJVM();
-
- /** @return The Operating System used to build the server */
- String getBuildOS();
-
- /** @return The build id */
- String getBuildID();
-
- /** @return The date the server was build */
- String getBuildDate();
-
- /**
- * Get the optional server configuration metadata
- *
- * @return A possibly empty map of configuration metadata
- */
- Map<String, Object> getMetaData();
-
- /**
- * Returns whether or not the server is started.
- *
- * JBBOOT-80
- * @return
- * @deprecated Should be removed when we won't be targeting
- * jboss-bootstrap for AS 5.x anymore. AS6 will not support
- * this invocation, instead we should use {@link Server#getState()}
- */
- @Deprecated
- boolean isStarted();
-}
Deleted: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServerProvider.java
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServerProvider.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServerProvider.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,44 +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.as.server;
-
-import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
-import org.jboss.bootstrap.api.as.server.JBossASServer;
-
-/**
- * JBossASServer
- *
- * Contract for implementations of JBossAS Servers
- *
- * @author Jason Dillon
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface JBossASServerProvider
- extends
- JBossASBasedServerProvider<JBossASServer, JBossASServerConfig>,
- JBossASServer
-{
-
-}
Copied: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASGenericServerProvider.java (from rev 99507, projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASBasedServerProvider.java)
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASGenericServerProvider.java (rev 0)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASGenericServerProvider.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap.spi.as.server;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig;
+import org.jboss.bootstrap.api.as.server.JBossASBasedServer;
+import org.jboss.bootstrap.api.server.Server;
+import org.jboss.bootstrap.spi.mc.server.MCBasedServerProvider;
+
+/**
+ * Contract for implementations of JBoss Application Servers
+ * and extensions thereof, backed by an MC implementation
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface MCBasedJBossASGenericServerProvider<K extends JBossASBasedServer<K, T>, T extends JBossASBasedServerConfig<T>>
+ extends
+ MCBasedServerProvider<K, T>,
+ JBossASBasedServer<K, T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /** @return The server start date */
+ Date getStartDate();
+
+ /** @return The server version, the underlying version expressed as a String */
+ String getVersion();
+
+ /** @return The server version code name */
+ String getVersionName();
+
+ /** @return The full server version number */
+ String getVersionNumber();
+
+ /** @return The date the server was build (compiled) */
+ String getBuildNumber();
+
+ /** @return The JVM used to build the server */
+ String getBuildJVM();
+
+ /** @return The Operating System used to build the server */
+ String getBuildOS();
+
+ /** @return The build id */
+ String getBuildID();
+
+ /** @return The date the server was build */
+ String getBuildDate();
+
+ /**
+ * Get the optional server configuration metadata
+ *
+ * @return A possibly empty map of configuration metadata
+ */
+ Map<String, Object> getMetaData();
+
+ /**
+ * Returns whether or not the server is started.
+ *
+ * JBBOOT-80
+ * @return
+ * @deprecated Should be removed when we won't be targeting
+ * jboss-bootstrap for AS 5.x anymore. AS6 will not support
+ * this invocation, instead we should use {@link Server#getState()}
+ */
+ @Deprecated
+ boolean isStarted();
+}
Copied: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASServerProvider.java (from rev 99507, projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServerProvider.java)
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASServerProvider.java (rev 0)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/MCBasedJBossASServerProvider.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -0,0 +1,44 @@
+/*
+ * 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.as.server;
+
+import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.api.as.server.JBossASServer;
+
+/**
+ * JBossASServer
+ *
+ * Contract for implementations of JBossAS Servers
+ *
+ * @author Jason Dillon
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface MCBasedJBossASServerProvider
+ extends
+ MCBasedJBossASGenericServerProvider<JBossASServer, JBossASServerConfig>,
+ JBossASServer
+{
+
+}
Copied: projects/bootstrap/trunk/spi-as/src/main/resources/schema (from rev 99507, projects/bootstrap/trunk/spi/src/main/resources/schema)
Modified: projects/bootstrap/trunk/spi-test/src/test/java/org/jboss/bootstrap/spi/test/ClassLoadingTestCase.java
===================================================================
--- projects/bootstrap/trunk/spi-test/src/test/java/org/jboss/bootstrap/spi/test/ClassLoadingTestCase.java 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-test/src/test/java/org/jboss/bootstrap/spi/test/ClassLoadingTestCase.java 2010-01-18 00:23:43 UTC (rev 99509)
@@ -119,7 +119,6 @@
// Configure it
final URL bootstrapHome = this.getTarget();
- server.getConfiguration().bootstrapHome(bootstrapHome);
getOut().println("Configured bootstrap home: " + bootstrapHome);
// Ensure not started
Deleted: projects/bootstrap/trunk/spi-test/src/test/resources/bootstrap.xml
===================================================================
--- projects/bootstrap/trunk/spi-test/src/test/resources/bootstrap.xml 2010-01-17 21:44:28 UTC (rev 99508)
+++ projects/bootstrap/trunk/spi-test/src/test/resources/bootstrap.xml 2010-01-18 00:23:43 UTC (rev 99509)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
-
- <!--
- Dummy file for testing, would ordinarily contain:
-
- <url>something.xml</url>
- -->
-
-</bootstrap>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list