org.carrot2.dcs
Class AppBase

java.lang.Object
  extended by org.carrot2.dcs.AppBase
Direct Known Subclasses:
BatchApp, BenchmarkApp, DCSApp

public abstract class AppBase
extends Object

A base for command-line invoked applications.

See Also:
BatchApp, DCSApp

Field Summary
protected  org.apache.commons.cli.Options cliOptions
          Command line options.
protected  String header
          Header text
 
Constructor Summary
protected AppBase(String appName)
          Initializing constructor.
protected AppBase(String appName, String header)
          Initializing constructor.
 
Method Summary
protected  String getCommandName()
          Override to provide command line app name.
protected  org.apache.log4j.Logger getLogger()
          Returns the logger for this class.
protected abstract  void go(org.apache.commons.cli.CommandLine line)
          Override and write your stuff using command line options.
protected  void go(String[] args)
          Initializes application context.
protected  ControllerContext initializeContext(File descriptorsDir)
          Initializes the processing context.
protected abstract  void initializeOptions(org.apache.commons.cli.Options options)
          Override and initialize options.
protected  void printHeader()
          Prints header text (if not blank).
protected  void printUsage()
          Prints usage (options).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cliOptions

protected final org.apache.commons.cli.Options cliOptions
Command line options.


header

protected final String header
Header text

Constructor Detail

AppBase

protected AppBase(String appName)
Initializing constructor.

Parameters:
appName - Application name (used in help and logger naming).

AppBase

protected AppBase(String appName,
                  String header)
Initializing constructor.

Parameters:
appName - Application name (used in help and logger naming).
header - Header text to be appended before options help
Method Detail

go

protected final void go(String[] args)
Initializes application context.


initializeContext

protected ControllerContext initializeContext(File descriptorsDir)
                                       throws ConfigurationException
Initializes the processing context.

Parameters:
descriptorsDir - A directory with definitions of processes and descriptors.
Throws:
ConfigurationException - if the configuration fails for some reason.

printHeader

protected void printHeader()
Prints header text (if not blank).


printUsage

protected void printUsage()
Prints usage (options).


go

protected abstract void go(org.apache.commons.cli.CommandLine line)
                    throws Exception
Override and write your stuff using command line options.

Throws:
Exception

initializeOptions

protected abstract void initializeOptions(org.apache.commons.cli.Options options)
Override and initialize options.


getCommandName

protected String getCommandName()
Override to provide command line app name.

Returns:
command line app name, eg. c2http

getLogger

protected final org.apache.log4j.Logger getLogger()
Returns the logger for this class.



Copyright (c) Dawid Weiss, Stanislaw Osinski