org.carrot2.core
Class ProcessingComponentBase

java.lang.Object
  extended by org.carrot2.core.ProcessingComponentBase
All Implemented Interfaces:
IProcessingComponent
Direct Known Subclasses:
BisectingKMeansClusteringAlgorithm, ByFieldClusteringAlgorithm, ByUrlClusteringAlgorithm, ClusteringMetricsCalculator, FubDocumentSource, LingoClusteringAlgorithm, LuceneDocumentSource, SearchEngineBase, STCClusteringAlgorithm, XmlDocumentSource

public abstract class ProcessingComponentBase
extends Object
implements IProcessingComponent

A base class for implementation of the IProcessingComponent interface that provides empty implementations of all life cycle methods.


Constructor Summary
ProcessingComponentBase()
           
 
Method Summary
 void afterProcessing()
          Invoked after the processing has finished, no matter whether an exception has been thrown or not.
 void beforeProcessing()
          Invoked after the attributes marked with Processing and Input annotations have been bound, but before a call to IProcessingComponent.process().
 void dispose()
          Invoked before this processing component is about to be destroyed.
protected  IControllerContext getContext()
          Return the IControllerContext passed in init(IControllerContext).
protected  ExecutorService getSharedExecutor(int maxConcurrentThreads, Class<?> clazz)
           
 void init(IControllerContext context)
          Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component.
 void process()
          Performs the processing required to fulfill the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessingComponentBase

public ProcessingComponentBase()
Method Detail

init

public void init(IControllerContext context)
Description copied from interface: IProcessingComponent
Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component. After a call to this method completes without an exception, attributes marked with Init Output will be collected. In this method, components should perform initializations based on the initialization-time attributes. This method is called once in the life time of a processing component instance.

Specified by:
init in interface IProcessingComponent
Parameters:
context - An instance of IControllerContext of the controller to which this component instance will be bound.

beforeProcessing

public void beforeProcessing()
                      throws ProcessingException
Description copied from interface: IProcessingComponent
Invoked after the attributes marked with Processing and Input annotations have been bound, but before a call to IProcessingComponent.process(). In this method, the processing component should perform any initializations based on the runtime attributes. This method is called once per request.

Specified by:
beforeProcessing in interface IProcessingComponent
Throws:
ProcessingException - when processing cannot start, e.g. because some attributes were not bound. If thrown, the IProcessingComponent.process() method will not be called. Instead, IProcessingComponent.afterProcessing() will be called immediately to allow clean-up actions, and the component will be ready to accept further requests or to be disposed of. Finally, the exception will be rethrown from the controller method that caused the component to perform processing.

process

public void process()
             throws ProcessingException
Description copied from interface: IProcessingComponent
Performs the processing required to fulfill the request. This method is called once per request.

Specified by:
process in interface IProcessingComponent
Throws:
ProcessingException - when processing failed. If thrown, the IProcessingComponent.afterProcessing() method will be called and the component will be ready to accept further requests or to be disposed of. Finally, the exception will be rethrown from the controller method that caused the component to perform processing.

afterProcessing

public void afterProcessing()
Description copied from interface: IProcessingComponent
Invoked after the processing has finished, no matter whether an exception has been thrown or not. After a call to this method completes, attributes marked with Processing and Output annotations will be collected. In this method, the processing component should dispose of any resources it has allocated to fulfill the request. No matter whether a call to this method completes successfully or with an exception, the component will be ready to accept further requests or to be disposed of. This method is called once per request.

Specified by:
afterProcessing in interface IProcessingComponent

getContext

protected final IControllerContext getContext()
Return the IControllerContext passed in init(IControllerContext).


getSharedExecutor

protected ExecutorService getSharedExecutor(int maxConcurrentThreads,
                                            Class<?> clazz)

dispose

public void dispose()
Description copied from interface: IProcessingComponent
Invoked before this processing component is about to be destroyed. In this method, the processing component should release any resources it allocated during initialization. After the call to this method, no other method of this processing component will be called and the component should be made reclaimable to the garbage collector. Exceptions thrown by this method will be ignored. This method is called once in the life time of a processing component instance.

Specified by:
dispose in interface IProcessingComponent


Copyright (c) Dawid Weiss, Stanislaw Osinski