| Method from org.jboss.tools.Boot Detail: |
public Boot.ApplicationBoot createApplicationBoot() {
return new ApplicationBoot();
}
This can be used to boot another application
From within another one. |
public static Boot getInstance() {
if( instance == null )
instance = new Boot();
return instance;
}
|
public synchronized Boot.ApplicationBoot[] getStartedApplications() {
ApplicationBoot rc[] = new ApplicationBoot[applicationBoots.size()];
return (ApplicationBoot[])applicationBoots.toArray(rc);
}
|
public static void main(String[] args) {
Boot boot = Boot.getInstance();
// Put the args in a linked list since it easier to work with.
LinkedList llargs = new LinkedList();
for (int i = 0; i < args.length; i++)
llargs.add(args[i]);
try {
LinkedList ab = boot.processCommandLine(llargs);
Iterator i = ab.iterator();
while (i.hasNext())
{
ApplicationBoot bootData = (ApplicationBoot) i.next();
boot.startApplication(bootData);
}
} catch ( InvalidCommandLineException e ) {
System.err.println("Invalid Usage: "+e.getMessage());
System.err.println();
showUsage();
System.exit(1);
} catch ( Throwable e ) {
System.err.println("Failure occured while executing application: ");
e.printStackTrace(System.err);
System.exit(1);
}
}
Main entry point when called from the command line |
protected Boot.ApplicationBoot processAppBootCommandLine(LinkedList args) throws Exception {
ApplicationBoot rc = new ApplicationBoot();
Iterator i = args.iterator();
while (i.hasNext())
{
String arg = (String) i.next();
i.remove();
if (rc.applicationClass == null)
{
if (arg.equalsIgnoreCase(CP))
{
if (!i.hasNext())
throw new InvalidCommandLineException("Invalid option: classpath missing after the " + CP + " option.");
String cp = (String) i.next();
i.remove();
StringTokenizer st = new StringTokenizer(cp, ",", false);
while (st.hasMoreTokens())
{
String t = st.nextToken();
if (t.length() == 0)
continue;
try
{
URL u = new URL(t);
rc.classpath.add(u);
}
catch (MalformedURLException e)
{
throw new InvalidCommandLineException("Application classpath value was invalid: " + e.getMessage());
}
}
continue;
}
rc.applicationClass = arg;
continue;
}
else
{
if (arg.equalsIgnoreCase(BOOT_APP_SEPERATOR))
{
break;
}
rc.args.add(arg);
}
}
if (rc.applicationClass == null)
return null;
return rc;
}
Processes the command line argumenst for the next application on the command line. |
protected void processBootOptions(LinkedList args) throws Exception {
Iterator i = args.iterator();
while (i.hasNext())
{
String arg = (String) i.next();
if (arg.equalsIgnoreCase(VERBOSE))
{
verbose = true;
i.remove();
continue;
}
if (arg.equalsIgnoreCase(HELP))
{
showUsage();
System.exit(0);
}
// Didn't recognize it a boot option, then we must have started the application
// boot options.
return;
}
}
Processes to global options. |
protected LinkedList processCommandLine(LinkedList args) throws Exception {
LinkedList rc = new LinkedList();
processBootOptions(args);
while (args.size() > 0)
{
ApplicationBoot d = processAppBootCommandLine(args);
if (d != null)
rc.add(d);
}
if (rc.size() == 0)
{
throw new InvalidCommandLineException("An application class name must be provided.");
}
return rc;
}
Processes the Boot class's command line arguments |
protected static void showUsage() {
String programName = System.getProperty("org.jboss.Boot.proces-name", "boot");
System.out.println("usage: " + programName + " [boot-options] [app-options] class [args..]");
System.out.println(" to execute a class");
System.out.println(" or " + programName + " [boot-options] [app-options] class-1 [args..] , ... , [app-options] class-n [args..]");
System.out.println(" to execute multiple classes");
System.out.println();
System.out.println("boot-options:");
System.out.println(" -help show this help message");
System.out.println(" -verbose display detail messages regarding the boot process.");
System.out.println("app-options:");
System.out.println(" -cp < directories and zip/jar urls separated by , > ");
System.out.println(" set search path for application classes and resources");
System.out.println();
}
|
public synchronized void startApplication(Boot.ApplicationBoot bootData) throws Exception {
if( bootData == null )
throw new NullPointerException("Invalid argument: bootData argument was null");
applicationBoots.add(bootData);
ThreadGroup threads = new ThreadGroup(bootThreadGroup, bootData.applicationClass);
new Thread(threads, bootData, "main").start();
}
Boots the application in a new threadgroup and thread. |
public static void systemExit(String[] argv) {
System.exit(0);
}
This method is here so that if JBoss is running under
Alexandria (An NT Service Installer), Alexandria can shutdown
the system down correctly. |
protected void verbose(String msg) {
if( verbose )
System.out.println("[Boot] "+msg);
}
logs verbose message to the console |