Class ThreadLocalFeatureManagerProvider

java.lang.Object
org.togglz.core.context.ThreadLocalFeatureManagerProvider
All Implemented Interfaces:
FeatureManagerProvider, Weighted

public class ThreadLocalFeatureManagerProvider extends Object implements FeatureManagerProvider
This implementation of FeatureManagerProvider allows to store the FeatureManager in a ThreadLocal for the current thread. Please note that it is very important to cleanup the ThreadLocal by calling release() before the thread is put back into a thread pool.
Author:
Christian Kaltepoth
  • Constructor Details

    • ThreadLocalFeatureManagerProvider

      public ThreadLocalFeatureManagerProvider()
  • Method Details

    • bind

      public static void bind(FeatureManager featureManager)
      Store the supplied FeatureManager in the thread context. After calling this method all calls of getFeatureManager() from the active thread will return this feature manager. Please don't forget to call release() before the thread is put back to a thread pool to prevent memory leaks.
      Parameters:
      featureManager - The FeatureManager to store
    • release

      public static void release()
      Removes the FeatureManager associated with the current thread from the thread's context. It's required to always call this method before a thread is put back to a thread pool.
    • priority

      public int priority()
      Description copied from interface: Weighted
      Low priorities are processed first.
      Specified by:
      priority in interface Weighted
    • getFeatureManager

      public FeatureManager getFeatureManager()
      Specified by:
      getFeatureManager in interface FeatureManagerProvider