public class CachingProcessingComponentManager extends Object implements IProcessingComponentManager
IProcessingComponentManager that implements processing results caching
functionality.
This manager wraps some delegate manager (e.g. a
SimpleProcessingComponentManager or a PoolingProcessingComponentManager
) and wraps the components the delegate with a functionality that either returns the
results from cache or performs the processing if the result are not yet cached.
| Modifier and Type | Field and Description |
|---|---|
static String |
CACHE_BYPASS_ATTR
Any values put under this attribute will cause a cache bypass (dropping of the stale value).
|
| Constructor and Description |
|---|
CachingProcessingComponentManager(IProcessingComponentManager delegate,
Class<? extends IProcessingComponent>... cachedComponentClasses)
Creates a
CachingProcessingComponentManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Called upon disposal of the controller.
|
Map<String,Object> |
getStatistics()
Called when the controller is requested to provide current statistics.
|
void |
init(IControllerContext context,
Map<String,Object> attributes,
ProcessingComponentConfiguration... configurations)
Called upon initialization of the
Controller. |
IProcessingComponent |
prepare(Class<? extends IProcessingComponent> clazz,
String id,
Map<String,Object> inputAttributes,
Map<String,Object> outputAttributes)
Prepares a component for processing.
|
void |
recycle(IProcessingComponent component,
String id)
Called after processing completed.
|
public static final String CACHE_BYPASS_ATTR
public CachingProcessingComponentManager(IProcessingComponentManager delegate, Class<? extends IProcessingComponent>... cachedComponentClasses)
CachingProcessingComponentManager.delegate - the manager to handle the preparation of the actual processing
component instancescachedComponentClasses - classes of components whose output should be cached
by the controller. If a superclass is provided here, e.g.
IDocumentSource, all its subclasses will be subject to caching.
If IProcessingComponent is provided here, output of all
components will be cached.public void init(IControllerContext context, Map<String,Object> attributes, ProcessingComponentConfiguration... configurations)
IProcessingComponentManagerController.init in interface IProcessingComponentManagercontext - controller contextattributes - global initialization attributes provided to the controllerconfigurations - component configurations provided to the controllerpublic IProcessingComponent prepare(Class<? extends IProcessingComponent> clazz, String id, Map<String,Object> inputAttributes, Map<String,Object> outputAttributes)
IProcessingComponentManagerprepare in interface IProcessingComponentManagerclazz - class of the component to prepareid - Identifier of the component to prepare. May be null.inputAttributes - input attributes for all components requested to perform
processing. Both Init- and Processing-time attributes
will be provided. Managers must not modify this map.outputAttributes - storage for output attributespublic void recycle(IProcessingComponent component, String id)
IProcessingComponentManagerrecycle in interface IProcessingComponentManagercomponent - Component instance returned from IProcessingComponentManager.prepare(java.lang.Class<? extends org.carrot2.core.IProcessingComponent>, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, java.util.Map<java.lang.String, java.lang.Object>).id - The same identifier of the component as used in the call to
IProcessingComponentManager.prepare(java.lang.Class<? extends org.carrot2.core.IProcessingComponent>, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, java.util.Map<java.lang.String, java.lang.Object>). May be null.public void dispose()
IProcessingComponentManagerdispose in interface IProcessingComponentManager