jdillon 2003/08/24 04:23:14
Modified: modules/core project.xml
modules/core/src/java/org/apache/geronimo Main.java
Added: modules/core/src/bin start
modules/core/src/conf/twiddle geronimo.conf
modules/core/src/java/org/apache/geronimo/command
StartCommand.java
Log:
o Created StartCommand
o Removed main entry-point from Main, use StartCommand
o Added start script, once command sets work can create a geronimo script
which has start|stop commands
o Added geronimo specific twiddle command configuration file
o Core now depends on Twiddle module
Revision Changes Path
1.12 +20 -1 incubator-geronimo/modules/core/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/project.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- project.xml 22 Aug 2003 19:03:37 -0000 1.11
+++ project.xml 24 Aug 2003 11:23:14 -0000 1.12
@@ -38,6 +38,15 @@
</dependency>
<dependency>
+ <groupId>geronimo</groupId>
+ <artifactId>geronimo-twiddle</artifactId>
+ <version>DEV</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ <dependency>
<groupId>geronimo-spec</groupId>
<artifactId>geronimo-spec-jta</artifactId>
<version>DEV</version>
@@ -158,6 +167,16 @@
<id>dom4j</id>
<version>1.4</version>
</dependency>
+
+ <dependency>
+ <id>commons-cli</id>
+ <version>1.0</version>
+ <url>http://jakarta.apache.org/commons/cli</url>
+ <properties>
+ <runtime>true</runtime>
+ </properties>
+ </dependency>
+
</dependencies>
1.1 incubator-geronimo/modules/core/src/bin/start
Index: start
===================================================================
#!/bin/sh
##############################################################################
## ##
## Twiddle Proxy ##
## ##
##############################################################################
##
## $Revision: 1.1 $ $Date: 2003/08/24 11:23:14 $
##
PROGNAME=`basename $0`
DIRNAME=`dirname $0`
COMMAND_PATH="geronimo/start"
if [ -n "$TWIDDLE_OPTS" ]; then
TWIDDLE_OPTS=""
fi
exec $DIRNAME/twiddle $TWIDDLE_OPTS $COMMAND_PATH -- "$@"
1.1
incubator-geronimo/modules/core/src/conf/twiddle/geronimo.conf
Index: geronimo.conf
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision: 1.1 $ $Date: 2003/08/24 11:23:14 $ -->
<configuration
xmlns="http://geronimo.apache.org/xml/schema/Twiddle/Configuration">
<!-- Command sets are not implemented yet so simulate them with command
name -->
<commands>
<command name="geronimo/start"
code="org.apache.geronimo.command.StartCommand"/>
</commands>
</configuration>
1.9 +1 -22
incubator-geronimo/modules/core/src/java/org/apache/geronimo/Main.java
Index: Main.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/Main.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Main.java 18 Aug 2003 22:15:36 -0000 1.8
+++ Main.java 24 Aug 2003 11:23:14 -0000 1.9
@@ -189,27 +189,6 @@
}
}
- /**
- * Command line entry point.
- * Starts a new ThreadGroup so that all owned threads can be identified.
- * @param args command line arguments
- */
- public static void main(String[] args) {
- try {
- // @todo get these from somewhere a little more flexible
- URL mletURL = new URL("file:src/conf/boot.mlet");
- URL deployURL = new URL("file:src/conf/boot-service.xml");
- Main main = new Main("geronimo", mletURL, deployURL);
-
- ThreadGroup group = new ThreadGroup("Geronimo");
- Thread mainThread = new Thread(group, main, "Main-Thread");
- mainThread.start();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- return;
- }
- }
-
private static class ShutdownThread extends Thread {
private final Thread mainThread;
1.1
incubator-geronimo/modules/core/src/java/org/apache/geronimo/command/StartCommand.java
Index: StartCommand.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.command;
import java.net.URL;
import java.io.PrintWriter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.ParseException;
import org.apache.geronimo.common.NullArgumentException;
import org.apache.geronimo.common.Strings;
import org.apache.geronimo.twiddle.command.Command;
import org.apache.geronimo.twiddle.command.CommandInfo;
import org.apache.geronimo.twiddle.command.CommandContext;
import org.apache.geronimo.twiddle.command.AbstractCommand;
import org.apache.geronimo.twiddle.util.HelpFormatter;
import org.apache.geronimo.Main;
/**
* A <em>Twiddle</em> command to start a Apache Geronimo server instance.
*
* @version $Revision: 1.1 $ $Date: 2003/08/24 11:23:14 $
*/
public class StartCommand
extends AbstractCommand
{
public int execute(String[] args) throws Exception
{
if (args == null) {
throw new NullArgumentException("args");
}
// Get our output writer
PrintWriter out = getWriter();
// Create the Options
Options options = new Options();
options.addOption(OptionBuilder.withLongOpt("help")
.withDescription("Display this help
message")
.create('h'));
options.addOption(OptionBuilder.withLongOpt("mlet")
.withDescription("MLet URL")
.hasArg()
.create('m'));
options.addOption(OptionBuilder.withLongOpt("deploy")
.withDescription("Deploy URL")
.hasArg()
.create('d'));
// Create the command line parser
CommandLineParser parser = new PosixParser();
// Carse the command line arguments
CommandLine line = parser.parse(options, args);
// Display help
if (line.hasOption('h')) {
CommandInfo info = getCommandInfo();
if (info.hasDescription()) {
out.println(info.getDescription());
out.println();
}
HelpFormatter formatter = new HelpFormatter(out);
formatter.print(info.getName() + " [options]", options);
return Command.SUCCESS;
}
URL mletURL = Strings.toURL("etc/boot.mlet");
if (line.hasOption('m')) {
String value = line.getOptionValue('m');
mletURL = Strings.toURL(value);
}
URL deployURL = Strings.toURL("etc/boot-service.xml");
if (line.hasOption('d')) {
String value = line.getOptionValue('d');
deployURL = Strings.toURL(value);
}
if (log.isDebugEnabled()) {
log.debug("MLet URL: " + mletURL);
log.debug("Deploy URL: " + deployURL);
}
Main main = new Main("geronimo", mletURL, deployURL);
ThreadGroup group = new ThreadGroup("Geronimo");
Thread mainThread = new Thread(group, main, "Main-Thread");
mainThread.start();
//
// TODO: Check if we are in interactive mode...
//
mainThread.join();
return Command.SUCCESS;
}
}