Class AnalysisComponent_ImplBase
- java.lang.Object
-
- org.apache.uima.analysis_component.AnalysisComponent_ImplBase
-
- All Implemented Interfaces:
AnalysisComponent
- Direct Known Subclasses:
Annotator_ImplBase
,CasMultiplier_ImplBase
,JCasMultiplier_ImplBase
,UimacppAnalysisComponent
public abstract class AnalysisComponent_ImplBase extends java.lang.Object implements AnalysisComponent
Implementation base class for AnalysisComponents. Normally developers do not extend this class directly. Instead extend one of the Annotator or CasMultiplier base classes.This class implements the
initialize(UimaContext)
method and stores theUimaContext
in a private field where it can be accessed via thegetContext()
method.This class also provides a "dumb" implementation of the
reconfigure()
method, which simply callsdestroy()
followed byinitialize(UimaContext)
. Developers of AnalysisComponents with expensive initialization logic should override this method and provide a more intelligent implementation.
-
-
Constructor Summary
Constructors Constructor Description AnalysisComponent_ImplBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
batchProcessComplete()
Completes the processing of a batch of CASes.void
collectionProcessComplete()
Notifies this AnalysisComponent that processing of an entire collection has been completed.void
destroy()
Frees all resources held by this AnalysisComponent.protected UimaContext
getContext()
Gets the UimaContext for this AnalysisComponent.protected ResultSpecification
getResultSpecification()
Gets the ResultSpecification for this AnalysisComponent.void
initialize(UimaContext aContext)
Performs any startup tasks required by this component.void
reconfigure()
Notifies this AnalysisComponent that its configuration parameters have changed.void
setResultSpecification(ResultSpecification aResultSpec)
Sets the Result Specification for this Analysis Component.-
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.analysis_component.AnalysisComponent
getCasInstancesRequired, getRequiredCasInterface, hasNext, next, process
-
-
-
-
Method Detail
-
initialize
public void initialize(UimaContext aContext) throws ResourceInitializationException
Description copied from interface:AnalysisComponent
Performs any startup tasks required by this component. The framework calls this method only once, just after the AnalysisComponent has been instantiated.The framework supplies this AnalysisComponent with a reference to the
UimaContext
that it will use, for example to access configuration settings or resources. This AnalysisComponent should store a reference to its theUimaContext
for later use.- Specified by:
initialize
in interfaceAnalysisComponent
- Parameters:
aContext
- Provides access to services and resources managed by the framework. This includes configuration parameters, logging, and access to external resources.- Throws:
ResourceInitializationException
- if this AnalysisComponent cannot initialize successfully.
-
reconfigure
public void reconfigure() throws ResourceConfigurationException, ResourceInitializationException
Notifies this AnalysisComponent that its configuration parameters have changed. This implementation just callsdestroy()
followed byinitialize(UimaContext)
. Subclasses can override to provide more efficient reconfiguration logic if necessary.- Specified by:
reconfigure
in interfaceAnalysisComponent
- Throws:
ResourceConfigurationException
- if the configuration specified for this component is invalid.ResourceInitializationException
- if this component fails to reinitialize itself based on the new configuration.- See Also:
AnalysisComponent.reconfigure()
-
batchProcessComplete
public void batchProcessComplete() throws AnalysisEngineProcessException
Description copied from interface:AnalysisComponent
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 ofbatchProcessComplete
is to give this AnalysisComponent 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 interfaceAnalysisComponent
- 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:AnalysisComponent
Notifies this AnalysisComponent 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 interfaceAnalysisComponent
- Throws:
AnalysisEngineProcessException
- if this component encounters a problem in its end-of-collection processing
-
destroy
public void destroy()
Description copied from interface:AnalysisComponent
Frees all resources held by this AnalysisComponent. The framework calls this method only once, when it is finished using this component.- Specified by:
destroy
in interfaceAnalysisComponent
-
setResultSpecification
public void setResultSpecification(ResultSpecification aResultSpec)
Sets the Result Specification for this Analysis Component. This implementation just saves the Result Specification to a field, where it can later be accessed by callinggetResultSpecification()
. An AnalysisComponent implementation may override this method if it would like to do specific processing when its ResultSpecificatin is changed.- Specified by:
setResultSpecification
in interfaceAnalysisComponent
- Parameters:
aResultSpec
- the ResultSpecification for this Analysis Component to use.- See Also:
AnalysisComponent.setResultSpecification(ResultSpecification)
-
getContext
protected final UimaContext getContext()
Gets the UimaContext for this AnalysisComponent. This provides access to configuration parameters and external resources.- Returns:
- the UimaContext for this AnalysisComponent
-
getResultSpecification
protected ResultSpecification getResultSpecification()
Gets the ResultSpecification for this AnalysisComponent. The ResultSpecification is a set of types and features that this AnalysisComponent is asked to produce. An Analysis Component may (but is not required to) optimize its processing by omitting the generation of any types or features that are not part of the ResultSpecification.- Returns:
- the ResultSpecification for this Analysis Component to use.
-
-