org.apache.uima.analysis_engine.service.impl
Class AnalysisEngineServiceAdapter

java.lang.Object
  extended by org.apache.uima.resource.Resource_ImplBase
      extended by org.apache.uima.resource.ConfigurableResource_ImplBase
          extended by org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
              extended by org.apache.uima.analysis_engine.service.impl.AnalysisEngineServiceAdapter
All Implemented Interfaces:
AnalysisEngine, TextAnalysisEngine, CasObjectProcessor, CasProcessor, CasConsumer, ConfigurableResource, Resource
Direct Known Subclasses:
SoapAnalysisEngineServiceAdapter, VinciAnalysisEngineServiceAdapter

public abstract class AnalysisEngineServiceAdapter
extends AnalysisEngineImplBase
implements TextAnalysisEngine, CasConsumer

Base class for analysis engine service adapters. Implements the AnalysisEngine interface by communicating with an Analysis Engine service. This insulates the application from having to know whether it is calling a local AnalysisEngine or a remote service.

Subclasses must provide an implementation of the AnalysisEngineImplBase.initialize(ResourceSpecifier,Map) method, which must create an AnalysisEngineStub object that can communicate with the remote service. The stub must be passed to the #setStub(AnalysisEngineStub) method of this class.


Field Summary
 
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
PARAM_CONFIG_PARAM_SETTINGS, PARAM_MBEAN_NAME_PREFIX, PARAM_MBEAN_SERVER, PARAM_NUM_SIMULTANEOUS_REQUESTS, PARAM_RESOURCE_MANAGER, PARAM_TIMEOUT_PERIOD
 
Fields inherited from interface org.apache.uima.resource.Resource
PARAM_AGGREGATE_SOFA_MAPPINGS, PARAM_CONFIG_MANAGER, PARAM_PERFORMANCE_TUNING_SETTINGS, PARAM_UIMA_CONTEXT
 
Constructor Summary
AnalysisEngineServiceAdapter()
           
 
Method Summary
 void batchProcessComplete()
          Notifies this AnalysisEngine that processing of a batch has completed.
 void collectionProcessComplete()
          Notifies this AnalysisEngine that processing of an entire collection has completed.
 void destroy()
          Releases all resources held by this Resource.
 java.lang.Object getConfigParameterValue(java.lang.String aParamName)
          Looks up the value of a configuration parameter.
 java.lang.Object getConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName)
          Looks up the value of a configuration parameter in a group.
 ResourceMetaData getMetaData()
          Gets the metadata that describes this Resource.
protected  java.lang.String getResourceName()
          Gets the name of this resource, for use in logging and trace messages.
protected  AnalysisEngineServiceStub getStub()
          Gets the stub to be used to communicate with the remote service.
 CasIterator processAndOutputNewCASes(CAS aCAS)
          Processes a CAS, possibly producing multiple CASes as a result.
 void reconfigure()
          Instructs this Resource to re-read its configuration parameter settings.
 void setConfigParameterValue(java.lang.String aParamName, java.lang.Object aValue)
          Sets the value of a configuration parameter.
 void setConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName, java.lang.Object aValue)
          Sets the value of a configuration parameter in a group.
protected  void setStub(AnalysisEngineServiceStub aStub)
          Sets the stub to be used to communicate with the remote service.
 
Methods inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
batchProcessComplete, buildProcessTraceFromMBeanStats, buildProcessTraceFromMBeanStats, collectionProcessComplete, createResultSpecification, createResultSpecification, enterBatchProcessComplete, enterCollectionProcessComplete, enterProcess, exitBatchProcessComplete, exitCollectionProcessComplete, exitProcess, finalize, getAnalysisEngineMetaData, getCurrentConfigParameterSettings, getFeatureNamesForType, getManagementInterface, getMBean, getMBeanNamePrefix, getMBeanServer, getPerformanceTuningSettings, getProcessingResourceMetaData, initialize, isProcessTraceEnabled, isReadOnly, isStateless, newCAS, newJCas, normalizeIsoLangCodes, process, process, process, process, process, process, process, processAndOutputNewCASes, processCas, processCas, resetResultSpecificationToDefault, setMetaData, setPerformanceTuningSettings, setResultSpecification, typeSystemInit
 
