[Mulgara-svn] r1113 - trunk/src/jar/server/java/org/mulgara/server
pag at mulgara.org
pag at mulgara.org
Mon Jul 28 22:59:47 UTC 2008
Author: pag
Date: 2008-07-28 15:59:46 -0700 (Mon, 28 Jul 2008)
New Revision: 1113
Modified:
trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraOptionParser.java
Log:
Added the SHUTDOWN option back in. I don't know when this was removed, but it still appears in the help text. Also took advantage of the update to reformat the file
Modified: trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraOptionParser.java
===================================================================
--- trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraOptionParser.java 2008-07-28 22:56:33 UTC (rev 1112)
+++ trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraOptionParser.java 2008-07-28 22:59:46 UTC (rev 1113)
@@ -29,6 +29,7 @@
// third party packages
import jargs.gnu.CmdLineParser;
+import static jargs.gnu.CmdLineParser.Option.*;
// third party packages
import org.apache.log4j.Logger;
@@ -37,114 +38,58 @@
* Command line option parser for the Mulgara server.
*
* @created 2001-12-21
- *
* @author Tom Adams
- *
- * @modified $Date: 2005/01/13 01:55:32 $ by $Author: raboczi $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
* @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
- *
- * @copyright ©2001-2004 <a href="http://www.pisoftware.com/">Plugged In
- * Software Pty Ltd</a>
- *
+ * @copyright ©2001-2004 <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
public class EmbeddedMulgaraOptionParser extends CmdLineParser {
- /**
- * option to display the help
- */
- public final static Option HELP =
- new CmdLineParser.Option.BooleanOption('h', "help");
+ /** option to display the help */
+ public final static Option HELP = new BooleanOption('h', "help");
- /**
- * option to use an external logging configuration file
- */
- public final static Option LOG_CONFIG =
- new CmdLineParser.Option.StringOption('l', "logconfig");
+ /** option to stop a running server */
+ public final static Option SHUTDOWN = new BooleanOption('x', "shutdown");
- /**
- * option to use an external configuration file
- */
- public final static Option SERVER_CONFIG =
- new CmdLineParser.Option.StringOption('c', "serverconfig");
+ /** option to use an external logging configuration file */
+ public final static Option LOG_CONFIG = new StringOption('l', "logconfig");
- /**
- * option to change the host the HTTP server is bound to
- */
- public final static Option HTTP_HOST =
- new CmdLineParser.Option.StringOption('o', "httphost");
+ /** option to use an external configuration file */
+ public final static Option SERVER_CONFIG = new StringOption('c', "serverconfig");
- /**
- * option to change the host the server is bound to
- */
- public final static Option SERVER_HOST =
- new CmdLineParser.Option.StringOption('k', "serverhost");
+ /** option to change the host the HTTP server is bound to */
+ public final static Option HTTP_HOST = new StringOption('o', "httphost");
- /**
- * option to disble the automatic starting of a RMI Registry
- */
- public final static Option NO_RMI =
- new CmdLineParser.Option.BooleanOption('n', "normi");
+ /** option to change the host the server is bound to */
+ public final static Option SERVER_HOST = new StringOption('k', "serverhost");
- /**
- * option to change to the port the RMI registry listens on
- */
- public final static Option RMI_PORT =
- new CmdLineParser.Option.StringOption('r', "rmiport");
+ /** option to disble the automatic starting of a RMI Registry */
+ public final static Option NO_RMI = new BooleanOption('n', "normi");
- /**
- * option to change the port the server is bound to
- */
- public final static Option PORT =
- new CmdLineParser.Option.StringOption('p', "port");
+ /** option to change to the port the RMI registry listens on */
+ public final static Option RMI_PORT = new StringOption('r', "rmiport");
- /**
- * option to change the name of the server
- */
- public final static Option SERVER_NAME =
- new CmdLineParser.Option.StringOption('s', "servername");
+ /** option to change the port the server is bound to */
+ public final static Option PORT = new StringOption('p', "port");
- /**
- * option to change the location of database files
- */
- public final static Option PERSISTENCE_PATH =
- new CmdLineParser.Option.StringOption('a', "path");
+ /** option to change the name of the server */
+ public final static Option SERVER_NAME = new StringOption('s', "servername");
- /**
- * option to set the smtp server
- */
- public final static Option SMTP_SERVER =
- new CmdLineParser.Option.StringOption('m', "smtp");
+ /** option to change the location of database files */
+ public final static Option PERSISTENCE_PATH = new StringOption('a', "path");
- //
- // Constants
- //
+ /** option to set the smtp server */
+ public final static Option SMTP_SERVER = new StringOption('m', "smtp");
- /**
- * the category to log to
- */
+ /** Logger */
private final static Logger log = Logger.getLogger(EmbeddedMulgaraOptionParser.class);
- //
- // members
- //
-
- /**
- * the command line arguments passed to the Mulgara server
- */
+ /** the command line arguments passed to the Mulgara server */
protected String[] args = null;
- /**
- * flag indicating whether we've parsed the options yet
- */
+ /** flag indicating whether we've parsed the options yet */
protected boolean optionsParsed = false;
- //
- // Constructors
- //
/**
* Creates a new Mulgara server command line option parser to parse the command
@@ -153,78 +98,59 @@
* @param args the command line arguments
*/
public EmbeddedMulgaraOptionParser(String[] args) {
-
- // call the superclass constructor
super();
+ if (args == null) throw new IllegalArgumentException("Null \"args\" parameter");
- // validate args parameter
- if (args == null) {
-
- throw new IllegalArgumentException("Null \"args\" parameter");
- }
-
- // end if
- // log that we've created a parser
- //log.debug("Created option parser for Mulgara server");
// set the member
- this.setArgs(args);
+ setArgs(args);
// add the options
- this.addOption(HELP);
- this.addOption(LOG_CONFIG);
- this.addOption(HTTP_HOST);
- this.addOption(SERVER_HOST);
- this.addOption(PORT);
- this.addOption(NO_RMI);
- this.addOption(RMI_PORT);
- this.addOption(SERVER_NAME);
- this.addOption(PERSISTENCE_PATH);
- this.addOption(SMTP_SERVER);
- this.addOption(SERVER_CONFIG);
+ addOption(HELP);
+ addOption(SHUTDOWN);
+ addOption(LOG_CONFIG);
+ addOption(HTTP_HOST);
+ addOption(SERVER_HOST);
+ addOption(PORT);
+ addOption(NO_RMI);
+ addOption(RMI_PORT);
+ addOption(SERVER_NAME);
+ addOption(PERSISTENCE_PATH);
+ addOption(SMTP_SERVER);
+ addOption(SERVER_CONFIG);
+ }
- } // EmbeddedMulgaraOptionParser()
- //
- // Public API
- //
-
/**
* Parses the command line arguments given to this parser.
- *
* @throws UnknownOptionException if an unknown option was specified in the
* list of options given to the parser
* @throws IllegalOptionValueException if an option given to the parser
* contains an illegal value
*/
- public void parse() throws UnknownOptionException,
- IllegalOptionValueException {
+ public void parse() throws UnknownOptionException, IllegalOptionValueException {
- // log that
- //log.debug("Parsing Mulgara server arguments");
// parse the arguments if we haven't done so already
if (!this.optionsParsed) {
// parse the arguments
- this.parse(this.getArgs());
+ parse(this.getArgs());
// fail if there are any remaing that we dodn't know about
- String[] remainingArgs = this.getRemainingArgs();
-
+ String[] remainingArgs = getRemainingArgs();
if (remainingArgs.length > 0) {
-
// throw a new exception to indicate that there were unkown arguments
+ log.error("Unknown options: " + remainingArgs);
throw new UnknownOptionException(remainingArgs[0]);
- } // end if
+ }
// we've now parser the options
- this.optionsParsed = true;
- } // end if
+ optionsParsed = true;
+ }
+ }
- } // parse()
/**
* Validates the command line options.
- *
* @return true if the options are valid
*/
public boolean optionsValid() {
@@ -232,46 +158,32 @@
boolean optionsValid = false;
try {
-
// validate params by parsing the arguments
this.parse();
optionsValid = true;
- }
- catch (UnknownOptionException uoe) {
-
+ } catch (UnknownOptionException uoe) {
optionsValid = false;
- }
- catch (IllegalOptionValueException iove) {
-
+ } catch (IllegalOptionValueException iove) {
optionsValid = false;
}
- // try-catch
- // return whether the options are valid
return optionsValid;
- } // optionsValid()
+ }
- //
- // Internal methods
- //
-
/**
* Sets the command line arguments passed to the itql interpreter.
- *
* @param args The new Args value
*/
protected void setArgs(String[] args) {
-
this.args = args;
- } // setArgs()
+ }
+
/**
* Returns the command line arguments passed to the itql interpreter.
- *
* @return the command line arguments passed to the itql interpreter
*/
protected String[] getArgs() {
-
- return this.args;
- } // getArgs()
+ return args;
+ }
}
More information about the Mulgara-svn
mailing list