Class ThreadLocalConfigurationPropertiesSource
- All Implemented Interfaces:
ConfigurationPropertiesSource
ThreadLocal variable.
This supports use cases where applications with different configuration needs are sharing a classloader,
making usage of ClasspathConfigurationPropertiesSource inappropriate.
The thread-local properties instance is retrieved from ThreadLocalConfigurationPropertiesHolder.
An application-specific means must be used to populate this appropriately for each thread, taking care
to also clear it at the appropriate time (e.g. before the thread will be returned to a thread-pool
and re-used).
For example, in a web application environment which uses Spring dependency injection, a servlet filter
would be used to obtain the Properties bean from the Spring web application context (via the servlet context),
and then populate the ThreadLocal via ThreadLocalConfigurationPropertiesHolder.setProperties(Properties),
making sure to then also clear it in a finally block after the filter chain has run via
ThreadLocalConfigurationPropertiesHolder.clear().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the property set exposed by the source.
-
Constructor Details
-
ThreadLocalConfigurationPropertiesSource
public ThreadLocalConfigurationPropertiesSource()
-
-
Method Details
-
getProperties
Get the property set exposed by the source.- Specified by:
getPropertiesin interfaceConfigurationPropertiesSource- Returns:
- the properties set or null
-