org.carrot2.core
Class CachingProcessingComponentManager

java.lang.Object
  extended by org.carrot2.core.CachingProcessingComponentManager
All Implemented Interfaces:
IProcessingComponentManager

public class CachingProcessingComponentManager
extends Object
implements IProcessingComponentManager

An 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.


Constructor Summary
CachingProcessingComponentManager(IProcessingComponentManager delegate, Class<? extends IProcessingComponent>... cachedComponentClasses)
          Creates a CachingProcessingComponentManager.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingProcessingComponentManager

public CachingProcessingComponentManager(IProcessingComponentManager delegate,
                                         Class<? extends IProcessingComponent>... cachedComponentClasses)
Creates a CachingProcessingComponentManager.

Parameters:
delegate - the manager to handle the preparation of the actual processing component instances
cachedComponentClasses - 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.
Method Detail

init

public void init(IControllerContext context,
                 Map<String,Object> attributes,
                 ProcessingComponentConfiguration... configurations)
Description copied from interface: IProcessingComponentManager
Called upon initialization of the Controller.

Specified by:
init in interface IProcessingComponentManager
Parameters:
context - controller context
attributes - global initialization attributes provided to the controller
configurations - component configurations provided to the controller

prepare

public IProcessingComponent prepare(Class<? extends IProcessingComponent> clazz,
                                    String id,
                                    Map<String,Object> inputAttributes,
                                    Map<String,Object> outputAttributes)
Description copied from interface: IProcessingComponentManager
Prepares a component for processing. Specific managers may simply instantiate a new component object, fetch a component from a pool or wrap a component prepared by a delegate manager etc.

Specified by:
prepare in interface IProcessingComponentManager
Parameters:
clazz - class of the component to prepare
id - 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 attributes

recycle

public void recycle(IProcessingComponent component,
                    String id)
Description copied from interface: IProcessingComponentManager
Called after processing completed. This method is called regardless of whether the processing completed successfully or with an error.

Specified by:
recycle in interface IProcessingComponentManager
Parameters:
component - Component instance returned from IProcessingComponentManager.prepare(java.lang.Class, java.lang.String, java.util.Map, java.util.Map).
id - The same identifier of the component as used in the call to IProcessingComponentManager.prepare(java.lang.Class, java.lang.String, java.util.Map, java.util.Map). May be null.

dispose

public void dispose()
Description copied from interface: IProcessingComponentManager
Called upon disposal of the controller.

Specified by:
dispose in interface IProcessingComponentManager

getStatistics

public Map<String,Object> getStatistics()
Called when the controller is requested to provide current statistics.



Copyright (c) Dawid Weiss, Stanislaw Osinski