Class ThreadLocalConfigurationPropertiesSource
- java.lang.Object
-
- org.opensaml.core.config.provider.ThreadLocalConfigurationPropertiesSource
-
- All Implemented Interfaces:
ConfigurationPropertiesSource
public class ThreadLocalConfigurationPropertiesSource extends Object implements ConfigurationPropertiesSource
A configuration properties source implementation which obtains the properties set from aThreadLocal
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 afinally
block after the filter chain has run viaThreadLocalConfigurationPropertiesHolder.clear()
.
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalConfigurationPropertiesSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Properties
getProperties()
Get the property set exposed by the source.
-
-
-
Method Detail
-
getProperties
public Properties getProperties()
Get the property set exposed by the source.- Specified by:
getProperties
in interfaceConfigurationPropertiesSource
- Returns:
- the properties set
-
-