Class ContextManagerImpl
- java.lang.Object
-
- org.exoplatform.container.context.ContextManagerImpl
-
- All Implemented Interfaces:
ThreadContextHolder,ContextManager
public class ContextManagerImpl extends Object implements ContextManager, ThreadContextHolder
The basic implementation of aContextManagerbased on aConcurrentHashMapthat is filled thanks to a component plugins.- Version:
- $Id$
- Author:
- Nicolas Filotto
-
-
Field Summary
-
Fields inherited from interface org.exoplatform.container.component.ThreadContextHolder
MANAGE_THREAD_LOCAL
-
-
Constructor Summary
Constructors Constructor Description ContextManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K> voidaddContext(AdvancedContext<K> ctx)Registers a contextvoidaddContexts(ContextPlugin plugin)Adds all the contexts defined in the given plugin<K> AdvancedContext<K>getContext(Class<? extends Annotation> scope)Gives the context corresponding to the given scopeThreadContextgetThreadContext()Gives the value corresponding to the context of the threadbooleanhasContext(Class<? extends Annotation> scope)Indicates whether or not a context has a been registered for the given scope
-
-
-
Method Detail
-
getContext
public <K> AdvancedContext<K> getContext(Class<? extends Annotation> scope) throws IllegalStateException
Gives the context corresponding to the given scope- Specified by:
getContextin interfaceContextManager- Parameters:
scope- the annotation class corresponding to the scope- Returns:
- the
Contextcorresponding to the given scope - Throws:
IllegalStateException
-
hasContext
public boolean hasContext(Class<? extends Annotation> scope)
Indicates whether or not a context has a been registered for the given scope- Specified by:
hasContextin interfaceContextManager- Parameters:
scope- the scope of the context- Returns:
trueif it exists a context for the given scope,falseotherwise
-
addContext
public <K> void addContext(AdvancedContext<K> ctx)
Registers a context- Specified by:
addContextin interfaceContextManager- Parameters:
ctx- theContextto register
-
addContexts
public void addContexts(ContextPlugin plugin)
Adds all the contexts defined in the given plugin
-
getThreadContext
public ThreadContext getThreadContext()
Gives the value corresponding to the context of the thread- Specified by:
getThreadContextin interfaceThreadContextHolder- Returns:
- a new instance of
ThreadContextif there are some valuableThreadLocalvariables to share otherwisenullis expected
-
-