Class CtxHelper

java.lang.Object
org.refcodes.decoupling.Reactor
org.refcodes.decoupling.ext.application.ApplicationReactor
org.refcodes.archetype.CtxHelper
All Implemented Interfaces:
org.refcodes.cli.Optionable, org.refcodes.mixin.VerboseAccessor, org.refcodes.properties.ext.application.ApplicationPropertiesAccessor

public class CtxHelper extends org.refcodes.decoupling.ext.application.ApplicationReactor
The CtxHelper enables harnessing the ApplicationProperties alongside the ApplicationProperties profile support (as of ProfileProperties.getRuntimeProfiles()) by automatically placing an accordingly configured ApplicationProperties instance into the container and enabling it for injection. The ApplicationProperties Dependency's alias is set to "applicationProperties" (as of this class's constant ApplicationReactor.APPLICATION_PROPERTIES_ALIAS).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 

    Nested classes/interfaces inherited from class org.refcodes.decoupling.ext.application.ApplicationReactor

    org.refcodes.decoupling.ext.application.ApplicationReactor.ProfilesMode

    Nested classes/interfaces inherited from interface org.refcodes.properties.ext.application.ApplicationPropertiesAccessor

    org.refcodes.properties.ext.application.ApplicationPropertiesAccessor.ApplicationPropertiesBuilder<B extends org.refcodes.properties.ext.application.ApplicationPropertiesAccessor.ApplicationPropertiesBuilder<B>>, org.refcodes.properties.ext.application.ApplicationPropertiesAccessor.ApplicationPropertiesMutator, org.refcodes.properties.ext.application.ApplicationPropertiesAccessor.ApplicationPropertiesProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.VerboseAccessor

    org.refcodes.mixin.VerboseAccessor.VerboseMutator, org.refcodes.mixin.VerboseAccessor.VerboseProperty
  • Field Summary

    Fields inherited from class org.refcodes.decoupling.ext.application.ApplicationReactor

    _properties, APPLICATION_BUS_ALIAS, APPLICATION_CONTEXT_ALIAS, APPLICATION_PROPERTIES_ALIAS

    Fields inherited from class org.refcodes.decoupling.Reactor

    _dependencies
  • Constructor Summary

    Constructors
    Constructor
    Description
    CtxHelper(File aFile)
    CtxHelper(File aFile, String[] aArgs)
    CtxHelper(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator)
    CtxHelper(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs)
    CtxHelper(InputStream aInputStream)
    CtxHelper(InputStream aInputStream, String[] aArgs)
    CtxHelper(String aFilePath)
    CtxHelper(String[] aArgs, Character aShortOptionPrefix, String aLongOptionPrefix, org.refcodes.cli.Constituent aArgsSyntax, org.refcodes.cli.SyntaxMetrics aSyntaxMetrics, String aTitle, String aName, String aDescription, String aCopyright, String aLicense, Collection<org.refcodes.cli.Example> aExamples, URL aUrl, InputStream aInputStream, File aFile, String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, Class<?> aResourceClass, char[] aDelimiters, boolean aIsVerboseFallback, String aPasswordPrompt, org.refcodes.textual.Font aBannerFont, char[] aBannerFontPalette, Character aSeparatorLnChar, org.refcodes.textual.TextBoxGrid aTextBoxGrid, String aLineBreak, Integer aConsoleWidth, Integer aMaxConsoleWidth, Boolean isEscCodesEnabled, String aBannerEscCode, String aBannerBorderEscCode, String aArgumentEscCode, String aCommandEscCode, String aOptionEscCode, String aDescriptionEscCode, String aLineSeparatorEscCode, String aResetEscCode, Consumer<Integer> aShutdownHook, PrintStream aStandardOut, PrintStream aErrorOut, org.refcodes.logger.RuntimeLogger aLogger)
    Creates a new CtxHelper with all the properties mainly regarded to the ApplicationProperties used under the hood (for ease of use please use the AbstractBuilderCli be calling the builder() method).
    CtxHelper(String aFilePath, String[] aArgs)
    CtxHelper(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator)
    CtxHelper(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs)
    CtxHelper(URL aUrl)
    CtxHelper(URL aUrl, String[] aArgs)
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates builder to build CtxHelper.
    void
    createResourceFile(String aResourcePath, File aDestinationFile)
    void
    createResourceFile(String aResourcePath, String aDestinationPath)
    void
    exit(int aStatusCode)
    void
    exit(org.refcodes.data.ExitCode aExitCode)
    void
    org.refcodes.properties.ext.application.ApplicationProperties
    Gets the runtime properties.
    boolean
    void
    void
    char[]
    char[]
    toOptions(org.refcodes.cli.Option<?> aOption)

    Methods inherited from class org.refcodes.decoupling.ext.application.ApplicationReactor

    addConfiguration, addConfiguration, addConfiguration, addConfiguration, addConfiguration, addConfiguration, createContext, createContext, createContext, createContext, toContext

    Methods inherited from class org.refcodes.decoupling.Reactor

    addDependency, addDependency, addDependency, addDependency, addDependency

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CtxHelper

      public CtxHelper()
    • CtxHelper

      public CtxHelper(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(File aFile, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(File aFile, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(File aFile) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(InputStream aInputStream, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(InputStream aInputStream) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(String aFilePath, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(String aFilePath) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(URL aUrl, String[] aArgs) throws IOException, ParseException, org.refcodes.cli.ArgsSyntaxException
      Throws:
      IOException
      ParseException
      org.refcodes.cli.ArgsSyntaxException
    • CtxHelper

      public CtxHelper(URL aUrl) throws IOException, ParseException
      Throws:
      IOException
      ParseException
    • CtxHelper

      public CtxHelper(String[] aArgs, Character aShortOptionPrefix, String aLongOptionPrefix, org.refcodes.cli.Constituent aArgsSyntax, org.refcodes.cli.SyntaxMetrics aSyntaxMetrics, String aTitle, String aName, String aDescription, String aCopyright, String aLicense, Collection<org.refcodes.cli.Example> aExamples, URL aUrl, InputStream aInputStream, File aFile, String aFilePath, org.refcodes.runtime.ConfigLocator aConfigLocator, Class<?> aResourceClass, char[] aDelimiters, boolean aIsVerboseFallback, String aPasswordPrompt, org.refcodes.textual.Font aBannerFont, char[] aBannerFontPalette, Character aSeparatorLnChar, org.refcodes.textual.TextBoxGrid aTextBoxGrid, String aLineBreak, Integer aConsoleWidth, Integer aMaxConsoleWidth, Boolean isEscCodesEnabled, String aBannerEscCode, String aBannerBorderEscCode, String aArgumentEscCode, String aCommandEscCode, String aOptionEscCode, String aDescriptionEscCode, String aLineSeparatorEscCode, String aResetEscCode, Consumer<Integer> aShutdownHook, PrintStream aStandardOut, PrintStream aErrorOut, org.refcodes.logger.RuntimeLogger aLogger)
      Creates a new CtxHelper with all the properties mainly regarded to the ApplicationProperties used under the hood (for ease of use please use the AbstractBuilderCli be calling the builder() method).
      Parameters:
      aArgs - The command line arguments.
      aShortOptionPrefix - The short options' prefix to be set.
      aLongOptionPrefix - The long options' prefix to be set.
      aArgsSyntax - The args syntax root node of your command line syntax.
      aSyntaxMetrics - the syntax metrics
      aTitle - The title of the application.
      aName - The name of your application.
      aDescription - The description to use when printing out the help.
      aCopyright - The copyright being applied.
      aLicense - The license for the application.
      aExamples - The Example examples to use when printing out the help.
      aUrl - The URL from which to load the configuration.
      aInputStream - The InputStream from which to load the configuration.s
      aFile - File from which to load the configuration.
      aFilePath - The name to your default config file.
      aConfigLocator - The ConfigLocator to use when locating the configuration file (defaults to ConfigLocator.DEFAULT.
      aResourceClass - The application's Class which to use when loading resources (of the according module) by invoking Class.getResourceAsStream(String).
      aDelimiters - The delimiters to be used when parsing specific configuration file notations.
      aIsVerboseFallback - the is verbose fallback
      aPasswordPrompt - The prompt to use when requesting a password.
      aBannerFont - The font for the banner to use.
      aBannerFontPalette - The ASCII color palette for the banner to use.
      aSeparatorLnChar - The line separator char to be used.
      aTextBoxGrid - The TextBoxGrid (or TextBoxStyle) to be used when drawing the banner.
      aLineBreak - The line break to use when printing to the terminal.
      aConsoleWidth - The console width when printing to the terminal.
      aMaxConsoleWidth - The max console width when printing to the terminal.
      isEscCodesEnabled - True in case the usage of Escape-Codes is enabled.
      aBannerEscCode - The banner Escape-Code to use when printing to the terminal.
      aBannerBorderEscCode - The banner border Escape-Code to use when printing to the terminal.
      aArgumentEscCode - The argument Escape-Code to use when printing to the terminal.
      aCommandEscCode - The command Escape-Code to use when printing to the terminal.
      aOptionEscCode - The option Escape-Code to use when printing to the terminal.
      aDescriptionEscCode - The description Escape-Code to use when printing to the terminal.
      aLineSeparatorEscCode - The line separator Escape-Code to use when printing to the terminal.
      aResetEscCode - The reset Escape-Code to use when printing to the terminal.
      aShutdownHook - the shutdown hook
      aStandardOut - The PrintStream to use for standard out.
      aErrorOut - The PrintStream to use for error out.
      aLogger - the logger
  • Method Details

    • exit

      public void exit(int aStatusCode)
    • exit

      public void exit(org.refcodes.data.ExitCode aExitCode)
    • getApplicationProperties

      public org.refcodes.properties.ext.application.ApplicationProperties getApplicationProperties()
      Gets the runtime properties.
      Specified by:
      getApplicationProperties in interface org.refcodes.properties.ext.application.ApplicationPropertiesAccessor
      Overrides:
      getApplicationProperties in class org.refcodes.decoupling.ext.application.ApplicationReactor
      Returns:
      the runtime properties
      See Also:
    • isVerbose

      public boolean isVerbose()
      Specified by:
      isVerbose in interface org.refcodes.mixin.VerboseAccessor
    • printSysInfo

      public void printSysInfo()
    • printException

      public void printException(Throwable aE)
    • exitOnException

      public void exitOnException(Throwable aE)
    • readPassword

      public char[] readPassword()
    • readPassword

      public char[] readPassword(String aPrompt)
    • createResourceFile

      public void createResourceFile(String aResourcePath, String aDestinationPath) throws IOException
      Throws:
      IOException
    • createResourceFile

      public void createResourceFile(String aResourcePath, File aDestinationFile) throws IOException
      Throws:
      IOException
    • toOptions

      public String[] toOptions(org.refcodes.cli.Option<?> aOption)
      Specified by:
      toOptions in interface org.refcodes.cli.Optionable
    • builder

      public static CtxHelper.Builder builder()
      Creates builder to build CtxHelper.
      Returns:
      created builder