org.dbmaintain.launch.commandline
Class CommandLine

java.lang.Object
  extended by org.dbmaintain.launch.commandline.CommandLine

public class CommandLine
extends Object

Class that exposes a set of DbMaintain operations for command line execution.

Author:
Filip Neven, Tim Ducheyne

Nested Class Summary
static class CommandLine.DbMaintainOperation
          Enum that defines all DbMaintain operations that can be invoked using this class.
 
Field Summary
static String DBMAINTAIN_PROPERTIES
           
 
Constructor Summary
CommandLine()
           
 
Method Summary
static void executeOperation(CommandLine.DbMaintainOperation operation, Properties configuration, CommandLineArguments commandLineArguments)
          Executes the given operation using the given configuration.
protected static CommandLine.DbMaintainOperation getDbMaintainOperation(CommandLineArguments commandLineArguments)
          Gets the requested DbMaintain operation.
protected static MainFactory getMainFactory(Properties configuration)
           
protected static URL getPropertiesAsURL(String fileName)
           
protected static Properties loadConfiguration(CommandLineArguments commandLineArguments)
          Loads the configuration from custom config file or, if no custom config file was configured, from DBMAINTAIN_PROPERTIES, if this file exists.
static void main(String[] args)
          Executes a DbMaintain operation.
protected static CommandLineArguments parseCommandLineArguments(String[] args)
          Parses the command line arguments and gives back a CommandLineArguments instance that represents these arguments in a more convenient way.
static void printHelpMessage()
          Prints out a help message that explains the usage of this class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBMAINTAIN_PROPERTIES

public static final String DBMAINTAIN_PROPERTIES
See Also:
Constant Field Values
Constructor Detail

CommandLine

public CommandLine()
Method Detail

main

public static void main(String[] args)
Executes a DbMaintain operation. The first command-line argument defines the operation that must be executed. The second argument defines the properties file that is used to configure DbMaintain.

Parameters:
args - The command line arguments

parseCommandLineArguments

protected static CommandLineArguments parseCommandLineArguments(String[] args)
Parses the command line arguments and gives back a CommandLineArguments instance that represents these arguments in a more convenient way.

Parameters:
args - The command line arguments as an array of strings
Returns:
An instance of CommandLineArguments

getDbMaintainOperation

protected static CommandLine.DbMaintainOperation getDbMaintainOperation(CommandLineArguments commandLineArguments)
Gets the requested DbMaintain operation. If the requested operation cannot be recognized, an error message is printed, a help message is shown and execution is ended.

Parameters:
commandLineArguments - The command line arguments
Returns:
The requested DbMaintain operation

loadConfiguration

protected static Properties loadConfiguration(CommandLineArguments commandLineArguments)
Loads the configuration from custom config file or, if no custom config file was configured, from DBMAINTAIN_PROPERTIES, if this file exists. If a custom config file was configured and the config file cannot be found, an error message is printed and execution is ended.

Parameters:
commandLineArguments - The command line arguments
Returns:
The configuration as a Properties file

executeOperation

public static void executeOperation(CommandLine.DbMaintainOperation operation,
                                    Properties configuration,
                                    CommandLineArguments commandLineArguments)
Executes the given operation using the given configuration.

Parameters:
operation - The operation that must be executed
configuration - The dbMaintain configuration
commandLineArguments - The command line arguments

getMainFactory

protected static MainFactory getMainFactory(Properties configuration)

getPropertiesAsURL

protected static URL getPropertiesAsURL(String fileName)
Parameters:
fileName - The name of the file
Returns:
An inputStream giving access to the file with the given name.

printHelpMessage

public static void printHelpMessage()
Prints out a help message that explains the usage of this class



Copyright © 2011. All Rights Reserved.