Package org.togglz.core.context
Class ThreadLocalFeatureManagerProvider
- java.lang.Object
-
- org.togglz.core.context.ThreadLocalFeatureManagerProvider
-
- All Implemented Interfaces:
FeatureManagerProvider,Weighted
public class ThreadLocalFeatureManagerProvider extends Object implements FeatureManagerProvider
This implementation ofFeatureManagerProviderallows to store theFeatureManagerin aThreadLocalfor the current thread. Please note that it is very important to cleanup theThreadLocalby callingrelease()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 Constructor Description ThreadLocalFeatureManagerProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidbind(FeatureManager featureManager)Store the suppliedFeatureManagerin the thread context.FeatureManagergetFeatureManager()intpriority()Low priorities are processed first.static voidrelease()Removes theFeatureManagerassociated with the current thread from the thread's context.
-
-
-
Method Detail
-
bind
public static void bind(FeatureManager featureManager)
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
public FeatureManager getFeatureManager()
- Specified by:
getFeatureManagerin interfaceFeatureManagerProvider
-
-