Methods inherited from class org.apache.uima.resource.Resource_ImplBase
getCasManager, getLogger, getResourceManager, getUimaContext, getUimaContextAdmin, setLogger
 
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
createResultSpecification, createResultSpecification, getAnalysisEngineMetaData, getFeatureNamesForType, getLogger, getManagementInterface, getPerformanceTuningSettings, getResourceManager, initialize, newCAS, newJCas, process, process, process, process, process, process, process, processAndOutputNewCASes, setLogger, setResultSpecification
 
Methods inherited from interface org.apache.uima.resource.Resource
getUimaContext, getUimaContextAdmin
 
Methods inherited from interface org.apache.uima.collection.base_cpm.CasObjectProcessor
processCas, processCas, typeSystemInit
 
Methods inherited from interface org.apache.uima.collection.base_cpm.CasProcessor
batchProcessComplete, collectionProcessComplete, getProcessingResourceMetaData, isReadOnly, isStateless
 
Methods inherited from interface org.apache.uima.collection.CasConsumer
isReadOnly
 

Constructor Detail

AnalysisEngineServiceAdapter

public AnalysisEngineServiceAdapter()
Method Detail

setStub

protected void setStub(AnalysisEngineServiceStub aStub)
Sets the stub to be used to communicate with the remote service. Subclasses must call this from their initialize method.

Parameters:
aStub - the stub for the remote service

getStub

protected AnalysisEngineServiceStub getStub()
Gets the stub to be used to communicate with the remote service.

Returns:
the stub for the remote service

getMetaData

public ResourceMetaData getMetaData()
Description copied from interface: Resource
Gets the metadata that describes this Resource.

Specified by:
getMetaData in interface Resource
Overrides:
getMetaData in class Resource_ImplBase
Returns:
an object containing all metadata for this resource.
See Also:
Resource.getMetaData()

destroy

public void destroy()
Description copied from interface: Resource
Releases all resources held by this Resource.

Specified by:
destroy in interface Resource
Overrides:
destroy in class Resource_ImplBase
See Also:
Resource.destroy()

processAndOutputNewCASes

public CasIterator processAndOutputNewCASes(CAS aCAS)
                                     throws AnalysisEngineProcessException
Description copied from interface: AnalysisEngine
Processes a CAS, possibly producing multiple CASes as a result. The application uses the CasIterator interface to step through the output CASes.

If this Analysis Engine does not produce output CASes, then the CasIterator will return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking the OperationalProperties.getOutputsNewCASes() operational property (getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()).

Once this method is called, the AnalysisEngine "owns" aCAS until such time as the CasIterator.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 call CasIterator.release(), which will stop further processing from occurring, and ownership of aCAS will revert to the caller.

Specified by:
processAndOutputNewCASes in interface AnalysisEngine
Overrides:
processAndOutputNewCASes in class AnalysisEngineImplBase
Parameters:
aCAS - the CAS to be processed
Returns:
an object for iterating through any output CASes
Throws:
AnalysisEngineProcessException - if a failure occurs during processing

reconfigure

public void reconfigure()
                 throws ResourceConfigurationException
Description copied from interface: ConfigurableResource
Instructs this Resource to re-read its configuration parameter settings.

Specified by:
reconfigure in interface AnalysisEngine
Specified by:
reconfigure in interface ConfigurableResource
Overrides:
reconfigure in class ConfigurableResource_ImplBase
Throws:
ResourceConfigurationException - if the configuration is not valid
See Also:
ConfigurableResource.reconfigure()

getConfigParameterValue

public java.lang.Object getConfigParameterValue(java.lang.String aGroupName,
                                                java.lang.String aParamName)
Description copied from interface: ConfigurableResource
Looks up the value of a configuration parameter in a group. If the parameter has no value assigned within the group, fallback strategies will be followed.

