[jboss-cvs] JBossAS SVN: r88583 - in branches/Branch_5_x_BootstrapLegacyRemoval/main: src/main/org/jboss and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun May 10 01:48:17 EDT 2009
Author: ALRubinger
Date: 2009-05-10 01:48:17 -0400 (Sun, 10 May 2009)
New Revision: 88583
Modified:
branches/Branch_5_x_BootstrapLegacyRemoval/main/.classpath
branches/Branch_5_x_BootstrapLegacyRemoval/main/build.xml
branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java
Log:
[JBAS-6856] Repackage run.jar and get booting. Still TODO: Init log4j for boot.log, ensure the vfsfile handlers are installed via VFS.init() explicit call
Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/.classpath
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/.classpath 2009-05-10 05:12:25 UTC (rev 88582)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/.classpath 2009-05-10 05:48:17 UTC (rev 88583)
@@ -4,7 +4,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="/thirdparty/gnu-getopt/lib/getopt.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-spi/lib/jboss-bootstrap-spi.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-spi-as/lib/jboss-bootstrap-spi-as.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-spi-mc/lib/jboss-bootstrap-spi-mc.jar"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-spi-as/lib/jboss-bootstrap-spi-as.jar"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/build.xml
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/build.xml 2009-05-10 05:12:25 UTC (rev 88582)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/build.xml 2009-05-10 05:48:17 UTC (rev 88583)
@@ -80,8 +80,8 @@
<path id="dependentmodule.classpath">
<path refid="jboss.jboss.bootstrap.impl.as.classpath"/>
<path refid="jboss.jboss.bootstrap.spi.classpath"/>
- <path refid="jboss.jboss.bootstrap.spi.mc.classpath"/>
- <path refid="jboss.jboss.bootstrap.spi.as.classpath"/>
+ <path refid="jboss.jboss.bootstrap.spi.as.classpath"/>
+ <path refid="jboss.jboss.bootstrap.spi.mc.classpath"/>
</path>
<!-- ===== -->
@@ -157,19 +157,27 @@
</jar>
<!-- Inflate out contents of the Bootstrap JAR into a Temp Directory -->
- <property name="inflated.dir" value="tmp-bootstrap" />
- <mkdir dir="${inflated.dir}"/>
- <unjar dest="${inflated.dir}">
+ <property name="inflated.spi.dir" value="tmp-bootstrap-spi" />
+ <property name="inflated.spi.as.dir" value="tmp-bootstrap-spi-as" />
+ <property name="inflated.spi.mc.dir" value="tmp-bootstrap-spi-mc" />
+ <mkdir dir="${inflated.spi.dir}"/>
+ <unjar dest="${inflated.spi.dir}">
<fileset dir="${jboss.jboss.bootstrap.spi.lib}">
<include name="jboss-bootstrap-spi.jar"/>
</fileset>
- <fileset dir="${jboss.jboss.bootstrap.spi.as.lib}">
- <include name="jboss-bootstrap-spi-as.jar"/>
- </fileset>
- <fileset dir="${jboss.jboss.bootstrap.spi.mc.lib}">
- <include name="jboss-bootstrap-spi-mc.jar"/>
+ </unjar>
+ <mkdir dir="${inflated.spi.as.dir}"/>
+ <unjar dest="${inflated.spi.as.dir}">
+ <fileset dir="${jboss.jboss.bootstrap.spi.as.lib}">
+ <include name="jboss-bootstrap-spi-as.jar"/>
</fileset>
- </unjar>
+ </unjar>
+ <mkdir dir="${inflated.spi.mc.dir}"/>
+ <unjar dest="${inflated.spi.mc.dir}">
+ <fileset dir="${jboss.jboss.bootstrap.spi.mc.lib}">
+ <include name="jboss-bootstrap-spi-mc.jar"/>
+ </fileset>
+ </unjar>
<!-- Build run.jar -->
<jar jarfile="${build.lib}/run.jar" manifest="${build.etc}/run.mf">
@@ -181,14 +189,17 @@
<include name="jdklogger.xml"/>
<include name="org/jboss/version.properties"/>
</fileset>
- <!-- Add some classes from Bootstrap -->
- <fileset dir="${inflated.dir}">
- <include name="org/jboss/bootstrap/NoAnnotationURLClassLoader.class"/>
- <include name="org/jboss/bootstrap/ServerLoader.class"/>
- <include name="org/jboss/bootstrap/spi/Server.class"/>
- <include name="org/jboss/bootstrap/spi/ServerConfig.class"/>
- <include name="org/jboss/bootstrap/spi/util/ServerConfigUtil.class"/>
+ <!-- Add Bootstrap SPI classes -->
+ <fileset dir="${inflated.spi.dir}">
+ <include name="org/jboss/bootstrap/spi/**"/>
</fileset>
+ <fileset dir="${inflated.spi.as.dir}">
+ <include name="org/jboss/bootstrap/spi/as/config/JBossASServerConfig.class"/>
+ <include name="org/jboss/bootstrap/spi/as/config/JBossASConfigurationInitializer.class"/>
+ </fileset>
+ <fileset dir="${inflated.spi.mc.dir}">
+ <include name="org/jboss/bootstrap/spi/mc/config/MCBasedServerConfig.class"/>
+ </fileset>
<!-- Include getopt -->
<zipfileset src="${gnu.getopt.lib}/getopt.jar">
Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java 2009-05-10 05:12:25 UTC (rev 88582)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/Main.java 2009-05-10 05:48:17 UTC (rev 88583)
@@ -40,8 +40,8 @@
import org.jboss.bootstrap.spi.as.config.JBossASConfigurationInitializer;
import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
-import org.jboss.bootstrap.spi.as.server.JBossASServer;
import org.jboss.bootstrap.spi.factory.ServerFactory;
+import org.jboss.bootstrap.spi.server.Server;
/**
* Provides a command line interface to start the JBoss server.
@@ -66,9 +66,6 @@
*/
public class Main
{
- /** EDU.oswego.cs.dl.util.concurrent */
- private String concurrentLib = "concurrent.jar";
-
/** A URL for obtaining microkernel patches */
private URL bootURL;
@@ -84,16 +81,78 @@
private List<URL> extraClasspath = new LinkedList<URL>();
/**
+ * The default list of boot libraries. Does not include
+ * the JAXP or JMX impl, users of this class should add the
+ * proper libraries.
+ * TODO: use vfs to list the root directory
+ * http://www.jboss.org/index.html?module=bb&op=viewtopic&t=153175
+ *
+ * Copied from legacy bootstrap ServerLoader
+ */
+ @Deprecated
+ public static final String[] DEFAULT_BOOT_LIBRARY_LIST =
+ {
+ // Logging
+ "log4j-boot.jar",
+ "jboss-logging-spi.jar",
+ "jboss-logging-log4j.jar",
+ "jboss-logging-jdk.jar",
+ "jboss-logmanager.jar",
+ "jboss-logbridge.jar",
+ // Common jars
+ "jboss-common-core.jar",
+ "jboss-xml-binding.jar",
+ // Bootstrap
+ "jboss-bootstrap-spi.jar",
+ "jboss-bootstrap-spi-as.jar",
+ "jboss-bootstrap-spi-mc.jar",
+ "jboss-bootstrap-impl-base.jar",
+ "jboss-bootstrap-impl-as.jar",
+ "jboss-bootstrap-impl-mc.jar",
+ // Microcontainer
+ "javassist.jar",
+ "jboss-reflect.jar",
+ "jboss-mdr.jar",
+ "jboss-dependency.jar",
+ "jboss-kernel.jar",
+ "jboss-metatype.jar",
+ "jboss-managed.jar",
+ // Fixme ClassLoading
+ "jboss-vfs.jar",
+ "jboss-classloading-spi.jar",
+ "jboss-classloader.jar",
+ "jboss-classloading.jar",
+ "jboss-classloading-vfs.jar",
+ // Fixme aop
+ "jboss-aop.jar",
+ "jboss-aop-mc-int.jar",
+ "trove.jar",};
+
+ /**
* Server properties. This object holds all of the required
* information to get the server up and running. Use System
* properties for defaults.
*/
private Properties props = new Properties(System.getProperties());
- /** The booted server instance */
- private JBossASServer server;
+ /**
+ * The booted server instance.
+ *
+ * We don't use JBossASServer directly here, because it has
+ * a reference to MC and the Kernel. This would put the bootstrap
+ * AS SPI upon the application classpath, with references to
+ * classes on child ClassLoaders, leading to NCDFE. So just use
+ * the minimal SPI set and load everything via reflection
+ * using the URLCLs we create the boot libraries.
+ */
+ private Server<?, ?> server;
/**
+ * The FQN of the default server implementation class to create
+ */
+ private static final String DEFAULT_AS_SERVER_IMPL_CLASS_NAME = "org.jboss.bootstrap.impl.as.server.JBossASServerImpl";
+
+ /**
* Explicit constructor.
*/
public Main()
@@ -105,7 +164,7 @@
* Access the booted server.
* @return the Server instance.
*/
- public JBossASServer getServer()
+ public Server<?, ?> getServer()
{
return server;
}
@@ -129,17 +188,60 @@
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
}
+ // Get JBOSS_HOME appropriately
+ final String homeUrl = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL);
+ final String homeDir = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR);
+ URL jbossHome = null;
+ // We've been given home URL
+ if (homeUrl != null)
+ {
+ jbossHome = new URL(homeUrl);
+ }
+ // We've been given home dir
+ else if (homeDir != null)
+ {
+ final File homeDirFile = new File(homeDir);
+ if(!homeDirFile.exists())
+ {
+ throw new IllegalArgumentException("Specified " + JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR
+ + " does not point to a valid location: " + homeDirFile.toString());
+ }
+ jbossHome = homeDirFile.toURI().toURL();
+ }
+ // Nothing specified, so autoset relative to our location
+ else
+ {
+ String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getFile();
+ /* The 1.4 JDK munges the code source file with URL encoding so run
+ * this path through the decoder so that is JBoss starts in a path with
+ * spaces we don't come crashing down.
+ */
+ path = URLDecoder.decode(path, "UTF-8");
+ File runJar = new File(path);
+ File homeFile = runJar.getParentFile().getParentFile();
+ URL homeUrlFromDir = homeFile.toURI().toURL();
+ jbossHome = homeUrlFromDir;
+ }
+
+ // Get Library URL
+ String libUrlFromProp = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BOOT_LIBRARY_URL);
+ URL libUrl = null;
+ if (libUrlFromProp != null)
+ {
+ libUrl = new URL(libUrlFromProp);
+ }
+ else
+ {
+ libUrl = new URL(jbossHome, JBossASConfigurationInitializer.VALUE_LIBRARY_URL_SUFFIX_DEFAULT);
+ }
+
+
// Get TCCL
final ClassLoader tccl = SecurityActions.getThreadContextClassLoader();
// Define a Set URLs to have visible to the CL loading the Server
final Set<URL> urls = new HashSet<URL>();
- //TODO
- // server.get
- // JBossASServerConfig config = new BasicJBossASServerConfig(props);
- // ServerLoader loader = new ServerLoader(props);
-
/* If there is a patch dir specified make it the first element of the
loader bootstrap classpath. If its a file url pointing to a dir, then
add the dir and its contents.
@@ -192,47 +294,58 @@
{
urls.add(extraClasspath.get(i));
}
-
+
+ // Add all boot libs required from $JBOSS_HOME/lib
+ final File bootLibDir = new File(libUrl.toURI());
+ if (!bootLibDir.exists())
+ {
+ throw new IllegalArgumentException("Boot lib directory not found: " + bootLibDir.toString());
+ }
+ if (!bootLibDir.isDirectory())
+ {
+ throw new IllegalArgumentException("Boot lib directory is not a directory: " + bootLibDir.toString());
+ }
+ for (String filename : DEFAULT_BOOT_LIBRARY_LIST)
+ {
+ final File bootLibFile = new File(bootLibDir, filename);
+ if (!bootLibFile.exists())
+ {
+ System.out.println("WARNING: Could not find expected boot lib " + bootLibFile);
+ }
+ final URL bootLibUrl = bootLibFile.toURI().toURL();
+ urls.add(bootLibUrl);
+ }
+
// Make a ClassLoader to be used in loading the server
final URL[] urlArray = urls.toArray(new URL[]
{});
final ClassLoader loadingCl = new URLClassLoader(urlArray, tccl);
// Load the server
- //TODO USe a impl-as factory
- server = (JBossASServer) ServerFactory.createServer("org.jboss.bootstrap.impl.as.server.JBossASServerImpl",
- loadingCl);
+ server = ServerFactory.createServer(DEFAULT_AS_SERVER_IMPL_CLASS_NAME,loadingCl);
- // Auto set HOME_DIR to ../bin/run.jar if not set
- String homeDir = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR);
- if (homeDir == null)
+ // Get out the default configuration
+ JBossASServerConfig config = (JBossASServerConfig) server.getConfiguration();
+
+ // Set JBOSS_HOME
+ config.jbossHome(jbossHome);
+
+ try
{
- String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getFile();
- /* The 1.4 JDK munges the code source file with URL encoding so run
- * this path through the decoder so that is JBoss starts in a path with
- * spaces we don't come crashing down.
- */
- path = URLDecoder.decode(path, "UTF-8");
- File runJar = new File(path);
- File homeFile = runJar.getParentFile().getParentFile();
- homeDir = homeFile.getCanonicalPath();
+ // Set the CL
+ SecurityActions.setThreadContextClassLoader(loadingCl);
+
+ // Initialize the server
+ server.initialize();
+
+ // Start 'er up mate!
+ server.start();
}
- props.setProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR, homeDir);
-
- // Setup HOME_URL too, ServerLoader needs this
- String homeURL = props.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL);
- if (homeURL == null)
+ finally
{
- File file = new File(homeDir);
- homeURL = file.toURI().toURL().toString();
- props.setProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL, homeURL);
+ // Reset the CL
+ SecurityActions.setThreadContextClassLoader(tccl);
}
-
- // Initialize the server
- server.initialize();
-
- // Start 'er up mate!
- server.start();
}
/**
Modified: branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java
===================================================================
--- branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java 2009-05-10 05:12:25 UTC (rev 88582)
+++ branches/Branch_5_x_BootstrapLegacyRemoval/main/src/main/org/jboss/SecurityActions.java 2009-05-10 05:48:17 UTC (rev 88583)
@@ -52,16 +52,55 @@
// Utility Methods --------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+ /**
+ * Sets the specified property with key and value
+ */
+ static void setSystemProperty(final String key, final String value)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ System.setProperty(key, value);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Obtains the Thread Context ClassLoader
+ */
static ClassLoader getThreadContextClassLoader()
{
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
-
public ClassLoader run()
{
return Thread.currentThread().getContextClassLoader();
}
+ });
+ }
+ /**
+ * Sets the specified CL upon the current Thread's Context
+ *
+ * @param cl
+ * @throws IllegalArgumentException If the CL was null
+ */
+ static void setThreadContextClassLoader(final ClassLoader cl) throws IllegalArgumentException
+ {
+ if (cl == null)
+ {
+ throw new IllegalArgumentException("ClassLoader was null");
+ }
+
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ };
});
}
}
More information about the jboss-cvs-commits
mailing list