org.apache.uima.flow
Class FlowController_ImplBase

java.lang.Object
  extended by org.apache.uima.flow.FlowController_ImplBase
All Implemented Interfaces:
FlowController
Direct Known Subclasses:
CasFlowController_ImplBase, JCasFlowController_ImplBase

public abstract class FlowController_ImplBase
extends Object
implements FlowController

Implementation base class for FlowControllers. Normally developers do not extend this class directly. Instead use JCasFlowController_ImplBase or CasFlowController_ImplBase, depending on which CAS interface you would like to use.

This class implements the initialize(FlowControllerContext) method and stores the FlowControllerContext in a private field where it can be accessed via the getContext() method.

This class also provides a "dumb" implementation of the reconfigure() method, which simply calls destroy() followed by initialize(FlowControllerContext). Developers of FlowControllers with expensive initialization logic should override this method and provide a more intelligent implementation.


Constructor Summary
FlowController_ImplBase()
           
 
Method Summary
 void addAnalysisEngines(Collection<String> aKeys)
          Does nothing by default.
 void batchProcessComplete()
          Completes the processing of a batch of CASes.
 void collectionProcessComplete()
          Notifies this component that processing of an entire collection has been completed.
 void destroy()
          Frees all resources held by this FlowController.
protected  FlowControllerContext getContext()
          Gets the FlowControllerContext for this FlowController.
 void initialize(FlowControllerContext aContext)
          Performs any startup tasks required by this component.
 void reconfigure()
          Alerts this FlowController that the values of its configuration parameters or external resources have changed.
 void removeAnalysisEngines(Collection<String> aKeys)
          Throws an AnalysisEngineProcessException by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.uima.flow.FlowController
computeFlow, getRequiredCasInterface
 

Constructor Detail

FlowController_ImplBase

public FlowController_ImplBase()
Method Detail

initialize

public void initialize(FlowControllerContext aContext)
                throws ResourceInitializationException
Description copied from interface: FlowController
Performs any startup tasks required by this component. The framework calls this method only once, just after the FlowController has been instantiated.

The framework supplies this FlowController with a reference to the FlowControllerContext that it will use, for example to access configuration settings or resources. This FlowController should store a reference to this Context for later use.

Specified by:
initialize in interface FlowController
Parameters:
aContext - Provides access to services and resources managed by the framework. This includes configuration parameters, logging, and access to external resources. Also provides the FlowController with the metadata of all of the AnalysisEngines that are possible targets for routing CASes.
Throws:
ResourceInitializationException - if the FlowController cannot initialize successfully.

reconfigure

public void reconfigure()
                 throws ResourceInitializationException,
                        ResourceConfigurationException
Description copied from interface: FlowController
Alerts this FlowController that the values of its configuration parameters or external resources have changed. This FlowController should re-read its configuration from the UimaContext and take appropriate action to reconfigure itself.

In the abstract base classes provided by the framework, this is generally implemented by calling destroy followed by initialize. If a more efficient implementation is needed, you can override that implementation.

Specified by:
reconfigure in interface FlowController
Throws:
ResourceInitializationException - if this component encounters a problem in reinitializing itself from the new configuration
ResourceConfigurationException

batchProcessComplete

public void batchProcessComplete()
                          throws AnalysisEngineProcessException
Description copied from interface: FlowController
Completes the processing of a batch of CASes. The size of a batch is determined based on configuration provided by the application that is using this component. The purpose of batchProcessComplete is to give this component the change to flush information from memory to persistent storage. In the event of an error, this allows the processing to be restarted from the end of the last completed batch.

If this component's descriptor declares that it is recoverable, then this component is required to be restartable from the end of the last completed batch.

Specified by:
batchProcessComplete in interface FlowController
Throws:
AnalysisEngineProcessException - if this component encounters a problem in flushing its state to persistent storage

collectionProcessComplete

public void collectionProcessComplete()
                               throws AnalysisEngineProcessException
Description copied from interface: FlowController
Notifies this component that processing of an entire collection has been completed. In this method, this component should finish writing any output relating to the current collection.

Specified by:
collectionProcessComplete in interface FlowController
Throws:
AnalysisEngineProcessException - if this component encounters a problem in its end-of-collection processing

destroy

public void destroy()
Description copied from interface: FlowController
Frees all resources held by this FlowController. The framework calls this method only once, when it is finished using this component.

Specified by:
destroy in interface FlowController

addAnalysisEngines

public void addAnalysisEngines(Collection<String> aKeys)
Does nothing by default. Subclasses may override this to support adding new AnalysisEngines to the flow.

Specified by:
addAnalysisEngines in interface FlowController
Parameters:
aKeys - a Collection of Strings, each of which is the key of an Analysis Engine to which CASes can be routed. These are the same keys as used in FlowControllerContext.getAnalysisEngineMetaDataMap().
See Also:
FlowController.addAnalysisEngines(java.util.Collection)

removeAnalysisEngines

public void removeAnalysisEngines(Collection<String> aKeys)
                           throws AnalysisEngineProcessException
Throws an AnalysisEngineProcessException by default. Subclasses may override this to support removing AnalysisEngines from the flow.

Specified by:
removeAnalysisEngines in interface FlowController
Parameters:
aKeys - a Collection of Strings, each of which is the key of an Analysis Engine to which CASes may no longer be routed.
Throws:
AnalysisEngineProcessException - if the FlowController cannot continue with these Analysis Engines removed, or doesn't support removing Analysis Engines at all.
See Also:
FlowController.removeAnalysisEngines(java.util.Collection)

getContext

protected FlowControllerContext getContext()
Gets the FlowControllerContext for this FlowController. This provides access to configuration parameters, resources, and also to metadata for each AnalysisEngine that is available for this FlowController to route CASes to.

Returns:
the FlowControllerContext for this FlowController


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.