Class PearAnalysisEngineWrapper
- java.lang.Object
-
- org.apache.uima.resource.Resource_ImplBase
-
- org.apache.uima.resource.ConfigurableResource_ImplBase
-
- org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
-
- org.apache.uima.analysis_engine.impl.PearAnalysisEngineWrapper
-
- All Implemented Interfaces:
AnalysisEngine,TextAnalysisEngine,CasObjectProcessor,CasProcessor,ConfigurableResource,Resource
public class PearAnalysisEngineWrapper extends AnalysisEngineImplBase
UIMA pear runtime analysis engine wrapper. With this wrapper implementation it is possible to run installed pear files out of the box in UIMA. Calls to the wrapper that are part of the public APIs of its superclasses are forwarded to the contained AE - this makes it possible to have the pear as a top level component. For instance, if you do an ae.getCas() - it will get a CAS with the type system of the contained ae. Or if you set parameters, it will set parameters of the contained ae.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPearAnalysisEngineWrapper.StringPairinner class StringPair
-
Field Summary
Fields Modifier and Type Field Description private AnalysisEngineaeprivate static java.util.Map<ResourceManager,java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager>>cachedResourceManagers-
Fields inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
LOG_RESOURCE_BUNDLE, PARAM_VERIFICATION_MODE
-
Fields inherited from interface org.apache.uima.analysis_engine.AnalysisEngine
MDC_ANNOTATOR_CONTEXT_NAME, MDC_ANNOTATOR_IMPL_NAME, MDC_CAS_ID, MDC_ROOT_CONTEXT_ID, PARAM_CONFIG_PARAM_SETTINGS, PARAM_MBEAN_NAME_PREFIX, PARAM_MBEAN_SERVER, PARAM_NUM_SIMULTANEOUS_REQUESTS, PARAM_RESOURCE_MANAGER, PARAM_THROTTLE_EXCESSIVE_ANNOTATOR_LOGGING, PARAM_TIMEOUT_PERIOD
-
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 PearAnalysisEngineWrapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbatchProcessComplete()Notifies this AnalysisEngine that processing of a batch has completed.voidbatchProcessComplete(ProcessTrace trace)Completes the processing of a batch.protected voidbuildProcessTraceFromMBeanStats(ProcessTrace trace)Modify an existing ProcessTrace object by adding events that represent the last excecution of this AnalysisEngine.voidcollectionProcessComplete()Notifies this AnalysisEngine that processing of an entire collection has completed.voidcollectionProcessComplete(ProcessTrace trace)Completes the processing of an entire collection.ResultSpecificationcreateResultSpecification()A factory method used to create an instance ofResultSpecificationfor use with this AnalysisEngine.ResultSpecificationcreateResultSpecification(TypeSystem typeSystem)A factory method used to create an instance ofResultSpecificationfor use with this AnalysisEngine.private ResourceManagercreateRM(PearAnalysisEngineWrapper.StringPair sp, PackageBrowser pkgBrowser, ResourceManager parentResourceManager)private java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager>createRMmap(PearAnalysisEngineWrapper.StringPair sp, ResourceManager rm)voiddestroy()Releases all resources held by thisResource.protected voidenterBatchProcessComplete()protected voidenterCollectionProcessComplete()protected voidenterProcess()protected voidexitBatchProcessComplete()protected voidexitCollectionProcessComplete()protected voidexitProcess()AnalysisEngineMetaDatagetAnalysisEngineMetaData()Gets the metadata that describes thisAnalysisEngine.static java.util.Map<ResourceManager,java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager>>getCachedResourceManagers()protected java.lang.StringgetMBeanNamePrefix()protected java.lang.ObjectgetMBeanServer()ResourceMetaDatagetMetaData()Gets the metadata that describes thisResource.java.util.PropertiesgetPerformanceTuningSettings()Gets the performance tuning settings in effect for this Analysis Engine.ProcessingResourceMetaDatagetProcessingResourceMetaData()Gets the metadata that describes thisCasProcesor.UimaContextgetUimaContext()Gets the UIMA Context for this Resource.UimaContextAdmingetUimaContextAdmin()Gets the Admin interface to this Resource's UimaContext.booleaninitialize(ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)Initializes thisResourcefrom aResourceSpecifier.protected booleanisProcessTraceEnabled()Gets whether the Process Trace (which collects performance stats for this AnalysisEngine) is enabled.CASnewCAS()Creates a new Common Analysis System appropriate for this Analysis Engine.CasIteratorprocessAndOutputNewCASes(CAS aCAS)Processes a CAS, possibly producing multiple CASes as a result.voidreconfigure()Instructs this Resource to re-read its configuration parameter settings.protected voidsetMetaData(ResourceMetaData aMetaData)Sets theResourceMetaDataobject associated with thisResource.protected voidsetPerformanceTuningSettings(java.util.Properties aSettings)Sets the performance tuning settings in effect for this Analysis Engine.voidsetResultSpecification(ResultSpecification resultSpec)Sets the list of output types and features that the application wants this AnalysisEngine to produce.voidtypeSystemInit(TypeSystem typeSystem)From the CAS Processor interface.-
Methods inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
buildProcessTraceFromMBeanStats, callInitializeMethod, callProcessMethod, finalize, getCurrentConfigParameterSettings, getFeatureNamesForType, getManagementInterface, getMBean, isReadOnly, isStateless, newJCas, normalizeIsoLangCodes, process, process, process, process, process, process, process, processAndOutputNewCASes, processCas, processCas, resetResultSpecificationToDefault
-
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, getRelativePathResolver, getResourceManager, loadUserClass, loadUserClassOrThrow, setContextHolder, setContextHolderX, setLogger, withContextHolder
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.uima.analysis_engine.AnalysisEngine
getLogger, getResourceManager, setLogger
-
Methods inherited from interface org.apache.uima.resource.ConfigurableResource
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
-
-
-
-
Field Detail
-
cachedResourceManagers
private static final java.util.Map<ResourceManager,java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager>> cachedResourceManagers
-
ae
private AnalysisEngine ae
-
-
Method Detail
-
createRMmap
private java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager> createRMmap(PearAnalysisEngineWrapper.StringPair sp, ResourceManager rm)
-
createRM
private ResourceManager createRM(PearAnalysisEngineWrapper.StringPair sp, PackageBrowser pkgBrowser, ResourceManager parentResourceManager) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
initialize
public boolean initialize(ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams) throws ResourceInitializationException
Description copied from interface:ResourceInitializes thisResourcefrom aResourceSpecifier. Applications do not need to call this method. It is called automatically by theResourceFactoryand cannot be called a second time.- Specified by:
initializein interfaceAnalysisEngine- Specified by:
initializein interfaceResource- Overrides:
initializein classAnalysisEngineImplBase- Parameters:
aSpecifier- specifies how to create a resource or locate an existing resource service.aAdditionalParams- a Map containing additional parameters. May benullif 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
ResourceSpecifieris not of an appropriate type for this Resource. If theResourceSpecifieris 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:
multi-thread safe, given that each instance of this class is only called on one thread, once. The critical parts that update shared information (in shared uima context) are inside a synchronize block
-
getAnalysisEngineMetaData
public AnalysisEngineMetaData getAnalysisEngineMetaData()
Description copied from interface:AnalysisEngineGets the metadata that describes thisAnalysisEngine. This is just a convenience method that callsResource.getMetaData()and casts the result to aAnalysisEngineMetaData.- Specified by:
getAnalysisEngineMetaDatain interfaceAnalysisEngine- Overrides:
getAnalysisEngineMetaDatain classAnalysisEngineImplBase- Returns:
- an object containing all metadata for this AnalysisEngine
- See Also:
AnalysisEngine.getAnalysisEngineMetaData()
-
getMetaData
public ResourceMetaData getMetaData()
Description copied from interface:ResourceGets the metadata that describes thisResource.- Specified by:
getMetaDatain interfaceResource- Overrides:
getMetaDatain classResource_ImplBase- Returns:
- an object containing all metadata for this resource.
- See Also:
Resource.getMetaData()
-
batchProcessComplete
public void batchProcessComplete() throws AnalysisEngineProcessExceptionDescription copied from interface:AnalysisEngineNotifies this AnalysisEngine that processing of a batch has completed. It is up to the caller to determine the size of a batch. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.- Specified by:
batchProcessCompletein interfaceAnalysisEngine- Overrides:
batchProcessCompletein classAnalysisEngineImplBase- Throws:
AnalysisEngineProcessException- if an exception occurs during processing
-
collectionProcessComplete
public void collectionProcessComplete() throws AnalysisEngineProcessExceptionDescription copied from interface:AnalysisEngineNotifies this AnalysisEngine that processing of an entire collection has completed. It is up to the caller to determine when this has occurred. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.If this AnalysisEngine is an aggregate, this method will call the collectionProcessComplete method of all components of that aggregate. If the aggregate descriptor declares a
fixedFloworcapabilityLanguageFlow, then the components' collectionProcessComplete methods will be called in the order specified by that flow element. Once all components in the flow have been called, any components not declared in the flow will be called, in arbitrary order. If there is nofixedFloworcapabilityLanguageFlow, then all components in the aggregate will be called in arbitrary order.- Specified by:
collectionProcessCompletein interfaceAnalysisEngine- Overrides:
collectionProcessCompletein classAnalysisEngineImplBase- Throws:
AnalysisEngineProcessException- if an exception occurs during processing
-
processAndOutputNewCASes
public CasIterator processAndOutputNewCASes(CAS aCAS) throws AnalysisEngineProcessException
Description copied from interface:AnalysisEngineProcesses a CAS, possibly producing multiple CASes as a result. The application uses theCasIteratorinterface to step through the output CASes.If this Analysis Engine does not produce output CASes, then the
CasIteratorwill return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking theOperationalProperties.getOutputsNewCASes()operational property (getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()).Once this method is called, the AnalysisEngine "owns"
aCASuntil such time as theCasIterator.hasNext()method returns false. That is, the caller should not attempt to modify or access the input CAS until it has read all of the elements from the CasIterator. If the caller wants to abort the processing before having read all of the output CASes, it may callCasIterator.release(), which will stop further processing from occurring, and ownership ofaCASwill revert to the caller.- Specified by:
processAndOutputNewCASesin interfaceAnalysisEngine- Overrides:
processAndOutputNewCASesin classAnalysisEngineImplBase- Parameters:
aCAS- the CAS to be processed- Returns:
- an object for iterating through any output CASes
- Throws:
AnalysisEngineProcessException- if a failure occurs during processing
-
destroy
public void destroy()
Description copied from interface:ResourceReleases all resources held by thisResource.- Specified by:
destroyin interfaceResource- Overrides:
destroyin classResource_ImplBase- See Also:
Resource.destroy()
-
reconfigure
public void reconfigure() throws ResourceConfigurationExceptionDescription copied from interface:ConfigurableResourceInstructs this Resource to re-read its configuration parameter settings.- Specified by:
reconfigurein interfaceAnalysisEngine- Specified by:
reconfigurein interfaceConfigurableResource- Overrides:
reconfigurein classConfigurableResource_ImplBase- Throws:
ResourceConfigurationException- if the configuration is not valid- See Also:
ConfigurableResource.reconfigure()
-
buildProcessTraceFromMBeanStats
protected void buildProcessTraceFromMBeanStats(ProcessTrace trace)
Description copied from class:AnalysisEngineImplBaseModify an existing ProcessTrace object by adding events that represent the last excecution of this AnalysisEngine. This is used so that we can return a ProcessTrace object from each process() call for backwards compatibility with version 1.x.- Overrides:
buildProcessTraceFromMBeanStatsin classAnalysisEngineImplBase- Parameters:
trace- -
-
enterBatchProcessComplete
protected void enterBatchProcessComplete()
- Overrides:
enterBatchProcessCompletein classAnalysisEngineImplBase
-
enterCollectionProcessComplete
protected void enterCollectionProcessComplete()
- Overrides:
enterCollectionProcessCompletein classAnalysisEngineImplBase
-
enterProcess
protected void enterProcess()
- Overrides:
enterProcessin classAnalysisEngineImplBase
-
exitBatchProcessComplete
protected void exitBatchProcessComplete()
- Overrides:
exitBatchProcessCompletein classAnalysisEngineImplBase
-
exitCollectionProcessComplete
protected void exitCollectionProcessComplete()
- Overrides:
exitCollectionProcessCompletein classAnalysisEngineImplBase
-
exitProcess
protected void exitProcess()
- Overrides:
exitProcessin classAnalysisEngineImplBase
-
getMBeanNamePrefix
protected java.lang.String getMBeanNamePrefix()
- Overrides:
getMBeanNamePrefixin classAnalysisEngineImplBase
-
getMBeanServer
protected java.lang.Object getMBeanServer()
- Overrides:
getMBeanServerin classAnalysisEngineImplBase
-
getPerformanceTuningSettings
public java.util.Properties getPerformanceTuningSettings()
Description copied from class:AnalysisEngineImplBaseGets the performance tuning settings in effect for this Analysis Engine.- Specified by:
getPerformanceTuningSettingsin interfaceAnalysisEngine- Overrides:
getPerformanceTuningSettingsin classAnalysisEngineImplBase- Returns:
- performance tuning settings
-
isProcessTraceEnabled
protected boolean isProcessTraceEnabled()
Description copied from class:AnalysisEngineImplBaseGets whether the Process Trace (which collects performance stats for this AnalysisEngine) is enabled. This is controlled through the PerformanceTuningSettings passed to the initialize() method.- Overrides:
isProcessTraceEnabledin classAnalysisEngineImplBase- Returns:
- true if the ProcessTrace is enabled, false if not.
-
setPerformanceTuningSettings
protected void setPerformanceTuningSettings(java.util.Properties aSettings)
Description copied from class:AnalysisEngineImplBaseSets the performance tuning settings in effect for this Analysis Engine. This should be set from the initialize() method if the defaults are to be overriden.- Overrides:
setPerformanceTuningSettingsin classAnalysisEngineImplBase- Parameters:
aSettings- performance tuning settings
-
getUimaContext
public UimaContext getUimaContext()
Description copied from interface:ResourceGets the UIMA Context for this Resource. This can be used to access external resources or facilities such as the Logger.- Specified by:
getUimaContextin interfaceResource- Overrides:
getUimaContextin classResource_ImplBase- Returns:
- the UimaContext for use by this Resource
-
getUimaContextAdmin
public UimaContextAdmin getUimaContextAdmin()
Description copied from class:Resource_ImplBaseGets the Admin interface to this Resource's UimaContext.- Specified by:
getUimaContextAdminin interfaceResource- Overrides:
getUimaContextAdminin classResource_ImplBase- Returns:
- the administrative interface to this Resource's UimaContext
-
setMetaData
protected void setMetaData(ResourceMetaData aMetaData)
Description copied from class:Resource_ImplBaseSets theResourceMetaDataobject associated with thisResource. Any previously existing metadata will be replaced.Resource subclasses should call this method during initialization in order to set the metadata before any calls to
Resource_ImplBase.getMetaData()are made.- Overrides:
setMetaDatain classAnalysisEngineImplBase- Parameters:
aMetaData- metadata to assign to thisResource
-
setResultSpecification
public void setResultSpecification(ResultSpecification resultSpec)
Description copied from interface:AnalysisEngineSets the list of output types and features that the application wants this AnalysisEngine to produce. This is only a guideline. Annotators may use this information to avoid doing unnecessary work, but they are not required to do so.- Specified by:
setResultSpecificationin interfaceAnalysisEngine- Overrides:
setResultSpecificationin classAnalysisEngineImplBase- Parameters:
resultSpec- specifies the list of output types and features that the application is interested in.
-
batchProcessComplete
public void batchProcessComplete(ProcessTrace trace) throws ResourceProcessException, java.io.IOException
Description copied from interface:CasProcessorCompletes 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:
batchProcessCompletein interfaceCasProcessor- Overrides:
batchProcessCompletein classAnalysisEngineImplBase- Parameters:
trace- 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
-
collectionProcessComplete
public void collectionProcessComplete(ProcessTrace trace) throws ResourceProcessException, java.io.IOException
Description copied from interface:CasProcessorCompletes the processing of an entire collection.- Specified by:
collectionProcessCompletein interfaceCasProcessor- Overrides:
collectionProcessCompletein classAnalysisEngineImplBase- Parameters:
trace- 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
-
createResultSpecification
public ResultSpecification createResultSpecification()
Description copied from interface:AnalysisEngineA factory method used to create an instance of
ResultSpecificationfor use with this AnalysisEngine. Applications use this method to constructResultSpecifications to pass to this AnalysisEngine'sAnalysisEngine.setResultSpecification(ResultSpecification)method.See also
AnalysisEngine.createResultSpecification(TypeSystem)which should be used if the type system associated with this result specification is known at this point in time.- Specified by:
createResultSpecificationin interfaceAnalysisEngine- Overrides:
createResultSpecificationin classAnalysisEngineImplBase- Returns:
- a new instance of
ResultSpecification - See Also:
AnalysisEngine.createResultSpecification()
-
createResultSpecification
public ResultSpecification createResultSpecification(TypeSystem typeSystem)
Description copied from interface:AnalysisEngineA factory method used to create an instance ofResultSpecificationfor use with this AnalysisEngine. Applications use this method to constructResultSpecifications to pass to this AnalysisEngine'sAnalysisEngine.setResultSpecification(ResultSpecification)method.- Specified by:
createResultSpecificationin interfaceAnalysisEngine- Overrides:
createResultSpecificationin classAnalysisEngineImplBase- Parameters:
typeSystem- the type system- Returns:
- a new instance of
ResultSpecification - See Also:
AnalysisEngine.createResultSpecification(TypeSystem)
-
getProcessingResourceMetaData
public ProcessingResourceMetaData getProcessingResourceMetaData()
Description copied from interface:CasProcessorGets the metadata that describes thisCasProcesor.- Specified by:
getProcessingResourceMetaDatain interfaceCasProcessor- Overrides:
getProcessingResourceMetaDatain classAnalysisEngineImplBase- Returns:
- an object containing all metadata for this CasProcessor
- See Also:
CasProcessor.getProcessingResourceMetaData()
-
newCAS
public CAS newCAS() throws ResourceInitializationException
Description copied from interface:AnalysisEngineCreates a new Common Analysis System appropriate for this Analysis Engine. An application can pre-populate this CAS, then pass it to theAnalysisEngine.process(CAS)method. Then, when the process method returns, the CAS will contain the results of the analysis.Important: CAS creation is expensive, so if at all possible an application should reuse CASes. When a CAS instance is no longer being used, call its
CAS.reset()method, which will remove all prior analysis information, and then reuse that same CAS instance for another call toAnalysisEngine.process(CAS).Note that the CAS allows multiple subjects of analysis (e.g. documents) and defines a separate "view" for each of them. If your application wants to work with a single subject of analysis, call the method
CAS.getCurrentView()and operate on the returned view.- Specified by:
newCASin interfaceAnalysisEngine- Overrides:
newCASin classAnalysisEngineImplBase- Returns:
- a new
CASappropriate for this AnalysisEngine. - Throws:
ResourceInitializationException- if a CAS could not be created because this AnalysisEngine's CAS metadata (type system, type priorities, or FS indexes) are invalid. Ideally this would be checked at AnalysisEngine initialization time, and it will likely be moved in the future.- See Also:
AnalysisEngine.newCAS()
-
typeSystemInit
public void typeSystemInit(TypeSystem typeSystem) throws ResourceInitializationException
Description copied from class:AnalysisEngineImplBaseFrom the CAS Processor interface. Called by the CPM if the CAS type system changes - this does not need to do anything since the annotators' typeSystemInit methods are automatically called prior to processing whenever it is necessary.- Specified by:
typeSystemInitin interfaceCasObjectProcessor- Overrides:
typeSystemInitin classAnalysisEngineImplBase- Parameters:
typeSystem- 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)
-
getCachedResourceManagers
public static java.util.Map<ResourceManager,java.util.Map<PearAnalysisEngineWrapper.StringPair,ResourceManager>> getCachedResourceManagers()
-
-