public static class AndHow.AndHowBuilder extends Object
builder.group(SomeGroup.class) would add a single group,
builder.groups(aListOfGroups) would add an entire list.
Usage always starts with AndHow.builder() and ends with build():
AndHow.builder()
.loader(new PropFileLoader)
.group(SomeGroup.class)
.group(SomeOtherGroup.class)
.cmdLineArgs([Array of cmd line arguments])
.build();
There is no return value because there is no need to hold a reference
to anything past framework startup. After a successful startup, Property
values can be read directly. For instance, for a Property named 'MyInt':
Integer value = MyInt.getValue();
Attempting to call build() a 2nd time will throw a RuntimeException, so
it is important that a single entry and configuration loading point to
your application is well defined.
See buildForNonPropduction() for a small backdoor for unit testing, which
provides a non-production, unsupported way to force the AndHow framework
to reload its state.| Constructor and Description |
|---|
AndHowBuilder() |
| Modifier and Type | Method and Description |
|---|---|
void |
build()
Executes the AndHow framework startup.
|
AndHow.Reloader |
buildForNonPropduction()
Bootstraps the AndHow framework and returns a Reloader that can be used
to destroy or reload the AndHow framework.
|
AndHow.AndHowBuilder |
cmdLineArg(String key,
String value)
Adds a command line argument in key=value form.
|
AndHow.AndHowBuilder |
cmdLineArgs(String[] commandLineArgs)
Adds the command line arguments, keeping any previously added.
|
AndHow.AndHowBuilder |
group(Class<? extends BasePropertyGroup> group)
Add a group to the list of groups being built.
|
AndHow.AndHowBuilder |
groups(Collection<Class<? extends BasePropertyGroup>> groups)
Add a list of groups to the list of groups being built.
|
AndHow.AndHowBuilder |
loader(Loader loader)
Add a loader to the list of loaders.
|
AndHow.AndHowBuilder |
loaders(Collection<Loader> loaders)
Add a list of loaders to the list being built.
|
AndHow.AndHowBuilder |
namingStrategy(NamingStrategy namingStrategy)
Sets the naming strategy, which determines how the property names
are realized when used in config files, JNDI and cmd line arguments.
|
void |
reloadForNonPropduction(AndHow.Reloader reloader)
After initial construction with buildForNonPropduction() this method
forces a reload using the reloader instance.
|
public AndHow.AndHowBuilder loader(Loader loader)
loader - public AndHow.AndHowBuilder loaders(Collection<Loader> loaders)
loaders - public AndHow.AndHowBuilder group(Class<? extends BasePropertyGroup> group)
group - public AndHow.AndHowBuilder groups(Collection<Class<? extends BasePropertyGroup>> groups)
groups - public AndHow.AndHowBuilder cmdLineArgs(String[] commandLineArgs)
commandLineArgs - public AndHow.AndHowBuilder cmdLineArg(String key, String value)
key - value - public AndHow.AndHowBuilder namingStrategy(NamingStrategy namingStrategy)
namingStrategy - public void build()
throws AppFatalException
Integer value = MyInt.getValue();AppFatalException - If the startup fails.public AndHow.Reloader buildForNonPropduction() throws AppFatalException
AppFatalExceptionpublic void reloadForNonPropduction(AndHow.Reloader reloader) throws AppFatalException
reloader - Must be the same instance given out by buildForNonPropduction.AppFatalExceptionCopyright © 2017. All rights reserved.