public class ThreadLocalConfigurationPropertiesSource extends Object implements 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 and Description |
---|
ThreadLocalConfigurationPropertiesSource() |
Modifier and Type | Method and Description |
---|---|
Properties |
getProperties()
Get the property set exposed by the source.
|
public ThreadLocalConfigurationPropertiesSource()
public Properties getProperties()
getProperties
in interface ConfigurationPropertiesSource
Copyright © 2016 JBoss by Red Hat. All rights reserved.