This method returns null if the parameter is optional and has not been assigned a value. (For mandatory parameters, an exception is thrown during initialization if no value has been assigned.) This method also returns null if there is no declared configuration parameter with the specified name.

Specified by:
getConfigParameterValue in interface ConfigurableResource
Overrides:
getConfigParameterValue in class ConfigurableResource_ImplBase
Parameters:
aGroupName - the name of a configuration group. If the group name is null, this method will return the same value as getParameterValue(String).
aParamName - the name of a parameter in the group
Returns:
the value of the parameter in group aGroupName with name aParamName,,null is either the parameter does not exist or it has not been assigned a value.
See Also:
ConfigurableResource.getConfigParameterValue(java.lang.String, java.lang.String)

getConfigParameterValue

public java.lang.Object getConfigParameterValue(java.lang.String aParamName)
Description copied from interface: ConfigurableResource
Looks up the value of a configuration parameter. This method will only return the value of a parameter that is not defined in any group.

This method returns null if the parameter is optional and has not been assigned a value. (For mandatory parameters, an exception is thrown during initialization if no value has been assigned.) This method also returns null if there is no declared configuration parameter with the specified name.

Specified by:
getConfigParameterValue in interface ConfigurableResource
Overrides:
getConfigParameterValue in class ConfigurableResource_ImplBase
Parameters:
aParamName - the name of a parameter that is not in any group
Returns:
the value of the parameter with name aParamName, null is either the parameter does not exist or it has not been assigned a value.
See Also:
ConfigurableResource.getConfigParameterValue(java.lang.String)

setConfigParameterValue

public void setConfigParameterValue(java.lang.String aParamName,
                                    java.lang.Object aValue)
Description copied from interface: ConfigurableResource
Sets the value of a configuration parameter. This only works for a parameter that is not defined in any group. Note that there is no guarantee that the change will take effect until ConfigurableResource.reconfigure() is called.

Specified by:
setConfigParameterValue in interface ConfigurableResource
Overrides:
setConfigParameterValue in class ConfigurableResource_ImplBase
Parameters:
aParamName - the name of a parameter that is not in any group
aValue - the value to assign to the parameter
See Also:
ConfigurableResource.setConfigParameterValue(java.lang.String, java.lang.Object)

setConfigParameterValue

public void setConfigParameterValue(java.lang.String aGroupName,
                                    java.lang.String aParamName,
                                    java.lang.Object aValue)
Description copied from interface: ConfigurableResource
Sets the value of a configuration parameter in a group. Note that there is no guarantee that the change will take effect until ConfigurableResource.reconfigure() is called.

Specified by:
setConfigParameterValue in interface ConfigurableResource
Overrides:
setConfigParameterValue in class ConfigurableResource_ImplBase
Parameters:
aGroupName - the name of a configuration group. If this parameter is null, this method will have the same effet as setParameterValue(String,Object).
aParamName - the name of a parameter in the group
aValue - the value to assign to the parameter.
See Also:
ConfigurableResource.setConfigParameterValue(java.lang.String, java.lang.String, java.lang.Object)

batchProcessComplete

public void batchProcessComplete()
                          throws AnalysisEngineProcessException
Description copied from interface: AnalysisEngine
Notifies 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:
batchProcessComplete in interface AnalysisEngine
Overrides:
batchProcessComplete in class AnalysisEngineImplBase
Throws:
AnalysisEngineProcessException - if an exception occurs during processing

collectionProcessComplete

public void collectionProcessComplete()
                               throws AnalysisEngineProcessException
Description copied from interface: AnalysisEngine
Notifies 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 fixedFlow or capabilityLanguageFlow, 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 no fixedFlow or capabilityLanguageFlow, then all components in the aggregate will be called in arbitrary order.

Specified by:
collectionProcessComplete in interface AnalysisEngine
Overrides:
collectionProcessComplete in class AnalysisEngineImplBase
Throws:
AnalysisEngineProcessException - if an exception occurs during processing

getResourceName

protected java.lang.String getResourceName()
Gets the name of this resource, for use in logging and trace messages.

Returns:
the name of this resource


Copyright © 2012. All Rights Reserved.