Package org.exoplatform.container
Class ComponentTaskContext
- java.lang.Object
-
- org.exoplatform.container.ComponentTaskContext
-
public class ComponentTaskContext extends Object
- Version:
- $Id$
- Author:
- Nicolas Filotto
-
-
Constructor Summary
Constructors Constructor Description ComponentTaskContext(Object componentKey, ComponentTaskType type)Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<T>addComponentToContext(Object key, org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<T> ctx)Adds theCreationalContextof the component corresponding to the given key, to the dependency resolution contextComponentTaskContextaddToContext(Object componentKey)This method will calladdToContext(Object, ComponentTaskType)with thelastTaskTypeas typeComponentTaskContextaddToContext(Object componentKey, ComponentTaskType type)Creates a newComponentTaskContextbased on the given dependency and the already registered ones.voidcheckDependency(Object componentKey, ComponentTaskType type)Checks if the given dependency has already been defined, if so aCyclicDependencyExceptionwill be thrown.<T> TgetComponentInstanceFromContext(Object key, Class<T> bindType)Tries to get the component related to the given from the context, if it can be found the current state of the component instance is returned, otherwisenullis returnedbooleanisLast(Object componentKey)Indicates whether the provided componentKey is the last dependency that has been added to the context.booleanisRoot()org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<?>removeComponentFromContext(Object key)Removes theCreationalContextof the component corresponding to the given key, from the dependency resolution contextComponentTaskContextresetDependencies(Object key, ComponentTaskType type)Resets the dependencies but keeps the current dependency resolution context.ComponentTaskContextsetLastTaskType(ComponentTaskType lastTaskType)Defines explicitly the last task type knownStringtoString()
-
-
-
Constructor Detail
-
ComponentTaskContext
public ComponentTaskContext(Object componentKey, ComponentTaskType type)
Default constructor
-
-
Method Detail
-
setLastTaskType
public ComponentTaskContext setLastTaskType(ComponentTaskType lastTaskType)
Defines explicitly the last task type known
-
addToContext
public ComponentTaskContext addToContext(Object componentKey) throws CyclicDependencyException
This method will calladdToContext(Object, ComponentTaskType)with thelastTaskTypeas type- Throws:
CyclicDependencyException
-
addToContext
public ComponentTaskContext addToContext(Object componentKey, ComponentTaskType type) throws CyclicDependencyException
Creates a newComponentTaskContextbased on the given dependency and the already registered ones. If the dependency has already been registered aCyclicDependencyExceptionwill be thrown.- Throws:
CyclicDependencyException
-
checkDependency
public void checkDependency(Object componentKey, ComponentTaskType type) throws CyclicDependencyException
Checks if the given dependency has already been defined, if so aCyclicDependencyExceptionwill be thrown.- Throws:
CyclicDependencyException
-
isLast
public boolean isLast(Object componentKey)
Indicates whether the provided componentKey is the last dependency that has been added to the context.- Returns:
trueif the dependency is the last,falseotherwise.
-
isRoot
public boolean isRoot()
- Returns:
- indicates whether the current context is the root context or not.
-
addComponentToContext
public <T> org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<T> addComponentToContext(Object key, org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<T> ctx)
Adds theCreationalContextof the component corresponding to the given key, to the dependency resolution context- Parameters:
key- The key of the component to add to the contextctx- TheCreationalContextof the component to add to the context- Returns:
ConcurrentContainer.CreationalContextComponentAdapterinstance that has been put into the map
-
removeComponentFromContext
public org.exoplatform.container.ConcurrentContainer.CreationalContextComponentAdapter<?> removeComponentFromContext(Object key)
Removes theCreationalContextof the component corresponding to the given key, from the dependency resolution context- Parameters:
key- The key of the component to remove from the context
-
getComponentInstanceFromContext
public <T> T getComponentInstanceFromContext(Object key, Class<T> bindType)
Tries to get the component related to the given from the context, if it can be found the current state of the component instance is returned, otherwisenullis returned
-
resetDependencies
public ComponentTaskContext resetDependencies(Object key, ComponentTaskType type)
Resets the dependencies but keeps the current dependency resolution context.- Parameters:
key- the key of the new first dependencytype- the type of the corresponding task- Returns:
- a
ComponentTaskContextinstance with the dependencies reseted
-
-