[jboss-cvs] JBossAS SVN: r81062 - in trunk/main: src/bin and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 10:06:42 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 10:06:42 -0500 (Fri, 14 Nov 2008)
New Revision: 81062
Modified:
trunk/main/build.bat
trunk/main/build.sh
trunk/main/build.xml
trunk/main/pom.xml
trunk/main/src/bin/classpath.sh
trunk/main/src/bin/probe.bat
trunk/main/src/bin/probe.sh
trunk/main/src/bin/run.bat
trunk/main/src/bin/run.sh
trunk/main/src/main/org/jboss/Main.java
trunk/main/src/main/org/jboss/handlers/stub/vfs/Handler.java
trunk/main/src/main/org/jboss/handlers/stub/vfsfile/Handler.java
trunk/main/src/main/org/jboss/handlers/stub/vfsjar/Handler.java
trunk/main/src/main/org/jboss/handlers/stub/vfsmemory/Handler.java
trunk/main/src/main/org/jboss/handlers/stub/vfszip/Handler.java
trunk/main/src/main/org/jboss/system/JBossRMIClassLoader.java
trunk/main/src/main/org/jboss/system/NoAnnotationURLClassLoader.java
trunk/main/src/main/org/jboss/system/ORBSingleton.java
trunk/main/src/main/org/jboss/system/server/ServerLoader.java
trunk/main/src/resources/log4j-debug.properties
trunk/main/src/resources/log4j-trace.properties
trunk/main/src/resources/log4j.properties
trunk/main/src/resources/org/jboss/version.properties
Log:
fix svn properties
Property changes on: trunk/main/build.bat
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/build.sh
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/build.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/pom.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/bin/classpath.sh
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/bin/probe.bat
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/bin/probe.sh
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Modified: trunk/main/src/bin/run.bat
===================================================================
--- trunk/main/src/bin/run.bat 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/bin/run.bat 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,151 +1,151 @@
- at echo off
-rem -------------------------------------------------------------------------
-rem JBoss Bootstrap Script for Windows
-rem -------------------------------------------------------------------------
-
-rem $Id: run.bat 63250 2007-05-30 13:22:21Z dimitris at jboss.org $
-
- at if not "%ECHO%" == "" echo %ECHO%
- at if "%OS%" == "Windows_NT" setlocal
-
-if "%OS%" == "Windows_NT" (
- set "DIRNAME=%~dp0%"
-) else (
- set DIRNAME=.\
-)
-
-pushd %DIRNAME%..
-if "x%JBOSS_HOME%" == "x" (
- set "JBOSS_HOME=%CD%"
-)
-popd
-
-set DIRNAME=
-
-if "%OS%" == "Windows_NT" (
- set "PROGNAME=%~nx0%"
-) else (
- set "PROGNAME=run.bat"
-)
-
-if "x%JAVA_OPTS%" == "x" (
- set "JAVA_OPTS=-Dprogram.name=%PROGNAME%"
-) else (
- set "JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%"
-)
-
-if "x%JAVA_HOME%" == "x" (
- set JAVA=java
- echo JAVA_HOME is not set. Unexpected results may occur.
- echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
-) else (
- set "JAVA=%JAVA_HOME%\bin\java"
- if exist "%JAVA_HOME%\lib\tools.jar" (
- set "JAVAC_JAR=%JAVA_HOME%\lib\tools.jar"
- )
-)
-
-rem Add -server to the JVM options, if supported
-"%JAVA%" -server -version 2>&1 | findstr /I hotspot > nul
-if not errorlevel == 1 (
- set "JAVA_OPTS=%JAVA_OPTS% -server"
-)
-
-rem Set Java platform if 64-Bit JVM used
-set JAVA_PLATFORM=
-"%JAVA%" -version 2>&1 | findstr /I "64-Bit ^| x86_64" > nul
-if not errorlevel == 1 (
- if /I "%PROCESSOR_ARCHITECTURE%"=="IA64" (set JAVA_PLATFORM=ia64
- ) else if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set JAVA_PLATFORM=x64
- ) else if /I "%PROCESSOR_ARCHITECTURE%"=="x64" (set JAVA_PLATFORM=x64
- ) else if /I "%PROCESSOR_ARCHITEW6432%"=="IA64" (set JAVA_PLATFORM=i64
- ) else if /I "%PROCESSOR_ARCHITEW6432%"=="AMD64" (set JAVA_PLATFORM=x64
- ) else (
- echo PROCESSOR_ARCHITECTURE is not set. Unexpected results may occur.
- echo Set PROCESSOR_ARCHITECTURE according to the 64-Bit JVM used.
- )
-)
-
-if "x%JAVA_PLATFORM%" == "x" set JAVA_PLATFORM=x86
-
-rem Add native to the PATH if present
-set JBOSS_NATIVE_LOC=
-if exist "%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%" (
- set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%"
-) else if exist "%JBOSS_HOME%\bin\native" (
- set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\native"
-)
-
-if not "x%JBOSS_NATIVE_HOME%" == "x" (
- set "PATH=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
- set JAVA_OPTS=%JAVA_OPTS% "-Djava.library.path=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
-)
-
-rem Find run.jar, or we can't continue
-
-if exist "%JBOSS_HOME%\bin\run.jar" (
- if "x%JAVAC_JAR%" == "x" (
- set "RUNJAR=%JAVAC_JAR%;%JBOSS_HOME%\bin\run.jar"
- ) else (
- set "RUNJAR=%JBOSS_HOME%\bin\run.jar"
- )
-) else (
- echo Could not locate "%JBOSS_HOME%\bin\run.jar".
- echo Please check that you are in the bin directory when running this script.
- goto END
-)
-
-rem If JBOSS_CLASSPATH empty, don't include it, as this will
-rem result in including the local directory in the classpath, which makes
-rem error tracking harder.
-if "x%JBOSS_CLASSPATH%" == "x" (
- set "RUN_CLASSPATH=%RUNJAR%"
-) else (
- set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%"
-)
-
-set JBOSS_CLASSPATH=%RUN_CLASSPATH%
-
-rem Setup JBoss specific properties
-rem JVM memory allocation pool parameters. Modify as appropriate.
-set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=256m
-
-rem Warn when resolving remote XML dtd/schemas
-set JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true
-
-rem With Sun JVMs reduce the RMI GCs to once per hour
-set JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
-
-rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.
-rem set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
-
-rem Setup the java endorsed dirs
-set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed
-
-echo ===============================================================================
-echo.
-echo JBoss Bootstrap Environment
-echo.
-echo JBOSS_HOME: %JBOSS_HOME%
-echo.
-echo JAVA: %JAVA%
-echo.
-echo JAVA_OPTS: %JAVA_OPTS%
-echo.
-echo CLASSPATH: %JBOSS_CLASSPATH%
-echo.
-echo ===============================================================================
-echo.
-
-:RESTART
-"%JAVA%" %JAVA_OPTS% ^
- -Djava.endorsed.dirs="%JBOSS_ENDORSED_DIRS%" ^
- -classpath "%JBOSS_CLASSPATH%" ^
- org.jboss.Main %*
-
-if ERRORLEVEL 10 goto RESTART
-
-:END
-if "x%NOPAUSE%" == "x" pause
-
-:END_NO_PAUSE
+ at echo off
+rem -------------------------------------------------------------------------
+rem JBoss Bootstrap Script for Windows
+rem -------------------------------------------------------------------------
+
+rem $Id: run.bat 63250 2007-05-30 13:22:21Z dimitris at jboss.org $
+
+ at if not "%ECHO%" == "" echo %ECHO%
+ at if "%OS%" == "Windows_NT" setlocal
+
+if "%OS%" == "Windows_NT" (
+ set "DIRNAME=%~dp0%"
+) else (
+ set DIRNAME=.\
+)
+
+pushd %DIRNAME%..
+if "x%JBOSS_HOME%" == "x" (
+ set "JBOSS_HOME=%CD%"
+)
+popd
+
+set DIRNAME=
+
+if "%OS%" == "Windows_NT" (
+ set "PROGNAME=%~nx0%"
+) else (
+ set "PROGNAME=run.bat"
+)
+
+if "x%JAVA_OPTS%" == "x" (
+ set "JAVA_OPTS=-Dprogram.name=%PROGNAME%"
+) else (
+ set "JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%"
+)
+
+if "x%JAVA_HOME%" == "x" (
+ set JAVA=java
+ echo JAVA_HOME is not set. Unexpected results may occur.
+ echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
+) else (
+ set "JAVA=%JAVA_HOME%\bin\java"
+ if exist "%JAVA_HOME%\lib\tools.jar" (
+ set "JAVAC_JAR=%JAVA_HOME%\lib\tools.jar"
+ )
+)
+
+rem Add -server to the JVM options, if supported
+"%JAVA%" -server -version 2>&1 | findstr /I hotspot > nul
+if not errorlevel == 1 (
+ set "JAVA_OPTS=%JAVA_OPTS% -server"
+)
+
+rem Set Java platform if 64-Bit JVM used
+set JAVA_PLATFORM=
+"%JAVA%" -version 2>&1 | findstr /I "64-Bit ^| x86_64" > nul
+if not errorlevel == 1 (
+ if /I "%PROCESSOR_ARCHITECTURE%"=="IA64" (set JAVA_PLATFORM=ia64
+ ) else if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" (set JAVA_PLATFORM=x64
+ ) else if /I "%PROCESSOR_ARCHITECTURE%"=="x64" (set JAVA_PLATFORM=x64
+ ) else if /I "%PROCESSOR_ARCHITEW6432%"=="IA64" (set JAVA_PLATFORM=i64
+ ) else if /I "%PROCESSOR_ARCHITEW6432%"=="AMD64" (set JAVA_PLATFORM=x64
+ ) else (
+ echo PROCESSOR_ARCHITECTURE is not set. Unexpected results may occur.
+ echo Set PROCESSOR_ARCHITECTURE according to the 64-Bit JVM used.
+ )
+)
+
+if "x%JAVA_PLATFORM%" == "x" set JAVA_PLATFORM=x86
+
+rem Add native to the PATH if present
+set JBOSS_NATIVE_LOC=
+if exist "%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%" (
+ set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\META-INF\lib\windows-%JAVA_PLATFORM%"
+) else if exist "%JBOSS_HOME%\bin\native" (
+ set "JBOSS_NATIVE_HOME=%JBOSS_HOME%\bin\native"
+)
+
+if not "x%JBOSS_NATIVE_HOME%" == "x" (
+ set "PATH=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
+ set JAVA_OPTS=%JAVA_OPTS% "-Djava.library.path=%JBOSS_NATIVE_HOME%;%PATH%;%JBOSS_HOME%\bin"
+)
+
+rem Find run.jar, or we can't continue
+
+if exist "%JBOSS_HOME%\bin\run.jar" (
+ if "x%JAVAC_JAR%" == "x" (
+ set "RUNJAR=%JAVAC_JAR%;%JBOSS_HOME%\bin\run.jar"
+ ) else (
+ set "RUNJAR=%JBOSS_HOME%\bin\run.jar"
+ )
+) else (
+ echo Could not locate "%JBOSS_HOME%\bin\run.jar".
+ echo Please check that you are in the bin directory when running this script.
+ goto END
+)
+
+rem If JBOSS_CLASSPATH empty, don't include it, as this will
+rem result in including the local directory in the classpath, which makes
+rem error tracking harder.
+if "x%JBOSS_CLASSPATH%" == "x" (
+ set "RUN_CLASSPATH=%RUNJAR%"
+) else (
+ set "RUN_CLASSPATH=%JBOSS_CLASSPATH%;%RUNJAR%"
+)
+
+set JBOSS_CLASSPATH=%RUN_CLASSPATH%
+
+rem Setup JBoss specific properties
+rem JVM memory allocation pool parameters. Modify as appropriate.
+set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=256m
+
+rem Warn when resolving remote XML dtd/schemas
+set JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true
+
+rem With Sun JVMs reduce the RMI GCs to once per hour
+set JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
+
+rem JPDA options. Uncomment and modify as appropriate to enable remote debugging.
+rem set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
+
+rem Setup the java endorsed dirs
+set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed
+
+echo ===============================================================================
+echo.
+echo JBoss Bootstrap Environment
+echo.
+echo JBOSS_HOME: %JBOSS_HOME%
+echo.
+echo JAVA: %JAVA%
+echo.
+echo JAVA_OPTS: %JAVA_OPTS%
+echo.
+echo CLASSPATH: %JBOSS_CLASSPATH%
+echo.
+echo ===============================================================================
+echo.
+
+:RESTART
+"%JAVA%" %JAVA_OPTS% ^
+ -Djava.endorsed.dirs="%JBOSS_ENDORSED_DIRS%" ^
+ -classpath "%JBOSS_CLASSPATH%" ^
+ org.jboss.Main %*
+
+if ERRORLEVEL 10 goto RESTART
+
+:END
+if "x%NOPAUSE%" == "x" pause
+
+:END_NO_PAUSE
Property changes on: trunk/main/src/bin/run.bat
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/bin/run.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/main/src/main/org/jboss/Main.java
===================================================================
--- trunk/main/src/main/org/jboss/Main.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/Main.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,581 +1,581 @@
-/*
- * 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;
-
-import gnu.getopt.Getopt;
-import gnu.getopt.LongOpt;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.bootstrap.spi.util.ServerConfigUtil;
-import org.jboss.system.server.ServerLoader;
-
-/**
- * Provides a command line interface to start the JBoss server.
- *
- * <p>
- * To enable debug or trace messages durring boot change the Log4j
- * configuration to use either <tt>log4j-debug.properties</tt>
- * <tt>log4j-trace.properties</tt> by setting the system property
- * <tt>log4j.configuration</tt>:
- *
- * <pre>
- * ./run.sh -Dlog4j.configuration=log4j-debug.properties
- * </pre>
- * TODO: Should jdk logging be the default
- *
- * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision: 63730 $
- */
-public class Main
-{
- /** EDU.oswego.cs.dl.util.concurrent */
- private String concurrentLib = "concurrent.jar";
-
- /** A URL for obtaining microkernel patches */
- private URL bootURL;
-
- /** Extra jars from the /lib location that are added to the start of the boot
- classpath. This can be used to override jboss /lib boot classes.
- */
- private List<String> bootLibraries = new LinkedList<String>();
-
- /** Extra libraries to load the server with .*/
- private List<String> extraLibraries = new LinkedList<String>();
-
- /** Extra classpath URLS to load the server with .*/
- private List<URL> extraClasspath = new LinkedList<URL>();
-
- /**
- * 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 Server server;
-
- /**
- * Explicit constructor.
- */
- public Main()
- {
- super();
- }
-
- /**
- * Access the booted server.
- * @return the Server instance.
- */
- public Server getServer()
- {
- return server;
- }
-
- /**
- * Boot up JBoss.
- *
- * @param args The command line arguments.
- *
- * @throws Exception Failed to boot.
- */
- public void boot(final String[] args) throws Exception
- {
- // First process the command line to pickup custom props/settings
- processCommandLine(args);
-
- // Auto set HOME_DIR to ../bin/run.jar if not set
- String homeDir = props.getProperty(ServerConfig.HOME_DIR);
- if (homeDir == null)
- {
- 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();
- }
- props.setProperty(ServerConfig.HOME_DIR, homeDir);
-
- // Setup HOME_URL too, ServerLoader needs this
- String homeURL = props.getProperty(ServerConfig.HOME_URL);
- if (homeURL == null)
- {
- File file = new File(homeDir);
- homeURL = file.toURI().toURL().toString();
- props.setProperty(ServerConfig.HOME_URL, homeURL);
- }
-
- // Load the server instance
- 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.
- */
- if (bootURL != null)
- {
- if (bootURL.getProtocol().equals("file"))
- {
- File dir = new File(bootURL.getFile());
- if (dir.exists())
- {
- // Add the local file patch directory
- loader.addURL(dir.toURL());
-
- // Add the contents of the directory too
- File[] jars = dir.listFiles(new JarFilter());
-
- for (int j = 0; jars != null && j < jars.length; j++)
- {
- loader.addURL(jars[j].getCanonicalFile().toURL());
- }
- }
- }
- else
- {
- loader.addURL(bootURL);
- }
- }
-
- // Add any extra libraries
- for (int i = 0; i < bootLibraries.size(); i++)
- {
- loader.addLibrary(bootLibraries.get(i));
- }
-
- // Add the jars from the endorsed dir
- loader.addEndorsedJars();
-
- // jmx UnifiedLoaderRepository needs a concurrent class...
- loader.addLibrary(concurrentLib);
-
- // Add any extra libraries after the boot libs
- for (int i = 0; i < extraLibraries.size(); i++)
- {
- loader.addLibrary(extraLibraries.get(i));
- }
-
- // Add any extra classapth URLs
- for (int i = 0; i < extraClasspath.size(); i++)
- {
- loader.addURL(extraClasspath.get(i));
- }
-
- // Load the server
- ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
- server = loader.load(parentCL);
-
- // Initialize the server
- server.init(props);
-
- // Start 'er up mate!
- server.start();
- }
-
- /**
- * Shutdown the booted Server instance.
- *
- */
- public void shutdown()
- {
- server.shutdown();
- }
-
- private URL makeURL(String urlspec) throws MalformedURLException
- {
- urlspec = urlspec.trim();
-
- URL url;
-
- try
- {
- url = new URL(urlspec);
- if (url.getProtocol().equals("file"))
- {
- // make sure the file is absolute & canonical file url
- File file = new File(url.getFile()).getCanonicalFile();
- url = file.toURL();
- }
- }
- catch (Exception e)
- {
- // make sure we have a absolute & canonical file url
- try
- {
- File file = new File(urlspec).getCanonicalFile();
- url = file.toURL();
- }
- catch (Exception n)
- {
- throw new MalformedURLException(n.toString());
- }
- }
-
- return url;
- }
-
- /** Process the command line... */
- private void processCommandLine(final String[] args) throws Exception
- {
- // set this from a system property or default to jboss
- String programName = System.getProperty("program.name", "jboss");
- String sopts = "-:hD:d:p:n:c:Vj::B:L:C:P:b:g:u:m:l:";
- LongOpt[] lopts =
- {
- new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
- new LongOpt("bootdir", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
- new LongOpt("patchdir", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
- new LongOpt("netboot", LongOpt.REQUIRED_ARGUMENT, null, 'n'),
- new LongOpt("configuration", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
- new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V'),
- new LongOpt("jaxp", LongOpt.REQUIRED_ARGUMENT, null, 'j'),
- new LongOpt("bootlib", LongOpt.REQUIRED_ARGUMENT, null, 'B'),
- new LongOpt("library", LongOpt.REQUIRED_ARGUMENT, null, 'L'),
- new LongOpt("classpath", LongOpt.REQUIRED_ARGUMENT, null, 'C'),
- new LongOpt("properties", LongOpt.REQUIRED_ARGUMENT, null, 'P'),
- new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
- new LongOpt("partition", LongOpt.REQUIRED_ARGUMENT, null, 'g'),
- new LongOpt("udp", LongOpt.REQUIRED_ARGUMENT, null, 'u'),
- new LongOpt("mcast_port", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
- new LongOpt("log", LongOpt.REQUIRED_ARGUMENT, null, 'l'),
- };
-
- Getopt getopt = new Getopt(programName, args, sopts, lopts);
- int code;
- String arg;
- props.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
- System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
- while ((code = getopt.getopt()) != -1)
- {
- switch (code)
- {
- case ':':
- case '?':
- // for now both of these should exit with error status
- System.exit(1);
- break; // for completeness
-
- case 1:
- // this will catch non-option arguments
- // (which we don't currently care about)
- System.err.println(programName +
- ": unused non-option argument: " +
- getopt.getOptarg());
- break; // for completeness
-
- case 'h':
- // show command line help
- System.out.println("usage: " + programName + " [options]");
- System.out.println();
- System.out.println("options:");
- System.out.println(" -h, --help Show this help message");
- System.out.println(" -V, --version Show version information");
- System.out.println(" -- Stop processing options");
- System.out.println(" -D<name>[=<value>] Set a system property");
- System.out.println(" -d, --bootdir=<dir> Set the boot patch directory; Must be absolute or url");
- System.out.println(" -p, --patchdir=<dir> Set the patch directory; Must be absolute or url");
- System.out.println(" -n, --netboot=<url> Boot from net with the given url as base");
- System.out.println(" -c, --configuration=<name> Set the server configuration name");
- System.out.println(" -B, --bootlib=<filename> Add an extra library to the front bootclasspath");
- System.out.println(" -L, --library=<filename> Add an extra library to the loaders classpath");
- System.out.println(" -C, --classpath=<url> Add an extra url to the loaders classpath");
- System.out.println(" -P, --properties=<url> Load system properties from the given url");
- System.out.println(" -b, --host=<host or ip> Bind address for all JBoss services");
- System.out.println(" -g, --partition=<name> HA Partition name (default=DefaultDomain)");
- System.out.println(" -m, --mcast_port=<ip> UDP multicast port; Only used by JGroups multiplexer");
- System.out.println(" -u, --udp=<ip> UDP multicast address");
- System.out.println(" -l, --log=<log4j|jdk> Specify the logger plugin type");
- System.out.println();
- System.exit(0);
- break; // for completeness
-
- case 'D':
- {
- // set a system property
- arg = getopt.getOptarg();
- String name, value;
- int i = arg.indexOf("=");
- if (i == -1)
- {
- name = arg;
- value = "true";
- }
- else
- {
- name = arg.substring(0, i);
- value = arg.substring(i + 1, arg.length());
- }
- System.setProperty(name, value);
- // Ensure setting the old bind.address property also sets the new
- // jgroups.bind_addr property, otherwise jgroups may ignore it
- if ("bind.address".equals(name))
- {
- // Wildcard address is not valid for JGroups
- String addr = ServerConfigUtil.fixRemoteAddress(value);
- System.setProperty("jgroups.bind_addr", addr);
- }
- else if ("jgroups.bind_addr".equals(name))
- {
- // Wildcard address is not valid for JGroups
- String addr = ServerConfigUtil.fixRemoteAddress(value);
- System.setProperty("jgroups.bind_addr", addr);
- }
- break;
- }
-
- case 'd':
- // set the boot patch URL
- bootURL = makeURL(getopt.getOptarg());
- break;
-
- case 'p':
- {
- // set the patch URL
- URL patchURL = makeURL(getopt.getOptarg());
- props.put(ServerConfig.PATCH_URL, patchURL.toString());
-
- break;
- }
-
- case 'n':
- // set the net boot url
- arg = getopt.getOptarg();
-
- // make sure there is a trailing '/'
- if (!arg.endsWith("/")) arg += "/";
-
- props.put(ServerConfig.HOME_URL, new URL(arg).toString());
- break;
-
- case 'c':
- // set the server name
- arg = getopt.getOptarg();
- props.put(ServerConfig.SERVER_NAME, arg);
- break;
-
- case 'V':
- {
- // Package information for org.jboss
- Package jbossPackage = Package.getPackage("org.jboss");
-
- // show version information
- System.out.println("JBoss " + jbossPackage.getImplementationVersion());
- System.out.println();
- System.out.println("Distributable under LGPL license.");
- System.out.println("See terms of license at gnu.org.");
- System.out.println();
- System.exit(0);
- break; // for completness
- }
-
- case 'j':
- // Show an error and exit
- System.err.println(programName + ": option '-j, --jaxp' no longer supported");
- System.exit(1);
- break; // for completness
-
- case 'B':
- arg = getopt.getOptarg();
- bootLibraries.add(arg);
- break;
-
- case 'L':
- arg = getopt.getOptarg();
- extraLibraries.add(arg);
- break;
-
- case 'C':
- {
- URL url = makeURL(getopt.getOptarg());
- extraClasspath.add(url);
- break;
- }
-
- case 'P':
- {
- // Set system properties from url/file
- URL url = makeURL(getopt.getOptarg());
- Properties props = System.getProperties();
- props.load(url.openConnection().getInputStream());
- break;
- }
- case 'b':
- arg = getopt.getOptarg();
- props.put(ServerConfig.SERVER_BIND_ADDRESS, arg);
- System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, arg);
- // used by JGroups; only set if not set via -D so users
- // can use a different interface for cluster communication
- // There are 2 versions of this property, deprecated bind.address
- // and the new version, jgroups.bind_addr
- String bindAddress = System.getProperty("bind.address");
- if (bindAddress == null)
- {
- // Wildcard address is not valid for JGroups
- bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
- System.setProperty("bind.address", bindAddress);
- }
- bindAddress = System.getProperty("jgroups.bind_addr");
- if (bindAddress == null)
- {
- // Wildcard address is not valid for JGroups
- bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
- System.setProperty("jgroups.bind_addr", bindAddress);
- }
-
- // Set the java.rmi.server.hostname if not set
- String rmiHost = System.getProperty("java.rmi.server.hostname");
- if( rmiHost == null )
- {
- rmiHost = ServerConfigUtil.fixRemoteAddress(arg);
- System.setProperty("java.rmi.server.hostname", rmiHost);
- }
- break;
-
- case 'g':
- arg = getopt.getOptarg();
- props.put(ServerConfig.PARTITION_NAME_PROPERTY, arg);
- System.setProperty(ServerConfig.PARTITION_NAME_PROPERTY, arg);
- break;
-
- case 'u':
- arg = getopt.getOptarg();
- props.put(ServerConfig.PARTITION_UDP_PROPERTY, arg);
- System.setProperty(ServerConfig.PARTITION_UDP_PROPERTY, arg);
- // the new jgroups property name
- System.setProperty("jgroups.udp.mcast_addr", arg);
- break;
-
- case 'm':
- arg = getopt.getOptarg();
- props.put(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
- System.setProperty(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
- break;
-
- case 'l':
- {
- arg = getopt.getOptarg();
- String logPlugin = arg;
- if( arg.equalsIgnoreCase("log4j") )
- logPlugin = "org.jboss.logging.Log4jLoggerPlugin";
- else if( arg.equalsIgnoreCase("jdk") )
- {
- logPlugin = "org.jboss.logging.JDK14LoggerPlugin";
- String name = System.getProperty("java.util.logging.manager");
- if (name == null) {
- // Also override the jdk LogManager
- System.setProperty("java.util.logging.manager",
- "org.jboss.logging.jdk.JDKLogManager");
- }
- }
- System.setProperty("org.jboss.logging.Logger.pluginClass", logPlugin);
- break;
- }
-
- default:
- // this should not happen,
- // if it does throw an error so we know about it
- throw new Error("unhandled option code: " + code);
- }
- }
-
- // Fix up other bind addresses
- String bindAddress = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
- if (System.getProperty("java.rmi.server.hostname") == null)
- System.setProperty("java.rmi.server.hostname", bindAddress);
- if (System.getProperty("jgroups.bind_addr") == null)
- System.setProperty("jgroups.bind_addr", bindAddress);
-
- // Enable jboss.vfs.forceCopy by default, if unspecified
- if (System.getProperty("jboss.vfs.forceCopy") == null)
- System.setProperty("jboss.vfs.forceCopy", "true");
- }
-
- /**
- * This is where the magic begins.
- *
- * <P>Starts up inside of a "jboss" thread group to allow better
- * identification of JBoss threads.
- *
- * @param args The command line arguments.
- * @throws Exception for any error
- */
- public static void main(final String[] args) throws Exception
- {
- Runnable worker = new Runnable() {
- public void run()
- {
- try
- {
- Main main = new Main();
- main.boot(args);
- }
- catch (Exception e)
- {
- System.err.println("Failed to boot JBoss:");
- e.printStackTrace();
- }
- }
-
- };
-
- ThreadGroup threads = new ThreadGroup("jboss");
- new Thread(threads, worker, "main").start();
- }
-
- /**
- * This method is here so that if JBoss is running under
- * Alexandria (An NT Service Installer), Alexandria can shutdown
- * the system down correctly.
- *
- * @param argv the arguments
- */
- public static void systemExit(String argv[])
- {
- System.exit(0);
- }
-
- static class JarFilter implements FilenameFilter
- {
- public boolean accept(File dir, String name)
- {
- return name.endsWith(".jar");
- }
- }
-}
+/*
+ * 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;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.bootstrap.spi.util.ServerConfigUtil;
+import org.jboss.system.server.ServerLoader;
+
+/**
+ * Provides a command line interface to start the JBoss server.
+ *
+ * <p>
+ * To enable debug or trace messages durring boot change the Log4j
+ * configuration to use either <tt>log4j-debug.properties</tt>
+ * <tt>log4j-trace.properties</tt> by setting the system property
+ * <tt>log4j.configuration</tt>:
+ *
+ * <pre>
+ * ./run.sh -Dlog4j.configuration=log4j-debug.properties
+ * </pre>
+ * TODO: Should jdk logging be the default
+ *
+ * @author <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 63730 $
+ */
+public class Main
+{
+ /** EDU.oswego.cs.dl.util.concurrent */
+ private String concurrentLib = "concurrent.jar";
+
+ /** A URL for obtaining microkernel patches */
+ private URL bootURL;
+
+ /** Extra jars from the /lib location that are added to the start of the boot
+ classpath. This can be used to override jboss /lib boot classes.
+ */
+ private List<String> bootLibraries = new LinkedList<String>();
+
+ /** Extra libraries to load the server with .*/
+ private List<String> extraLibraries = new LinkedList<String>();
+
+ /** Extra classpath URLS to load the server with .*/
+ private List<URL> extraClasspath = new LinkedList<URL>();
+
+ /**
+ * 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 Server server;
+
+ /**
+ * Explicit constructor.
+ */
+ public Main()
+ {
+ super();
+ }
+
+ /**
+ * Access the booted server.
+ * @return the Server instance.
+ */
+ public Server getServer()
+ {
+ return server;
+ }
+
+ /**
+ * Boot up JBoss.
+ *
+ * @param args The command line arguments.
+ *
+ * @throws Exception Failed to boot.
+ */
+ public void boot(final String[] args) throws Exception
+ {
+ // First process the command line to pickup custom props/settings
+ processCommandLine(args);
+
+ // Auto set HOME_DIR to ../bin/run.jar if not set
+ String homeDir = props.getProperty(ServerConfig.HOME_DIR);
+ if (homeDir == null)
+ {
+ 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();
+ }
+ props.setProperty(ServerConfig.HOME_DIR, homeDir);
+
+ // Setup HOME_URL too, ServerLoader needs this
+ String homeURL = props.getProperty(ServerConfig.HOME_URL);
+ if (homeURL == null)
+ {
+ File file = new File(homeDir);
+ homeURL = file.toURI().toURL().toString();
+ props.setProperty(ServerConfig.HOME_URL, homeURL);
+ }
+
+ // Load the server instance
+ 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.
+ */
+ if (bootURL != null)
+ {
+ if (bootURL.getProtocol().equals("file"))
+ {
+ File dir = new File(bootURL.getFile());
+ if (dir.exists())
+ {
+ // Add the local file patch directory
+ loader.addURL(dir.toURL());
+
+ // Add the contents of the directory too
+ File[] jars = dir.listFiles(new JarFilter());
+
+ for (int j = 0; jars != null && j < jars.length; j++)
+ {
+ loader.addURL(jars[j].getCanonicalFile().toURL());
+ }
+ }
+ }
+ else
+ {
+ loader.addURL(bootURL);
+ }
+ }
+
+ // Add any extra libraries
+ for (int i = 0; i < bootLibraries.size(); i++)
+ {
+ loader.addLibrary(bootLibraries.get(i));
+ }
+
+ // Add the jars from the endorsed dir
+ loader.addEndorsedJars();
+
+ // jmx UnifiedLoaderRepository needs a concurrent class...
+ loader.addLibrary(concurrentLib);
+
+ // Add any extra libraries after the boot libs
+ for (int i = 0; i < extraLibraries.size(); i++)
+ {
+ loader.addLibrary(extraLibraries.get(i));
+ }
+
+ // Add any extra classapth URLs
+ for (int i = 0; i < extraClasspath.size(); i++)
+ {
+ loader.addURL(extraClasspath.get(i));
+ }
+
+ // Load the server
+ ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
+ server = loader.load(parentCL);
+
+ // Initialize the server
+ server.init(props);
+
+ // Start 'er up mate!
+ server.start();
+ }
+
+ /**
+ * Shutdown the booted Server instance.
+ *
+ */
+ public void shutdown()
+ {
+ server.shutdown();
+ }
+
+ private URL makeURL(String urlspec) throws MalformedURLException
+ {
+ urlspec = urlspec.trim();
+
+ URL url;
+
+ try
+ {
+ url = new URL(urlspec);
+ if (url.getProtocol().equals("file"))
+ {
+ // make sure the file is absolute & canonical file url
+ File file = new File(url.getFile()).getCanonicalFile();
+ url = file.toURL();
+ }
+ }
+ catch (Exception e)
+ {
+ // make sure we have a absolute & canonical file url
+ try
+ {
+ File file = new File(urlspec).getCanonicalFile();
+ url = file.toURL();
+ }
+ catch (Exception n)
+ {
+ throw new MalformedURLException(n.toString());
+ }
+ }
+
+ return url;
+ }
+
+ /** Process the command line... */
+ private void processCommandLine(final String[] args) throws Exception
+ {
+ // set this from a system property or default to jboss
+ String programName = System.getProperty("program.name", "jboss");
+ String sopts = "-:hD:d:p:n:c:Vj::B:L:C:P:b:g:u:m:l:";
+ LongOpt[] lopts =
+ {
+ new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+ new LongOpt("bootdir", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
+ new LongOpt("patchdir", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
+ new LongOpt("netboot", LongOpt.REQUIRED_ARGUMENT, null, 'n'),
+ new LongOpt("configuration", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+ new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V'),
+ new LongOpt("jaxp", LongOpt.REQUIRED_ARGUMENT, null, 'j'),
+ new LongOpt("bootlib", LongOpt.REQUIRED_ARGUMENT, null, 'B'),
+ new LongOpt("library", LongOpt.REQUIRED_ARGUMENT, null, 'L'),
+ new LongOpt("classpath", LongOpt.REQUIRED_ARGUMENT, null, 'C'),
+ new LongOpt("properties", LongOpt.REQUIRED_ARGUMENT, null, 'P'),
+ new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
+ new LongOpt("partition", LongOpt.REQUIRED_ARGUMENT, null, 'g'),
+ new LongOpt("udp", LongOpt.REQUIRED_ARGUMENT, null, 'u'),
+ new LongOpt("mcast_port", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
+ new LongOpt("log", LongOpt.REQUIRED_ARGUMENT, null, 'l'),
+ };
+
+ Getopt getopt = new Getopt(programName, args, sopts, lopts);
+ int code;
+ String arg;
+ props.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
+ System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, "127.0.0.1");
+ while ((code = getopt.getopt()) != -1)
+ {
+ switch (code)
+ {
+ case ':':
+ case '?':
+ // for now both of these should exit with error status
+ System.exit(1);
+ break; // for completeness
+
+ case 1:
+ // this will catch non-option arguments
+ // (which we don't currently care about)
+ System.err.println(programName +
+ ": unused non-option argument: " +
+ getopt.getOptarg());
+ break; // for completeness
+
+ case 'h':
+ // show command line help
+ System.out.println("usage: " + programName + " [options]");
+ System.out.println();
+ System.out.println("options:");
+ System.out.println(" -h, --help Show this help message");
+ System.out.println(" -V, --version Show version information");
+ System.out.println(" -- Stop processing options");
+ System.out.println(" -D<name>[=<value>] Set a system property");
+ System.out.println(" -d, --bootdir=<dir> Set the boot patch directory; Must be absolute or url");
+ System.out.println(" -p, --patchdir=<dir> Set the patch directory; Must be absolute or url");
+ System.out.println(" -n, --netboot=<url> Boot from net with the given url as base");
+ System.out.println(" -c, --configuration=<name> Set the server configuration name");
+ System.out.println(" -B, --bootlib=<filename> Add an extra library to the front bootclasspath");
+ System.out.println(" -L, --library=<filename> Add an extra library to the loaders classpath");
+ System.out.println(" -C, --classpath=<url> Add an extra url to the loaders classpath");
+ System.out.println(" -P, --properties=<url> Load system properties from the given url");
+ System.out.println(" -b, --host=<host or ip> Bind address for all JBoss services");
+ System.out.println(" -g, --partition=<name> HA Partition name (default=DefaultDomain)");
+ System.out.println(" -m, --mcast_port=<ip> UDP multicast port; Only used by JGroups multiplexer");
+ System.out.println(" -u, --udp=<ip> UDP multicast address");
+ System.out.println(" -l, --log=<log4j|jdk> Specify the logger plugin type");
+ System.out.println();
+ System.exit(0);
+ break; // for completeness
+
+ case 'D':
+ {
+ // set a system property
+ arg = getopt.getOptarg();
+ String name, value;
+ int i = arg.indexOf("=");
+ if (i == -1)
+ {
+ name = arg;
+ value = "true";
+ }
+ else
+ {
+ name = arg.substring(0, i);
+ value = arg.substring(i + 1, arg.length());
+ }
+ System.setProperty(name, value);
+ // Ensure setting the old bind.address property also sets the new
+ // jgroups.bind_addr property, otherwise jgroups may ignore it
+ if ("bind.address".equals(name))
+ {
+ // Wildcard address is not valid for JGroups
+ String addr = ServerConfigUtil.fixRemoteAddress(value);
+ System.setProperty("jgroups.bind_addr", addr);
+ }
+ else if ("jgroups.bind_addr".equals(name))
+ {
+ // Wildcard address is not valid for JGroups
+ String addr = ServerConfigUtil.fixRemoteAddress(value);
+ System.setProperty("jgroups.bind_addr", addr);
+ }
+ break;
+ }
+
+ case 'd':
+ // set the boot patch URL
+ bootURL = makeURL(getopt.getOptarg());
+ break;
+
+ case 'p':
+ {
+ // set the patch URL
+ URL patchURL = makeURL(getopt.getOptarg());
+ props.put(ServerConfig.PATCH_URL, patchURL.toString());
+
+ break;
+ }
+
+ case 'n':
+ // set the net boot url
+ arg = getopt.getOptarg();
+
+ // make sure there is a trailing '/'
+ if (!arg.endsWith("/")) arg += "/";
+
+ props.put(ServerConfig.HOME_URL, new URL(arg).toString());
+ break;
+
+ case 'c':
+ // set the server name
+ arg = getopt.getOptarg();
+ props.put(ServerConfig.SERVER_NAME, arg);
+ break;
+
+ case 'V':
+ {
+ // Package information for org.jboss
+ Package jbossPackage = Package.getPackage("org.jboss");
+
+ // show version information
+ System.out.println("JBoss " + jbossPackage.getImplementationVersion());
+ System.out.println();
+ System.out.println("Distributable under LGPL license.");
+ System.out.println("See terms of license at gnu.org.");
+ System.out.println();
+ System.exit(0);
+ break; // for completness
+ }
+
+ case 'j':
+ // Show an error and exit
+ System.err.println(programName + ": option '-j, --jaxp' no longer supported");
+ System.exit(1);
+ break; // for completness
+
+ case 'B':
+ arg = getopt.getOptarg();
+ bootLibraries.add(arg);
+ break;
+
+ case 'L':
+ arg = getopt.getOptarg();
+ extraLibraries.add(arg);
+ break;
+
+ case 'C':
+ {
+ URL url = makeURL(getopt.getOptarg());
+ extraClasspath.add(url);
+ break;
+ }
+
+ case 'P':
+ {
+ // Set system properties from url/file
+ URL url = makeURL(getopt.getOptarg());
+ Properties props = System.getProperties();
+ props.load(url.openConnection().getInputStream());
+ break;
+ }
+ case 'b':
+ arg = getopt.getOptarg();
+ props.put(ServerConfig.SERVER_BIND_ADDRESS, arg);
+ System.setProperty(ServerConfig.SERVER_BIND_ADDRESS, arg);
+ // used by JGroups; only set if not set via -D so users
+ // can use a different interface for cluster communication
+ // There are 2 versions of this property, deprecated bind.address
+ // and the new version, jgroups.bind_addr
+ String bindAddress = System.getProperty("bind.address");
+ if (bindAddress == null)
+ {
+ // Wildcard address is not valid for JGroups
+ bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
+ System.setProperty("bind.address", bindAddress);
+ }
+ bindAddress = System.getProperty("jgroups.bind_addr");
+ if (bindAddress == null)
+ {
+ // Wildcard address is not valid for JGroups
+ bindAddress = ServerConfigUtil.fixRemoteAddress(arg);
+ System.setProperty("jgroups.bind_addr", bindAddress);
+ }
+
+ // Set the java.rmi.server.hostname if not set
+ String rmiHost = System.getProperty("java.rmi.server.hostname");
+ if( rmiHost == null )
+ {
+ rmiHost = ServerConfigUtil.fixRemoteAddress(arg);
+ System.setProperty("java.rmi.server.hostname", rmiHost);
+ }
+ break;
+
+ case 'g':
+ arg = getopt.getOptarg();
+ props.put(ServerConfig.PARTITION_NAME_PROPERTY, arg);
+ System.setProperty(ServerConfig.PARTITION_NAME_PROPERTY, arg);
+ break;
+
+ case 'u':
+ arg = getopt.getOptarg();
+ props.put(ServerConfig.PARTITION_UDP_PROPERTY, arg);
+ System.setProperty(ServerConfig.PARTITION_UDP_PROPERTY, arg);
+ // the new jgroups property name
+ System.setProperty("jgroups.udp.mcast_addr", arg);
+ break;
+
+ case 'm':
+ arg = getopt.getOptarg();
+ props.put(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
+ System.setProperty(ServerConfig.PARTITION_UDP_PORT_PROPERTY, arg);
+ break;
+
+ case 'l':
+ {
+ arg = getopt.getOptarg();
+ String logPlugin = arg;
+ if( arg.equalsIgnoreCase("log4j") )
+ logPlugin = "org.jboss.logging.Log4jLoggerPlugin";
+ else if( arg.equalsIgnoreCase("jdk") )
+ {
+ logPlugin = "org.jboss.logging.JDK14LoggerPlugin";
+ String name = System.getProperty("java.util.logging.manager");
+ if (name == null) {
+ // Also override the jdk LogManager
+ System.setProperty("java.util.logging.manager",
+ "org.jboss.logging.jdk.JDKLogManager");
+ }
+ }
+ System.setProperty("org.jboss.logging.Logger.pluginClass", logPlugin);
+ break;
+ }
+
+ default:
+ // this should not happen,
+ // if it does throw an error so we know about it
+ throw new Error("unhandled option code: " + code);
+ }
+ }
+
+ // Fix up other bind addresses
+ String bindAddress = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
+ if (System.getProperty("java.rmi.server.hostname") == null)
+ System.setProperty("java.rmi.server.hostname", bindAddress);
+ if (System.getProperty("jgroups.bind_addr") == null)
+ System.setProperty("jgroups.bind_addr", bindAddress);
+
+ // Enable jboss.vfs.forceCopy by default, if unspecified
+ if (System.getProperty("jboss.vfs.forceCopy") == null)
+ System.setProperty("jboss.vfs.forceCopy", "true");
+ }
+
+ /**
+ * This is where the magic begins.
+ *
+ * <P>Starts up inside of a "jboss" thread group to allow better
+ * identification of JBoss threads.
+ *
+ * @param args The command line arguments.
+ * @throws Exception for any error
+ */
+ public static void main(final String[] args) throws Exception
+ {
+ Runnable worker = new Runnable() {
+ public void run()
+ {
+ try
+ {
+ Main main = new Main();
+ main.boot(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println("Failed to boot JBoss:");
+ e.printStackTrace();
+ }
+ }
+
+ };
+
+ ThreadGroup threads = new ThreadGroup("jboss");
+ new Thread(threads, worker, "main").start();
+ }
+
+ /**
+ * This method is here so that if JBoss is running under
+ * Alexandria (An NT Service Installer), Alexandria can shutdown
+ * the system down correctly.
+ *
+ * @param argv the arguments
+ */
+ public static void systemExit(String argv[])
+ {
+ System.exit(0);
+ }
+
+ static class JarFilter implements FilenameFilter
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.endsWith(".jar");
+ }
+ }
+}
Property changes on: trunk/main/src/main/org/jboss/Main.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/handlers/stub/vfs/Handler.java
===================================================================
--- trunk/main/src/main/org/jboss/handlers/stub/vfs/Handler.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/handlers/stub/vfs/Handler.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,46 +1,46 @@
-/*
- * 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.handlers.stub.vfs;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * VFS Handler Stub
- * @author David M Lloyd
- */
-public final class Handler extends URLStreamHandler
-{
-
- protected URLConnection openConnection(final URL u) throws IOException
- {
- return new URLConnection(u)
- {
- public void connect() throws IOException
- {
- throw new UnsupportedOperationException("connect()");
- }
- };
- }
+/*
+ * 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.handlers.stub.vfs;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * VFS Handler Stub
+ * @author David M Lloyd
+ */
+public final class Handler extends URLStreamHandler
+{
+
+ protected URLConnection openConnection(final URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ public void connect() throws IOException
+ {
+ throw new UnsupportedOperationException("connect()");
+ }
+ };
+ }
}
\ No newline at end of file
Property changes on: trunk/main/src/main/org/jboss/handlers/stub/vfs/Handler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/handlers/stub/vfsfile/Handler.java
===================================================================
--- trunk/main/src/main/org/jboss/handlers/stub/vfsfile/Handler.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/handlers/stub/vfsfile/Handler.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,45 +1,45 @@
-/*
- * 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.handlers.stub.vfsfile;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * VFS Handler Stub
- * @author David M Lloyd
- */
-public final class Handler extends URLStreamHandler
-{
- protected URLConnection openConnection(final URL u) throws IOException
- {
- return new URLConnection(u)
- {
- public void connect() throws IOException
- {
- throw new UnsupportedOperationException("connect()");
- }
- };
- }
+/*
+ * 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.handlers.stub.vfsfile;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * VFS Handler Stub
+ * @author David M Lloyd
+ */
+public final class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(final URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ public void connect() throws IOException
+ {
+ throw new UnsupportedOperationException("connect()");
+ }
+ };
+ }
}
\ No newline at end of file
Property changes on: trunk/main/src/main/org/jboss/handlers/stub/vfsfile/Handler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/handlers/stub/vfsjar/Handler.java
===================================================================
--- trunk/main/src/main/org/jboss/handlers/stub/vfsjar/Handler.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/handlers/stub/vfsjar/Handler.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,45 +1,45 @@
-/*
- * 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.handlers.stub.vfsjar;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * VFS Handler Stub
- * @author David M Lloyd
- */
-public final class Handler extends URLStreamHandler
-{
- protected URLConnection openConnection(final URL u) throws IOException
- {
- return new URLConnection(u)
- {
- public void connect() throws IOException
- {
- throw new UnsupportedOperationException("connect()");
- }
- };
- }
+/*
+ * 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.handlers.stub.vfsjar;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * VFS Handler Stub
+ * @author David M Lloyd
+ */
+public final class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(final URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ public void connect() throws IOException
+ {
+ throw new UnsupportedOperationException("connect()");
+ }
+ };
+ }
}
\ No newline at end of file
Property changes on: trunk/main/src/main/org/jboss/handlers/stub/vfsjar/Handler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/handlers/stub/vfsmemory/Handler.java
===================================================================
--- trunk/main/src/main/org/jboss/handlers/stub/vfsmemory/Handler.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/handlers/stub/vfsmemory/Handler.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,45 +1,45 @@
-/*
- * 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.handlers.stub.vfsmemory;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * VFS Handler Stub
- * @author David M Lloyd
- */
-public final class Handler extends URLStreamHandler
-{
- protected URLConnection openConnection(final URL u) throws IOException
- {
- return new URLConnection(u)
- {
- public void connect() throws IOException
- {
- throw new UnsupportedOperationException("connect()");
- }
- };
- }
+/*
+ * 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.handlers.stub.vfsmemory;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * VFS Handler Stub
+ * @author David M Lloyd
+ */
+public final class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(final URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ public void connect() throws IOException
+ {
+ throw new UnsupportedOperationException("connect()");
+ }
+ };
+ }
}
\ No newline at end of file
Property changes on: trunk/main/src/main/org/jboss/handlers/stub/vfsmemory/Handler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/handlers/stub/vfszip/Handler.java
===================================================================
--- trunk/main/src/main/org/jboss/handlers/stub/vfszip/Handler.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/handlers/stub/vfszip/Handler.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,45 +1,45 @@
-/*
- * 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.handlers.stub.vfszip;
-
-import java.net.URLStreamHandler;
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-
-/**
- * VFS Handler Stub
- * @author David M Lloyd
- */
-public final class Handler extends URLStreamHandler
-{
- protected URLConnection openConnection(final URL u) throws IOException
- {
- return new URLConnection(u)
- {
- public void connect() throws IOException
- {
- throw new UnsupportedOperationException("connect()");
- }
- };
- }
+/*
+ * 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.handlers.stub.vfszip;
+
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * VFS Handler Stub
+ * @author David M Lloyd
+ */
+public final class Handler extends URLStreamHandler
+{
+ protected URLConnection openConnection(final URL u) throws IOException
+ {
+ return new URLConnection(u)
+ {
+ public void connect() throws IOException
+ {
+ throw new UnsupportedOperationException("connect()");
+ }
+ };
+ }
}
\ No newline at end of file
Property changes on: trunk/main/src/main/org/jboss/handlers/stub/vfszip/Handler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/system/JBossRMIClassLoader.java
===================================================================
--- trunk/main/src/main/org/jboss/system/JBossRMIClassLoader.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/system/JBossRMIClassLoader.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,121 +1,121 @@
-/*
- * 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.system;
-
-import java.net.MalformedURLException;
-
-import java.rmi.server.RMIClassLoader;
-import java.rmi.server.RMIClassLoaderSpi;
-
-/**
- * An implementation of RMIClassLoaderSpi to workaround the
- * proxy ClassCastException problem in 1.4<p>
- *
- * <b>THIS IS A HACK!</b><p>
- *
- * Sun's implementation uses the caller classloader when
- * unmarshalling proxies. This is effectively jboss.jar since
- * that is where JRMPInvokerProxy lives. On a redeploy the
- * new interfaces are ignored because a proxy is already cached
- * against the classloader.<p>
- *
- * Another redeployment problem is that the getClassAnnotation(String)
- * will end up using the old deployment class loader and this can result
- * in NPEs do the class loader being destroyed.
- *
- * This class ignores Sun's guess at a suitable classloader and
- * uses the thread context classloader instead.<p>
- *
- * It has to exist in the system classloader so I have included it
- * in "system" for inclusion in run.jar<p>
- *
- * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 63730 $
- */
-public class JBossRMIClassLoader
- extends RMIClassLoaderSpi
-{
- // Attributes ----------------------------------------------------
-
- /**
- * The JVM implementation (we delegate most work to it)
- */
- RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance();
-
- // Constructors --------------------------------------------------
-
- /**
- * Required constructor
- */
- public JBossRMIClassLoader()
- {
- }
-
- // RMIClassLoaderSpi Implementation ------------------------------
-
- /*
- * Ignore the JVM, use the thread context classloader for proxy caching
- */
- public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored)
- throws MalformedURLException, ClassNotFoundException
- {
- return delegate.loadProxyClass(codebase, interfaces, Thread.currentThread().getContextClassLoader());
- }
-
- /*
- * Just delegate
- */
- public Class<?> loadClass(String codebase, String name, ClassLoader ignored)
- throws MalformedURLException, ClassNotFoundException
- {
- return delegate.loadClass(codebase, name, Thread.currentThread().getContextClassLoader());
- }
-
- /*
- * Just delegate
- */
- public ClassLoader getClassLoader(String codebase)
- throws MalformedURLException
- {
- return delegate.getClassLoader(codebase);
- }
-
- /*
- * Try to delegate an default to the java.rmi.server.codebase on any
- * failure.
- */
- public String getClassAnnotation(Class<?> cl)
- {
- String annotation = null;
- try
- {
- annotation = delegate.getClassAnnotation(cl);
- }
- catch(Throwable t)
- {
- // Try the java.rmi.server.codebase property
- annotation = System.getProperty("java.rmi.server.codebase");
- }
- return annotation;
- }
-}
+/*
+ * 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.system;
+
+import java.net.MalformedURLException;
+
+import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
+
+/**
+ * An implementation of RMIClassLoaderSpi to workaround the
+ * proxy ClassCastException problem in 1.4<p>
+ *
+ * <b>THIS IS A HACK!</b><p>
+ *
+ * Sun's implementation uses the caller classloader when
+ * unmarshalling proxies. This is effectively jboss.jar since
+ * that is where JRMPInvokerProxy lives. On a redeploy the
+ * new interfaces are ignored because a proxy is already cached
+ * against the classloader.<p>
+ *
+ * Another redeployment problem is that the getClassAnnotation(String)
+ * will end up using the old deployment class loader and this can result
+ * in NPEs do the class loader being destroyed.
+ *
+ * This class ignores Sun's guess at a suitable classloader and
+ * uses the thread context classloader instead.<p>
+ *
+ * It has to exist in the system classloader so I have included it
+ * in "system" for inclusion in run.jar<p>
+ *
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 63730 $
+ */
+public class JBossRMIClassLoader
+ extends RMIClassLoaderSpi
+{
+ // Attributes ----------------------------------------------------
+
+ /**
+ * The JVM implementation (we delegate most work to it)
+ */
+ RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance();
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Required constructor
+ */
+ public JBossRMIClassLoader()
+ {
+ }
+
+ // RMIClassLoaderSpi Implementation ------------------------------
+
+ /*
+ * Ignore the JVM, use the thread context classloader for proxy caching
+ */
+ public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ return delegate.loadProxyClass(codebase, interfaces, Thread.currentThread().getContextClassLoader());
+ }
+
+ /*
+ * Just delegate
+ */
+ public Class<?> loadClass(String codebase, String name, ClassLoader ignored)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ return delegate.loadClass(codebase, name, Thread.currentThread().getContextClassLoader());
+ }
+
+ /*
+ * Just delegate
+ */
+ public ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ return delegate.getClassLoader(codebase);
+ }
+
+ /*
+ * Try to delegate an default to the java.rmi.server.codebase on any
+ * failure.
+ */
+ public String getClassAnnotation(Class<?> cl)
+ {
+ String annotation = null;
+ try
+ {
+ annotation = delegate.getClassAnnotation(cl);
+ }
+ catch(Throwable t)
+ {
+ // Try the java.rmi.server.codebase property
+ annotation = System.getProperty("java.rmi.server.codebase");
+ }
+ return annotation;
+ }
+}
Property changes on: trunk/main/src/main/org/jboss/system/JBossRMIClassLoader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/system/NoAnnotationURLClassLoader.java
===================================================================
--- trunk/main/src/main/org/jboss/system/NoAnnotationURLClassLoader.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/system/NoAnnotationURLClassLoader.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,120 +1,120 @@
-/*
- * 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.system;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLStreamHandlerFactory;
-
-/**
- * A URL classloader to avoid URL annotation of classes in RMI
- *
- * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>
- * @version $Revision: 63730 $
- */
-public class NoAnnotationURLClassLoader
- extends URLClassLoader
-{
- /** The value returned by {@link getURLs}. */
- private static final URL[] EMPTY_URL_ARRAY = {};
-
- /**
- * Create a classloader with the context classloader as parent
- *
- * @param urls the urls
- * @return the classloader
- */
- public static NoAnnotationURLClassLoader createClassLoader(URL... urls)
- {
- return createClassLoader(Thread.currentThread().getContextClassLoader(), urls);
- }
-
- /**
- * Create a classloader
- *
- * @param parent the parent classloader
- * @param urls the urls
- * @return the classloader
- */
- public static NoAnnotationURLClassLoader createClassLoader(ClassLoader parent, URL... urls)
- {
- return new NoAnnotationURLClassLoader(urls, parent);
- }
-
- /**
- * Construct a <tt>URLClassLoader</tt>
- *
- * @param urls the URLs to load classes from.
- */
- public NoAnnotationURLClassLoader(URL[] urls)
- {
- super(urls);
- }
-
- /**
- * Construct a <tt>URLClassLoader</tt>
- *
- * @param urls the URLs to load classes from.
- * @param parent the parent classloader.
- */
- public NoAnnotationURLClassLoader(URL[] urls, ClassLoader parent)
- {
- super(urls, parent);
- }
-
- /**
- * Construct a <tt>URLClassLoader</tt>
- *
- * @param urls the URLs to load classes from.
- * @param parent the parent classloader.
- * @param factory the url stream factory.
- */
- public NoAnnotationURLClassLoader(URL[] urls, ClassLoader parent,
- URLStreamHandlerFactory factory)
- {
- super(urls, parent, factory);
- }
-
- /**
- * Return all library URLs
- *
- * <p>Do not remove this method without running the WebIntegrationTestSuite
- * @return the urls
- */
- public URL[] getAllURLs()
- {
- return super.getURLs();
- }
-
- /**
- * Return an empty URL array to force the RMI marshalling subsystem to
- * use the <tt>java.server.codebase</tt> property as the annotated codebase.
- *
- * <p>Do not remove this method without discussing it on the dev list.
- *
- * @return Empty URL[]
- */
- public URL[] getURLs()
- {
- return EMPTY_URL_ARRAY;
- }
-}
+/*
+ * 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.system;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * A URL classloader to avoid URL annotation of classes in RMI
+ *
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>
+ * @version $Revision: 63730 $
+ */
+public class NoAnnotationURLClassLoader
+ extends URLClassLoader
+{
+ /** The value returned by {@link getURLs}. */
+ private static final URL[] EMPTY_URL_ARRAY = {};
+
+ /**
+ * Create a classloader with the context classloader as parent
+ *
+ * @param urls the urls
+ * @return the classloader
+ */
+ public static NoAnnotationURLClassLoader createClassLoader(URL... urls)
+ {
+ return createClassLoader(Thread.currentThread().getContextClassLoader(), urls);
+ }
+
+ /**
+ * Create a classloader
+ *
+ * @param parent the parent classloader
+ * @param urls the urls
+ * @return the classloader
+ */
+ public static NoAnnotationURLClassLoader createClassLoader(ClassLoader parent, URL... urls)
+ {
+ return new NoAnnotationURLClassLoader(urls, parent);
+ }
+
+ /**
+ * Construct a <tt>URLClassLoader</tt>
+ *
+ * @param urls the URLs to load classes from.
+ */
+ public NoAnnotationURLClassLoader(URL[] urls)
+ {
+ super(urls);
+ }
+
+ /**
+ * Construct a <tt>URLClassLoader</tt>
+ *
+ * @param urls the URLs to load classes from.
+ * @param parent the parent classloader.
+ */
+ public NoAnnotationURLClassLoader(URL[] urls, ClassLoader parent)
+ {
+ super(urls, parent);
+ }
+
+ /**
+ * Construct a <tt>URLClassLoader</tt>
+ *
+ * @param urls the URLs to load classes from.
+ * @param parent the parent classloader.
+ * @param factory the url stream factory.
+ */
+ public NoAnnotationURLClassLoader(URL[] urls, ClassLoader parent,
+ URLStreamHandlerFactory factory)
+ {
+ super(urls, parent, factory);
+ }
+
+ /**
+ * Return all library URLs
+ *
+ * <p>Do not remove this method without running the WebIntegrationTestSuite
+ * @return the urls
+ */
+ public URL[] getAllURLs()
+ {
+ return super.getURLs();
+ }
+
+ /**
+ * Return an empty URL array to force the RMI marshalling subsystem to
+ * use the <tt>java.server.codebase</tt> property as the annotated codebase.
+ *
+ * <p>Do not remove this method without discussing it on the dev list.
+ *
+ * @return Empty URL[]
+ */
+ public URL[] getURLs()
+ {
+ return EMPTY_URL_ARRAY;
+ }
+}
Property changes on: trunk/main/src/main/org/jboss/system/NoAnnotationURLClassLoader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/system/ORBSingleton.java
===================================================================
--- trunk/main/src/main/org/jboss/system/ORBSingleton.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/system/ORBSingleton.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,360 +1,360 @@
-/*
- * 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.system;
-
-import java.util.Properties;
-import org.omg.CORBA.Any;
-import org.omg.CORBA.Context;
-import org.omg.CORBA.ContextList;
-import org.omg.CORBA.Current;
-import org.omg.CORBA.Environment;
-import org.omg.CORBA.ExceptionList;
-import org.omg.CORBA.INITIALIZE;
-import org.omg.CORBA.NamedValue;
-import org.omg.CORBA.NO_IMPLEMENT;
-import org.omg.CORBA.NVList;
-import org.omg.CORBA.ORBPackage.InvalidName;
-import org.omg.CORBA.Request;
-import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
-import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.UnionMember;
-import org.omg.CORBA.ValueMember;
-import org.omg.CORBA_2_3.ORB;
-
-/**
- * Thin wrapper class that fulfills the contract of an ORB singleton and
- * forwards every invocation to an instance of the actual ORB singleton class,
- * which it loads with the context classloader. The name of the actual ORB
- * singleton class is specified by the system property
- * <code>org.jboss.ORBSingletonDelegate</code>.
- * <p>
- * This class is a workaround to the the following problem: unlike the Sun VMs,
- * IBM VMs do not use the context classloader to load the ORB singleton class
- * specified by the system property
- * <code>org.omg.CORBA.ORBSingletonClass</code>. IBM VMs use the
- * system classloader, thus requiring the ORB singleton class to be in
- * the system classpath. Rather than adding a third-party jar file (e.g.
- * jacorb.jar) to the system classpath, we include this class in run.jar.
- * Instead of setting the system property
- * <pre>
- * org.omg.CORBA.ORBSingletonClass=some.orb.impl.ORBSingletonImpl
- * </pre>
- * we set two properties:
- * <pre>
- * org.omg.CORBA.ORBSingletonClass=org.jboss.system.ORBSingleton
- * org.jboss.ORBSingletonDelegate=some.orb.impl.ORBSingletonImpl
- * </pre>
- * <p>
- * This class should be removed when IBM fixes its VMs.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision: 37459 $
- */
-public class ORBSingleton extends ORB
-{
- /** System property key that specifies the actual ORB singleton class. */
- public static String DELEGATE_CLASS_KEY = "org.jboss.ORBSingletonDelegate";
-
- /** The ORB singleton instance to which all invocations are forwarded. */
- private static ORB delegate = null;
-
- /**
- * The ORBSingleton constructor does what the IBM VM does not do: it uses
- * the context classloader to load the actual ORB singleton class.
- */
- public ORBSingleton()
- {
- if (delegate == null)
- {
- String className = System.getProperty(DELEGATE_CLASS_KEY);
- if (className == null)
- className = "org.jacorb.orb.ORBSingleton";
- try
- {
- delegate = (ORB)Class.forName(className).newInstance();
- }
- catch (ClassNotFoundException ex)
- {
- }
- catch (Exception ex) {
- throw new INITIALIZE(
- "can't instantiate ORBSingleton implementation " + className);
- }
-
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null)
- cl = ClassLoader.getSystemClassLoader();
- try
- {
- delegate = (ORB)Class.forName(className, true, cl).newInstance();
- }
- catch (Exception ex)
- {
- throw new INITIALIZE(
- "can't instantiate ORBSingleton implementation " + className);
- }
- }
- }
-
- // All the rest is pretty dumb code: it implements all the methods of the
- // class org.omg.CORBA.ORB, either forwarding the invocation to the
- // delegate (methods that may be called on the restricted singleton ORB
- // instance) or throwing an exception (methods that may not be called on
- // the restricted singleton ORB instance).
-
- public Any create_any()
- {
- return delegate.create_any();
- }
-
- public TypeCode create_alias_tc(String id,
- String name,
- TypeCode original_type)
- {
- return delegate.create_alias_tc(id, name, original_type);
- }
-
- public TypeCode create_array_tc(int length, TypeCode element_type)
- {
- return delegate.create_array_tc(length, element_type);
- }
-
- public TypeCode create_enum_tc(String id, String name, String[] members)
- {
- return delegate.create_enum_tc(id, name, members);
- }
-
- public TypeCode create_exception_tc(String id,
- String name,
- StructMember[] members)
- {
- return delegate.create_exception_tc(id, name, members);
- }
-
- public TypeCode create_interface_tc(String id, String name)
- {
- return delegate.create_interface_tc(id, name);
- }
-
- public TypeCode create_fixed_tc(short digits, short scale)
- {
- return delegate.create_fixed_tc(digits, scale);
- }
-
- public TypeCode create_recursive_tc(String id)
- {
- return delegate.create_recursive_tc(id);
- }
-
- /*
- * @deprecated Deprecated by CORBA 2.3.
- */
- public TypeCode create_recursive_sequence_tc(int bound, int offset)
- {
- throw new NO_IMPLEMENT("deprecated by CORBA 2.3");
- }
-
- public TypeCode create_sequence_tc(int bound, TypeCode element_type)
- {
- return delegate.create_sequence_tc(bound, element_type);
- }
-
- public TypeCode create_string_tc(int bound)
- {
- return delegate.create_string_tc(bound);
- }
-
- public TypeCode create_wstring_tc(int bound)
- {
- return delegate.create_wstring_tc(bound);
- }
-
- public TypeCode create_struct_tc(String id,
- String name,
- StructMember[] members)
- {
- return delegate.create_struct_tc(id, name, members);
- }
-
- public TypeCode create_union_tc(String id,
- String name,
- TypeCode discriminator_type,
- UnionMember[] members)
- {
- return delegate.create_union_tc(id, name,
- discriminator_type, members);
- }
-
- public TypeCode get_primitive_tc(TCKind tcKind)
- {
- return delegate.get_primitive_tc(tcKind);
- }
-
- public TypeCode create_value_tc(String id,
- String name,
- short type_modifier,
- TypeCode concrete_base,
- ValueMember[] members)
- {
- return delegate.create_value_tc(id, name, type_modifier,
- concrete_base, members);
- }
-
- public TypeCode create_value_box_tc(String id,
- String name,
- TypeCode boxed_type)
- {
- return delegate.create_value_box_tc(id, name, boxed_type);
- }
-
- public TypeCode create_abstract_interface_tc(String id, String name)
- {
- return delegate.create_abstract_interface_tc(id, name);
- }
-
- public TypeCode create_native_tc(String id, String name)
- {
- return delegate.create_native_tc(id, name);
- }
-
- /* Methods not allowed on the singleton ORB: */
-
- public ExceptionList create_exception_list()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public NVList create_list(int count)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public NamedValue create_named_value(String name, Any value, int flags)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public NVList create_operation_list(org.omg.CORBA.Object obj)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public org.omg.CORBA.Object string_to_object(String str)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public Environment create_environment()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public ContextList create_context_list()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public org.omg.CORBA.portable.OutputStream create_output_stream()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- /*
- * @deprecated Deprecated by CORBA 2.3.
- */
- public Current get_current()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public Context get_default_context()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public Request get_next_response()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public String[] list_initial_services()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public String object_to_string(org.omg.CORBA.Object obj)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public boolean poll_next_response()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public org.omg.CORBA.Object resolve_initial_references(String identifier)
- throws InvalidName
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public void send_multiple_requests_deferred(Request[] req)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public void send_multiple_requests_oneway(Request[] req)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- protected void set_parameters(String[] args, Properties props)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- protected void set_parameters(java.applet.Applet app, Properties props)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public void run()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public void shutdown(boolean wait_for_completion)
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public boolean work_pending()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-
- public void perform_work()
- {
- throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
- }
-}
+/*
+ * 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.system;
+
+import java.util.Properties;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.Current;
+import org.omg.CORBA.Environment;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.INITIALIZE;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.NVList;
+import org.omg.CORBA.ORBPackage.InvalidName;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.StructMember;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.UnionMember;
+import org.omg.CORBA.ValueMember;
+import org.omg.CORBA_2_3.ORB;
+
+/**
+ * Thin wrapper class that fulfills the contract of an ORB singleton and
+ * forwards every invocation to an instance of the actual ORB singleton class,
+ * which it loads with the context classloader. The name of the actual ORB
+ * singleton class is specified by the system property
+ * <code>org.jboss.ORBSingletonDelegate</code>.
+ * <p>
+ * This class is a workaround to the the following problem: unlike the Sun VMs,
+ * IBM VMs do not use the context classloader to load the ORB singleton class
+ * specified by the system property
+ * <code>org.omg.CORBA.ORBSingletonClass</code>. IBM VMs use the
+ * system classloader, thus requiring the ORB singleton class to be in
+ * the system classpath. Rather than adding a third-party jar file (e.g.
+ * jacorb.jar) to the system classpath, we include this class in run.jar.
+ * Instead of setting the system property
+ * <pre>
+ * org.omg.CORBA.ORBSingletonClass=some.orb.impl.ORBSingletonImpl
+ * </pre>
+ * we set two properties:
+ * <pre>
+ * org.omg.CORBA.ORBSingletonClass=org.jboss.system.ORBSingleton
+ * org.jboss.ORBSingletonDelegate=some.orb.impl.ORBSingletonImpl
+ * </pre>
+ * <p>
+ * This class should be removed when IBM fixes its VMs.
+ *
+ * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
+ * @version $Revision: 37459 $
+ */
+public class ORBSingleton extends ORB
+{
+ /** System property key that specifies the actual ORB singleton class. */
+ public static String DELEGATE_CLASS_KEY = "org.jboss.ORBSingletonDelegate";
+
+ /** The ORB singleton instance to which all invocations are forwarded. */
+ private static ORB delegate = null;
+
+ /**
+ * The ORBSingleton constructor does what the IBM VM does not do: it uses
+ * the context classloader to load the actual ORB singleton class.
+ */
+ public ORBSingleton()
+ {
+ if (delegate == null)
+ {
+ String className = System.getProperty(DELEGATE_CLASS_KEY);
+ if (className == null)
+ className = "org.jacorb.orb.ORBSingleton";
+ try
+ {
+ delegate = (ORB)Class.forName(className).newInstance();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ }
+ catch (Exception ex) {
+ throw new INITIALIZE(
+ "can't instantiate ORBSingleton implementation " + className);
+ }
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null)
+ cl = ClassLoader.getSystemClassLoader();
+ try
+ {
+ delegate = (ORB)Class.forName(className, true, cl).newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw new INITIALIZE(
+ "can't instantiate ORBSingleton implementation " + className);
+ }
+ }
+ }
+
+ // All the rest is pretty dumb code: it implements all the methods of the
+ // class org.omg.CORBA.ORB, either forwarding the invocation to the
+ // delegate (methods that may be called on the restricted singleton ORB
+ // instance) or throwing an exception (methods that may not be called on
+ // the restricted singleton ORB instance).
+
+ public Any create_any()
+ {
+ return delegate.create_any();
+ }
+
+ public TypeCode create_alias_tc(String id,
+ String name,
+ TypeCode original_type)
+ {
+ return delegate.create_alias_tc(id, name, original_type);
+ }
+
+ public TypeCode create_array_tc(int length, TypeCode element_type)
+ {
+ return delegate.create_array_tc(length, element_type);
+ }
+
+ public TypeCode create_enum_tc(String id, String name, String[] members)
+ {
+ return delegate.create_enum_tc(id, name, members);
+ }
+
+ public TypeCode create_exception_tc(String id,
+ String name,
+ StructMember[] members)
+ {
+ return delegate.create_exception_tc(id, name, members);
+ }
+
+ public TypeCode create_interface_tc(String id, String name)
+ {
+ return delegate.create_interface_tc(id, name);
+ }
+
+ public TypeCode create_fixed_tc(short digits, short scale)
+ {
+ return delegate.create_fixed_tc(digits, scale);
+ }
+
+ public TypeCode create_recursive_tc(String id)
+ {
+ return delegate.create_recursive_tc(id);
+ }
+
+ /*
+ * @deprecated Deprecated by CORBA 2.3.
+ */
+ public TypeCode create_recursive_sequence_tc(int bound, int offset)
+ {
+ throw new NO_IMPLEMENT("deprecated by CORBA 2.3");
+ }
+
+ public TypeCode create_sequence_tc(int bound, TypeCode element_type)
+ {
+ return delegate.create_sequence_tc(bound, element_type);
+ }
+
+ public TypeCode create_string_tc(int bound)
+ {
+ return delegate.create_string_tc(bound);
+ }
+
+ public TypeCode create_wstring_tc(int bound)
+ {
+ return delegate.create_wstring_tc(bound);
+ }
+
+ public TypeCode create_struct_tc(String id,
+ String name,
+ StructMember[] members)
+ {
+ return delegate.create_struct_tc(id, name, members);
+ }
+
+ public TypeCode create_union_tc(String id,
+ String name,
+ TypeCode discriminator_type,
+ UnionMember[] members)
+ {
+ return delegate.create_union_tc(id, name,
+ discriminator_type, members);
+ }
+
+ public TypeCode get_primitive_tc(TCKind tcKind)
+ {
+ return delegate.get_primitive_tc(tcKind);
+ }
+
+ public TypeCode create_value_tc(String id,
+ String name,
+ short type_modifier,
+ TypeCode concrete_base,
+ ValueMember[] members)
+ {
+ return delegate.create_value_tc(id, name, type_modifier,
+ concrete_base, members);
+ }
+
+ public TypeCode create_value_box_tc(String id,
+ String name,
+ TypeCode boxed_type)
+ {
+ return delegate.create_value_box_tc(id, name, boxed_type);
+ }
+
+ public TypeCode create_abstract_interface_tc(String id, String name)
+ {
+ return delegate.create_abstract_interface_tc(id, name);
+ }
+
+ public TypeCode create_native_tc(String id, String name)
+ {
+ return delegate.create_native_tc(id, name);
+ }
+
+ /* Methods not allowed on the singleton ORB: */
+
+ public ExceptionList create_exception_list()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public NVList create_list(int count)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public NamedValue create_named_value(String name, Any value, int flags)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public NVList create_operation_list(org.omg.CORBA.Object obj)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public org.omg.CORBA.Object string_to_object(String str)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public Environment create_environment()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public ContextList create_context_list()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public org.omg.CORBA.portable.OutputStream create_output_stream()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ /*
+ * @deprecated Deprecated by CORBA 2.3.
+ */
+ public Current get_current()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public Context get_default_context()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public Request get_next_response()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public String[] list_initial_services()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public String object_to_string(org.omg.CORBA.Object obj)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public boolean poll_next_response()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public org.omg.CORBA.Object resolve_initial_references(String identifier)
+ throws InvalidName
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public void send_multiple_requests_deferred(Request[] req)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public void send_multiple_requests_oneway(Request[] req)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ protected void set_parameters(String[] args, Properties props)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ protected void set_parameters(java.applet.Applet app, Properties props)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public void run()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public void shutdown(boolean wait_for_completion)
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public boolean work_pending()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+
+ public void perform_work()
+ {
+ throw new NO_IMPLEMENT("The Singleton ORB only permits factory methods");
+ }
+}
Property changes on: trunk/main/src/main/org/jboss/system/ORBSingleton.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/main/src/main/org/jboss/system/server/ServerLoader.java
===================================================================
--- trunk/main/src/main/org/jboss/system/server/ServerLoader.java 2008-11-14 15:06:02 UTC (rev 81061)
+++ trunk/main/src/main/org/jboss/system/server/ServerLoader.java 2008-11-14 15:06:42 UTC (rev 81062)
@@ -1,361 +1,361 @@
-/*
- * 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.system.server;
-
-// $Id: ServerLoader.java 64043 2007-07-13 16:59:19Z adrian at jboss.org $
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.system.NoAnnotationURLClassLoader;
-
-/**
- * A helper class to load a JBoss server instance.
- *
- * <p>Basic usage is something like this:
- * <pre>
- * // setup the basic server config properties
- * Properties props = new Properties(System.getProperties());
- * props.put(ServerConfig.SERVER_LIBRARY_URL, "http://myserver.com/myjboss/lib/");
- * // set some more properties
- *
- * // create a new loader to do the dirty work
- * ServerLoader loader = new ServerLoader(props);
- *
- * // add the jaxp & jmx library to use
- * loader.addLibrary("crimson.jar");
- * loader.addLibrary("jboss-jmx-core.jar");
- *
- * // load and initialize the server instance
- * ClassLoader parent = Thread.currentThread().getContextClassLoader();
- * Server server = loader.load(parent);
- * server.init(props);
- *
- * // start up the server
- * server.start();
- *
- * // go make some coffee, drink a beer or play GTA3
- * // ...
- *
- * // shutdown and go to sleep
- * server.shutdown();
- * </pre>
- * @version <tt>$Revision: 64043 $</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @author Thomas.Diesler at jboss.org
- */
-public class ServerLoader
-{
- /**
- * The default 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
- */
- public static final String[] DEFAULT_BOOT_LIBRARY_LIST = {
- // Logging
- "log4j-boot.jar",
- "jboss-logging-spi.jar",
- "jboss-logging-log4j.jar",
- "jboss-logging-jdk.jar",
- // Common jars
- "jboss-common-core.jar",
- "jboss-xml-binding.jar",
- "jaxb-api.jar",
- // Bootstrap
- "jboss-bootstrap.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",
- };
-
- /** The default server type. */
- public static final String DEFAULT_SERVER_TYPE = "org.jboss.bootstrap.microcontainer.ServerImpl";
-
- /**
- * Configuration properties.
- */
- protected Properties props;
-
- /**
- * The URL where libraries are read from.
- */
- protected URL libraryURL;
-
- /**
- * A list of extra URLs to add to the classpath when loading
- * the server.
- */
- protected List<URL> extraClasspath = new LinkedList<URL>();
-
- /**
- * Construct a <tt>ServerLoader</tt>.
- *
- * @param props Configuration properties.
- *
- * @throws Exception Invalid configuration
- */
- public ServerLoader(final Properties props) throws Exception
- {
- if (props == null)
- throw new IllegalArgumentException("props is null");
-
- this.props = props;
-
- // must have HOME_URL, or we can't continue
- URL homeURL = getURL(ServerConfig.HOME_URL);
- if (homeURL == null)
- {
- throw new Exception("Missing configuration value for: "
- + ServerConfig.HOME_URL);
- }
-
- libraryURL = getURL(ServerConfig.LIBRARY_URL);
- if (libraryURL == null)
- {
- // need library url to make boot urls list
- libraryURL = new URL(homeURL, ServerConfig.LIBRARY_URL_SUFFIX);
- }
-
- // If the home URL begins with http add the webav and httpclient jars
- if( homeURL.getProtocol().startsWith("http") == true )
- {
- this.addLibrary("webdavlib.jar");
- this.addLibrary("commons-httpclient.jar");
- this.addLibrary("commons-logging.jar");
- }
- }
-
- /**
- * Add an extra library to the end of list of libraries
- * which will be loaded from the library URL when loading
- * the Server class.
- *
- * @param filename A filename (no directory parts)
- *
- * @throws MalformedURLException Could not generate URL from library URL + filename
- */
- public void addLibrary(final String filename) throws MalformedURLException
- {
- if (filename == null)
- throw new IllegalArgumentException("filename is null");
-
- URL jarURL = new URL(libraryURL, filename);
- extraClasspath.add(jarURL);
- }
-
- /**
- * Add a list of comma seperated library file names.
- *
- * @param filenames A list of comma seperated filenames (with no directory parts)
- *
- * @throws MalformedURLException Could not generate URL from library URL + filename
- */
- public void addLibraries(final String filenames) throws MalformedURLException
- {
- if (filenames == null)
- throw new IllegalArgumentException("filenames is null");
-
- StringTokenizer stok = new StringTokenizer(filenames, ",");
- while (stok.hasMoreElements())
- {
- addLibrary(stok.nextToken().trim());
- }
- }
-
- /**
- * Add an extra URL to the classpath used to load the server.
- *
- * @param url A URL to add to the classpath.
- */
- public void addURL(final URL url)
- {
- if (url == null)
- throw new IllegalArgumentException("url is null");
-
- extraClasspath.add(url);
- }
-
- /**
- * Add the jars from the lib/endorsed dir if it exists.
- * Note, the path must exist locally for this to work.
- * @throws MalformedURLException Could not generate URL from library URL + filename
- */
- public void addEndorsedJars() throws MalformedURLException
- {
- File endorsedDir = new File(libraryURL.getPath() + "/endorsed");
- if (endorsedDir.exists())
- {
- String [] list = endorsedDir.list();
- for (int i = 0; list != null && i < list.length; i++)
- {
- String jarname = list[i];
- addLibrary("endorsed/" + jarname);
- }
- }
- }
-
- /**
- * Get a URL from configuration or system properties.
- *
- * @param name the system property
- * @return the url
- * @throws MalformedURLException for a bad url
- */
- protected URL getURL(final String name) throws MalformedURLException
- {
- String value = props.getProperty(name, null);
- if (value != null)
- {
- if (!value.endsWith("/")) value += "/";
- return new URL(value);
- }
- return null;
- }
-
- /**
- * Returns an array of URLs which will be used to load the
- * core system and construct a new Server object instance.
- * @return the urls
- * @throws MalformedURLException for a bad url
- */
- protected URL[] getBootClasspath() throws MalformedURLException
- {
- List<URL> list = new LinkedList<URL>();
-
- // prepend users classpath to allow for overrides
- list.addAll(extraClasspath);
-
- String value = props.getProperty(ServerConfig.BOOT_LIBRARY_LIST);
- if( value != null )
- {
- StringTokenizer stok = new StringTokenizer(value, ",");
- while (stok.hasMoreElements())
- {
- URL url = new URL(libraryURL, stok.nextToken().trim());
- list.add(url);
- }
- }
- else
- {
- for(String jar : DEFAULT_BOOT_LIBRARY_LIST)
- {
- URL url = new URL(libraryURL, jar);
- list.add(url);
- }
- }
-
- return list.toArray(new URL[list.size()]);
- }
-
- /**
- * Load a {@link Server} instance.
- *
- * @parent The parent of any class loader created during boot.
- * @return An uninitialized (and unstarted) Server instance.
- *
- * @param parent the parent classloader
- * @throws Exception Failed to load or create Server instance.
- */
- public Server load(final ClassLoader parent) throws Exception
- {
- Server server;
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
-
- try
- {
- // get the boot lib list
- URL[] urls = getBootClasspath();
- URLClassLoader classLoader = new NoAnnotationURLClassLoader(urls, parent);
- Thread.currentThread().setContextClassLoader(classLoader);
-
- /*
-
- Log the boot URLs (uncomment to test)
-
- StringBuffer sb = new StringBuffer("Boot URLs:\n");
- for(URL url : urls)
- {
- sb.append(url.toExternalForm());
- sb.append("\n");
- }
- System.out.println(sb);
-
- */
-
- // construct a new Server instance
- String typename = props.getProperty(ServerConfig.SERVER_TYPE, DEFAULT_SERVER_TYPE);
- server = createServer(typename, classLoader);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldCL);
- }
-
- // thats all folks, have fun
- return server;
- }
-
- /**
- * Construct a new instance of Server, loading all required classes from
- * the given ClassLoader.
- * @param typename - the fqcn of the Server implementation
- * @param loader - the ClassLoader to load typename with
- * @return the server
- * @throws Exception for any error
- */
- protected Server createServer(final String typename, final ClassLoader loader)
- throws Exception
- {
- // load the class first
- Class<?> type = loader.loadClass(typename);
-
- // and then create a new instance
- Server server = (Server) type.newInstance();
- return 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.system.server;
+
+// $Id: ServerLoader.java 64043 2007-07-13 16:59:19Z adrian at jboss.org $
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.system.NoAnnotationURLClassLoader;
+
+/**
+ * A helper class to load a JBoss server instance.
+ *
+ * <p>Basic usage is something like this:
+ * <pre>
+ * // setup the basic server config properties
+ * Properties props = new Properties(System.getProperties());
+ * props.put(ServerConfig.SERVER_LIBRARY_URL, "http://myserver.com/myjboss/lib/");
+ * // set some more properties
+ *
+ * // create a new loader to do the dirty work
+ * ServerLoader loader = new ServerLoader(props);
+ *
+ * // add the jaxp & jmx library to use
+ * loader.addLibrary("crimson.jar");
+ * loader.addLibrary("jboss-jmx-core.jar");
+ *
+ * // load and initialize the server instance
+ * ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ * Server server = loader.load(parent);
+ * server.init(props);
+ *
+ * // start up the server
+ * server.start();
+ *
+ * // go make some coffee, drink a beer or play GTA3
+ * // ...
+ *
+ * // shutdown and go to sleep
+ * server.shutdown();
+ * </pre>
+ * @version <tt>$Revision: 64043 $</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ */
+public class ServerLoader
+{
+ /**
+ * The default 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
+ */
+ public static final String[] DEFAULT_BOOT_LIBRARY_LIST = {
+ // Logging
+ "log4j-boot.jar",
+ "jboss-logging-spi.jar",
+ "jboss-logging-log4j.jar",
+ "jboss-logging-jdk.jar",
+ // Common jars
+ "jboss-common-core.jar",
+ "jboss-xml-binding.jar",
+ "jaxb-api.jar",
+ // Bootstrap
+ "jboss-bootstrap.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",
+ };
+
+ /** The default server type. */
+ public static final String DEFAULT_SERVER_TYPE = "org.jboss.bootstrap.microcontainer.ServerImpl";
+
+ /**
+ * Configuration properties.
+ */
+ protected Properties props;
+
+ /**
+ * The URL where libraries are read from.
+ */
+ protected URL libraryURL;
+
+ /**
+ * A list of extra URLs to add to the classpath when loading
+ * the server.
+ */
+ protected List<URL> extraClasspath = new LinkedList<URL>();
+
+ /**
+ * Construct a <tt>ServerLoader</tt>.
+ *
+ * @param props Configuration properties.
+ *
+ * @throws Exception Invalid configuration
+ */
+ public ServerLoader(final Properties props) throws Exception
+ {
+ if (props == null)
+ throw new IllegalArgumentException("props is null");
+
+ this.props = props;
+
+ // must have HOME_URL, or we can't continue
+ URL homeURL = getURL(ServerConfig.HOME_URL);
+ if (homeURL == null)
+ {
+ throw new Exception("Missing configuration value for: "
+ + ServerConfig.HOME_URL);
+ }
+
+ libraryURL = getURL(ServerConfig.LIBRARY_URL);
+ if (libraryURL == null)
+ {
+ // need library url to make boot urls list
+ libraryURL = new URL(homeURL, ServerConfig.LIBRARY_URL_SUFFIX);
+ }
+
+ // If the home URL begins with http add the webav and httpclient jars
+ if( homeURL.getProtocol().startsWith("http") == true )
+ {
+ this.addLibrary("webdavlib.jar");
+ this.addLibrary("commons-httpclient.jar");
+ this.addLibrary("commons-logging.jar");
+ }
+ }
+
+ /**
+ * Add an extra library to the end of list of libraries
+ * which will be loaded from the library URL when loading
+ * the Server class.
+ *
+ * @param filename A filename (no directory parts)
+ *
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addLibrary(final String filename) throws MalformedURLException
+ {
+ if (filename == null)
+ throw new IllegalArgumentException("filename is null");
+
+ URL jarURL = new URL(libraryURL, filename);
+ extraClasspath.add(jarURL);
+ }
+
+ /**
+ * Add a list of comma seperated library file names.
+ *
+ * @param filenames A list of comma seperated filenames (with no directory parts)
+ *
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addLibraries(final String filenames) throws MalformedURLException
+ {
+ if (filenames == null)
+ throw new IllegalArgumentException("filenames is null");
+
+ StringTokenizer stok = new StringTokenizer(filenames, ",");
+ while (stok.hasMoreElements())
+ {
+ addLibrary(stok.nextToken().trim());
+ }
+ }
+
+ /**
+ * Add an extra URL to the classpath used to load the server.
+ *
+ * @param url A URL to add to the classpath.
+ */
+ public void addURL(final URL url)
+ {
+ if (url == null)
+ throw new IllegalArgumentException("url is null");
+
+ extraClasspath.add(url);
+ }
+
+ /**
+ * Add the jars from the lib/endorsed dir if it exists.
+ * Note, the path must exist locally for this to work.
+ * @throws MalformedURLException Could not generate URL from library URL + filename
+ */
+ public void addEndorsedJars() throws MalformedURLException
+ {
+ File endorsedDir = new File(libraryURL.getPath() + "/endorsed");
+ if (endorsedDir.exists())
+ {
+ String [] list = endorsedDir.list();
+ for (int i = 0; list != null && i < list.length; i++)
+ {
+ String jarname = list[i];
+ addLibrary("endorsed/" + jarname);
+ }
+ }
+ }
+
+ /**
+ * Get a URL from configuration or system properties.
+ *
+ * @param name the system property
+ * @return the url
+ * @throws MalformedURLException for a bad url
+ */
+ protected URL getURL(final String name) throws MalformedURLException
+ {
+ String value = props.getProperty(name, null);
+ if (value != null)
+ {
+ if (!value.endsWith("/")) value += "/";
+ return new URL(value);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an array of URLs which will be used to load the
+ * core system and construct a new Server object instance.
+ * @return the urls
+ * @throws MalformedURLException for a bad url
+ */
+ protected URL[] getBootClasspath() throws MalformedURLException
+ {
+ List<URL> list = new LinkedList<URL>();
+
+ // prepend users classpath to allow for overrides
+ list.addAll(extraClasspath);
+
+ String value = props.getProperty(ServerConfig.BOOT_LIBRARY_LIST);
+ if( value != null )
+ {
+ StringTokenizer stok = new StringTokenizer(value, ",");
+ while (stok.hasMoreElements())
+ {
+ URL url = new URL(libraryURL, stok.nextToken().trim());
+ list.add(url);
+ }
+ }
+ else
+ {
+ for(String jar : DEFAULT_BOOT_LIBRARY_LIST)
+ {
+ URL url = new URL(libraryURL, jar);
+ list.add(url);
+ }
+ }
+
+ return list.toArray(new URL[list.size()]);
+ }
+
+ /**
+ * Load a {@link Server} instance.
+ *
+ * @parent The parent of any class loader created during boot.
+ * @return An uninitialized (and unstarted) Server instance.
+ *
+ * @param parent the parent classloader
+ * @throws Exception Failed to load or create Server instance.
+ */
+ public Server load(final ClassLoader parent) throws Exception
+ {
+ Server server;
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ try
+ {
+ // get the boot lib list
+ URL[] urls = getBootClasspath();
+ URLClassLoader classLoader = new NoAnnotationURLClassLoader(urls, parent);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ /*
+
+ Log the boot URLs (uncomment to test)
+
+ StringBuffer sb = new StringBuffer("Boot URLs:\n");
+ for(URL url : urls)
+ {
+ sb.append(url.toExternalForm());
+ sb.append("\n");
+ }
+ System.out.println(sb);
+
+ */
+
+ // construct a new Server instance
+ String typename = props.getProperty(ServerConfig.SERVER_TYPE, DEFAULT_SERVER_TYPE);
+ server = createServer(typename, classLoader);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldCL);
+ }
+
+ // thats all folks, have fun
+ return server;
+ }
+
+ /**
+ * Construct a new instance of Server, loading all required classes from
+ * the given ClassLoader.
+ * @param typename - the fqcn of the Server implementation
+ * @param loader - the ClassLoader to load typename with
+ * @return the server
+ * @throws Exception for any error
+ */
+ protected Server createServer(final String typename, final ClassLoader loader)
+ throws Exception
+ {
+ // load the class first
+ Class<?> type = loader.loadClass(typename);
+
+ // and then create a new instance
+ Server server = (Server) type.newInstance();
+ return server;
+ }
+}
Property changes on: trunk/main/src/main/org/jboss/system/server/ServerLoader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/resources/log4j-debug.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/resources/log4j-trace.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/resources/log4j.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/main/src/resources/org/jboss/version.properties
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list