[jboss-cvs] JBossAS SVN: r83870 - in projects/bootstrap/trunk: src/main/java/org/jboss/bootstrap and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 4 21:54:38 EST 2009
Author: scott.stark at jboss.org
Date: 2009-02-04 21:54:37 -0500 (Wed, 04 Feb 2009)
New Revision: 83870
Added:
projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/ServerLoader.java
Modified:
projects/bootstrap/trunk/.classpath
projects/bootstrap/trunk/.project
projects/bootstrap/trunk/pom.xml
projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java
projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/microcontainer/ServerImpl.java
projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/Server.java
projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot5/unit/CleanShutdownOnIncompleteInitTestCase.java
Log:
JBBOOT-7, Move ServerLoader into bootstrap
JBBOOT-8, xtend the Server interface to support metadata.
JBBOOT-9, Have the ServerLoad scan the bootstrap lib for jars
Modified: projects/bootstrap/trunk/.classpath
===================================================================
--- projects/bootstrap/trunk/.classpath 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/.classpath 2009-02-05 02:54:37 UTC (rev 83870)
@@ -1,22 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
- <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.8.GA/jboss-common-core-2.2.8.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.8.GA/jboss-common-core-2.2.8.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.CR5/jboss-dependency-2.0.0.CR5-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5.jar" sourcepath="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.CR5/jboss-kernel-2.0.0.CR5-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR4/jboss-managed-2.0.0.CR4.jar" sourcepath="M2_REPO/org/jboss/man/jboss-managed/2.0.0.CR4/jboss-managed-2.0.0.CR4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.GA/jboss-mdr-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.0.GA/jboss-mdr-2.0.0.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR4/jboss-metatype-2.0.0.CR4.jar" sourcepath="M2_REPO/org/jboss/man/jboss-metatype/2.0.0.CR4/jboss-metatype-2.0.0.CR4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.CR1/jboss-reflect-2.0.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.GA/jbossxb-2.0.0.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
-</classpath>
\ No newline at end of file
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Modified: projects/bootstrap/trunk/.project
===================================================================
--- projects/bootstrap/trunk/.project 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/.project 2009-02-05 02:54:37 UTC (rev 83870)
@@ -1,13 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jboss-as-bootstrap</name>
- <comment>Common Bootstrap for Distributions of JBossAS</comment>
- <projects/>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
\ No newline at end of file
+ <name>jboss-as-bootstrap</name>
+ <comment>Common Bootstrap for Distributions of JBossAS</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Modified: projects/bootstrap/trunk/pom.xml
===================================================================
--- projects/bootstrap/trunk/pom.xml 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/pom.xml 2009-02-05 02:54:37 UTC (rev 83870)
@@ -24,9 +24,9 @@
<properties>
<!-- Versioning -->
- <version.org.jboss_jboss.vfs>2.0.0.CR5</version.org.jboss_jboss.vfs>
- <version.org.jboss.man_jboss.managed>2.0.0.CR4</version.org.jboss.man_jboss.managed>
- <version.org.jboss.microcontainer_jboss.kernel>2.0.0.CR5</version.org.jboss.microcontainer_jboss.kernel>
+ <version.org.jboss_jboss.vfs>2.0.1.GA</version.org.jboss_jboss.vfs>
+ <version.org.jboss.man_jboss.managed>2.0.0.GA</version.org.jboss.man_jboss.managed>
+ <version.org.jboss.microcontainer_jboss.kernel>2.0.0.GA</version.org.jboss.microcontainer_jboss.kernel>
<version.junit_junit>4.5</version.junit_junit>
</properties>
@@ -101,4 +101,4 @@
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java 2009-02-05 02:54:37 UTC (rev 83870)
@@ -23,8 +23,10 @@
import java.lang.reflect.Method;
import java.net.URL;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.LogManager;
@@ -49,7 +51,7 @@
* @author Scott.Stark at jboss.org
* @author Dimitris.Andreadis at jboss.org
* @author adrian at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public abstract class AbstractServerImpl extends NotificationBroadcasterSupport
implements ServerProcess, NotificationEmitter
@@ -66,6 +68,9 @@
/** The basic configuration for the server. */
private BaseServerConfig config;
+ /** The optional configuration metadata for the server */
+ private Map<String, Object> metadata;
+
/** When the server was started. */
private Date startDate;
@@ -129,14 +134,24 @@
}
/**
+ * Initialize the server by calling init(props, null);
+ */
+ public void init(final Properties props)
+ throws IllegalStateException, Exception
+ {
+ init(props, null);
+ }
+ /**
* Initialize the Server instance.
*
* @param props - The configuration properties for the server.
+ * @param metadata configuration metadata for the server
*
* @throws IllegalStateException Already initialized.
* @throws Exception Failed to initialize.
*/
- public void init(final Properties props) throws IllegalStateException, Exception
+ public void init(final Properties props, final Map<String, Object> metadata)
+ throws IllegalStateException, Exception
{
if (props == null)
throw new IllegalArgumentException("props is null");
@@ -144,6 +159,11 @@
if (config != null)
throw new IllegalStateException("already initialized");
+ if (metadata == null)
+ this.metadata = Collections.emptyMap();
+ else
+ this.metadata = Collections.unmodifiableMap(metadata);
+
ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
try
@@ -320,7 +340,17 @@
this.config = config;
}
+
/**
+ * Get the optional server configuration metadata
+ * @return a possibly empty map of configuration metadata.
+ */
+ public Map<String, Object> getMetaData()
+ {
+ return metadata;
+ }
+
+ /**
* Check if the server is started.
*
* @return True if the server is started, else false.
Property changes on: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Added: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/ServerLoader.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/ServerLoader.java (rev 0)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/ServerLoader.java 2009-02-05 02:54:37 UTC (rev 83870)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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;
+
+//$Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A helper class to load a JBoss server instance.
+ *
+ * <p>Basic usage is something like this:
+ * <pre>
+ * // setup the basic server config properties
+ * Properties props = new Properties(System.getProperties());
+ * props.put(ServerConfig.SERVER_LIBRARY_URL, "http://myserver.com/myjboss/lib/");
+ * // set some more properties
+ *
+ * // Obtain any addition server metadata
+ * Map metadata = ...;
+ *
+ * // create a new loader to do the dirty work
+ * ServerLoader loader = new ServerLoader(props);
+ *
+ *
+ * // load and initialize the server instance
+ * ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ * Server server = loader.load(parent);
+ * server.init(props, metadata);
+ *
+ * // start up the server
+ * server.start();
+ *
+ * // go make some coffee, drink a beer or play GTA3
+ * // ...
+ *
+ * // shutdown and go to sleep
+ * server.shutdown();
+ * </pre>
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ */
+public class ServerLoader
+{
+ /** The default server type. */
+ public static final String DEFAULT_SERVER_TYPE = "org.jboss.bootstrap.microcontainer.ServerImpl";
+
+ /**
+ * Configuration properties.
+ */
+ protected Properties props;
+
+ /**
+ * The URL where libraries are read from.
+ */
+ protected URL libraryURL;
+
+ /**
+ * A list of extra URLs to add to the classpath when loading
+ * the server.
+ */
+ protected List<URL> extraClasspath = new LinkedList<URL>();
+
+ /**
+ * Construct a <tt>ServerLoader</tt>.
+ *
+ * @param props Configuration properties.
+ *
+ * @throws Exception Invalid configuration
+ */
+ public ServerLoader(final Properties props) throws Exception
+ {
+ if (props == null)
+ throw new IllegalArgumentException("props is null");
+
+ this.props = props;
+
+ // must have HOME_URL, or we can't continue
+ URL homeURL = getURL(ServerConfig.HOME_URL);
+ if (homeURL == null)
+ {
+ throw new Exception("Missing configuration value for: "
+ + ServerConfig.HOME_URL);
+ }
+
+ libraryURL = getURL(ServerConfig.LIBRARY_URL);
+ if (libraryURL == null)
+ {
+ // need library url to make boot urls list
+ libraryURL = new URL(homeURL, ServerConfig.LIBRARY_URL_SUFFIX);
+ }
+ }
+
+ /**
+ * Add an extra library to the end of list of libraries
+ * which will be loaded from the library URL when loading
+ * the Server class.
+ *
+ * @param filename A filename (no directory parts)
+ *
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addLibrary(final String filename) throws MalformedURLException
+ {
+ if (filename == null)
+ throw new IllegalArgumentException("filename is null");
+
+ URL jarURL = new URL(libraryURL, filename);
+ extraClasspath.add(jarURL);
+ }
+
+ /**
+ * Add a list of comma seperated library file names.
+ *
+ * @param filenames A list of comma seperated filenames (with no directory parts)
+ *
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addLibraries(final String filenames) throws MalformedURLException
+ {
+ if (filenames == null)
+ throw new IllegalArgumentException("filenames is null");
+
+ StringTokenizer stok = new StringTokenizer(filenames, ",");
+ while (stok.hasMoreElements())
+ {
+ addLibrary(stok.nextToken().trim());
+ }
+ }
+
+ /**
+ * Add an extra URL to the classpath used to load the server.
+ *
+ * @param url A URL to add to the classpath.
+ */
+ public void addURL(final URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("url is null");
+
+ extraClasspath.add(url);
+ }
+
+ /**
+ * Add the jars from the lib/endorsed dir if it exists.
+ * Note, the path must exist locally for this to work.
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addEndorsedJars() throws MalformedURLException
+ {
+ File endorsedDir = new File(libraryURL.getPath() + "/endorsed");
+ if (endorsedDir.exists())
+ {
+ String [] list = endorsedDir.list();
+ for (int i = 0; list != null && i < list.length; i++)
+ {
+ String jarname = list[i];
+ addLibrary("endorsed/" + jarname);
+ }
+ }
+ }
+
+ /**
+ * Get a URL from configuration or system properties.
+ *
+ * @param name the system property
+ * @return the url
+ * @throws MalformedURLException for a bad url
+ */
+ protected URL getURL(final String name) throws MalformedURLException
+ {
+ String value = props.getProperty(name, null);
+ if (value != null)
+ {
+ if (!value.endsWith("/")) value += "/";
+ return new URL(value);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an array of URLs which will be used to load the
+ * core system and construct a new Server object instance.
+ * @return the urls
+ * @throws IOException for a bad url or library access problem
+ */
+ protected URL[] getBootClasspath() throws IOException, URISyntaxException
+ {
+ List<URL> list = new LinkedList<URL>();
+
+ // prepend users classpath to allow for overrides
+ list.addAll(extraClasspath);
+
+ String value = props.getProperty(ServerConfig.BOOT_LIBRARY_LIST);
+ if( value != null )
+ {
+ StringTokenizer stok = new StringTokenizer(value, ",");
+ while (stok.hasMoreElements())
+ {
+ URL url = new URL(libraryURL, stok.nextToken().trim());
+ list.add(url);
+ }
+ }
+ // Scan the libraryURL using the VFS
+ else
+ {
+ VirtualFile libraryDir = VFS.getRoot(libraryURL);
+ List<VirtualFile> jars = libraryDir.getChildren();
+ if(jars != null)
+ {
+ for(VirtualFile jar : jars)
+ {
+ URL url = jar.toURL();
+ list.add(url);
+ }
+ }
+ }
+
+ return list.toArray(new URL[list.size()]);
+ }
+
+ /**
+ * Load a {@link Server} instance.
+ *
+ * @parent The parent of any class loader created during boot.
+ * @return An uninitialized (and unstarted) Server instance.
+ *
+ * @param parent the parent classloader
+ * @throws Exception Failed to load or create Server instance.
+ */
+ public Server load(final ClassLoader parent) throws Exception
+ {
+ Server server;
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ // get the boot lib list
+ URL[] urls = getBootClasspath();
+ URLClassLoader classLoader = new NoAnnotationURLClassLoader(urls, parent);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ if(props.containsKey(""))
+ {
+ // Log the boot URLs (uncomment to test)
+
+ StringBuffer sb = new StringBuffer("Boot URLs:\n");
+ for(URL url : urls)
+ {
+ sb.append(url.toExternalForm());
+ sb.append("\n");
+ }
+ System.out.println(sb);
+ }
+
+ // construct a new Server instance
+ String typename = props.getProperty(ServerConfig.SERVER_TYPE, DEFAULT_SERVER_TYPE);
+ server = createServer(typename, classLoader);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+
+ // thats all folks, have fun
+ return server;
+ }
+
+ /**
+ * Construct a new instance of Server, loading all required classes from
+ * the given ClassLoader.
+ * @param typename - the fqcn of the Server implementation
+ * @param loader - the ClassLoader to load typename with
+ * @return the server
+ * @throws Exception for any error
+ */
+ protected Server createServer(final String typename, final ClassLoader loader)
+ throws Exception
+ {
+ // load the class first
+ Class<Server> type = (Class<Server>) loader.loadClass(typename);
+
+ // and then create a new instance
+ Server server = type.newInstance();
+ return server;
+ }
+}
Property changes on: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/ServerLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/microcontainer/ServerImpl.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/microcontainer/ServerImpl.java 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/microcontainer/ServerImpl.java 2009-02-05 02:54:37 UTC (rev 83870)
@@ -22,34 +22,43 @@
package org.jboss.bootstrap.microcontainer;
import java.net.URL;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.InstallCallbackMetaData;
-import org.jboss.beans.metadata.plugins.UninstallCallbackMetaData;
-import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.bootstrap.AbstractServerImpl;
import org.jboss.bootstrap.BootstrapMetaData;
import org.jboss.bootstrap.spi.microcontainer.MCServer;
import org.jboss.bootstrap.xml.BootstrapParser;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-// TODO: JBMICROCONT-383 import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
import org.jboss.kernel.plugins.event.AbstractEvent;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.kernel.spi.event.KernelEvent;
import org.jboss.kernel.spi.event.KernelEventManager;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.util.StopWatch;
/**
- * ServerImpl.
+ * A Server implementation that bootstraps an MC kernel based on the beans
+ * deployments referenced by a bootstrap.xml descriptor.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
*/
+ at ManagementObject(
+ name="jboss.system:type=MCServer",
+ isRuntime=true,
+ properties=ManagementProperties.EXPLICIT,
+ description="the MCServer bootstrap view",
+ componentType=@ManagementComponent(type="MCBean", subtype="*")
+ )
public class ServerImpl extends AbstractServerImpl
implements MCServer
{
@@ -70,6 +79,7 @@
*
* @return the kernel
*/
+ @ManagementProperty(ignored=true)
public Kernel getKernel()
{
return kernel;
@@ -78,6 +88,7 @@
* Get the kernel deployments
* @return the kernel deployments
*/
+ @ManagementProperty(ignored=true)
public Map<String, KernelDeployment> getDeployments()
{
Map<String, KernelDeployment> deployments = null;
@@ -94,16 +105,14 @@
bootstrap.run();
kernel = bootstrap.getKernel();
- // Register the server implementation
+ /* Register the server implementation and register context dependency
+ injection for beans that implement the Bootstrap interface
+ */
KernelController controller = kernel.getController();
- AbstractBeanMetaData metaData = new AbstractBeanMetaData("JBossServer", getClass().getName());
- InstallCallbackMetaData install = new InstallCallbackMetaData();
- install.setMethodName("addBootstrap");
- metaData.setInstallCallbacks(Collections.singletonList((CallbackMetaData) install));
- UninstallCallbackMetaData uninstall = new UninstallCallbackMetaData();
- uninstall.setMethodName("removeBootstrap");
- metaData.setUninstallCallbacks(Collections.singletonList((CallbackMetaData) uninstall));
- controller.install(metaData, this);
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("JBossServer", getClass().getName());
+ builder.addMethodInstallCallback("addBootstrap");
+ builder.addMethodUninstallCallback("removeBootstrap");
+ controller.install(builder.getBeanMetaData(), this);
// Determine the url for the bootstrap
URL configURL = getConfig().getServerConfigURL();
Property changes on: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/microcontainer/ServerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/Server.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/Server.java 2009-02-04 21:23:17 UTC (rev 83869)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/Server.java 2009-02-05 02:54:37 UTC (rev 83870)
@@ -22,6 +22,7 @@
package org.jboss.bootstrap.spi;
import java.util.Date;
+import java.util.Map;
import java.util.Properties;
/**
@@ -30,7 +31,7 @@
*
* @author Jason Dillon
* @author Scott.Stark at jboss.org
- * @version $Revision: 63730 $
+ * @version $Revision$
*/
public interface Server
{
@@ -73,7 +74,7 @@
/**
- * Initialize the Server instance.
+ * Initialize the Server instance by calling {@link #init(Properties, Map=null)}.
*
* @param props The configuration properties for the server.
*
@@ -83,6 +84,17 @@
void init(Properties props) throws IllegalStateException, Exception;
/**
+ * Initialize the Server instance.
+ *
+ * @param props The configuration properties for the server.
+ * @param metadata configuration metadata for the server
+ *
+ * @throws IllegalStateException Already initialized.
+ * @throws Exception Failed to initialize.
+ */
+ void init(Properties props, Map<String, Object> metaData) throws IllegalStateException, Exception;
+
+ /**
* Get the typed server configuration object which the
* server has been initalized to use.
*
@@ -93,6 +105,12 @@
ServerConfig getConfig() throws IllegalStateException;
/**
+ * Get the optional server configuration metadata
+ * @return a possibly empty map of configuration metadata.
+ */
+ Map<String, Object> getMetaData();
+
+ /**
* Start the Server instance.
*
* @throws IllegalStateException Already started or not initialized.
Property changes on: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/Server.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot5/unit/CleanShutdownOnIncompleteInitTestCase.java
===================================================================
Property changes on: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot5/unit/CleanShutdownOnIncompleteInitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
More information about the jboss-cvs-commits
mailing list