-
- All Known Implementing Classes:
ContextAwarePropertySource
,EnvironmentPropertySource
,PropertiesPropertySource
,PropertyFilePropertySource
,SystemPropertiesPropertySource
public interface PropertySource
A source for global configuration properties.- Since:
- 2.10.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
PropertySource.Comparator
Comparator for ordering PropertySource instances by priority.static class
PropertySource.Util
Utility methods useful for PropertySource implementations.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PRIORITY
static String
MAPPING_FILE
static String
PREFIX
static String
SYSTEM_CONTEXT
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default boolean
containsProperty(String key)
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.default void
forEach(BiConsumer<String,String> action)
Iterates over all properties and performs an action for each key/value pair.default CharSequence
getNormalForm(Iterable<? extends CharSequence> tokens)
Converts a list of property name tokens into a normal form.default int
getPriority()
Returns the order in which this PropertySource has priority.default String
getProperty(String key)
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.default Collection<String>
getPropertyNames()
Returns the list of all property names for the System Context.
-
-
-
Field Detail
-
PREFIX
static final String PREFIX
- See Also:
- Constant Field Values
-
SYSTEM_CONTEXT
static final String SYSTEM_CONTEXT
- See Also:
- Constant Field Values
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITY
- See Also:
- Constant Field Values
-
MAPPING_FILE
static final String MAPPING_FILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPriority
default int getPriority()
Returns the order in which this PropertySource has priority. A higher value means that the source will be searched later and can be overridden by other property sources.- Returns:
- priority value
-
forEach
default void forEach(BiConsumer<String,String> action)
Iterates over all properties and performs an action for each key/value pair.- Parameters:
action
- action to perform on each key/value pair
-
getPropertyNames
default Collection<String> getPropertyNames()
Returns the list of all property names for the System Context.- Returns:
- list of property names
-
getNormalForm
default CharSequence getNormalForm(Iterable<? extends CharSequence> tokens)
Converts a list of property name tokens into a normal form. For example, by default a list of tokens such as "foo", "bar", "baz", will be normalized into the property name "log4j2.foo.bar.baz". Note that this is normally used in conjunction with Util.tokenize() which breaks a string into tokens and then this puts them back together.- Parameters:
tokens
- list of property name tokens- Returns:
- a normalized property name using the given tokens
-
getProperty
default String getProperty(String key)
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Parameters:
key
- The key to search for.- Returns:
- The value or null;
- Since:
- 2.13.0
-
containsProperty
default boolean containsProperty(String key)
For PropertySources that cannot iterate over all the potential properties this provides a direct lookup.- Parameters:
key
- The key to search for.- Returns:
- The value or null;
- Since:
- 2.13.0
-
-