[jboss-cvs] JBossAS SVN: r80998 - in trunk/bootstrap/src/main/org/jboss: bootstrap and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 07:07:35 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 07:07:35 -0500 (Fri, 14 Nov 2008)
New Revision: 80998
Modified:
trunk/bootstrap/src/main/org/jboss/Version.java
trunk/bootstrap/src/main/org/jboss/bootstrap/AbstractServerImpl.java
trunk/bootstrap/src/main/org/jboss/bootstrap/BaseServerConfig.java
trunk/bootstrap/src/main/org/jboss/bootstrap/BootstrapMetaData.java
trunk/bootstrap/src/main/org/jboss/bootstrap/SecurityActions.java
trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Bootstrap.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Server.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerConfig.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerProcess.java
trunk/bootstrap/src/main/org/jboss/bootstrap/spi/util/ServerConfigUtil.java
trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapParser.java
trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapSchemaBinding.java
Log:
JBAS-3916, use the right copyright header
Modified: trunk/bootstrap/src/main/org/jboss/Version.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/Version.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/Version.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,303 +1,303 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Provides access to JBoss version (and build) properties.
- *
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision: 63730 $
- */
-public final class Version
-{
- public final static String VERSION_MAJOR = "version.major";
- public final static String VERSION_MINOR = "version.minor";
- public final static String VERSION_REVISION = "version.revision";
- public final static String VERSION_TAG = "version.tag";
- public final static String VERSION_NAME = "version.name";
- public final static String VERSION_CVSTAG = "version.cvstag";
-
- public final static String BUILD_NUMBER = "build.number";
- public final static String BUILD_ID = "build.id";
- public final static String BUILD_DATE = "build.day";
- public final static String BUILD_JVM_VERSION = "java.vm.version";
- public final static String BUILD_JVM_VENDOR = "java.vendor";
- public final static String BUILD_OS = "os.name";
- public final static String BUILD_OS_ARCH = "os.arch";
- public final static String BUILD_OS_VERSION = "os.version";
-
- /**
- * The single instance.
- */
- private static Version instance = null;
-
- /**
- * The version properties.
- */
- private Properties props;
-
- /**
- * Do not allow direct public construction.
- */
- private Version()
- {
- props = loadProperties();
- }
-
- /**
- * Get the single <tt>Version</tt> instance.
- *
- * @return The single <tt>Version</tt> instance.
- */
- public static Version getInstance()
- {
- if (instance == null)
- {
- instance = new Version();
- }
- return instance;
- }
-
- /**
- * Returns an unmodifiable map of version properties.
- *
- * @return An unmodifiable map of version properties.
- */
- public Map<Object, Object> getProperties()
- {
- return Collections.unmodifiableMap(props);
- }
-
- /**
- * Returns the value for the given property name.
- *
- * @param name - The name of the property.
- * @return The property value or null if the property is not set.
- */
- public String getProperty(final String name)
- {
- return props.getProperty(name);
- }
-
- /**
- * Returns the major number of the version.
- *
- * @return The major number of the version.
- */
- public int getMajor()
- {
- return getIntProperty(VERSION_MAJOR);
- }
-
- /**
- * Returns the minor number of the version.
- *
- * @return The minor number of the version.
- */
- public int getMinor()
- {
- return getIntProperty(VERSION_MINOR);
- }
-
- /**
- * Returns the revision number of the version.
- *
- * @return The revision number of the version.
- */
- public int getRevision()
- {
- return getIntProperty(VERSION_REVISION);
- }
-
- /**
- * Returns the tag of the version.
- *
- * @return The tag of the version.
- */
- public String getTag()
- {
- return props.getProperty(VERSION_TAG);
- }
- /**
- * Returns the CVS tag of the version.
- *
- * @return The CVS tag of the version.
- */
- public String getCvsTag()
- {
- return props.getProperty(VERSION_CVSTAG);
- }
-
- /**
- * Returns the name number of the version.
- *
- * @return The name of the version.
- */
- public String getName()
- {
- return props.getProperty(VERSION_NAME);
- }
-
- /**
- * Returns the build identifier for this version.
- *
- * @return The build identifier for this version.
- */
- public String getBuildID()
- {
- return props.getProperty(BUILD_ID);
- }
-
- /**
- * Returns the build number for this version.
- *
- * @return The build number for this version.
- */
- public String getBuildNumber()
- {
- return props.getProperty(BUILD_NUMBER);
- }
-
- /**
- * Returns the build date for this version.
- *
- * @return The build date for this version.
- */
- public String getBuildDate()
- {
- return props.getProperty(BUILD_DATE);
- }
-
- /** Returns the BUILD_JVM_VERSION (BUILD_JVM_VENDOR) which should look like:
- * 1.4.2_05-b04 (Sun Microsystems Inc.)
- * @return the jvm
- */
- public String getBuildJVM()
- {
- String vm = props.getProperty(BUILD_JVM_VERSION);
- String vendor = props.getProperty(BUILD_JVM_VENDOR);
- return vm + '(' + vendor + ')';
- }
-
- /** Returns the BUILD_OS (BUILD_OS_ARCH,BUILD_OS_VERSION) which should look
- * like:
- * Windows XP (x86,5.1)
- * Linux (i386,2.4.21-4.ELsmp)
- * @return the OS
- */
- public String getBuildOS()
- {
- String os = props.getProperty(BUILD_OS);
- String arch = props.getProperty(BUILD_OS_ARCH);
- String version = props.getProperty(BUILD_OS_VERSION);
- return os + '(' + arch +',' + version + ')';
- }
-
- /**
- * Returns the full version number, e.g. 5.0.0.GA
- *
- * @return The full version number as string
- */
- public String getVersionNumber()
- {
- StringBuffer buff = new StringBuffer();
-
- buff.append(getMajor()).append(".");
- buff.append(getMinor()).append(".");
- buff.append(getRevision()).append(".");
- buff.append(getTag());
-
- return buff.toString();
- }
-
- /**
- * Returns the version information as a string.
- *
- * @return Basic information as a string.
- */
- public String toString()
- {
- StringBuffer buff = new StringBuffer();
-
- buff.append(getVersionNumber());
- buff.append(" (build: SVNTag=");
- buff.append(getCvsTag());
- buff.append(" date=");
- buff.append(getBuildID());
- buff.append(")");
-
- return buff.toString();
- }
-
- /**
- * Returns a property value as an int.
- *
- * @param name - The name of the property.
- * @return The property value, or -1 if there was a problem converting
- * it to an int.
- */
- private int getIntProperty(final String name)
- {
- try
- {
- return Integer.valueOf(props.getProperty(name)).intValue();
- }
- catch (Exception e)
- {
- return -1;
- }
- }
-
- /**
- * Load the version properties from a resource.
- */
- private Properties loadProperties()
- {
- props = new Properties();
-
- try
- {
- InputStream in =
- Version.class.getResourceAsStream("/org/jboss/version.properties");
- if( in != null )
- {
- props.load(in);
- in.close();
- }
- }
- catch (IOException e)
- {
- throw new Error("Missing version.properties");
- }
-
- return props;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Provides access to JBoss version (and build) properties.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 63730 $
+ */
+public final class Version
+{
+ public final static String VERSION_MAJOR = "version.major";
+ public final static String VERSION_MINOR = "version.minor";
+ public final static String VERSION_REVISION = "version.revision";
+ public final static String VERSION_TAG = "version.tag";
+ public final static String VERSION_NAME = "version.name";
+ public final static String VERSION_CVSTAG = "version.cvstag";
+
+ public final static String BUILD_NUMBER = "build.number";
+ public final static String BUILD_ID = "build.id";
+ public final static String BUILD_DATE = "build.day";
+ public final static String BUILD_JVM_VERSION = "java.vm.version";
+ public final static String BUILD_JVM_VENDOR = "java.vendor";
+ public final static String BUILD_OS = "os.name";
+ public final static String BUILD_OS_ARCH = "os.arch";
+ public final static String BUILD_OS_VERSION = "os.version";
+
+ /**
+ * The single instance.
+ */
+ private static Version instance = null;
+
+ /**
+ * The version properties.
+ */
+ private Properties props;
+
+ /**
+ * Do not allow direct public construction.
+ */
+ private Version()
+ {
+ props = loadProperties();
+ }
+
+ /**
+ * Get the single <tt>Version</tt> instance.
+ *
+ * @return The single <tt>Version</tt> instance.
+ */
+ public static Version getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new Version();
+ }
+ return instance;
+ }
+
+ /**
+ * Returns an unmodifiable map of version properties.
+ *
+ * @return An unmodifiable map of version properties.
+ */
+ public Map<Object, Object> getProperties()
+ {
+ return Collections.unmodifiableMap(props);
+ }
+
+ /**
+ * Returns the value for the given property name.
+ *
+ * @param name - The name of the property.
+ * @return The property value or null if the property is not set.
+ */
+ public String getProperty(final String name)
+ {
+ return props.getProperty(name);
+ }
+
+ /**
+ * Returns the major number of the version.
+ *
+ * @return The major number of the version.
+ */
+ public int getMajor()
+ {
+ return getIntProperty(VERSION_MAJOR);
+ }
+
+ /**
+ * Returns the minor number of the version.
+ *
+ * @return The minor number of the version.
+ */
+ public int getMinor()
+ {
+ return getIntProperty(VERSION_MINOR);
+ }
+
+ /**
+ * Returns the revision number of the version.
+ *
+ * @return The revision number of the version.
+ */
+ public int getRevision()
+ {
+ return getIntProperty(VERSION_REVISION);
+ }
+
+ /**
+ * Returns the tag of the version.
+ *
+ * @return The tag of the version.
+ */
+ public String getTag()
+ {
+ return props.getProperty(VERSION_TAG);
+ }
+ /**
+ * Returns the CVS tag of the version.
+ *
+ * @return The CVS tag of the version.
+ */
+ public String getCvsTag()
+ {
+ return props.getProperty(VERSION_CVSTAG);
+ }
+
+ /**
+ * Returns the name number of the version.
+ *
+ * @return The name of the version.
+ */
+ public String getName()
+ {
+ return props.getProperty(VERSION_NAME);
+ }
+
+ /**
+ * Returns the build identifier for this version.
+ *
+ * @return The build identifier for this version.
+ */
+ public String getBuildID()
+ {
+ return props.getProperty(BUILD_ID);
+ }
+
+ /**
+ * Returns the build number for this version.
+ *
+ * @return The build number for this version.
+ */
+ public String getBuildNumber()
+ {
+ return props.getProperty(BUILD_NUMBER);
+ }
+
+ /**
+ * Returns the build date for this version.
+ *
+ * @return The build date for this version.
+ */
+ public String getBuildDate()
+ {
+ return props.getProperty(BUILD_DATE);
+ }
+
+ /** Returns the BUILD_JVM_VERSION (BUILD_JVM_VENDOR) which should look like:
+ * 1.4.2_05-b04 (Sun Microsystems Inc.)
+ * @return the jvm
+ */
+ public String getBuildJVM()
+ {
+ String vm = props.getProperty(BUILD_JVM_VERSION);
+ String vendor = props.getProperty(BUILD_JVM_VENDOR);
+ return vm + '(' + vendor + ')';
+ }
+
+ /** Returns the BUILD_OS (BUILD_OS_ARCH,BUILD_OS_VERSION) which should look
+ * like:
+ * Windows XP (x86,5.1)
+ * Linux (i386,2.4.21-4.ELsmp)
+ * @return the OS
+ */
+ public String getBuildOS()
+ {
+ String os = props.getProperty(BUILD_OS);
+ String arch = props.getProperty(BUILD_OS_ARCH);
+ String version = props.getProperty(BUILD_OS_VERSION);
+ return os + '(' + arch +',' + version + ')';
+ }
+
+ /**
+ * Returns the full version number, e.g. 5.0.0.GA
+ *
+ * @return The full version number as string
+ */
+ public String getVersionNumber()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append(getMajor()).append(".");
+ buff.append(getMinor()).append(".");
+ buff.append(getRevision()).append(".");
+ buff.append(getTag());
+
+ return buff.toString();
+ }
+
+ /**
+ * Returns the version information as a string.
+ *
+ * @return Basic information as a string.
+ */
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append(getVersionNumber());
+ buff.append(" (build: SVNTag=");
+ buff.append(getCvsTag());
+ buff.append(" date=");
+ buff.append(getBuildID());
+ buff.append(")");
+
+ return buff.toString();
+ }
+
+ /**
+ * Returns a property value as an int.
+ *
+ * @param name - The name of the property.
+ * @return The property value, or -1 if there was a problem converting
+ * it to an int.
+ */
+ private int getIntProperty(final String name)
+ {
+ try
+ {
+ return Integer.valueOf(props.getProperty(name)).intValue();
+ }
+ catch (Exception e)
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * Load the version properties from a resource.
+ */
+ private Properties loadProperties()
+ {
+ props = new Properties();
+
+ try
+ {
+ InputStream in =
+ Version.class.getResourceAsStream("/org/jboss/version.properties");
+ if( in != null )
+ {
+ props.load(in);
+ in.close();
+ }
+ }
+ catch (IOException e)
+ {
+ throw new Error("Missing version.properties");
+ }
+
+ return props;
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/AbstractServerImpl.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/AbstractServerImpl.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/AbstractServerImpl.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,847 +1,847 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.LogManager;
-
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-
-import org.jboss.Version;
-import org.jboss.bootstrap.spi.Bootstrap;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.bootstrap.spi.ServerProcess;
-import org.jboss.logging.Logger;
-import org.jboss.net.protocol.URLStreamHandlerFactory;
-import org.jboss.util.StopWatch;
-
-/**
- * A Server implementation that uses the deployer-beans.xml and ProfileService
- * to boot the server.
- *
- * @author Scott.Stark at jboss.org
- * @author Dimitris.Andreadis at jboss.org
- * @author adrian at jboss.org
- * @version $Revision:$
- */
-public abstract class AbstractServerImpl extends NotificationBroadcasterSupport
- implements ServerProcess, NotificationEmitter
-{
- /** Instance logger. */
- protected Logger log;
-
- /** Container for version information. */
- private final Version version = Version.getInstance();
-
- /** Package information for org.jboss */
- private final Package jbossPackage = Package.getPackage("org.jboss");
-
- /** The basic configuration for the server. */
- private BaseServerConfig config;
-
- /** When the server was started. */
- private Date startDate;
-
- /** Flag to indicate if we are started. */
- private boolean started;
-
- /** A flag indicating if start has been called */
- private boolean isInStart;
-
- /** A flag indicating if shutdown has been called */
- private boolean isInShutdown;
-
- /** A flag indicating if shutdownServer has been called */
- private boolean isInternalShutdown;
-
- /** The JVM shutdown hook */
- private ShutdownHook shutdownHook;
-
- /** The JBoss Life Thread */
- private LifeThread lifeThread;
-
- /** The bootstraps */
- private List<Bootstrap> bootstraps = new CopyOnWriteArrayList<Bootstrap>();
-
- /** The started bootstraps */
- private List<Bootstrap> startedBootstraps = new CopyOnWriteArrayList<Bootstrap>();
-
- /**
- * No-arg constructor for ServerImpl
- */
- public AbstractServerImpl()
- {
- }
-
- /**
- * Add a bootstrap
- *
- * @param bootstrap the bootstrap
- * @throws IllegalArgumentException for a null bootstrap
- */
- public void addBootstrap(Bootstrap bootstrap)
- {
- if (bootstrap == null)
- throw new IllegalArgumentException("Null bootstrap");
-
- bootstraps.add(bootstrap);
- }
-
- /**
- * Remove a bootstrap
- *
- * @param bootstrap the bootstrap
- * @throws IllegalArgumentException for a null bootstrap
- */
- public void removeBootstrap(Bootstrap bootstrap)
- {
- if (bootstrap == null)
- throw new IllegalArgumentException("Null bootstrap");
-
- bootstraps.add(bootstrap);
- }
-
- /**
- * Initialize the Server instance.
- *
- * @param props - The configuration properties for the server.
- *
- * @throws IllegalStateException Already initialized.
- * @throws Exception Failed to initialize.
- */
- public void init(final Properties props) throws IllegalStateException, Exception
- {
- if (props == null)
- throw new IllegalArgumentException("props is null");
-
- if (config != null)
- throw new IllegalStateException("already initialized");
-
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
-
- try
- {
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- doInit(props);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
- }
-
- /**
- * Initialize server configuration and jvm settings.
- *
- * @param props
- * @throws Exception
- */
- private void doInit(final Properties props) throws Exception
- {
- // Create a new config object from the give properties
- this.config = new BaseServerConfig(props);
-
- // Set the VM temp directory to the server tmp dir
- boolean overrideTmpDir = Boolean.getBoolean("jboss.server.temp.dir.overrideJavaTmpDir");
- if (overrideTmpDir)
- {
- File serverTmpDir = config.getServerTempDir();
- System.setProperty("java.io.tmpdir", serverTmpDir.getCanonicalPath());
- }
-
- // Initialize the logging layer using the ServerImpl class. The server log
- // directory is initialized prior to this to ensure the jboss.server.log.dir
- //system property is set in case its used by the logging configs.
- config.getServerLogDir();
- log = Logger.getLogger(getClass());
-
- // Setup URL handlers - do this before initializing the ServerConfig
- initURLHandlers();
- config.initURLs();
-
- log.info("Starting JBoss (Microcontainer)...");
-
- if (jbossPackage != null)
- {
- // Show what release this is...
- log.info("Release ID: " +
- jbossPackage.getImplementationTitle() + " " +
- jbossPackage.getImplementationVersion());
- }
- else
- {
- log.warn("could not get package info to display release, either the " +
- "jar manifest in jboss-system.jar has been mangled or you're " +
- "running unit tests from ant outside of JBoss itself.");
- }
-
- log.debug("Using config: " + config);
-
- // make sure our impl type is exposed
- log.debug("Server type: " + getClass());
-
- // log the boot classloader
- ClassLoader cl = getClass().getClassLoader();
- log.debug("Server loaded through: " + cl.getClass().getName());
-
- // Log the basic configuration elements
- log.info("Bootstrap URL: " + config.getBootstrapURL());
- log.info("Home Dir: " + config.getHomeDir());
- log.info("Home URL: " + config.getHomeURL());
- log.info("Library URL: " + config.getLibraryURL());
- log.info("Patch URL: " + config.getPatchURL());
- log.info("Common Base URL: " + config.getCommonBaseURL());
- log.info("Common Library URL: " + config.getCommonLibraryURL());
- log.info("Server Name: " + config.getServerName());
- log.info("Server Base Dir: " + config.getServerBaseDir());
- log.info("Server Base URL: " + config.getServerBaseURL());
- log.info("Server Config URL: " + config.getServerConfigURL());
- log.info("Server Home Dir: " + config.getServerHomeDir());
- log.info("Server Home URL: " + config.getServerHomeURL());
- log.info("Server Data Dir: " + config.getServerDataDir());
- log.info("Server Library URL: " + config.getServerLibraryURL());
- log.info("Server Log Dir: " + config.getServerLogDir());
- log.info("Server Native Dir: " + config.getServerNativeDir());
- log.info("Server Temp Dir: " + config.getServerTempDir());
- log.info("Server Temp Deploy Dir: " + config.getServerTempDeployDir());
- log.info("Root Deployment Filename: " + config.getRootDeploymentFilename());
- }
-
- /**
- * The <code>initURLHandlers</code> method calls
- * internalInitURLHandlers. if requireJBossURLStreamHandlers is
- * false, any exceptions are logged and ignored.
- *
- * TODO move to the common project alongside URLStreamHandlerFactory
- */
- private void initURLHandlers()
- {
- if (config.getRequireJBossURLStreamHandlerFactory())
- {
- internalInitURLHandlers();
- }
- else
- {
- try
- {
- internalInitURLHandlers();
- }
- catch (SecurityException e)
- {
- log.warn("You do not have permissions to set URLStreamHandlerFactory", e);
- }
- catch (Error e)
- {
- log.warn("URLStreamHandlerFactory already set", e);
- }
- }
- }
-
- /**
- * Set up our only URLStreamHandlerFactory.
- * This is needed to ensure Sun's version is not used (as it leaves files
- * locked on Win2K/WinXP platforms.
- */
- private void internalInitURLHandlers()
- {
- try
- {
- // Install a URLStreamHandlerFactory that uses the TCL
- URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory());
-
- // Preload JBoss URL handlers
- URLStreamHandlerFactory.preload();
- }
- catch (Error error)
- { // very naughty but we HAVE to do this or
- // we'll fail if we ever try to do this again
- log.warn("Caught Throwable Error, this probably means " +
- "we've already set the URLStreamHAndlerFactory before");
- }
-
- // Include the default JBoss protocol handler package
- String handlerPkgs = System.getProperty("java.protocol.handler.pkgs");
- if (handlerPkgs != null)
- {
- handlerPkgs += "|org.jboss.net.protocol";
- }
- else
- {
- handlerPkgs = "org.jboss.net.protocol";
- }
- System.setProperty("java.protocol.handler.pkgs", handlerPkgs);
- }
-
- /**
- * Get the typed server configuration object which the
- * server has been initalized to use.
- *
- * @return Typed server configuration object.
- * @throws IllegalStateException Not initialized.
- */
- public ServerConfig getConfig() throws IllegalStateException
- {
- if (config == null)
- throw new IllegalStateException("not initialized");
-
- return config;
- }
-
- /**
- * Check if the server is started.
- *
- * @return True if the server is started, else false.
- */
- public boolean isStarted()
- {
- return started;
- }
-
- /**
- * Check if the shutdown operation has been called/is in progress.
- *
- * @return true if shutdown has been called, false otherwise
- */
- public boolean isInShutdown()
- {
- return isInShutdown;
- }
-
- /**
- * Start the Server instance.
- *
- * @throws IllegalStateException Already started or not initialized.
- * @throws Exception Failed to start.
- */
- public void start() throws IllegalStateException, Exception
- {
- synchronized (this)
- {
- if (isInStart == false)
- {
- isInStart = true;
- }
- else
- {
- log.debug("Already in start, ignoring duplicate start");
- return;
- }
- }
-
- // make sure we are initialized
- ServerConfig config = getConfig();
-
- // make sure we aren't started yet
- if (started)
- throw new IllegalStateException("already started");
-
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
-
- try
- {
- ClassLoader myCL = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(myCL);
-
- // See how long it takes us to start up
- StopWatch watch = new StopWatch(true);
-
- // Remember when we we started
- startDate = new Date();
-
- // Install the shutdown hook
- shutdownHook = new ShutdownHook();
- shutdownHook.setDaemon(true);
-
- try
- {
- Runtime.getRuntime().addShutdownHook(shutdownHook);
- log.debug("Shutdown hook added " + shutdownHook);
- }
- catch (Exception e)
- {
- log.warn("Failed to add shutdown hook; ignoring", e);
- }
-
- // Do the main start
- doStart(watch);
-
- // TODO Fix the TCL hack used here!
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try
- {
- // Run the bootstraps
- for (Bootstrap bootstrap : bootstraps)
- {
- Thread.currentThread().setContextClassLoader(bootstrap.getClass().getClassLoader());
- startedBootstraps.add(0, bootstrap);
- bootstrap.start(this);
- }
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- if (config.isInstallLifeThread())
- {
- lifeThread = new LifeThread();
- log.debug("Installing life thread " + lifeThread);
- lifeThread.start();
- }
-
- started = true;
-
- // Send a notification that the startup is complete
- Notification msg = new Notification(START_NOTIFICATION_TYPE, this, 1);
- msg.setUserData(new Long(watch.getLapTime()));
- sendNotification(msg);
-
- watch.stop();
-
- if (jbossPackage != null)
- {
- // Tell the world how fast it was =)
- log.info("JBoss (Microcontainer) [" + jbossPackage.getImplementationVersion() +
- "] Started in " + watch);
- }
- else
- {
- log.info("JBoss (Microcontainer) [unknown version] Started in " + watch);
- }
- }
- catch (Throwable t)
- {
- log.debug("Failed to start", t);
-
- if (t instanceof Exception)
- throw (Exception)t;
- if (t instanceof Error)
- throw (Error)t;
-
- throw new RuntimeException("Unexpected error", t);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldCL);
- isInStart = false;
- }
- }
-
- /**
- * Override to perform the start operations
- *
- * @param watch the stop watch
- * @throws Throwable for any error
- */
- protected abstract void doStart(StopWatch watch) throws Throwable;
-
- /**
- * Override to perform the shutdown
- */
- protected abstract void doShutdown();
-
- /**
- * Shutdown the server
- */
- protected void shutdownServer()
- {
- if (log.isTraceEnabled())
- log.trace("Shutdown caller:", new Throwable("Here"));
-
- // avoid entering twice; may happen when called directly
- // from AbstractServerImpl.shutdown(), then called again when all
- // non-daemon threads have exited and the ShutdownHook runs.
- if (isInternalShutdown)
- return;
- else
- isInternalShutdown = true;
-
- // Send a notification that server stop is initiated
- Notification msg = new Notification(STOP_NOTIFICATION_TYPE, this, 2);
- sendNotification(msg);
-
- // TODO Fix the TCL hack used here!
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try
- {
- for (Bootstrap bootstrap : startedBootstraps)
- bootstrap.prepareShutdown(this);
-
- // Do the bootstraps in reverse order
- for (Bootstrap bootstrap : startedBootstraps)
- {
- Thread.currentThread().setContextClassLoader(bootstrap.getClass().getClassLoader());
- try
- {
- bootstrap.shutdown(this);
- }
- catch (Throwable t)
- {
- log.warn("Error shutting down bootstrap: " + bootstrap, t);
- }
- }
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- try
- {
- doShutdown();
- }
- finally
- {
- // Done
- log.info("Shutdown complete");
- System.out.println("Shutdown complete");
- }
- }
-
- /**
- * Shutdown the Server instance and run shutdown hooks.
- *
- * <p>If the exit on shutdown flag is true, then {@link #exit()}
- * is called, else only the shutdown hook is run.
- *
- * @throws IllegalStateException No started.
- */
- public void shutdown() throws IllegalStateException
- {
- if (log.isTraceEnabled())
- log.trace("Shutdown caller:", new Throwable("Here"));
-
- if (!started)
- throw new IllegalStateException("not started");
-
- if (isInShutdown)
- throw new IllegalStateException("already in shutdown mode");
-
- isInShutdown = true;
- boolean exitOnShutdown = config.getExitOnShutdown();
- boolean blockingShutdown = config.getBlockingShutdown();
- log.info("Shutting down the server, blockingShutdown: " + blockingShutdown);
-
- log.debug("exitOnShutdown: " + exitOnShutdown);
- log.debug("blockingShutdown: " + blockingShutdown);
-
- if (exitOnShutdown)
- {
- exit(0);
- }
- else
- {
- // signal lifethread to exit; if no non-daemon threads
- // remain, the JVM will eventually exit
- lifeThread.interrupt();
-
- if (blockingShutdown)
- {
- shutdownServer();
- }
- else
- {
- // start in new thread to give positive
- // feedback to requesting client of success.
- new Thread()
- {
- public void run()
- {
- // just run the hook, don't call System.exit, as we may
- // be embeded in a vm that would not like that very much
- shutdownServer();
- }
- }.start();
- }
- }
- }
-
- /**
- * Exit the JVM, run shutdown hooks, shutdown the server.
- *
- * @param exitcode The exit code returned to the operating system.
- */
- public void exit(final int exitcode)
- {
- // exit() in new thread so that we might have a chance to give positive
- // feed back to requesting client of success.
- new Thread()
- {
- public void run()
- {
- log.info("Server exit(" + exitcode + ") called");
-
- // Set exit code in the shutdown hook, in case halt is enabled
- shutdownHook.setHaltExitCode(exitcode);
-
- // Initiate exiting, shutdown hook will be called
- Runtime.getRuntime().exit(exitcode);
- }
- }.start();
- }
-
- /**
- * Exit the JVM with code 1, run shutdown hooks, shutdown the server.
- */
- public void exit()
- {
- exit(1);
- }
-
- /**
- * Forcibly terminates the currently running Java virtual machine.
- *
- * @param exitcode The exit code returned to the operating system.
- */
- public void halt(final int exitcode)
- {
- // halt() in new thread so that we might have a chance to give positive
- // feed back to requesting client of success.
- new Thread()
- {
- public void run()
- {
- System.err.println("Server halt(" + exitcode + ") called, halting the JVM now!");
- Runtime.getRuntime().halt(exitcode);
- }
- }.start();
- }
-
- /**
- * Forcibly terminates the currently running Java virtual machine.
- * Halts with code 1.
- */
- public void halt()
- {
- halt(1);
- }
-
-
-////////////////////////////////////////////////////////////////////////// /
-// Runtime Access //
-////////////////////////////////////////////////////////////////////////// /
-
- /**
- * A simple helper used to log the Runtime memory information.
- *
- * @param rt the runtime
- */
- private void logMemoryUsage(final Runtime rt)
- {
- log.info("Total/free memory: " + rt.totalMemory() + "/" + rt.freeMemory());
- }
-
- /**
- * Hint to the JVM to run the garbage collector.
- */
- public void runGarbageCollector()
- {
- Runtime rt = Runtime.getRuntime();
-
- logMemoryUsage(rt);
- rt.gc();
- log.info("Hinted to the JVM to run garbage collection");
- logMemoryUsage(rt);
- }
-
- /**
- * Hint to the JVM to run any pending object finalizations.
- */
- public void runFinalization()
- {
- Runtime.getRuntime().runFinalization();
- log.info("Hinted to the JVM to run any pending object finalizations");
- }
-
- /**
- * Enable or disable tracing method calls at the Runtime level.
- *
- * @param flag whether to enable trace
- */
- public void traceMethodCalls(final Boolean flag)
- {
- Runtime.getRuntime().traceMethodCalls(flag.booleanValue());
- }
-
- /**
- * Enable or disable tracing instructions the Runtime level.
- *
- * @param flag whether to enable trace
- */
- public void traceInstructions(final Boolean flag)
- {
- Runtime.getRuntime().traceInstructions(flag.booleanValue());
- }
-
-
-///////////////////////////////////////////////////////////////////////////
-// Server Information //
-///////////////////////////////////////////////////////////////////////////
-
- public Date getStartDate()
- {
- return startDate;
- }
-
- public String getVersion()
- {
- return version.toString();
- }
-
- public String getVersionName()
- {
- return version.getName();
- }
-
- public String getVersionNumber()
- {
- return version.getVersionNumber();
- }
-
- public String getBuildNumber()
- {
- return version.getBuildNumber();
- }
-
- public String getBuildJVM()
- {
- return version.getBuildJVM();
- }
-
- public String getBuildOS()
- {
- return version.getBuildOS();
- }
-
- public String getBuildID()
- {
- return version.getBuildID();
- }
-
- /**
- * The server build date
- * @return server build date
- */
- public String getBuildDate()
- {
- return version.getBuildDate();
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Lifecycle Thread //
- ///////////////////////////////////////////////////////////////////////////
-
- /** A simple thread that keeps the vm alive in the event there are no
- * other threads started.
- */
- private class LifeThread extends Thread
- {
- Object lock = new Object();
-
- LifeThread()
- {
- super("JBossLifeThread");
- }
-
- public void run()
- {
- synchronized (lock)
- {
- try
- {
- lock.wait();
- }
- catch (InterruptedException ignore)
- {
- }
- }
- log.info("LifeThread.run() exits!");
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Shutdown Hook //
- ///////////////////////////////////////////////////////////////////////////
-
- private class ShutdownHook extends Thread
- {
- /** Whether to halt the JMV at the end of the shutdown hook */
- private boolean forceHalt = true;
-
- /** The exit code to use if forceHalt is enabled */
- private int haltExitCode;
-
- public ShutdownHook()
- {
- super("JBoss Shutdown Hook");
-
- String value = SecurityActions.getSystemProperty("jboss.shutdown.forceHalt", null);
- if (value != null)
- {
- forceHalt = Boolean.valueOf(value).booleanValue();
- }
- }
-
- public void setHaltExitCode(int haltExitCode)
- {
- this.haltExitCode = haltExitCode;
- }
-
- public void run()
- {
- log.info("Runtime shutdown hook called, forceHalt: " + forceHalt);
-
- // shutdown the server
- shutdownServer();
-
- // Execute the jdk JBossJDKLogManager doReset via reflection
- LogManager lm = LogManager.getLogManager();
- try
- {
- Class<?>[] sig = {};
- Method doReset = lm.getClass().getDeclaredMethod("doReset", sig);
- Object[] args = {};
- doReset.invoke(lm, args);
- }
- catch(Exception e)
- {
- if (log.isTraceEnabled())
- log.trace("No doReset found?", e);
- }
-
- // later bitch - other shutdown hooks may be killed
- if (forceHalt)
- {
- System.out.println("Halting VM");
- Runtime.getRuntime().halt(haltExitCode);
- }
- }
- }
-}
+/*
+ * 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;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.LogManager;
+
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+
+import org.jboss.Version;
+import org.jboss.bootstrap.spi.Bootstrap;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.bootstrap.spi.ServerProcess;
+import org.jboss.logging.Logger;
+import org.jboss.net.protocol.URLStreamHandlerFactory;
+import org.jboss.util.StopWatch;
+
+/**
+ * A Server implementation that uses the deployer-beans.xml and ProfileService
+ * to boot the server.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Dimitris.Andreadis at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision:$
+ */
+public abstract class AbstractServerImpl extends NotificationBroadcasterSupport
+ implements ServerProcess, NotificationEmitter
+{
+ /** Instance logger. */
+ protected Logger log;
+
+ /** Container for version information. */
+ private final Version version = Version.getInstance();
+
+ /** Package information for org.jboss */
+ private final Package jbossPackage = Package.getPackage("org.jboss");
+
+ /** The basic configuration for the server. */
+ private BaseServerConfig config;
+
+ /** When the server was started. */
+ private Date startDate;
+
+ /** Flag to indicate if we are started. */
+ private boolean started;
+
+ /** A flag indicating if start has been called */
+ private boolean isInStart;
+
+ /** A flag indicating if shutdown has been called */
+ private boolean isInShutdown;
+
+ /** A flag indicating if shutdownServer has been called */
+ private boolean isInternalShutdown;
+
+ /** The JVM shutdown hook */
+ private ShutdownHook shutdownHook;
+
+ /** The JBoss Life Thread */
+ private LifeThread lifeThread;
+
+ /** The bootstraps */
+ private List<Bootstrap> bootstraps = new CopyOnWriteArrayList<Bootstrap>();
+
+ /** The started bootstraps */
+ private List<Bootstrap> startedBootstraps = new CopyOnWriteArrayList<Bootstrap>();
+
+ /**
+ * No-arg constructor for ServerImpl
+ */
+ public AbstractServerImpl()
+ {
+ }
+
+ /**
+ * Add a bootstrap
+ *
+ * @param bootstrap the bootstrap
+ * @throws IllegalArgumentException for a null bootstrap
+ */
+ public void addBootstrap(Bootstrap bootstrap)
+ {
+ if (bootstrap == null)
+ throw new IllegalArgumentException("Null bootstrap");
+
+ bootstraps.add(bootstrap);
+ }
+
+ /**
+ * Remove a bootstrap
+ *
+ * @param bootstrap the bootstrap
+ * @throws IllegalArgumentException for a null bootstrap
+ */
+ public void removeBootstrap(Bootstrap bootstrap)
+ {
+ if (bootstrap == null)
+ throw new IllegalArgumentException("Null bootstrap");
+
+ bootstraps.add(bootstrap);
+ }
+
+ /**
+ * Initialize the Server instance.
+ *
+ * @param props - The configuration properties for the server.
+ *
+ * @throws IllegalStateException Already initialized.
+ * @throws Exception Failed to initialize.
+ */
+ public void init(final Properties props) throws IllegalStateException, Exception
+ {
+ if (props == null)
+ throw new IllegalArgumentException("props is null");
+
+ if (config != null)
+ throw new IllegalStateException("already initialized");
+
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ doInit(props);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+ }
+
+ /**
+ * Initialize server configuration and jvm settings.
+ *
+ * @param props
+ * @throws Exception
+ */
+ private void doInit(final Properties props) throws Exception
+ {
+ // Create a new config object from the give properties
+ this.config = new BaseServerConfig(props);
+
+ // Set the VM temp directory to the server tmp dir
+ boolean overrideTmpDir = Boolean.getBoolean("jboss.server.temp.dir.overrideJavaTmpDir");
+ if (overrideTmpDir)
+ {
+ File serverTmpDir = config.getServerTempDir();
+ System.setProperty("java.io.tmpdir", serverTmpDir.getCanonicalPath());
+ }
+
+ // Initialize the logging layer using the ServerImpl class. The server log
+ // directory is initialized prior to this to ensure the jboss.server.log.dir
+ //system property is set in case its used by the logging configs.
+ config.getServerLogDir();
+ log = Logger.getLogger(getClass());
+
+ // Setup URL handlers - do this before initializing the ServerConfig
+ initURLHandlers();
+ config.initURLs();
+
+ log.info("Starting JBoss (Microcontainer)...");
+
+ if (jbossPackage != null)
+ {
+ // Show what release this is...
+ log.info("Release ID: " +
+ jbossPackage.getImplementationTitle() + " " +
+ jbossPackage.getImplementationVersion());
+ }
+ else
+ {
+ log.warn("could not get package info to display release, either the " +
+ "jar manifest in jboss-system.jar has been mangled or you're " +
+ "running unit tests from ant outside of JBoss itself.");
+ }
+
+ log.debug("Using config: " + config);
+
+ // make sure our impl type is exposed
+ log.debug("Server type: " + getClass());
+
+ // log the boot classloader
+ ClassLoader cl = getClass().getClassLoader();
+ log.debug("Server loaded through: " + cl.getClass().getName());
+
+ // Log the basic configuration elements
+ log.info("Bootstrap URL: " + config.getBootstrapURL());
+ log.info("Home Dir: " + config.getHomeDir());
+ log.info("Home URL: " + config.getHomeURL());
+ log.info("Library URL: " + config.getLibraryURL());
+ log.info("Patch URL: " + config.getPatchURL());
+ log.info("Common Base URL: " + config.getCommonBaseURL());
+ log.info("Common Library URL: " + config.getCommonLibraryURL());
+ log.info("Server Name: " + config.getServerName());
+ log.info("Server Base Dir: " + config.getServerBaseDir());
+ log.info("Server Base URL: " + config.getServerBaseURL());
+ log.info("Server Config URL: " + config.getServerConfigURL());
+ log.info("Server Home Dir: " + config.getServerHomeDir());
+ log.info("Server Home URL: " + config.getServerHomeURL());
+ log.info("Server Data Dir: " + config.getServerDataDir());
+ log.info("Server Library URL: " + config.getServerLibraryURL());
+ log.info("Server Log Dir: " + config.getServerLogDir());
+ log.info("Server Native Dir: " + config.getServerNativeDir());
+ log.info("Server Temp Dir: " + config.getServerTempDir());
+ log.info("Server Temp Deploy Dir: " + config.getServerTempDeployDir());
+ log.info("Root Deployment Filename: " + config.getRootDeploymentFilename());
+ }
+
+ /**
+ * The <code>initURLHandlers</code> method calls
+ * internalInitURLHandlers. if requireJBossURLStreamHandlers is
+ * false, any exceptions are logged and ignored.
+ *
+ * TODO move to the common project alongside URLStreamHandlerFactory
+ */
+ private void initURLHandlers()
+ {
+ if (config.getRequireJBossURLStreamHandlerFactory())
+ {
+ internalInitURLHandlers();
+ }
+ else
+ {
+ try
+ {
+ internalInitURLHandlers();
+ }
+ catch (SecurityException e)
+ {
+ log.warn("You do not have permissions to set URLStreamHandlerFactory", e);
+ }
+ catch (Error e)
+ {
+ log.warn("URLStreamHandlerFactory already set", e);
+ }
+ }
+ }
+
+ /**
+ * Set up our only URLStreamHandlerFactory.
+ * This is needed to ensure Sun's version is not used (as it leaves files
+ * locked on Win2K/WinXP platforms.
+ */
+ private void internalInitURLHandlers()
+ {
+ try
+ {
+ // Install a URLStreamHandlerFactory that uses the TCL
+ URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory());
+
+ // Preload JBoss URL handlers
+ URLStreamHandlerFactory.preload();
+ }
+ catch (Error error)
+ { // very naughty but we HAVE to do this or
+ // we'll fail if we ever try to do this again
+ log.warn("Caught Throwable Error, this probably means " +
+ "we've already set the URLStreamHAndlerFactory before");
+ }
+
+ // Include the default JBoss protocol handler package
+ String handlerPkgs = System.getProperty("java.protocol.handler.pkgs");
+ if (handlerPkgs != null)
+ {
+ handlerPkgs += "|org.jboss.net.protocol";
+ }
+ else
+ {
+ handlerPkgs = "org.jboss.net.protocol";
+ }
+ System.setProperty("java.protocol.handler.pkgs", handlerPkgs);
+ }
+
+ /**
+ * Get the typed server configuration object which the
+ * server has been initalized to use.
+ *
+ * @return Typed server configuration object.
+ * @throws IllegalStateException Not initialized.
+ */
+ public ServerConfig getConfig() throws IllegalStateException
+ {
+ if (config == null)
+ throw new IllegalStateException("not initialized");
+
+ return config;
+ }
+
+ /**
+ * Check if the server is started.
+ *
+ * @return True if the server is started, else false.
+ */
+ public boolean isStarted()
+ {
+ return started;
+ }
+
+ /**
+ * Check if the shutdown operation has been called/is in progress.
+ *
+ * @return true if shutdown has been called, false otherwise
+ */
+ public boolean isInShutdown()
+ {
+ return isInShutdown;
+ }
+
+ /**
+ * Start the Server instance.
+ *
+ * @throws IllegalStateException Already started or not initialized.
+ * @throws Exception Failed to start.
+ */
+ public void start() throws IllegalStateException, Exception
+ {
+ synchronized (this)
+ {
+ if (isInStart == false)
+ {
+ isInStart = true;
+ }
+ else
+ {
+ log.debug("Already in start, ignoring duplicate start");
+ return;
+ }
+ }
+
+ // make sure we are initialized
+ ServerConfig config = getConfig();
+
+ // make sure we aren't started yet
+ if (started)
+ throw new IllegalStateException("already started");
+
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ ClassLoader myCL = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(myCL);
+
+ // See how long it takes us to start up
+ StopWatch watch = new StopWatch(true);
+
+ // Remember when we we started
+ startDate = new Date();
+
+ // Install the shutdown hook
+ shutdownHook = new ShutdownHook();
+ shutdownHook.setDaemon(true);
+
+ try
+ {
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ log.debug("Shutdown hook added " + shutdownHook);
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to add shutdown hook; ignoring", e);
+ }
+
+ // Do the main start
+ doStart(watch);
+
+ // TODO Fix the TCL hack used here!
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Run the bootstraps
+ for (Bootstrap bootstrap : bootstraps)
+ {
+ Thread.currentThread().setContextClassLoader(bootstrap.getClass().getClassLoader());
+ startedBootstraps.add(0, bootstrap);
+ bootstrap.start(this);
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ if (config.isInstallLifeThread())
+ {
+ lifeThread = new LifeThread();
+ log.debug("Installing life thread " + lifeThread);
+ lifeThread.start();
+ }
+
+ started = true;
+
+ // Send a notification that the startup is complete
+ Notification msg = new Notification(START_NOTIFICATION_TYPE, this, 1);
+ msg.setUserData(new Long(watch.getLapTime()));
+ sendNotification(msg);
+
+ watch.stop();
+
+ if (jbossPackage != null)
+ {
+ // Tell the world how fast it was =)
+ log.info("JBoss (Microcontainer) [" + jbossPackage.getImplementationVersion() +
+ "] Started in " + watch);
+ }
+ else
+ {
+ log.info("JBoss (Microcontainer) [unknown version] Started in " + watch);
+ }
+ }
+ catch (Throwable t)
+ {
+ log.debug("Failed to start", t);
+
+ if (t instanceof Exception)
+ throw (Exception)t;
+ if (t instanceof Error)
+ throw (Error)t;
+
+ throw new RuntimeException("Unexpected error", t);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ isInStart = false;
+ }
+ }
+
+ /**
+ * Override to perform the start operations
+ *
+ * @param watch the stop watch
+ * @throws Throwable for any error
+ */
+ protected abstract void doStart(StopWatch watch) throws Throwable;
+
+ /**
+ * Override to perform the shutdown
+ */
+ protected abstract void doShutdown();
+
+ /**
+ * Shutdown the server
+ */
+ protected void shutdownServer()
+ {
+ if (log.isTraceEnabled())
+ log.trace("Shutdown caller:", new Throwable("Here"));
+
+ // avoid entering twice; may happen when called directly
+ // from AbstractServerImpl.shutdown(), then called again when all
+ // non-daemon threads have exited and the ShutdownHook runs.
+ if (isInternalShutdown)
+ return;
+ else
+ isInternalShutdown = true;
+
+ // Send a notification that server stop is initiated
+ Notification msg = new Notification(STOP_NOTIFICATION_TYPE, this, 2);
+ sendNotification(msg);
+
+ // TODO Fix the TCL hack used here!
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ for (Bootstrap bootstrap : startedBootstraps)
+ bootstrap.prepareShutdown(this);
+
+ // Do the bootstraps in reverse order
+ for (Bootstrap bootstrap : startedBootstraps)
+ {
+ Thread.currentThread().setContextClassLoader(bootstrap.getClass().getClassLoader());
+ try
+ {
+ bootstrap.shutdown(this);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error shutting down bootstrap: " + bootstrap, t);
+ }
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ try
+ {
+ doShutdown();
+ }
+ finally
+ {
+ // Done
+ log.info("Shutdown complete");
+ System.out.println("Shutdown complete");
+ }
+ }
+
+ /**
+ * Shutdown the Server instance and run shutdown hooks.
+ *
+ * <p>If the exit on shutdown flag is true, then {@link #exit()}
+ * is called, else only the shutdown hook is run.
+ *
+ * @throws IllegalStateException No started.
+ */
+ public void shutdown() throws IllegalStateException
+ {
+ if (log.isTraceEnabled())
+ log.trace("Shutdown caller:", new Throwable("Here"));
+
+ if (!started)
+ throw new IllegalStateException("not started");
+
+ if (isInShutdown)
+ throw new IllegalStateException("already in shutdown mode");
+
+ isInShutdown = true;
+ boolean exitOnShutdown = config.getExitOnShutdown();
+ boolean blockingShutdown = config.getBlockingShutdown();
+ log.info("Shutting down the server, blockingShutdown: " + blockingShutdown);
+
+ log.debug("exitOnShutdown: " + exitOnShutdown);
+ log.debug("blockingShutdown: " + blockingShutdown);
+
+ if (exitOnShutdown)
+ {
+ exit(0);
+ }
+ else
+ {
+ // signal lifethread to exit; if no non-daemon threads
+ // remain, the JVM will eventually exit
+ lifeThread.interrupt();
+
+ if (blockingShutdown)
+ {
+ shutdownServer();
+ }
+ else
+ {
+ // start in new thread to give positive
+ // feedback to requesting client of success.
+ new Thread()
+ {
+ public void run()
+ {
+ // just run the hook, don't call System.exit, as we may
+ // be embeded in a vm that would not like that very much
+ shutdownServer();
+ }
+ }.start();
+ }
+ }
+ }
+
+ /**
+ * Exit the JVM, run shutdown hooks, shutdown the server.
+ *
+ * @param exitcode The exit code returned to the operating system.
+ */
+ public void exit(final int exitcode)
+ {
+ // exit() in new thread so that we might have a chance to give positive
+ // feed back to requesting client of success.
+ new Thread()
+ {
+ public void run()
+ {
+ log.info("Server exit(" + exitcode + ") called");
+
+ // Set exit code in the shutdown hook, in case halt is enabled
+ shutdownHook.setHaltExitCode(exitcode);
+
+ // Initiate exiting, shutdown hook will be called
+ Runtime.getRuntime().exit(exitcode);
+ }
+ }.start();
+ }
+
+ /**
+ * Exit the JVM with code 1, run shutdown hooks, shutdown the server.
+ */
+ public void exit()
+ {
+ exit(1);
+ }
+
+ /**
+ * Forcibly terminates the currently running Java virtual machine.
+ *
+ * @param exitcode The exit code returned to the operating system.
+ */
+ public void halt(final int exitcode)
+ {
+ // halt() in new thread so that we might have a chance to give positive
+ // feed back to requesting client of success.
+ new Thread()
+ {
+ public void run()
+ {
+ System.err.println("Server halt(" + exitcode + ") called, halting the JVM now!");
+ Runtime.getRuntime().halt(exitcode);
+ }
+ }.start();
+ }
+
+ /**
+ * Forcibly terminates the currently running Java virtual machine.
+ * Halts with code 1.
+ */
+ public void halt()
+ {
+ halt(1);
+ }
+
+
+////////////////////////////////////////////////////////////////////////// /
+// Runtime Access //
+////////////////////////////////////////////////////////////////////////// /
+
+ /**
+ * A simple helper used to log the Runtime memory information.
+ *
+ * @param rt the runtime
+ */
+ private void logMemoryUsage(final Runtime rt)
+ {
+ log.info("Total/free memory: " + rt.totalMemory() + "/" + rt.freeMemory());
+ }
+
+ /**
+ * Hint to the JVM to run the garbage collector.
+ */
+ public void runGarbageCollector()
+ {
+ Runtime rt = Runtime.getRuntime();
+
+ logMemoryUsage(rt);
+ rt.gc();
+ log.info("Hinted to the JVM to run garbage collection");
+ logMemoryUsage(rt);
+ }
+
+ /**
+ * Hint to the JVM to run any pending object finalizations.
+ */
+ public void runFinalization()
+ {
+ Runtime.getRuntime().runFinalization();
+ log.info("Hinted to the JVM to run any pending object finalizations");
+ }
+
+ /**
+ * Enable or disable tracing method calls at the Runtime level.
+ *
+ * @param flag whether to enable trace
+ */
+ public void traceMethodCalls(final Boolean flag)
+ {
+ Runtime.getRuntime().traceMethodCalls(flag.booleanValue());
+ }
+
+ /**
+ * Enable or disable tracing instructions the Runtime level.
+ *
+ * @param flag whether to enable trace
+ */
+ public void traceInstructions(final Boolean flag)
+ {
+ Runtime.getRuntime().traceInstructions(flag.booleanValue());
+ }
+
+
+///////////////////////////////////////////////////////////////////////////
+// Server Information //
+///////////////////////////////////////////////////////////////////////////
+
+ public Date getStartDate()
+ {
+ return startDate;
+ }
+
+ public String getVersion()
+ {
+ return version.toString();
+ }
+
+ public String getVersionName()
+ {
+ return version.getName();
+ }
+
+ public String getVersionNumber()
+ {
+ return version.getVersionNumber();
+ }
+
+ public String getBuildNumber()
+ {
+ return version.getBuildNumber();
+ }
+
+ public String getBuildJVM()
+ {
+ return version.getBuildJVM();
+ }
+
+ public String getBuildOS()
+ {
+ return version.getBuildOS();
+ }
+
+ public String getBuildID()
+ {
+ return version.getBuildID();
+ }
+
+ /**
+ * The server build date
+ * @return server build date
+ */
+ public String getBuildDate()
+ {
+ return version.getBuildDate();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Lifecycle Thread //
+ ///////////////////////////////////////////////////////////////////////////
+
+ /** A simple thread that keeps the vm alive in the event there are no
+ * other threads started.
+ */
+ private class LifeThread extends Thread
+ {
+ Object lock = new Object();
+
+ LifeThread()
+ {
+ super("JBossLifeThread");
+ }
+
+ public void run()
+ {
+ synchronized (lock)
+ {
+ try
+ {
+ lock.wait();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ }
+ log.info("LifeThread.run() exits!");
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Shutdown Hook //
+ ///////////////////////////////////////////////////////////////////////////
+
+ private class ShutdownHook extends Thread
+ {
+ /** Whether to halt the JMV at the end of the shutdown hook */
+ private boolean forceHalt = true;
+
+ /** The exit code to use if forceHalt is enabled */
+ private int haltExitCode;
+
+ public ShutdownHook()
+ {
+ super("JBoss Shutdown Hook");
+
+ String value = SecurityActions.getSystemProperty("jboss.shutdown.forceHalt", null);
+ if (value != null)
+ {
+ forceHalt = Boolean.valueOf(value).booleanValue();
+ }
+ }
+
+ public void setHaltExitCode(int haltExitCode)
+ {
+ this.haltExitCode = haltExitCode;
+ }
+
+ public void run()
+ {
+ log.info("Runtime shutdown hook called, forceHalt: " + forceHalt);
+
+ // shutdown the server
+ shutdownServer();
+
+ // Execute the jdk JBossJDKLogManager doReset via reflection
+ LogManager lm = LogManager.getLogManager();
+ try
+ {
+ Class<?>[] sig = {};
+ Method doReset = lm.getClass().getDeclaredMethod("doReset", sig);
+ Object[] args = {};
+ doReset.invoke(lm, args);
+ }
+ catch(Exception e)
+ {
+ if (log.isTraceEnabled())
+ log.trace("No doReset found?", e);
+ }
+
+ // later bitch - other shutdown hooks may be killed
+ if (forceHalt)
+ {
+ System.out.println("Halting VM");
+ Runtime.getRuntime().halt(haltExitCode);
+ }
+ }
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/BaseServerConfig.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/BaseServerConfig.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/BaseServerConfig.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,23 +1,24 @@
-/* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
+/*
+ * 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;
import java.io.File;
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/BootstrapMetaData.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/BootstrapMetaData.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/BootstrapMetaData.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,66 +1,66 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2007, JBoss Inc., and individual contributors as indicated
-* 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;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * BootstrapMetaData.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class BootstrapMetaData implements Serializable
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 7850412833463503239L;
-
- /** The bootstrap urls */
- private List<String> bootstrapURLs;
-
- /**
- * Get the bootstrapURLs.
- *
- * @return the bootstrapURLs.
- */
- public List<String> getBootstrapURLs()
- {
- return bootstrapURLs;
- }
-
- /**
- * Set the bootstrapURLs.
- *
- * @param bootstrapURLs the bootstrapURLs.
- */
- public void setBootstrapURLs(List<String> bootstrapURLs)
- {
- this.bootstrapURLs = bootstrapURLs;
- }
-
- @Override
- public String toString()
- {
- return super.toString() + "{" + bootstrapURLs + "}";
- }
-}
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * BootstrapMetaData.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapMetaData implements Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7850412833463503239L;
+
+ /** The bootstrap urls */
+ private List<String> bootstrapURLs;
+
+ /**
+ * Get the bootstrapURLs.
+ *
+ * @return the bootstrapURLs.
+ */
+ public List<String> getBootstrapURLs()
+ {
+ return bootstrapURLs;
+ }
+
+ /**
+ * Set the bootstrapURLs.
+ *
+ * @param bootstrapURLs the bootstrapURLs.
+ */
+ public void setBootstrapURLs(List<String> bootstrapURLs)
+ {
+ this.bootstrapURLs = bootstrapURLs;
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "{" + bootstrapURLs + "}";
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/SecurityActions.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/SecurityActions.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/SecurityActions.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,46 +1,46 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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;
-
-import java.security.PrivilegedAction;
-import java.security.AccessController;
-
-/**
- * Package privileged actions.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-class SecurityActions
-{
- static String getSystemProperty(final String name, final String defaultValue)
- {
- PrivilegedAction<String> action = new PrivilegedAction<String>()
- {
- public String run()
- {
- return System.getProperty(name, defaultValue);
- }
- };
- return AccessController.doPrivileged(action);
- }
-}
+/*
+ * 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;
+
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+
+/**
+ * Package privileged actions.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+class SecurityActions
+{
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/microcontainer/ServerImpl.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,214 +1,214 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* 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.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.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.util.StopWatch;
-
-/**
- * ServerImpl.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ServerImpl extends AbstractServerImpl
- implements MCServer
-{
- /** The bootstrap file */
- public static String BOOTSTRAP_XML_NAME = "bootstrap.xml";
-
- /** The bootstrap */
- private BasicBootstrap bootstrap;
-
- /** The kernel */
- private Kernel kernel;
-
- /** The kernel deployer */
- private TempBasicXMLDeployer kernelDeployer;
-
- /**
- * Get the kernel
- *
- * @return the kernel
- */
- public Kernel getKernel()
- {
- return kernel;
- }
- /**
- * Get the kernel deployments
- * @return the kernel deployments
- */
- public Map<String, KernelDeployment> getDeployments()
- {
- Map<String, KernelDeployment> deployments = null;
- if(kernelDeployer != null)
- deployments = kernelDeployer.getDeployments();
- return deployments;
- }
-
- @Override
- protected void doStart(StopWatch watch) throws Throwable
- {
- // Bootstrap the kernel
- BasicBootstrap bootstrap = new BasicBootstrap();
- bootstrap.run();
- kernel = bootstrap.getKernel();
-
- // Register the server implementation
- 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);
-
- // Determine the url for the bootstrap
- URL configURL = getConfig().getServerConfigURL();
- URL url = getConfig().getBootstrapURL();
- if (url == null)
- url = new URL(configURL, BOOTSTRAP_XML_NAME);
- log.info("Starting Microcontainer, bootstrapURL=" + url);
-
- // Parse the bootstrap metadata
- BootstrapMetaData bootstrapMetaData = BootstrapParser.parse(url);
- List<String> bootstrapURLs = bootstrapMetaData.getBootstrapURLs();
- if (bootstrapURLs == null || bootstrapURLs.isEmpty())
- throw new IllegalStateException("No bootstrap urls in " + url);
- log.debug("BootstrapURLs=" + bootstrapURLs);
-
- // Create an xml deployer
- kernelDeployer = new TempBasicXMLDeployer(kernel);
- try
- {
- // Deploy the bootstrap urls
- for (String bootstrapURL : bootstrapURLs)
- {
- log.debug("Deploying bootstrap xml:" + bootstrapURL);
- url = new URL(configURL, bootstrapURL);
- kernelDeployer.deploy(url);
- }
-
- // Check it is complete
- kernelDeployer.validate();
-
- // Send a notification that the startup is complete
- KernelEventManager eventMgr = kernel.getEventManager();
- KernelEvent startEvent = new AbstractEvent(eventMgr, START_NOTIFICATION_TYPE, 0, System.currentTimeMillis(), new Long(watch.getLapTime()));
- eventMgr.fireKernelEvent(startEvent);
-
- this.bootstrap = bootstrap;
- }
- catch (Throwable t)
- {
- try
- {
- kernelDeployer.shutdown();
- }
- catch (Throwable ignored)
- {
- }
- throw t;
- }
- }
-
- @Override
- protected void doShutdown()
- {
- // Send a stop event msg
- try
- {
- if (bootstrap != null)
- {
- KernelEvent stopEvent = bootstrap.createEvent(STOP_NOTIFICATION_TYPE, null);
- bootstrap.fireKernelEvent(stopEvent);
- }
- }
- catch (Throwable t)
- {
- log.warn("Error sending stop notification", t);
- }
-
- // Shutdown the deployer
- try
- {
- if (kernelDeployer != null)
- {
- kernelDeployer.shutdown();
- kernelDeployer = null;
- }
- }
- catch (Throwable t)
- {
- log.warn("Error stopping xml deployer", t);
- }
-
- // Shutdown the controller
- try
- {
- Kernel currentKernel = null;
- if (kernel != null)
- {
- currentKernel = kernel;
- kernel = null;
- }
- else if (bootstrap != null)
- {
- currentKernel = bootstrap.getKernel();
- }
- bootstrap = null;
-
- if (currentKernel != null)
- {
- KernelController controller = currentKernel.getController();
- controller.shutdown();
- }
- }
- catch (Throwable t)
- {
- log.warn("Error stopping xml deployer", t);
- }
- }
-}
+/*
+ * 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.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.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.util.StopWatch;
+
+/**
+ * ServerImpl.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServerImpl extends AbstractServerImpl
+ implements MCServer
+{
+ /** The bootstrap file */
+ public static String BOOTSTRAP_XML_NAME = "bootstrap.xml";
+
+ /** The bootstrap */
+ private BasicBootstrap bootstrap;
+
+ /** The kernel */
+ private Kernel kernel;
+
+ /** The kernel deployer */
+ private TempBasicXMLDeployer kernelDeployer;
+
+ /**
+ * Get the kernel
+ *
+ * @return the kernel
+ */
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+ /**
+ * Get the kernel deployments
+ * @return the kernel deployments
+ */
+ public Map<String, KernelDeployment> getDeployments()
+ {
+ Map<String, KernelDeployment> deployments = null;
+ if(kernelDeployer != null)
+ deployments = kernelDeployer.getDeployments();
+ return deployments;
+ }
+
+ @Override
+ protected void doStart(StopWatch watch) throws Throwable
+ {
+ // Bootstrap the kernel
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ kernel = bootstrap.getKernel();
+
+ // Register the server implementation
+ 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);
+
+ // Determine the url for the bootstrap
+ URL configURL = getConfig().getServerConfigURL();
+ URL url = getConfig().getBootstrapURL();
+ if (url == null)
+ url = new URL(configURL, BOOTSTRAP_XML_NAME);
+ log.info("Starting Microcontainer, bootstrapURL=" + url);
+
+ // Parse the bootstrap metadata
+ BootstrapMetaData bootstrapMetaData = BootstrapParser.parse(url);
+ List<String> bootstrapURLs = bootstrapMetaData.getBootstrapURLs();
+ if (bootstrapURLs == null || bootstrapURLs.isEmpty())
+ throw new IllegalStateException("No bootstrap urls in " + url);
+ log.debug("BootstrapURLs=" + bootstrapURLs);
+
+ // Create an xml deployer
+ kernelDeployer = new TempBasicXMLDeployer(kernel);
+ try
+ {
+ // Deploy the bootstrap urls
+ for (String bootstrapURL : bootstrapURLs)
+ {
+ log.debug("Deploying bootstrap xml:" + bootstrapURL);
+ url = new URL(configURL, bootstrapURL);
+ kernelDeployer.deploy(url);
+ }
+
+ // Check it is complete
+ kernelDeployer.validate();
+
+ // Send a notification that the startup is complete
+ KernelEventManager eventMgr = kernel.getEventManager();
+ KernelEvent startEvent = new AbstractEvent(eventMgr, START_NOTIFICATION_TYPE, 0, System.currentTimeMillis(), new Long(watch.getLapTime()));
+ eventMgr.fireKernelEvent(startEvent);
+
+ this.bootstrap = bootstrap;
+ }
+ catch (Throwable t)
+ {
+ try
+ {
+ kernelDeployer.shutdown();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ throw t;
+ }
+ }
+
+ @Override
+ protected void doShutdown()
+ {
+ // Send a stop event msg
+ try
+ {
+ if (bootstrap != null)
+ {
+ KernelEvent stopEvent = bootstrap.createEvent(STOP_NOTIFICATION_TYPE, null);
+ bootstrap.fireKernelEvent(stopEvent);
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error sending stop notification", t);
+ }
+
+ // Shutdown the deployer
+ try
+ {
+ if (kernelDeployer != null)
+ {
+ kernelDeployer.shutdown();
+ kernelDeployer = null;
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error stopping xml deployer", t);
+ }
+
+ // Shutdown the controller
+ try
+ {
+ Kernel currentKernel = null;
+ if (kernel != null)
+ {
+ currentKernel = kernel;
+ kernel = null;
+ }
+ else if (bootstrap != null)
+ {
+ currentKernel = bootstrap.getKernel();
+ }
+ bootstrap = null;
+
+ if (currentKernel != null)
+ {
+ KernelController controller = currentKernel.getController();
+ controller.shutdown();
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error stopping xml deployer", t);
+ }
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Bootstrap.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Bootstrap.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Bootstrap.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,54 +1,54 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* 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.spi;
-
-
-/**
- * Bootstrap.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface Bootstrap
-{
- /**
- * Invoked at startup
- *
- * @param server the server instance
- * @throws Exception for any error
- */
- void start(Server server) throws Exception;
-
- /**
- * Invoked to say we are preparing shutdown
- *
- * @param server the server
- */
- void prepareShutdown(Server server);
-
- /**
- * Invoked at shutdown
- *
- * @param server the server instance
- */
- void shutdown(Server server);
-}
+/*
+ * 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;
+
+
+/**
+ * Bootstrap.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Bootstrap
+{
+ /**
+ * Invoked at startup
+ *
+ * @param server the server instance
+ * @throws Exception for any error
+ */
+ void start(Server server) throws Exception;
+
+ /**
+ * Invoked to say we are preparing shutdown
+ *
+ * @param server the server
+ */
+ void prepareShutdown(Server server);
+
+ /**
+ * Invoked at shutdown
+ *
+ * @param server the server instance
+ */
+ void shutdown(Server server);
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Server.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Server.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/Server.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,119 +1,119 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.spi;
-
-import java.util.Date;
-import java.util.Properties;
-
-/**
- * The interface of the server loaded by the ServerLoader
- * @see ServerLoader
- *
- * @author Jason Dillon
- * @author Scott.Stark at jboss.org
- * @version $Revision: 63730 $
- */
-public interface Server
-{
- /** The JMX notification event type sent on end of server startup */
- public final String START_NOTIFICATION_TYPE = "org.jboss.system.server.started";
- /** The JMX notification event type sent on begin of the server shutdown */
- public final String STOP_NOTIFICATION_TYPE = "org.jboss.system.server.stopped";
-
- /** @return The server start date */
- Date getStartDate();
-
- /** @return The server version */
- String getVersion();
-
- /** @return The server version code name */
- String getVersionName();
-
- /** @return The full server version number */
- String getVersionNumber();
-
- /** @return The date the server was build (compiled) */
- String getBuildNumber();
-
- /** @return The JVM used to build the server */
- String getBuildJVM();
-
- /** @return The Operating System used to build the server */
- String getBuildOS();
-
- /** @return The build id */
- String getBuildID();
-
- /** @return The date the server was build */
- String getBuildDate();
-
- /** @return A flag indicating if shutdown has been called */
- boolean isInShutdown();
-
- // Operations ----------------------------------------------------
-
-
- /**
- * Initialize the Server instance.
- *
- * @param props The configuration properties for the server.
- *
- * @throws IllegalStateException Already initialized.
- * @throws Exception Failed to initialize.
- */
- void init(Properties props) throws IllegalStateException, Exception;
-
- /**
- * Get the typed server configuration object which the
- * server has been initalized to use.
- *
- * @return Typed server configuration object.
- *
- * @throws IllegalStateException Not initialized.
- */
- ServerConfig getConfig() throws IllegalStateException;
-
- /**
- * Start the Server instance.
- *
- * @throws IllegalStateException Already started or not initialized.
- * @throws Exception Failed to start.
- */
- void start() throws IllegalStateException, Exception;
-
- /**
- * Check if the server is started.
- *
- * @return True if the server is started, else false.
- */
- boolean isStarted();
-
- /**
- * Shutdown the Server instance and run shutdown hooks.
- *
- * <p>If the exit on shutdown flag is true, then {@link #exit()}
- * is called, else only the shutdown hook is run.
- *
- * @throws IllegalStateException No started.
- */
- void shutdown() throws IllegalStateException;
-}
+/*
+ * 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;
+
+import java.util.Date;
+import java.util.Properties;
+
+/**
+ * The interface of the server loaded by the ServerLoader
+ * @see ServerLoader
+ *
+ * @author Jason Dillon
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 63730 $
+ */
+public interface Server
+{
+ /** The JMX notification event type sent on end of server startup */
+ public final String START_NOTIFICATION_TYPE = "org.jboss.system.server.started";
+ /** The JMX notification event type sent on begin of the server shutdown */
+ public final String STOP_NOTIFICATION_TYPE = "org.jboss.system.server.stopped";
+
+ /** @return The server start date */
+ Date getStartDate();
+
+ /** @return The server version */
+ String getVersion();
+
+ /** @return The server version code name */
+ String getVersionName();
+
+ /** @return The full server version number */
+ String getVersionNumber();
+
+ /** @return The date the server was build (compiled) */
+ String getBuildNumber();
+
+ /** @return The JVM used to build the server */
+ String getBuildJVM();
+
+ /** @return The Operating System used to build the server */
+ String getBuildOS();
+
+ /** @return The build id */
+ String getBuildID();
+
+ /** @return The date the server was build */
+ String getBuildDate();
+
+ /** @return A flag indicating if shutdown has been called */
+ boolean isInShutdown();
+
+ // Operations ----------------------------------------------------
+
+
+ /**
+ * Initialize the Server instance.
+ *
+ * @param props The configuration properties for the server.
+ *
+ * @throws IllegalStateException Already initialized.
+ * @throws Exception Failed to initialize.
+ */
+ void init(Properties props) throws IllegalStateException, Exception;
+
+ /**
+ * Get the typed server configuration object which the
+ * server has been initalized to use.
+ *
+ * @return Typed server configuration object.
+ *
+ * @throws IllegalStateException Not initialized.
+ */
+ ServerConfig getConfig() throws IllegalStateException;
+
+ /**
+ * Start the Server instance.
+ *
+ * @throws IllegalStateException Already started or not initialized.
+ * @throws Exception Failed to start.
+ */
+ void start() throws IllegalStateException, Exception;
+
+ /**
+ * Check if the server is started.
+ *
+ * @return True if the server is started, else false.
+ */
+ boolean isStarted();
+
+ /**
+ * Shutdown the Server instance and run shutdown hooks.
+ *
+ * <p>If the exit on shutdown flag is true, then {@link #exit()}
+ * is called, else only the shutdown hook is run.
+ *
+ * @throws IllegalStateException No started.
+ */
+ void shutdown() throws IllegalStateException;
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerConfig.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerConfig.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerConfig.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,575 +1,575 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.spi;
-
-import java.io.File;
-import java.net.URL;
-
-/**
- * The interface of the basic <em>typed</em> JBoss server configuration.
- *
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
- * @author Dimitris.Andreadis at jboss.org
- * @version $Revision: 63730 $
- */
-public interface ServerConfig
-{
-
- /** The default partition name */
- String DEFAULT_PARITION_NAME = "DefaultPartition";
-
- /** The partition name property */
- String PARTITION_NAME_PROPERTY = "jboss.partition.name";
-
- /** The udp address property */
- String PARTITION_UDP_PROPERTY = "jboss.partition.udpGroup";
-
- /** The udp port property */
- String PARTITION_UDP_PORT_PROPERTY = "jboss.jgroups.udp.mcast_port";
-
- /** Whether to load native libraries */
- String NATIVE_LOAD_PROPERTY = "jboss.native.load";
-
- /** The location of native libraries property */
- String NATIVE_DIR_PROPERTY = "jboss.native.dir";
-
- /////////////////////////////////////////////////////////////////////////
- // Bootstrap Specific Config //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * Constant that holds the name of the environment property
- * for specifying a comma seperated list of the basenames of
- * to the boot libraries required load the core system.
- *
- * <p>These libraries will be loaded from <tt>LIBRARY_URL</tt>.
- */
- String BOOT_LIBRARY_LIST = "jboss.boot.library.list";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the class type of the server to create.
- */
- String SERVER_TYPE = "jboss.server.type";
-
- /**
- * The bootstrap url
- *
- * <p>If not set then the server will default to {@link #SERVER_CONFIG_URL}/bootstrap.xml.
- */
- String BOOTSTRAP_URL = "jboss.bootstrap.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the root deployment filename (relative to the server
- * config URL that will be deployed to finalize the boot strap process.
- *
- * <p>If not set then the server will default to {@link #DEFAULT_ROOT_DEPLOYMENT_FILENAME}.
- */
- String ROOT_DEPLOYMENT_FILENAME = "jboss.server.root.deployment.filename";
-
-
- /////////////////////////////////////////////////////////////////////////
- // Configuration Value Identifiers //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the home directory for JBoss.
- */
- String HOME_DIR = "jboss.home.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the home URL for JBoss.
- *
- * <p>If not set then the value of HOME_DIR will converted into a URL.
- */
- String HOME_URL = "jboss.home.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the URL where JBoss will read library files
- * from.
- *
- * <p>Defaults to <tt><em>HOME_URL</em>/lib</tt>/
- */
- String LIBRARY_URL = "jboss.lib.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the URL where JBoss will read patch library files
- * from.
- *
- * <p>If this value is a <tt>file</tt> URL, then all .zip and .jar files
- * inside will be prepended to the classpath. Otherwise the URL will be
- * added to the classpath. If not set then the no patch files will be
- * loaded.
- */
- String PATCH_URL = "jboss.patch.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the name of the server which will be used to
- * calculate the servers home directory and url.
- *
- * <p>Defaults to <tt>default</tt>.
- */
- String SERVER_NAME = "jboss.server.name";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the base directory for calculating server
- * home directories.
- *
- * <p>Defaults to <tt><em>HOME_DIR</em>/server</tt>.
- */
- String SERVER_BASE_DIR = "jboss.server.base.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the server home directory for JBoss.
- *
- * <p>Defaults to <tt><em>SERVER_BASE_DIR</em>/<em>SERVER_NAME</em></tt>.
- */
- String SERVER_HOME_DIR = "jboss.server.home.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the server log directory for JBoss.
- *
- * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/<em>log</em></tt>.
- */
- String SERVER_LOG_DIR = "jboss.server.log.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the directory which JBoss will use for
- * temporary file storage.
- *
- * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/tmp</tt> .
- */
- String SERVER_TEMP_DIR = "jboss.server.temp.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the directory which JBoss will use for
- * persistent data file storage.
- *
- * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/data</tt>.
- */
- String SERVER_DATA_DIR = "jboss.server.data.dir";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the base URL for calculating server
- * home URLs.
- *
- * <p>Defaults to <tt><em>HOME_URL</em>/server</tt>.
- */
- String SERVER_BASE_URL = "jboss.server.base.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the server home URL for JBoss.
- *
- * <p>Defaults to <tt><em>SERVER_BASE_URL</em>/<em>SERVER_NAME</em></tt>.
- */
- String SERVER_HOME_URL = "jboss.server.home.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the server configuration URL.
- *
- * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/conf</tt> .
- */
- String SERVER_CONFIG_URL = "jboss.server.config.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the URL where JBoss will read server specific
- * library files from.
- *
- * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/lib</tt>/
- */
- String SERVER_LIBRARY_URL = "jboss.server.lib.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the base URL for files and directories
- * common to different server configurations
- *
- * <p>Defaults to <tt><em>HOME_URL</em>/common/</tt>
- */
- String COMMON_BASE_URL = "jboss.common.base.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying a library directory URL that points to libraries
- * shared by the various server configurations.
- *
- * <p>Defaults to <tt><em>COMMON_BASE_URL</em>/lib/</tt>
- */
- String COMMON_LIBRARY_URL = "jboss.common.lib.url";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying the bind address for all jboss services
- *
- */
- String SERVER_BIND_ADDRESS = "jboss.bind.address";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying whether or not the server should exit the
- * JVM on shutdown.
- *
- * <p>If not set then the server will default to exiting on shutdown.
- */
- String EXIT_ON_SHUTDOWN = "jboss.server.exitonshutdown";
-
- /**
- * Constant that holds the name of the environment property for
- * specifying whether or not the server should shutdown
- * synchronously (true) or asynchronously (false).
- *
- * <p>If not set then the server will default to asynchronous shutdown.
- */
- String BLOCKING_SHUTDOWN = "jboss.server.blockingshutdown";
-
- /**
- * Constant that holds the name of the environment property
- * for specifying whether or not to install the lifethread
- *
- * <p>If not set then the server will default to installing the lifethread.
- */
- String INSTALL_LIFE_THREAD = "jboss.server.lifethread";
-
- /**
- * Constant that holds the name of the environment property for
- * specifying whether or not the server should log and ignore
- * exceptions when setting the URLStreamHandlerFactory.
- *
- * <p>If not set then the server will default to asynchronous shutdown.
- */
- String REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY = "jboss.server.requirejbossurlstreamhandlerfactory";
-
- /**
- * Constant that holds the name of the environment property for specifying
- * whether or not to use as the main jboss server the MBeanServer returned
- * from ManagementFactory.getPlatformMBeanServer(), when running under jdk1.5+
- *
- * <p>If not set then jboss will instantiate its own MBeanServer
- */
- String PLATFORM_MBEANSERVER = "jboss.platform.mbeanserver";
-
- /////////////////////////////////////////////////////////////////////////
- // Path Suffixes //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * The suffix used when generating the default value for {@link #LIBRARY_URL},
- * {@link #COMMON_LIBRARY_URL} and {@link #SERVER_LIBRARY_URL}.
- */
- String LIBRARY_URL_SUFFIX = "lib/";
-
- /**
- * The suffix used when generating the default value for {@link #COMMON_BASE_URL}
- */
- String COMMON_BASE_URL_SUFFIX = "common/";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_CONFIG_URL}.
- */
- String SERVER_CONFIG_URL_SUFFIX = "conf/";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_BASE_DIR}.
- */
- String SERVER_BASE_DIR_SUFFIX = "server";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_BASE_URL}.
- */
- String SERVER_BASE_URL_SUFFIX = "server/";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_DATA_DIR}.
- */
- String SERVER_DATA_DIR_SUFFIX = "data";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_LOG_DIR}.
- */
- String SERVER_LOG_DIR_SUFFIX = "log";
-
- /**
- * The suffix used when generating the default value for {@link #SERVER_TEMP_DIR}.
- */
- String SERVER_TEMP_DIR_SUFFIX = "tmp";
-
-
- /////////////////////////////////////////////////////////////////////////
- // Defaults //
- /////////////////////////////////////////////////////////////////////////
-
- /** The default value for {@link #SERVER_NAME}. */
- String DEFAULT_SERVER_NAME = "default";
-
- /** The default value for {@link #EXIT_ON_SHUTDOWN}. */
- boolean DEFAULT_EXIT_ON_SHUTDOWN = true;
-
- /** The default value for {@link #BLOCKING_SHUTDOWN}. */
- boolean DEFAULT_BLOCKING_SHUTDOWN = false;
-
- /** The default value for {@link #INSTALL_LIFE_THREAD}. */
- boolean DEFAULT_INSTALL_LIFE_THREAD = true;
-
- /** The default value for {@link #REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY}. */
- boolean DEFAULT_REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY = true;
-
- /** The default value for {@link #PLATFORM_MBEANSERVER}. */
- boolean DEFAULT_PLATFORM_MBEANSERVER = false;
-
- /** The default value for {@link #ROOT_DEPLOYMENT_FILENAME}. */
- String DEFAULT_ROOT_DEPLOYMENT_FILENAME = "jboss-service.xml";
-
-
- /////////////////////////////////////////////////////////////////////////
- // Typed Access Methods //
- /////////////////////////////////////////////////////////////////////////
-
- /**
- * Get the bootstrap url
- *
- * @return the bootstrap url
- */
- URL getBootstrapURL();
-
- /**
- * Get the local home directory which the server is running from.
- *
- * @return The local server home directory.
- */
- File getHomeDir();
-
- /**
- * Get the home URL which the server is running from.
- *
- * @return The home URL which the server is running from.
- */
- URL getHomeURL();
-
- /**
- * Get the library URL for the server.
- *
- * @return The library URL for the server.
- */
- URL getLibraryURL();
-
- /**
- * Get the patch URL for the server.
- *
- * @return The patch URL for the server.
- */
- URL getPatchURL();
-
- /**
- * Get the name of the server.
- *
- * @return The name of the server.
- */
- String getServerName();
-
- /**
- * Get the base directory for calculating server home directories.
- *
- * @return Base server home directory.
- */
- File getServerBaseDir();
-
- /**
- * Get the server home directory.
- *
- * @return Server home directory.
- */
- File getServerHomeDir();
-
- /**
- * Get the directory where log files will be stored.
- *
- * @return The directory where the server writes log files.
- */
- File getServerLogDir();
-
- /**
- * Get the directory where temporary files will be stored.
- *
- * @return The directory where the server stores temporary files.
- */
- File getServerTempDir();
-
- /**
- * Get the directory where local data will be stored.
- *
- * @return The directory where the server stores local data.
- */
- File getServerDataDir();
-
- /**
- * Get the base directory for calculating server home URLs.
- *
- * @return Base server home URL.
- */
- URL getServerBaseURL();
-
- /**
- * Get the server home URL.
- *
- * @return Server home URL.
- */
- URL getServerHomeURL();
-
- /**
- * Get the server library URL.
- *
- * @return Server library URL.
- */
- URL getServerLibraryURL();
-
- /**
- * Get the server configuration URL.
- *
- * @return Server configuration URL.
- */
- URL getServerConfigURL();
-
- /**
- * Get the common base URL.
- *
- * @return Common base URL.
- */
- URL getCommonBaseURL();
-
- /**
- * Get the common library URL.
- *
- * @return Common library URL.
- */
- URL getCommonLibraryURL();
-
- /**
- * Get the current value of the flag that indicates if we are
- * using the platform MBeanServer as the main jboss server.
- * Both the {@link ServerConfig#PLATFORM_MBEANSERVER}
- * property must be set, and the jvm must be jdk1.5+
- *
- * @return true if jboss runs on the jvm platfrom MBeanServer
- */
- boolean getPlatformMBeanServer();
-
- /**
- * Enable or disable exiting the JVM when {@link Server#shutdown()} is called.
- * If enabled, then shutdown calls {@link Server#exit()}. If disabled, then
- * only the shutdown hook will be run.
- *
- * @param flag True to enable calling exit on shutdown.
- */
- void setExitOnShutdown(boolean flag);
-
- /**
- * Get the current value of the exit on shutdown flag.
- *
- * @return The current value of the exit on shutdown flag.
- */
- boolean getExitOnShutdown();
-
-
- /**
- * Get the BlockingShutdown value.
- * @return the BlockingShutdown value.
- */
- boolean getBlockingShutdown();
-
- /**
- * Set the BlockingShutdown value.
- * @param blockingShutdown The new BlockingShutdown value.
- */
- void setBlockingShutdown(boolean blockingShutdown);
-
- /**
- * Whether to install the lifethread
- *
- * @return true to install the life thread
- */
- boolean isInstallLifeThread();
-
- /**
- * Get the RequireJBossURLStreamHandlerFactory value.
- * @return the RequireJBossURLStreamHandlerFactory value.
- */
- boolean getRequireJBossURLStreamHandlerFactory();
-
- /**
- * Set the RequireJBossURLStreamHandlerFactory value.
- * @param requireJBossURLStreamHandlerFactory The new RequireJBossURLStreamHandlerFactory value.
- */
- void setRequireJBossURLStreamHandlerFactory(boolean requireJBossURLStreamHandlerFactory);
-
- /**
- * Set the filename of the root deployable that will be used to finalize
- * the bootstrap process.
- *
- * @param filename The filename of the root deployable.
- */
- void setRootDeploymentFilename(String filename);
-
- /**
- * Get the filename of the root deployable that will be used to finalize
- * the bootstrap process.
- *
- * @return The filename of the root deployable.
- */
- String getRootDeploymentFilename();
-
- /**
- * Get the native dir for unpacking
- *
- * @return the directory
- */
- File getServerNativeDir();
-
- /**
- * Get the temporary deployment dir for unpacking
- *
- * @return the directory
- */
- File getServerTempDeployDir();
-
- /**
- * Get the server Specification-Version
- *
- * @return the spec version
- */
- String getSpecificationVersion();
-}
+/*
+ * 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;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * The interface of the basic <em>typed</em> JBoss server configuration.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ * @author Dimitris.Andreadis at jboss.org
+ * @version $Revision: 63730 $
+ */
+public interface ServerConfig
+{
+
+ /** The default partition name */
+ String DEFAULT_PARITION_NAME = "DefaultPartition";
+
+ /** The partition name property */
+ String PARTITION_NAME_PROPERTY = "jboss.partition.name";
+
+ /** The udp address property */
+ String PARTITION_UDP_PROPERTY = "jboss.partition.udpGroup";
+
+ /** The udp port property */
+ String PARTITION_UDP_PORT_PROPERTY = "jboss.jgroups.udp.mcast_port";
+
+ /** Whether to load native libraries */
+ String NATIVE_LOAD_PROPERTY = "jboss.native.load";
+
+ /** The location of native libraries property */
+ String NATIVE_DIR_PROPERTY = "jboss.native.dir";
+
+ /////////////////////////////////////////////////////////////////////////
+ // Bootstrap Specific Config //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying a comma seperated list of the basenames of
+ * to the boot libraries required load the core system.
+ *
+ * <p>These libraries will be loaded from <tt>LIBRARY_URL</tt>.
+ */
+ String BOOT_LIBRARY_LIST = "jboss.boot.library.list";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the class type of the server to create.
+ */
+ String SERVER_TYPE = "jboss.server.type";
+
+ /**
+ * The bootstrap url
+ *
+ * <p>If not set then the server will default to {@link #SERVER_CONFIG_URL}/bootstrap.xml.
+ */
+ String BOOTSTRAP_URL = "jboss.bootstrap.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the root deployment filename (relative to the server
+ * config URL that will be deployed to finalize the boot strap process.
+ *
+ * <p>If not set then the server will default to {@link #DEFAULT_ROOT_DEPLOYMENT_FILENAME}.
+ */
+ String ROOT_DEPLOYMENT_FILENAME = "jboss.server.root.deployment.filename";
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Configuration Value Identifiers //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the home directory for JBoss.
+ */
+ String HOME_DIR = "jboss.home.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the home URL for JBoss.
+ *
+ * <p>If not set then the value of HOME_DIR will converted into a URL.
+ */
+ String HOME_URL = "jboss.home.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the URL where JBoss will read library files
+ * from.
+ *
+ * <p>Defaults to <tt><em>HOME_URL</em>/lib</tt>/
+ */
+ String LIBRARY_URL = "jboss.lib.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the URL where JBoss will read patch library files
+ * from.
+ *
+ * <p>If this value is a <tt>file</tt> URL, then all .zip and .jar files
+ * inside will be prepended to the classpath. Otherwise the URL will be
+ * added to the classpath. If not set then the no patch files will be
+ * loaded.
+ */
+ String PATCH_URL = "jboss.patch.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the name of the server which will be used to
+ * calculate the servers home directory and url.
+ *
+ * <p>Defaults to <tt>default</tt>.
+ */
+ String SERVER_NAME = "jboss.server.name";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the base directory for calculating server
+ * home directories.
+ *
+ * <p>Defaults to <tt><em>HOME_DIR</em>/server</tt>.
+ */
+ String SERVER_BASE_DIR = "jboss.server.base.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the server home directory for JBoss.
+ *
+ * <p>Defaults to <tt><em>SERVER_BASE_DIR</em>/<em>SERVER_NAME</em></tt>.
+ */
+ String SERVER_HOME_DIR = "jboss.server.home.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the server log directory for JBoss.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/<em>log</em></tt>.
+ */
+ String SERVER_LOG_DIR = "jboss.server.log.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the directory which JBoss will use for
+ * temporary file storage.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/tmp</tt> .
+ */
+ String SERVER_TEMP_DIR = "jboss.server.temp.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the directory which JBoss will use for
+ * persistent data file storage.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_DIR</em>/data</tt>.
+ */
+ String SERVER_DATA_DIR = "jboss.server.data.dir";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the base URL for calculating server
+ * home URLs.
+ *
+ * <p>Defaults to <tt><em>HOME_URL</em>/server</tt>.
+ */
+ String SERVER_BASE_URL = "jboss.server.base.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the server home URL for JBoss.
+ *
+ * <p>Defaults to <tt><em>SERVER_BASE_URL</em>/<em>SERVER_NAME</em></tt>.
+ */
+ String SERVER_HOME_URL = "jboss.server.home.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the server configuration URL.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/conf</tt> .
+ */
+ String SERVER_CONFIG_URL = "jboss.server.config.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the URL where JBoss will read server specific
+ * library files from.
+ *
+ * <p>Defaults to <tt><em>SERVER_HOME_URL</em>/lib</tt>/
+ */
+ String SERVER_LIBRARY_URL = "jboss.server.lib.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the base URL for files and directories
+ * common to different server configurations
+ *
+ * <p>Defaults to <tt><em>HOME_URL</em>/common/</tt>
+ */
+ String COMMON_BASE_URL = "jboss.common.base.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying a library directory URL that points to libraries
+ * shared by the various server configurations.
+ *
+ * <p>Defaults to <tt><em>COMMON_BASE_URL</em>/lib/</tt>
+ */
+ String COMMON_LIBRARY_URL = "jboss.common.lib.url";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying the bind address for all jboss services
+ *
+ */
+ String SERVER_BIND_ADDRESS = "jboss.bind.address";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying whether or not the server should exit the
+ * JVM on shutdown.
+ *
+ * <p>If not set then the server will default to exiting on shutdown.
+ */
+ String EXIT_ON_SHUTDOWN = "jboss.server.exitonshutdown";
+
+ /**
+ * Constant that holds the name of the environment property for
+ * specifying whether or not the server should shutdown
+ * synchronously (true) or asynchronously (false).
+ *
+ * <p>If not set then the server will default to asynchronous shutdown.
+ */
+ String BLOCKING_SHUTDOWN = "jboss.server.blockingshutdown";
+
+ /**
+ * Constant that holds the name of the environment property
+ * for specifying whether or not to install the lifethread
+ *
+ * <p>If not set then the server will default to installing the lifethread.
+ */
+ String INSTALL_LIFE_THREAD = "jboss.server.lifethread";
+
+ /**
+ * Constant that holds the name of the environment property for
+ * specifying whether or not the server should log and ignore
+ * exceptions when setting the URLStreamHandlerFactory.
+ *
+ * <p>If not set then the server will default to asynchronous shutdown.
+ */
+ String REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY = "jboss.server.requirejbossurlstreamhandlerfactory";
+
+ /**
+ * Constant that holds the name of the environment property for specifying
+ * whether or not to use as the main jboss server the MBeanServer returned
+ * from ManagementFactory.getPlatformMBeanServer(), when running under jdk1.5+
+ *
+ * <p>If not set then jboss will instantiate its own MBeanServer
+ */
+ String PLATFORM_MBEANSERVER = "jboss.platform.mbeanserver";
+
+ /////////////////////////////////////////////////////////////////////////
+ // Path Suffixes //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * The suffix used when generating the default value for {@link #LIBRARY_URL},
+ * {@link #COMMON_LIBRARY_URL} and {@link #SERVER_LIBRARY_URL}.
+ */
+ String LIBRARY_URL_SUFFIX = "lib/";
+
+ /**
+ * The suffix used when generating the default value for {@link #COMMON_BASE_URL}
+ */
+ String COMMON_BASE_URL_SUFFIX = "common/";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_CONFIG_URL}.
+ */
+ String SERVER_CONFIG_URL_SUFFIX = "conf/";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_BASE_DIR}.
+ */
+ String SERVER_BASE_DIR_SUFFIX = "server";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_BASE_URL}.
+ */
+ String SERVER_BASE_URL_SUFFIX = "server/";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_DATA_DIR}.
+ */
+ String SERVER_DATA_DIR_SUFFIX = "data";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_LOG_DIR}.
+ */
+ String SERVER_LOG_DIR_SUFFIX = "log";
+
+ /**
+ * The suffix used when generating the default value for {@link #SERVER_TEMP_DIR}.
+ */
+ String SERVER_TEMP_DIR_SUFFIX = "tmp";
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Defaults //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** The default value for {@link #SERVER_NAME}. */
+ String DEFAULT_SERVER_NAME = "default";
+
+ /** The default value for {@link #EXIT_ON_SHUTDOWN}. */
+ boolean DEFAULT_EXIT_ON_SHUTDOWN = true;
+
+ /** The default value for {@link #BLOCKING_SHUTDOWN}. */
+ boolean DEFAULT_BLOCKING_SHUTDOWN = false;
+
+ /** The default value for {@link #INSTALL_LIFE_THREAD}. */
+ boolean DEFAULT_INSTALL_LIFE_THREAD = true;
+
+ /** The default value for {@link #REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY}. */
+ boolean DEFAULT_REQUIRE_JBOSS_URL_STREAM_HANDLER_FACTORY = true;
+
+ /** The default value for {@link #PLATFORM_MBEANSERVER}. */
+ boolean DEFAULT_PLATFORM_MBEANSERVER = false;
+
+ /** The default value for {@link #ROOT_DEPLOYMENT_FILENAME}. */
+ String DEFAULT_ROOT_DEPLOYMENT_FILENAME = "jboss-service.xml";
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Typed Access Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get the bootstrap url
+ *
+ * @return the bootstrap url
+ */
+ URL getBootstrapURL();
+
+ /**
+ * Get the local home directory which the server is running from.
+ *
+ * @return The local server home directory.
+ */
+ File getHomeDir();
+
+ /**
+ * Get the home URL which the server is running from.
+ *
+ * @return The home URL which the server is running from.
+ */
+ URL getHomeURL();
+
+ /**
+ * Get the library URL for the server.
+ *
+ * @return The library URL for the server.
+ */
+ URL getLibraryURL();
+
+ /**
+ * Get the patch URL for the server.
+ *
+ * @return The patch URL for the server.
+ */
+ URL getPatchURL();
+
+ /**
+ * Get the name of the server.
+ *
+ * @return The name of the server.
+ */
+ String getServerName();
+
+ /**
+ * Get the base directory for calculating server home directories.
+ *
+ * @return Base server home directory.
+ */
+ File getServerBaseDir();
+
+ /**
+ * Get the server home directory.
+ *
+ * @return Server home directory.
+ */
+ File getServerHomeDir();
+
+ /**
+ * Get the directory where log files will be stored.
+ *
+ * @return The directory where the server writes log files.
+ */
+ File getServerLogDir();
+
+ /**
+ * Get the directory where temporary files will be stored.
+ *
+ * @return The directory where the server stores temporary files.
+ */
+ File getServerTempDir();
+
+ /**
+ * Get the directory where local data will be stored.
+ *
+ * @return The directory where the server stores local data.
+ */
+ File getServerDataDir();
+
+ /**
+ * Get the base directory for calculating server home URLs.
+ *
+ * @return Base server home URL.
+ */
+ URL getServerBaseURL();
+
+ /**
+ * Get the server home URL.
+ *
+ * @return Server home URL.
+ */
+ URL getServerHomeURL();
+
+ /**
+ * Get the server library URL.
+ *
+ * @return Server library URL.
+ */
+ URL getServerLibraryURL();
+
+ /**
+ * Get the server configuration URL.
+ *
+ * @return Server configuration URL.
+ */
+ URL getServerConfigURL();
+
+ /**
+ * Get the common base URL.
+ *
+ * @return Common base URL.
+ */
+ URL getCommonBaseURL();
+
+ /**
+ * Get the common library URL.
+ *
+ * @return Common library URL.
+ */
+ URL getCommonLibraryURL();
+
+ /**
+ * Get the current value of the flag that indicates if we are
+ * using the platform MBeanServer as the main jboss server.
+ * Both the {@link ServerConfig#PLATFORM_MBEANSERVER}
+ * property must be set, and the jvm must be jdk1.5+
+ *
+ * @return true if jboss runs on the jvm platfrom MBeanServer
+ */
+ boolean getPlatformMBeanServer();
+
+ /**
+ * Enable or disable exiting the JVM when {@link Server#shutdown()} is called.
+ * If enabled, then shutdown calls {@link Server#exit()}. If disabled, then
+ * only the shutdown hook will be run.
+ *
+ * @param flag True to enable calling exit on shutdown.
+ */
+ void setExitOnShutdown(boolean flag);
+
+ /**
+ * Get the current value of the exit on shutdown flag.
+ *
+ * @return The current value of the exit on shutdown flag.
+ */
+ boolean getExitOnShutdown();
+
+
+ /**
+ * Get the BlockingShutdown value.
+ * @return the BlockingShutdown value.
+ */
+ boolean getBlockingShutdown();
+
+ /**
+ * Set the BlockingShutdown value.
+ * @param blockingShutdown The new BlockingShutdown value.
+ */
+ void setBlockingShutdown(boolean blockingShutdown);
+
+ /**
+ * Whether to install the lifethread
+ *
+ * @return true to install the life thread
+ */
+ boolean isInstallLifeThread();
+
+ /**
+ * Get the RequireJBossURLStreamHandlerFactory value.
+ * @return the RequireJBossURLStreamHandlerFactory value.
+ */
+ boolean getRequireJBossURLStreamHandlerFactory();
+
+ /**
+ * Set the RequireJBossURLStreamHandlerFactory value.
+ * @param requireJBossURLStreamHandlerFactory The new RequireJBossURLStreamHandlerFactory value.
+ */
+ void setRequireJBossURLStreamHandlerFactory(boolean requireJBossURLStreamHandlerFactory);
+
+ /**
+ * Set the filename of the root deployable that will be used to finalize
+ * the bootstrap process.
+ *
+ * @param filename The filename of the root deployable.
+ */
+ void setRootDeploymentFilename(String filename);
+
+ /**
+ * Get the filename of the root deployable that will be used to finalize
+ * the bootstrap process.
+ *
+ * @return The filename of the root deployable.
+ */
+ String getRootDeploymentFilename();
+
+ /**
+ * Get the native dir for unpacking
+ *
+ * @return the directory
+ */
+ File getServerNativeDir();
+
+ /**
+ * Get the temporary deployment dir for unpacking
+ *
+ * @return the directory
+ */
+ File getServerTempDeployDir();
+
+ /**
+ * Get the server Specification-Version
+ *
+ * @return the spec version
+ */
+ String getSpecificationVersion();
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerProcess.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerProcess.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/ServerProcess.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,57 +1,57 @@
-/*
- * 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;
-
-/**
- * ServerProcess
- *
- * An abstraction of an AS instance as run from within
- * a dedicated / standalone Process (JVM)
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface ServerProcess extends Server
-{
- /**
- * Shutdown the server, the JVM and run shutdown hooks.
- *
- * @param exitcode The exit code returned to the operating system.
- */
- void exit(int exitcode);
- /**
- * Shutdown the server, the JVM and run shutdown hooks. Exits with code 1.
- */
- void exit();
-
- /**
- * Forcibly terminates the currently running Java virtual machine.
- *
- * @param exitcode The exit code returned to the operating system.
- */
- void halt(int exitcode);
- /**
- * Forcibly terminates the currently running Java virtual machine. Exits with code 1.
- */
- void halt();
-
-}
+/*
+ * 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;
+
+/**
+ * ServerProcess
+ *
+ * An abstraction of an AS instance as run from within
+ * a dedicated / standalone Process (JVM)
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ServerProcess extends Server
+{
+ /**
+ * Shutdown the server, the JVM and run shutdown hooks.
+ *
+ * @param exitcode The exit code returned to the operating system.
+ */
+ void exit(int exitcode);
+ /**
+ * Shutdown the server, the JVM and run shutdown hooks. Exits with code 1.
+ */
+ void exit();
+
+ /**
+ * Forcibly terminates the currently running Java virtual machine.
+ *
+ * @param exitcode The exit code returned to the operating system.
+ */
+ void halt(int exitcode);
+ /**
+ * Forcibly terminates the currently running Java virtual machine. Exits with code 1.
+ */
+ void halt();
+
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/spi/util/ServerConfigUtil.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/spi/util/ServerConfigUtil.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/spi/util/ServerConfigUtil.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,148 +1,148 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.spi.util;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.jboss.bootstrap.spi.ServerConfig;
-
-/**
- * Utilities for accessing server configuration
- *
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @version <tt>$Revision: 57108 $</tt>
- */
-public class ServerConfigUtil
-{
- private static final String ANY = "0.0.0.0";
-
- /**
- * Retrieve the default bind address for the server
- *
- * @return the default bind adress
- */
- public static String getDefaultBindAddress()
- {
- return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
- }
-
- /**
- * Retrieve the default bind address, but only if it is specific
- *
- * @return the specific bind address
- */
- public static String getSpecificBindAddress()
- {
- String address = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
- if (address == null || address.equals(ANY))
- return null;
- return address;
- }
-
- /**
- * Fix the remote inet address.
- *
- * If we pass the address to the client we don't want to
- * tell it to connect to 0.0.0.0, use our host name instead
- * @param address the passed address
- * @return the fixed address
- */
- public static InetAddress fixRemoteAddress(InetAddress address)
- {
- try
- {
- if (address == null || InetAddress.getByName(ANY).equals(address))
- return InetAddress.getLocalHost();
- }
- catch (UnknownHostException ignored)
- {
- }
- return address;
- }
-
- /**
- * Fix the remote address.
- *
- * If we pass the address to the client we don't want to
- * tell it to connect to 0.0.0.0, use our host name instead
- * @param address the passed address
- * @return the fixed address
- */
- public static String fixRemoteAddress(String address)
- {
- try
- {
- if (address == null || ANY.equals(address))
- return InetAddress.getLocalHost().getHostName();
- }
- catch (UnknownHostException ignored)
- {
- }
- return address;
- }
-
- /**
- * Get the default partition name
- *
- * @return the default partition name
- */
- public static String getDefaultPartitionName()
- {
- return System.getProperty(ServerConfig.PARTITION_NAME_PROPERTY, ServerConfig.DEFAULT_PARITION_NAME);
- }
-
- /**
- * Whether to load native directories
- *
- * @return true when loading native directories
- */
- public static boolean isLoadNative()
- {
- return Boolean.getBoolean(ServerConfig.NATIVE_LOAD_PROPERTY);
- }
-
- /**
- * Utility to get a shortened url relative to the server home if possible
- *
- * @param longUrl
- * @return the short url
- */
- public static String shortUrlFromServerHome(String longUrl)
- {
- String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
-
- if (longUrl == null || serverHomeUrl == null)
- return longUrl;
-
- if (longUrl.startsWith(serverHomeUrl))
- return ".../" + longUrl.substring(serverHomeUrl.length());
- else
- {
- String jarServerHomeUrl = "jar:" + serverHomeUrl;
- if (longUrl.startsWith(jarServerHomeUrl))
- return ".../" + longUrl.substring(jarServerHomeUrl.length());
- else
- return longUrl;
- }
- }
-}
+/*
+ * 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.util;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+
+/**
+ * Utilities for accessing server configuration
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @version <tt>$Revision: 57108 $</tt>
+ */
+public class ServerConfigUtil
+{
+ private static final String ANY = "0.0.0.0";
+
+ /**
+ * Retrieve the default bind address for the server
+ *
+ * @return the default bind adress
+ */
+ public static String getDefaultBindAddress()
+ {
+ return System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
+ }
+
+ /**
+ * Retrieve the default bind address, but only if it is specific
+ *
+ * @return the specific bind address
+ */
+ public static String getSpecificBindAddress()
+ {
+ String address = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
+ if (address == null || address.equals(ANY))
+ return null;
+ return address;
+ }
+
+ /**
+ * Fix the remote inet address.
+ *
+ * If we pass the address to the client we don't want to
+ * tell it to connect to 0.0.0.0, use our host name instead
+ * @param address the passed address
+ * @return the fixed address
+ */
+ public static InetAddress fixRemoteAddress(InetAddress address)
+ {
+ try
+ {
+ if (address == null || InetAddress.getByName(ANY).equals(address))
+ return InetAddress.getLocalHost();
+ }
+ catch (UnknownHostException ignored)
+ {
+ }
+ return address;
+ }
+
+ /**
+ * Fix the remote address.
+ *
+ * If we pass the address to the client we don't want to
+ * tell it to connect to 0.0.0.0, use our host name instead
+ * @param address the passed address
+ * @return the fixed address
+ */
+ public static String fixRemoteAddress(String address)
+ {
+ try
+ {
+ if (address == null || ANY.equals(address))
+ return InetAddress.getLocalHost().getHostName();
+ }
+ catch (UnknownHostException ignored)
+ {
+ }
+ return address;
+ }
+
+ /**
+ * Get the default partition name
+ *
+ * @return the default partition name
+ */
+ public static String getDefaultPartitionName()
+ {
+ return System.getProperty(ServerConfig.PARTITION_NAME_PROPERTY, ServerConfig.DEFAULT_PARITION_NAME);
+ }
+
+ /**
+ * Whether to load native directories
+ *
+ * @return true when loading native directories
+ */
+ public static boolean isLoadNative()
+ {
+ return Boolean.getBoolean(ServerConfig.NATIVE_LOAD_PROPERTY);
+ }
+
+ /**
+ * Utility to get a shortened url relative to the server home if possible
+ *
+ * @param longUrl
+ * @return the short url
+ */
+ public static String shortUrlFromServerHome(String longUrl)
+ {
+ String serverHomeUrl = System.getProperty(org.jboss.bootstrap.spi.ServerConfig.SERVER_HOME_URL);
+
+ if (longUrl == null || serverHomeUrl == null)
+ return longUrl;
+
+ if (longUrl.startsWith(serverHomeUrl))
+ return ".../" + longUrl.substring(serverHomeUrl.length());
+ else
+ {
+ String jarServerHomeUrl = "jar:" + serverHomeUrl;
+ if (longUrl.startsWith(jarServerHomeUrl))
+ return ".../" + longUrl.substring(jarServerHomeUrl.length());
+ else
+ return longUrl;
+ }
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapParser.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapParser.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapParser.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,63 +1,63 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, JBoss Inc., and individual contributors as indicated
-* 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.xml;
-
-import java.net.URL;
-
-import org.jboss.bootstrap.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);
- }
- }
-}
+/*
+ * 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.xml;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.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);
+ }
+ }
+}
Modified: trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapSchemaBinding.java
===================================================================
--- trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapSchemaBinding.java 2008-11-14 12:05:02 UTC (rev 80997)
+++ trunk/bootstrap/src/main/org/jboss/bootstrap/xml/BootstrapSchemaBinding.java 2008-11-14 12:07:35 UTC (rev 80998)
@@ -1,97 +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.xml;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.bootstrap.BootstrapMetaData;
-import org.jboss.xb.binding.SimpleTypeBindings;
-import org.jboss.xb.binding.metadata.ClassMetaData;
-import org.jboss.xb.binding.sunday.unmarshalling.AllBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
-import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
-import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
-
-/**
- * SchemaBinding for the bootstrap
- *
- * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 71554 $
- */
-public class BootstrapSchemaBinding extends SchemaBinding
-{
- /** The bootstrap namespace */
- public static final String NAMESPACE = "urn:jboss:bootstrap:1.0";
-
- /**
- * Create a new BootstrapSchemaBinding.
- */
- public BootstrapSchemaBinding()
- {
- TypeBinding stringType = getType(SimpleTypeBindings.typeQName(String.class));
-
- setNamespaces(Collections.singleton(NAMESPACE));
- setIgnoreLowLine(true);
- setIgnoreUnresolvedFieldOrClass(false);
- setReplacePropertyRefs(true);
- setStrictSchema(true);
-
- // The bootstrap type
- TypeBinding bootstrapType = new TypeBinding(new QName(NAMESPACE, "bootstrapType"));
- bootstrapType.setSimple(false);
- AllBinding bootstrapModel = new AllBinding(this);
- ParticleBinding bootstrapParticle = new ParticleBinding(bootstrapModel, 1, 1, false);
- bootstrapType.setParticle(bootstrapParticle);
- ClassMetaData bootstrapClassMetaData = new ClassMetaData();
- bootstrapClassMetaData.setImpl(BootstrapMetaData.class.getName());
- bootstrapType.setClassMetaData(bootstrapClassMetaData);
-
- // Bootstrap can take some urls
- ElementBinding urlElement = new ElementBinding(this, new QName(NAMESPACE, "url"), stringType);
- ParticleBinding urlParticle = new ParticleBinding(urlElement, 0, 1, true);
- bootstrapModel.addParticle(urlParticle);
- bootstrapType.pushInterceptor(urlElement.getQName(), new DefaultElementInterceptor()
- {
- public void add(Object parent, Object child, QName name)
- {
- BootstrapMetaData bootstrap = (BootstrapMetaData) parent;
- String url = (String) child;
- List<String> bootstrapURLs = bootstrap.getBootstrapURLs();
- if (bootstrapURLs == null)
- {
- bootstrapURLs = new ArrayList<String>();
- bootstrap.setBootstrapURLs(bootstrapURLs);
- }
- bootstrapURLs.add(url);
- }
- });
-
- // The bootstrap root element
- addElement(new ElementBinding(this, new QName(NAMESPACE, "bootstrap"), bootstrapType));
- }
-}
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.bootstrap.BootstrapMetaData;
+import org.jboss.xb.binding.SimpleTypeBindings;
+import org.jboss.xb.binding.metadata.ClassMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.AllBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * SchemaBinding for the bootstrap
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 71554 $
+ */
+public class BootstrapSchemaBinding extends SchemaBinding
+{
+ /** The bootstrap namespace */
+ public static final String NAMESPACE = "urn:jboss:bootstrap:1.0";
+
+ /**
+ * Create a new BootstrapSchemaBinding.
+ */
+ public BootstrapSchemaBinding()
+ {
+ TypeBinding stringType = getType(SimpleTypeBindings.typeQName(String.class));
+
+ setNamespaces(Collections.singleton(NAMESPACE));
+ setIgnoreLowLine(true);
+ setIgnoreUnresolvedFieldOrClass(false);
+ setReplacePropertyRefs(true);
+ setStrictSchema(true);
+
+ // The bootstrap type
+ TypeBinding bootstrapType = new TypeBinding(new QName(NAMESPACE, "bootstrapType"));
+ bootstrapType.setSimple(false);
+ AllBinding bootstrapModel = new AllBinding(this);
+ ParticleBinding bootstrapParticle = new ParticleBinding(bootstrapModel, 1, 1, false);
+ bootstrapType.setParticle(bootstrapParticle);
+ ClassMetaData bootstrapClassMetaData = new ClassMetaData();
+ bootstrapClassMetaData.setImpl(BootstrapMetaData.class.getName());
+ bootstrapType.setClassMetaData(bootstrapClassMetaData);
+
+ // Bootstrap can take some urls
+ ElementBinding urlElement = new ElementBinding(this, new QName(NAMESPACE, "url"), stringType);
+ ParticleBinding urlParticle = new ParticleBinding(urlElement, 0, 1, true);
+ bootstrapModel.addParticle(urlParticle);
+ bootstrapType.pushInterceptor(urlElement.getQName(), new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ BootstrapMetaData bootstrap = (BootstrapMetaData) parent;
+ String url = (String) child;
+ List<String> bootstrapURLs = bootstrap.getBootstrapURLs();
+ if (bootstrapURLs == null)
+ {
+ bootstrapURLs = new ArrayList<String>();
+ bootstrap.setBootstrapURLs(bootstrapURLs);
+ }
+ bootstrapURLs.add(url);
+ }
+ });
+
+ // The bootstrap root element
+ addElement(new ElementBinding(this, new QName(NAMESPACE, "bootstrap"), bootstrapType));
+ }
+}
More information about the jboss-cvs-commits
mailing list