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 a 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 Details

    • ThreadLocalConfigurationPropertiesSource

      public ThreadLocalConfigurationPropertiesSource()
  • Method Details