Package org.apache.uima.collection
Class CasConsumer_ImplBase
- java.lang.Object
-
- org.apache.uima.resource.Resource_ImplBase
-
- org.apache.uima.resource.ConfigurableResource_ImplBase
-
- org.apache.uima.collection.CasConsumer_ImplBase
-
- All Implemented Interfaces:
CasObjectProcessor
,CasProcessor
,CasConsumer
,ConfigurableResource
,Resource
- Direct Known Subclasses:
InlineXmlCasConsumer
,XCasWriterCasConsumer
,XmiWriterCasConsumer
public abstract class CasConsumer_ImplBase extends ConfigurableResource_ImplBase implements CasConsumer
Base class for CAS Consumers in UIMA SDK v1.x, which developers should extend with their own CAS Consumer implementation classes. As of v2.0, there is no difference in capability between CAS Consumers and ordinary Analysis Engines, except for the default setting of the XML parameters for multipleDeploymentAllowed and modifiesCas. We recommend for future work that users implement and use Analysis Engine components instead of CAS Consumers.
-
-
Field Summary
-
Fields inherited from interface org.apache.uima.resource.Resource
PARAM_AGGREGATE_SOFA_MAPPINGS, PARAM_CONFIG_MANAGER, PARAM_CONFIG_PARAM_SETTINGS, PARAM_EXTERNAL_OVERRIDE_SETTINGS, PARAM_PERFORMANCE_TUNING_SETTINGS, PARAM_RESOURCE_MANAGER, PARAM_UIMA_CONTEXT
-
-
Constructor Summary
Constructors Constructor Description CasConsumer_ImplBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
batchProcessComplete(ProcessTrace arg0)
Completes the processing of a batch.void
collectionProcessComplete(ProcessTrace arg0)
Completes the processing of an entire collection.void
destroy()
Releases all resources held by thisResource
.ProcessingResourceMetaData
getProcessingResourceMetaData()
Gets the metadata that describes thisCasProcesor
.void
initialize()
This method is called during initialization, and does nothing by default.boolean
initialize(ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)
Called by the framework to initialize this CAS Consumer.boolean
isReadOnly()
Returns true.boolean
isStateless()
Gets whether this is a stateless CAS Processor.void
processCas(CAS[] aCASes)
Processes multiple CASes.void
reconfigure()
Notifies this CAS Consumer that its configuration parameter settings have been changed.void
typeSystemInit(TypeSystem arg0)
Informs this CasConsumer that the CAS TypeSystem has changed.-
Methods inherited from class org.apache.uima.resource.ConfigurableResource_ImplBase
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
-
Methods inherited from class org.apache.uima.resource.Resource_ImplBase
getCasManager, getLogger, getMetaData, getRelativePathResolver, getResourceManager, getUimaContext, getUimaContextAdmin, loadUserClass, loadUserClassOrThrow, setContextHolder, setContextHolderX, setLogger, setMetaData, withContextHolder
-
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.collection.base_cpm.CasObjectProcessor
processCas
-
Methods inherited from interface org.apache.uima.resource.ConfigurableResource
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
-
Methods inherited from interface org.apache.uima.resource.Resource
getLogger, getMetaData, getResourceManager, getUimaContext, getUimaContextAdmin, setLogger
-
-
-
-
Method Detail
-
initialize
public boolean initialize(ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams) throws ResourceInitializationException
Called by the framework to initialize this CAS Consumer. Subclasses should NOT override this method; instead they should override the zero-argumentinitialize()
method and access metadata via thegetProcessingResourceMetaData()
method. This method is non-final only for legacy reasons.- Specified by:
initialize
in interfaceResource
- Overrides:
initialize
in classResource_ImplBase
- Parameters:
aSpecifier
- specifies how to create a resource or locate an existing resource service.aAdditionalParams
- a Map containing additional parameters. May benull
if there are no parameters. Each class that implements this interface can decide what additional parameters it supports.- Returns:
- true if and only if initialization completed successfully. Returns false if the given
ResourceSpecifier
is not of an appropriate type for this Resource. If theResourceSpecifier
is of an appropriate type but is invalid or if some other failure occurs, an exception should be thrown. - Throws:
ResourceInitializationException
- if a failure occurs during initialization.- See Also:
Resource.initialize(org.apache.uima.resource.ResourceSpecifier, java.util.Map)
-
initialize
public void initialize() throws ResourceInitializationException
This method is called during initialization, and does nothing by default. Subclasses should override it to perform one-time startup logic.- Throws:
ResourceInitializationException
- if a failure occurs during initialization.
-
destroy
public void destroy()
Description copied from interface:Resource
Releases all resources held by thisResource
.- Specified by:
destroy
in interfaceResource
- Overrides:
destroy
in classResource_ImplBase
- See Also:
Resource.destroy()
-
typeSystemInit
public void typeSystemInit(TypeSystem arg0) throws ResourceInitializationException
Description copied from interface:CasObjectProcessor
Informs this CasConsumer that the CAS TypeSystem has changed. The CPM calls this method prior to initiating collection processing, and will call it again whenever the CAS TypeSystem changes.In this method, the CasConsumer should use the
TypeSystem
to resolve the names of Type and Features to the actualType
andFeature
objects, which can then be used during processing.- Specified by:
typeSystemInit
in interfaceCasObjectProcessor
- Parameters:
arg0
- the type system to use- Throws:
ResourceInitializationException
- if the type system is not compatible with this Cas Consumer- See Also:
CasObjectProcessor.typeSystemInit(org.apache.uima.cas.TypeSystem)
-
processCas
public void processCas(CAS[] aCASes) throws ResourceProcessException
Description copied from interface:CasObjectProcessor
Processes multiple CASes.- Specified by:
processCas
in interfaceCasObjectProcessor
- Parameters:
aCASes
- an array of CASes to be processed. Additional information may be added to these CASes (if this CAS processor is notread-only
).- Throws:
ResourceProcessException
- if processing fails for any of the CASes- See Also:
CasObjectProcessor.processCas(org.apache.uima.cas.CAS[])
-
isStateless
public boolean isStateless()
Description copied from interface:CasProcessor
Gets whether this is a stateless CAS Processor. Stateless CAS Processors do not maintain any data between calls to their process methods.- Specified by:
isStateless
in interfaceCasProcessor
- Returns:
- true if this CAS processor is stateless, false if it is stateful.
- See Also:
CasProcessor.isStateless()
-
isReadOnly
public final boolean isReadOnly()
Returns true. By contract, CAS Consumers must be read only.- Specified by:
isReadOnly
in interfaceCasConsumer
- Specified by:
isReadOnly
in interfaceCasProcessor
- Returns:
- true if this CAS processor does not modify the CAS, false if it does.
- See Also:
CasProcessor.isReadOnly()
-
getProcessingResourceMetaData
public ProcessingResourceMetaData getProcessingResourceMetaData()
Description copied from interface:CasProcessor
Gets the metadata that describes thisCasProcesor
.- Specified by:
getProcessingResourceMetaData
in interfaceCasProcessor
- Returns:
- an object containing all metadata for this CasProcessor
- See Also:
CasProcessor.getProcessingResourceMetaData()
-
batchProcessComplete
public void batchProcessComplete(ProcessTrace arg0) throws ResourceProcessException, java.io.IOException
Description copied from interface:CasProcessor
Completes the processing of a batch. A collection may be divided into one or more batches - it is up to the CollectionProcessingManager or the application to determine the number and size of batches.- Specified by:
batchProcessComplete
in interfaceCasProcessor
- Parameters:
arg0
- an object that records information, such as timing, about this method's execution.- Throws:
ResourceProcessException
- if an exception occurs during processingjava.io.IOException
- if an I/O failure occurs- See Also:
CasProcessor.batchProcessComplete(org.apache.uima.util.ProcessTrace)
-
collectionProcessComplete
public void collectionProcessComplete(ProcessTrace arg0) throws ResourceProcessException, java.io.IOException
Description copied from interface:CasProcessor
Completes the processing of an entire collection.- Specified by:
collectionProcessComplete
in interfaceCasProcessor
- Parameters:
arg0
- an object that records information, such as timing, about this method's execution.- Throws:
ResourceProcessException
- if an exception occurs during processingjava.io.IOException
- if an I/O failure occurs- See Also:
CasProcessor.collectionProcessComplete(org.apache.uima.util.ProcessTrace)
-
reconfigure
public void reconfigure() throws ResourceConfigurationException
Notifies this CAS Consumer that its configuration parameter settings have been changed. By default this method just callsdestroy()
followed byinitialize()
. CAS Consumers that have expensive initialization that does not need to be redone whenever configuration parameters change may wish to override this method to provide a more efficient implementation.- Specified by:
reconfigure
in interfaceConfigurableResource
- Overrides:
reconfigure
in classConfigurableResource_ImplBase
- Throws:
ResourceConfigurationException
- if the configuration is not valid- See Also:
ConfigurableResource_ImplBase.reconfigure()
-
-