public class StdJndiLoader extends BaseLoader implements LookupLoader, StandardLoader
Property in the JNDI
environment and loads the value for any that are found.
org.foo.My_Prop:
java:comp/env/org/foo/My_Prop
java:comp/env/org.foo.My_Prop
java:org/foo/My_Prop
java:org.foo.My_Prop
org/foo/My_Prop
org.foo.My_Prop
java:comp/env/ is used by Tomcat and several other application servers,
java: is used by some non-container environments and at least one
application server (Glassfish) uses no root at all. In all, AndHow will
search for each property under six different names (2 X 3).
AndHow will throw an error at startup if it finds multiple names in the
JNDI context that refer to the same property.
<Context>
. . .
<Environment name="org/simple/GettingStarted/COUNT_DOWN_START" value="3" type="java.lang.Integer" override="false"/>
<Environment name="org/simple/GettingStarted/LAUNCH_CMD" value="GoGoGo!" type="java.lang.String" override="false"/>
. . .
</Context>
java:comp/env/
to the name it associates with each value. As the example shows, JNDI values
can be typed. If AndHow finds the value to already be the type it expects
(e.g. an Integer), great! If AndHow finds a String and needs a
different type, AndHow will do the conversion. Any other type of conversion
(e.g. from a Short to an Integer) will result in an exception.
java:xyz/ as a system property on command line:
java -Dorg.yarnandtail.andhow.load.std.StdJndiLoader.CONFIG.ADDED_JNDI_ROOTS=java:xyz/ -jar MyJarName.jar
StandardLoader's, this loader is intended to be auto-created
by AndHow. The set of standard loaders and their order can bet set
via the AndHowConfiguration.setStandardLoaders() methods.
Other loaders which don't implement the StandardLoader interface can
be inserted into the load order via the
AndHowConfiguration.insertLoaderBefore/After().| Modifier and Type | Class and Description |
|---|---|
static interface |
StdJndiLoader.CONFIG |
| Constructor and Description |
|---|
StdJndiLoader()
There is no reason to use the constructor in production application code
because AndHow creates a single instance on demand at runtime.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<String> |
buildJndiNames(PropertyConfigurationInternal appConfigDef,
List<String> roots,
Property prop)
Builds a complete list of complete JNDI names to search for a parameter value.
|
protected List<String> |
buildJndiRoots(ValidatedValues values)
Combines the values of STANDARD_JNDI_ROOTS and ADDED_JNDI_ROOTS into one list of jndi root contexts to search.
|
Class<?> |
getClassConfig()
Returns a PropertyGroup used to globally configure a class of Loader.
|
SamplePrinter |
getConfigSamplePrinter()
Returns a ConfigSamplePrinter, which can be used to print a configuration
sample for this Loader.
|
String |
getLoaderDialect()
The type dialect of the loader.
|
String |
getLoaderType()
The type of the loader, such as JNDI, PropertyFile, SystemProperty,
etc..
|
String |
getSpecificLoadDescription()
For this particular load, where was info loaded from?
This may vary from run to run based on config params.
|
boolean |
isFailedEnvironmentAProblem()
If true, then a failure to initiate or connect to the needed environment
or external system will result in a failure and it will register a
'Propblem' during load which will cause application initiation to stop.
|
boolean |
isTrimmingRequiredForStringValues()
If true, values for string properties are trimmed by the Trimmer of
the property they are associated with.
|
LoaderValues |
load(PropertyConfigurationInternal appConfigDef,
ValidatedValuesWithContext existingValues)
Builds up a list of LoaderValues by loading property values from a
configuration source.
|
void |
setFailedEnvironmentAProblem(boolean isAProblem)
If true, failing to initialize the environment needed to lookup values is
considered a problem/error.
|
protected List<String> |
split(String rootStr)
Spits a comma separate list of JNDI roots into individual root strings.
|
attemptToAdd, attemptToAdd, attemptToAdd, attemptToAddIfNotDuplicate, createValue, findDuplicateProperty, getInstanceConfig, mapNametoProperty, releaseResourcesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstanceConfig, releaseResourcespublic StdJndiLoader()
public LoaderValues load(PropertyConfigurationInternal appConfigDef, ValidatedValuesWithContext existingValues)
Loaderpublic boolean isTrimmingRequiredForStringValues()
LoaderisTrimmingRequiredForStringValues in interface Loaderpublic String getSpecificLoadDescription()
LoadergetSpecificLoadDescription in interface Loaderpublic Class<?> getClassConfig()
LoadergetClassConfig in interface LoadergetClassConfig in class BaseLoaderpublic SamplePrinter getConfigSamplePrinter()
LoadergetConfigSamplePrinter in interface LoadergetConfigSamplePrinter in class BaseLoaderprotected List<String> buildJndiRoots(ValidatedValues values)
values - The configuration state.protected List<String> buildJndiNames(PropertyConfigurationInternal appConfigDef, List<String> roots, Property prop)
appConfigDef - roots - prop - protected List<String> split(String rootStr)
rootStr - public String getLoaderType()
LoadergetLoaderType in interface Loaderpublic String getLoaderDialect()
LoadergetLoaderDialect in interface Loaderpublic void setFailedEnvironmentAProblem(boolean isAProblem)
LookupLoadersetFailedEnvironmentAProblem in interface LookupLoaderpublic boolean isFailedEnvironmentAProblem()
LookupLoaderisFailedEnvironmentAProblem in interface LookupLoaderCopyright © 2021. All rights reserved.