User: user57
Date: 02/02/27 01:24:26
Modified: src/main/org/jboss Main.java
Log:
o Release structure and server config changes
Revision Changes Path
1.3 +85 -75 jboss-system/src/main/org/jboss/Main.java
Index: Main.java
===================================================================
RCS file: /cvsroot/jboss/jboss-system/src/main/org/jboss/Main.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Main.java 27 Feb 2002 04:47:23 -0000 1.2
+++ Main.java 27 Feb 2002 09:24:26 -0000 1.3
@@ -37,7 +37,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class Main
{
@@ -54,6 +54,13 @@
private List extraClasspath = new LinkedList();
/**
+ * 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());
+
+ /**
* Explicit constructor.
*/
public Main()
@@ -70,45 +77,59 @@
*/
public void boot(final String[] args) throws Exception
{
- //
- // Set a jboss.home property from the location of the Main.class jar
- // if the property does not exist.
- //
- // Should let ServerConfigImpl handle setting these
- //
- if (System.getProperty("jboss.home") == null)
- {
+ // Auto set HOME_DIR to ../bin/run.jar if not set
+ String homeDir = System.getProperty(ServerConfig.HOME_DIR);
+ if (homeDir == null) {
String path =
Main.class.getProtectionDomain().getCodeSource().getLocation().getFile();
- File runJar = new File(path);
- // Home dir should be the parent of the dir containing run.jar
- File homeDir = new File(runJar.getParent(), "..");
- System.setProperty("jboss.home", homeDir.getCanonicalPath());
+ File file = new File(path).getParentFile().getParentFile();
+ homeDir = file.getCanonicalPath();
}
- String home = System.getProperty("jboss.home");
+ props.setProperty(ServerConfig.HOME_DIR, homeDir);
- //
- // FIXME: Change me to jboss.server.home, system is too confusing here
- //
- if (System.getProperty("jboss.system.home") == null)
- {
- // default to jboss.home if jboss.system.home is not set
- System.setProperty("jboss.system.home", home);
+ // Setup HOME_URL too, ServerLoader needs this
+ String homeURL = System.getProperty(ServerConfig.HOME_URL);
+ if (homeURL == null) {
+ File file = new File(homeDir);
+ homeURL = file.toURL().toString();
}
- String systemHome = System.getProperty("jboss.system.home");
+ props.setProperty(ServerConfig.HOME_URL, homeURL);
+
+ // process the command line
+ processCommandLine(args);
- // Create a new server properties. This object holds all
- // of the required information to get the server up and running.
- // Use System properties for defaults.
- Properties props = new Properties(System.getProperties());
-
- // Use jboss.home for HOME_DIR and/or INSTALL_URL if not set.
- if (!props.containsKey(ServerConfig.HOME_DIR)) {
- props.setProperty(ServerConfig.HOME_DIR, home);
+ // Load the server instance
+ ServerLoader loader = new ServerLoader(props);
+
+ // Add JAXP and JMX libs
+ loader.addLibrary(jaxpLib);
+ loader.addLibrary(jmxLib);
+
+ // Add any extra libraries
+ for (Iterator iter=extraLibraries.iterator(); iter.hasNext();) {
+ loader.addLibrary((String)iter.next());
}
- if (!props.containsKey(ServerConfig.INSTALL_URL)) {
- props.setProperty(ServerConfig.INSTALL_URL, new
File(home).toURL().toString());
+
+ // Add any extra classapth
+ for (Iterator iter=extraClasspath.iterator(); iter.hasNext();) {
+ loader.addURL((URL)iter.next());
}
+ // Load the server
+ ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
+ Server server = loader.load(parentCL);
+
+ // Initialize & make sure that shutdown exits the VM
+ server.init(props);
+ ServerConfig config = server.getConfig();
+ config.setExitOnShutdown(true);
+
+ // Start 'er up mate!
+ server.start();
+ }
+
+ /** 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("jboss.boot.loader.name", "jboss");
String sopts = "-:hD:p:n:c:Vj:L:C:";
@@ -166,6 +187,7 @@
break; // for completeness
case 'D':
+ {
// set a system property
arg = getopt.getOptarg();
String name, value;
@@ -182,12 +204,25 @@
}
System.setProperty(name, value);
break;
+ }
case 'p':
- // set the local patch directory
+ {
+ // set the patch URL
arg = getopt.getOptarg();
- props.put(ServerConfig.PATCH_URL, new URL(arg).toString());
+
+ URL url;
+ try {
+ url = new URL(arg);
+ }
+ catch (Exception e) {
+ File file = new File(arg);
+ url = file.toURL();
+ }
+ props.put(ServerConfig.PATCH_URL, url.toString());
+
break;
+ }
case 'n':
// set the net boot url
@@ -196,13 +231,13 @@
// make sure there is a trailing '/'
if (!arg.endsWith("/")) arg += "/";
- props.put(ServerConfig.INSTALL_URL, new URL(arg).toString());
+ props.put(ServerConfig.HOME_URL, new URL(arg).toString());
break;
case 'c':
- // set the configuration name
+ // set the server name
arg = getopt.getOptarg();
- props.put(ServerConfig.CONFIG_NAME, arg);
+ props.put(ServerConfig.SERVER_NAME, arg);
break;
case 'V':
@@ -216,6 +251,7 @@
break; // for completness
case 'j':
+ {
// set the JAXP impl type
arg = getopt.getOptarg().toLowerCase();
String domFactoryType, saxFactoryType;
@@ -234,8 +270,7 @@
}
else
{
- System.err.println("Invalid JAXP type: " + arg +
- " (Expected 'crimson' or 'xerces')");
+ System.err.println("Invalid JAXP type: " + arg + " (Expected
'crimson' or 'xerces')");
// don't continue, user needs to fix this!
System.exit(1);
@@ -245,11 +280,11 @@
}
// set the controlling properties
- System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
- domFactoryType);
- System.setProperty("javax.xml.parsers.SAXParserFactory",
- saxFactoryType);
+ System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
domFactoryType);
+ System.setProperty("javax.xml.parsers.SAXParserFactory",
saxFactoryType);
+
break;
+ }
case 'L':
arg = getopt.getOptarg();
@@ -257,17 +292,21 @@
break;
case 'C':
+ {
arg = getopt.getOptarg();
+
URL url;
try {
- File file = new File(arg);
- url = file.toURL();
+ url = new URL(arg);
}
catch (Exception e) {
- url = new URL(arg);
+ File file = new File(arg);
+ url = file.toURL();
}
+
extraClasspath.add(url);
break;
+ }
default:
// this should not happen,
@@ -275,35 +314,6 @@
throw new Error("unhandled option code: " + code);
}
}
-
- // Load the server instance
- ServerLoader loader = new ServerLoader(props);
-
- // Add JAXP and JMX libs
- loader.addLibrary(jaxpLib);
- loader.addLibrary(jmxLib);
-
- // Add any extra libraries
- for (Iterator iter=extraLibraries.iterator(); iter.hasNext();) {
- loader.addLibrary((String)iter.next());
- }
-
- // Add any extra classapth
- for (Iterator iter=extraClasspath.iterator(); iter.hasNext();) {
- loader.addURL((URL)iter.next());
- }
-
- // Load the server
- ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
- Server server = loader.load(parentCL);
-
- // Initialize & make sure that shutdown exits the VM
- server.init(props);
- ServerConfig config = server.getConfig();
- config.setExitOnShutdown(true);
-
- // Start 'er up mate!
- server.start();
}
/**
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development