org.carrot2.core
Interface IProcessingComponent

All Known Subinterfaces:
IClusteringAlgorithm, IDocumentSource
All Known Implementing Classes:
AmbientDocumentSource, Bing2DocumentSource, Bing2ImageDocumentSource, Bing2NewsDocumentSource, Bing2WebDocumentSource, BisectingKMeansClusteringAlgorithm, ByFieldClusteringAlgorithm, ByUrlClusteringAlgorithm, ClusteringMetricsCalculator, EToolsDocumentSource, FubDocumentSource, GoogleDesktopDocumentSource, GoogleDocumentSource, IdolDocumentSource, LingoClusteringAlgorithm, LuceneDocumentSource, MultipageSearchEngine, Odp239DocumentSource, OpenSearchDocumentSource, ProcessingComponentBase, PubMedDocumentSource, RemoteXmlSimpleSearchEngineBase, SearchEngineBase, SimpleSearchEngine, SolrDocumentSource, STCClusteringAlgorithm, XmlDocumentSource

public interface IProcessingComponent

Defines the life cycle of a Carrot2 processing component. The life cycle governs how IProcessingComponent instances are initialized and disposed of (init(IControllerContext), dispose()) and how processing proceeds (beforeProcessing(), process(), afterProcessing()). See Controller for a reference implementation of this life cycle.


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 process().
 void dispose()
          Invoked before this processing component is about to be destroyed.
 void init(IControllerContext ctx)
          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.
 

Method Detail

init

void init(IControllerContext ctx)
          throws ComponentInitializationException
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.

Parameters:
ctx - An instance of IControllerContext of the controller to which this component instance will be bound.
Throws:
ComponentInitializationException - when initialization failed. If thrown, the dispose() method will be called on this component instance to allow clean-up actions. The instance will not be used for any further processing and should be made reclaimable to the garbage collector. Finally, the exception will be rethrown from the controller method that caused the component to initialize.

beforeProcessing

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

Throws:
ProcessingException - when processing cannot start, e.g. because some attributes were not bound. If thrown, the process() method will not be called. Instead, 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

void process()
             throws ProcessingException
Performs the processing required to fulfill the request. This method is called once per request.

Throws:
ProcessingException - when processing failed. If thrown, the 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

void afterProcessing()
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.


dispose

void dispose()
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.



Copyright (c) Dawid Weiss, Stanislaw Osinski