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/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
ConstructorDescriptionCtxHelper
(InputStream aInputStream) CtxHelper
(InputStream aInputStream, String[] aArgs) 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) -
Method Summary
Modifier and TypeMethodDescriptionstatic CtxHelper.Builder
builder()
Creates builder to buildCtxHelper
.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[]
readPassword
(String aPrompt) String[]
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
-
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
- 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
- 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
- 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
- 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 newCtxHelper
with all the properties mainly regarded to theApplicationProperties
used under the hood (for ease of use please use theAbstractBuilderCli
be calling thebuilder()
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 metricsaTitle
- 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
- TheExample
examples to use when printing out the help.aUrl
- TheURL
from which to load the configuration.aInputStream
- TheInputStream
from which to load the configuration.saFile
-File
from which to load the configuration.aFilePath
- The name to your default config file.aConfigLocator
- TheConfigLocator
to use when locating the configuration file (defaults toConfigLocator.DEFAULT
.aResourceClass
- The application'sClass
which to use when loading resources (of the according module) by invokingClass.getResourceAsStream(String)
.aDelimiters
- The delimiters to be used when parsing specific configuration file notations.aIsVerboseFallback
- the is verbose fallbackaPasswordPrompt
- 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
- TheTextBoxGrid
(orTextBoxStyle
) 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 hookaStandardOut
- ThePrintStream
to use for standard out.aErrorOut
- ThePrintStream
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 interfaceorg.refcodes.properties.ext.application.ApplicationPropertiesAccessor
- Overrides:
getApplicationProperties
in classorg.refcodes.decoupling.ext.application.ApplicationReactor
- Returns:
- the runtime properties
- See Also:
-
isVerbose
public boolean isVerbose()- Specified by:
isVerbose
in interfaceorg.refcodes.mixin.VerboseAccessor
-
printSysInfo
public void printSysInfo() -
printException
-
exitOnException
-
readPassword
public char[] readPassword() -
readPassword
-
createResourceFile
- Throws:
IOException
-
createResourceFile
- Throws:
IOException
-
toOptions
- Specified by:
toOptions
in interfaceorg.refcodes.cli.Optionable
-
builder
Creates builder to buildCtxHelper
.- Returns:
- created builder
-