Package org.togglz.core.context
Class ThreadLocalFeatureManagerProvider
java.lang.Object
org.togglz.core.context.ThreadLocalFeatureManagerProvider
- All Implemented Interfaces:
FeatureManagerProvider,Weighted
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.togglz.core.util.Weighted
Weighted.WeightedComparator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbind(FeatureManager featureManager) Store the suppliedFeatureManagerin the thread context.intpriority()Low priorities are processed first.static voidrelease()Removes theFeatureManagerassociated with the current thread from the thread's context.
-
Constructor Details
-
ThreadLocalFeatureManagerProvider
public ThreadLocalFeatureManagerProvider()
-
-
Method Details
-
bind
Store the suppliedFeatureManagerin the thread context. After calling this method all calls ofgetFeatureManager()from the active thread will return this feature manager. Please don't forget to callrelease()before the thread is put back to a thread pool to prevent memory leaks.- Parameters:
featureManager- TheFeatureManagerto store
-
release
public static void release()Removes theFeatureManagerassociated 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:WeightedLow priorities are processed first. -
getFeatureManager
- Specified by:
getFeatureManagerin interfaceFeatureManagerProvider
-