Class ConfigurableCommandsImpl

  • All Implemented Interfaces:
    Logable, Commands, Serializable

    public abstract class ConfigurableCommandsImpl
    extends Object
    implements Commands
    Basic implementation of Commands. This supports loading configurations. 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 actual Commands implementations that do everything.

    Created by Jeff Gaynor
    on 5/20/13 at 11:35 AM

    See Also:
    Serialized Form
    • Constructor Detail

      • ConfigurableCommandsImpl

        protected ConfigurableCommandsImpl​(MyLoggingFacade logger)
    • Method Detail

      • showHelp

        protected boolean showHelp​(InputLine inputLine)
        returns "true if the command has the flag --help in it. This is a cue from the user to show the help for a given function. So it the function is called "X" and its help is in the function "showXHelp" then a value of true from this should simply invoke "showXHelp" and return.
        Parameters:
        inputLine -
        Returns:
      • say

        protected void say​(String x)
      • sayv

        protected void sayv​(String x)
      • getConfigName

        public String getConfigName()
      • setConfigName

        public void setConfigName​(String configName)
      • 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
      • showLoadHelp

        protected void showLoadHelp()
      • getComponentName

        public abstract String getComponentName()
        For the configuration. This is the tag name (e.g. "client" or "server") in the XML file.
        Returns:
      • readEnv

        protected void readEnv​(String path,
                               boolean verbose)
      • initialize

        protected 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.
      • getConfigFile

        public String getConfigFile()
      • setConfigFile

        public void setConfigFile​(String configFile)
      • isDebugOn

        public boolean isDebugOn()
        Description copied from interface: Logable
        Query if debugging is enabled for this logger.
        Specified by:
        isDebugOn in interface Logable
        Returns:
      • setDebugOn

        public void setDebugOn​(boolean setOn)
        Description copied from interface: Logable
        Enable/disable debugging for this logger
        Specified by:
        setDebugOn in interface Logable
      • setMyLogger

        public void setMyLogger​(MyLoggingFacade myLoggingFacade)
      • hasLogger

        protected boolean hasLogger()
      • debug

        public void debug​(String x)
        Description copied from interface: Logable
        Write a debug message to the log.
        Specified by:
        debug in interface Logable
      • info

        public void info​(String x)
        Description copied from interface: Logable
        Write an informational message to the log
        Specified by:
        info in interface Logable
      • warn

        public void warn​(String x)
        Description copied from interface: Logable
        Write a warning to the log. This indicates a severe, but non-fatal condition exists.
        Specified by:
        warn in interface Logable
      • error

        public void error​(String x)
        Description copied from interface: Logable
        Write an error message to the log. Typically this is invoked as the last command before throwing an exception.
        Specified by:
        error in interface Logable
      • isVerbose

        public boolean isVerbose()
      • setVerbose

        public void setVerbose​(boolean verbose)
      • padLineWithBlanks

        protected String padLineWithBlanks​(String x,
                                           int width)
        This will take a String and append the correct number of blanks on the left so it is the right width. This is used for making the banner.

        Used extensively in subclasses for formatting help

        Returns:
      • 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.
        Parameters:
        inputLine -
        Returns:
        Throws:
        Exception
        Throwable
      • switchOrRun

        protected boolean switchOrRun​(InputLine inputLine,
                                      CommonCommands 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. Requires use(InputLine) be overridden.
        Parameters:
        inputLine -
        commands -
        Returns:
      • getDriver

        public CLIDriver getDriver()
        Description copied from interface: Commands
        Back reference to the driver that manages this instance.
        Specified by:
        getDriver in interface Commands
        Returns:
      • setDriver

        public void setDriver​(CLIDriver driver)
        Back reference to the driver for this class
        Specified by:
        setDriver in interface Commands
        Parameters:
        driver -