Package edu.uiuc.ncsa.security.util.cli
Class ConfigurableCommandsImpl2
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
-
- edu.uiuc.ncsa.security.util.cli.ConfigurableCommandsImpl2
-
- All Implemented Interfaces:
Logable,Commands,Serializable
- Direct Known Subclasses:
TestCCI
public abstract class ConfigurableCommandsImpl2 extends AbstractCommandsImpl
Basic implementation of Commands that supports loading configurations. It is intended as a the superclass for commands that have multiple components. NOTE This does not actually run commands! It is a top-level class that delegates to its command implementations (such as for stores, keys). Therefore, you should not put code here that actually executes things. The contract of this is that it manages logging, loading configurations and instantiating the actualCommandsimplementations that do everything.Created by Jeff Gaynor
on 5/20/13 at 11:35 AM- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfigurableCommandsImpl2.ListOnlyNotification
-
Field Summary
Fields Modifier and Type Field Description protected StringCFG_FILE_SWITCHstatic StringCONFIG_FILE_LONG_OPTIONstatic StringCONFIG_FILE_OPTIONstatic StringCONFIG_NAME_LONG_OPTIONstatic StringCONFIG_NAME_OPTION-
Fields inherited from class edu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
CL_INPUT_FILE_FLAG, CL_OUTPUT_FILE_FLAG, DEFAULT_NULL_VALUE_PLACEHOLDER, defaultIndent, INDENT, LOGO, logoName, NO_HEADER, NO_LOGO, showHeader, showLogo, SILENT
-
-
Constructor Summary
Constructors Constructor Description ConfigurableCommandsImpl2(CLIDriver driver)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description InputLinebootstrap(InputLine args)Parses command line arguments.protected List<String>doListNames(File target)Figures out by file extension what to list.protected abstract ConfigurationLoader<? extends AbstractEnvironment>figureOutLoader(String fileName, String configName)This is done so configurations can be loaded by inheritors.abstract StringgetComponentName()For the configuration.StringgetConfigFile()StringgetConfigName()AbstractEnvironmentgetEnvironment()abstract ConfigurationLoader<? extends AbstractEnvironment>getLoader()voidinitHelp()voidinitialize()Called at initialization to read and process the command line arguments.protected voidlistConfigs(InputLine inputLine)protected List<String>listXMLConfigs(File target)voidload(InputLine inputLine)Load resources before showing logos etc.protected voidloadConfig(String filename, String configName)Loads the configuration and sets the filename and configuration given as the current ones.voidsetConfigFile(String configFile)voidsetConfigName(String configName)voidsetDriver(CLIDriver driver)Back reference to the driver for this classvoidsetEnvironment(AbstractEnvironment environment)abstract voidsetLoader(ConfigurationLoader<? extends AbstractEnvironment> loader)protected voidshowLoadHelp()protected booleanswitchOrRun(InputLine inputLine, CommonCommands2 commands)Either switch to another component or (if there are arguments) simply run the single command and return.booleanuse(InputLine inputLine)Override this to invoke the specific components that make up your CLI.abstract voiduseHelp()-
Methods inherited from class edu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
about, bootstrap, clear_env, clearEnvHelp, configureCommands, debug, error, error, get_env, getDriver, getHelpUtil, getInput, getIOInterface, getLogoName, getPropertyHelp, gracefulExit, hasLogger, indentWidth, info, isDebugOn, isOk, isShowHeader, isShowLogo, print_env, printEnvHelp, printGetEnvHelp, printReadEnvHelp, printSaveEnvHelp, printSetEnvHelp, read_env, readJSON, readline, readline, save_env, say, say, sayi, sayv, set_env, setDebugOn, setLogoName, setShowHeader, setShowLogo, showHelp, warn
-
-
-
-
Field Detail
-
CFG_FILE_SWITCH
protected String CFG_FILE_SWITCH
-
CONFIG_FILE_OPTION
public static final String CONFIG_FILE_OPTION
- See Also:
- Constant Field Values
-
CONFIG_FILE_LONG_OPTION
public static final String CONFIG_FILE_LONG_OPTION
- See Also:
- Constant Field Values
-
CONFIG_NAME_OPTION
public static final String CONFIG_NAME_OPTION
- See Also:
- Constant Field Values
-
CONFIG_NAME_LONG_OPTION
public static final String CONFIG_NAME_LONG_OPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConfigurableCommandsImpl2
public ConfigurableCommandsImpl2(CLIDriver driver)
-
-
Method Detail
-
getConfigName
public String getConfigName()
-
setConfigName
public void setConfigName(String configName)
-
load
public void load(InputLine inputLine) throws Throwable
Description copied from class:AbstractCommandsImplLoad resources before showing logos etc. This is typically called on your behalf inAbstractCommandsImpl.bootstrap(InputLine)amd should load resources needed. Note that an exception in this does not stop booting. This allows you to start a system with a missing configuration file (for instnace) and prompt for it.
SeeAbstractCommandsImpl.initialize()which is called after this and is charged with actually starting- Specified by:
loadin classAbstractCommandsImpl- Throws:
Throwable
-
doListNames
protected List<String> doListNames(File target) throws Exception
Figures out by file extension what to list. Override as needed. Default is .xml.- Parameters:
target-- Returns:
- Throws:
Exception
-
listXMLConfigs
protected List<String> listXMLConfigs(File target) throws Exception
- Throws:
Exception
-
showLoadHelp
protected void showLoadHelp()
-
getEnvironment
public AbstractEnvironment getEnvironment() throws Exception
- Throws:
Exception
-
setEnvironment
public void setEnvironment(AbstractEnvironment environment)
-
getComponentName
public abstract String getComponentName()
For the configuration. This is the tag name (e.g. "client" or "server") in the XML file. Note this is used by subclasses in other projects.- Returns:
-
getLoader
public abstract ConfigurationLoader<? extends AbstractEnvironment> getLoader()
-
setLoader
public abstract void setLoader(ConfigurationLoader<? extends AbstractEnvironment> loader)
-
initHelp
public void initHelp() throws Throwable- Overrides:
initHelpin classAbstractCommandsImpl- Throws:
Throwable
-
initialize
public void initialize()
Called at initialization to read and process the command line arguments. NOTE that this is not called in this class, but by inheritors.- Specified by:
initializein classAbstractCommandsImpl
-
loadConfig
protected void loadConfig(String filename, String configName) throws Throwable
Loads the configuration and sets the filename and configuration given as the current ones.- Parameters:
filename-configName-- Throws:
Throwable
-
figureOutLoader
protected abstract ConfigurationLoader<? extends AbstractEnvironment> figureOutLoader(String fileName, String configName) throws Throwable
This is done so configurations can be loaded by inheritors.- Parameters:
fileName-configName-- Returns:
- Throws:
Throwable
-
getConfigFile
public String getConfigFile()
-
setConfigFile
public void setConfigFile(String configFile)
-
bootstrap
public InputLine bootstrap(InputLine args) throws Throwable
Parses command line arguments. This is usually called afterCLIDriver.bootstrap(String[]), which pulls off its startup options
-
useHelp
public abstract void useHelp()
-
use
public boolean use(InputLine inputLine) throws Throwable
Override this to invoke the specific components that make up your CLI.
-
switchOrRun
protected boolean switchOrRun(InputLine inputLine, CommonCommands2 commands)
Either switch to another component or (if there are arguments) simply run the single command and return. Note that each component has stored state, so these will be run with whatever is in that state. Requiresuse(InputLine)be overridden.- Parameters:
inputLine-commands-- Returns:
-
setDriver
public void setDriver(CLIDriver driver)
Back reference to the driver for this class- Specified by:
setDriverin interfaceCommands- Overrides:
setDriverin classAbstractCommandsImpl- Parameters:
driver-
-
-