public abstract class UimaContext_ImplBase extends Object implements UimaContextAdmin
Modifier and Type | Field and Description |
---|---|
protected int |
loggingThrottleLimit
A number to throttle logging from Annotators If not the max value, it wraps loggers obtained
with getLogger() that are for Annotator classes, with the ThrottlingLogger.
|
protected int |
mCasPoolSize
Size of the CAS pool used to support the
getEmptyCas(Class) method. |
protected AnalysisEngineManagementImpl |
mMBean
Object that implements management interface to the AE.
|
protected Set<CAS> |
mOutstandingCASes
CASes that have been requested via
getEmptyCas(Class) minus the number calls the
framework has made to returnedCAS(AbstractCas) (which indicate that the
AnalysisComponent has returned a CAS from its next() method or released the CAS. |
protected String |
mQualifiedContextName
Fully-qualified name of this context.
|
protected Map<String,String> |
mSofaMappings
Mapping between sofa names assigned by an aggregate engine to sofa names assigned by the
component engines.
|
Constructor and Description |
---|
UimaContext_ImplBase()
Default constructor.
|
UimaContext_ImplBase(String contextName,
Map<String,String> sofaMappings)
Constructor for non Root instances
|
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
combineSofaMappings(Map<String,String> aSofaMappings)
Create the child sofa map by combining existing mapping from the current context with any
mappings specific for this child, passed in as aSofaMappings
|
UimaContextAdmin |
createChild(String aContextName,
Map<String,String> aSofaMappings)
Creates a UimaContext that is a child of this UimaContext.
|
void |
defineCasPool(int aSize,
Properties aPerformanceTuningSettings,
boolean aSofaAware)
Defines the CAS pool that this UimaContext must support.
|
ComponentInfo |
getComponentInfo()
Gets the ComponentInfo object for this component, which can be passed to
CAS.setCurrentComponentInfo(ComponentInfo) . |
String[] |
getConfigParameterNames()
Gets the names of all configuration parameters that are not declared in a group.
|
String[] |
getConfigParameterNames(String aGroup)
Gets the names of all configuration parameters in the specified group.
|
Object |
getConfigParameterValue(String aName)
Retrieves the value for a configuration parameter that is not defined in any group or is
defined in the default group.
|
Object |
getConfigParameterValue(String aGroupName,
String aParamName)
Retrieves the value for a configuration parameter in a particular group.
|
String[] |
getConfigurationGroupNames()
Gets the names of all configuration parameter groups.
|
String |
getDataPath()
Deprecated.
|
List<String> |
getDataPathElements()
Gets the data path elements used to resolve relative paths.
|
<T extends AbstractCas> |
getEmptyCas(Class<T> aCasInterface)
Get an empty CAS.
|
Settings |
getExternalOverrides()
(non-Javadoc)
|
AnalysisEngineManagement |
getManagementInterface()
Gets an object that can be used to do monitoring or management of this AnalysisEngine.
|
String |
getMdcId() |
String |
getQualifiedContextName()
Gets the fully-qualified name of this context.
|
InputStream |
getResourceAsStream(String aKey)
Acquires Resource InputStreams using the ResourceManager.
|
InputStream |
getResourceAsStream(String aKey,
String[] aParams)
Retrieves an InputStream for reading from the named resource.
|
String |
getResourceFilePath(String aKey)
Retrieves the absolute file path to the named resource.
|
String |
getResourceFilePath(String aKey,
String[] aParams)
Retrieves the absolute file path to the named resource.
|
Object |
getResourceObject(String aKey)
Acquires a Resource object using the ResourceManager.
|
Object |
getResourceObject(String aKey,
String[] aParams)
Retrieves the named resource object.
|
URI |
getResourceURI(String aKey)
Retrieves the URI to the named resource.
|
URI |
getResourceURI(String aKey,
String[] aParams)
Retrieves the URI to the named resource.
|
URL |
getResourceURL(String aKey)
Locates Resource URL's using the ResourceManager.
|
URL |
getResourceURL(String aKey,
String[] aParams)
Retrieves the URL to the named resource.
|
String[] |
getSharedSettingArray(String name)
Get the array of values for a shared configuration parameter from the external override
settings.
|
String[] |
getSharedSettingNames()
Get the names of all the external override settings available.
|
String |
getSharedSettingValue(String name)
Get the value of a shared configuration parameter from the external override settings.
|
Map<String,String> |
getSofaMap()
Gets an unmodifiable Map containing the mapping of component sofa name to absolute sofa ID.
|
SofaID[] |
getSofaMappings()
(non-Javadoc)
|
String |
getUniqueName()
Returns a UUID-like unique name of this component.
|
protected String |
makeQualifiedName(String name) |
String |
mapSofaIDToComponentSofaName(String aSofaID)
(non-Javadoc)
|
SofaID |
mapToSofaID(String aSofaName)
Changes here should also be made in UimaContext_ImplBase.mapToSofaID (non-Javadoc)
|
protected Logger |
maybeThrottleLogger(Logger logger) |
void |
returnedCAS(AbstractCas aCAS)
Called internally by the framework whenever the AnalysisComponent returns a CAS from its next()
method or calls cas.release().
|
void |
setExternalOverrides(Settings externalOverrides)
(non-Javadoc)
|
void |
setLoggingThrottleLimit(Integer v) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfigurationManager, getResourceManager, getRootContext, initializeRoot, setLogger, setProcessTrace, setSession
getInstrumentationFacility, getLogger, getSession
protected final String mQualifiedContextName
protected final Map<String,String> mSofaMappings
protected volatile int mCasPoolSize
getEmptyCas(Class)
method. Note: CASes
obtained by a CAS Multiplier, which then leave (exit) the CAS Multiplier, are not counted
toward this limit.
Rather, this limit limits the number of CASes that can be obtained while inside an annotator.
The (maybe unobvious) use-case: Consider an annotator that receives hundreds of CASes, and
sorts them into 3 kinds of aggregations, each of which accumulates information in a separate
CAS for a while, and then releases these CASes for further processing. The limit would need to
be set to 3 for this annotator instance, for this to work.
The value of this max is set by calling the annotator's method getCasInstancesRequired method,
a user-supplied method that is used to configure this. The default is 1.protected final Set<CAS> mOutstandingCASes
getEmptyCas(Class)
minus the number calls the
framework has made to returnedCAS(AbstractCas)
(which indicate that the
AnalysisComponent has returned a CAS from its next() method or released the CAS.
If this Set size is at the maximum for this annotator, and the Analysis Component requests any
additional CASes, then the AnalysisComponent has requested more CASes than it is allowed to and
we throw an exception.
This was changed from a simple int count to a set, in
https://issues.apache.org/jira/browse/UIMA-437 revision 546169 (see history). CAS Multiplier
use counts the CAS as returned after it is produced by the next() method when that method
returns. Note that the CAS is not at that point "released" back into the CasPool - it is
typically following a flow path and will eventually be released at some later point. The reason
it is counted as released in this context's count is that this count limit is for limiting the
number of CASes that can be requested within one process(), next(), or hasNext() methods,
simultaneously, before that CAS is set onwards. Normally this is just 1 (at a time).
The set is managed as a ConcurrentMap, to allow "remove" operations to not interlock with add
or size operations. The size check followed by an add is in one sync block within
getEmptyCas(), locked on the set object itself (not shared with any other locks).protected final AnalysisEngineManagementImpl mMBean
protected int loggingThrottleLimit
public UimaContext_ImplBase()
public String getUniqueName()
UimaContextAdmin
getUniqueName
in interface UimaContextAdmin
public UimaContextAdmin createChild(String aContextName, Map<String,String> aSofaMappings)
UimaContextAdmin
createChild
in interface UimaContextAdmin
aContextName
- a name for the new context, which must be unique with respect to all children of the
parent context.aSofaMappings
- mappings from child's sofa name to parent's sofa name. May be null.public Map<String,String> combineSofaMappings(Map<String,String> aSofaMappings)
aSofaMappings
- -public Object getConfigParameterValue(String aName)
UimaContext
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.
getConfigParameterValue
in interface UimaContext
aName
- the name of the parameter to look upnull
if the parameter does not exist or has
not been assigned a value.AnnotatorContext.getConfigParameterValue(java.lang.String)
public Object getConfigParameterValue(String aGroupName, String aParamName)
UimaContext
ConfigurationParameterDeclarations.getSearchStrategy()
property will be used. The search strategy can be specified in the descriptor.
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.
getConfigParameterValue
in interface UimaContext
aGroupName
- the name of the group containing the parameteraParamName
- the name of the parameter to look upnull
if the parameter does not exist or has
not been assigned a value.AnnotatorContext.getConfigParameterValue(java.lang.String,
java.lang.String)
public String getSharedSettingValue(String name) throws ResourceConfigurationException
UimaContext
getSharedSettingValue
in interface UimaContext
name
- - the name of the parameterResourceConfigurationException
- if the value references an undefined parameter, or the value is an arraypublic String[] getSharedSettingArray(String name) throws ResourceConfigurationException
UimaContext
getSharedSettingArray
in interface UimaContext
name
- - the name of the parameterResourceConfigurationException
- if the value references an undefined parameter, or the value is not an arraypublic String[] getSharedSettingNames()
UimaContext
getSharedSettingNames
in interface UimaContext
public URL getResourceURL(String aKey) throws ResourceAccessException
getResourceURL
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.URL
at which the named resource is located, null
if the
named resource could not be found.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceURL(java.lang.String)
public URI getResourceURI(String aKey) throws ResourceAccessException
UimaContext
This method is safer than UimaContext.getResourceURL(String)
in its treatment of file paths
containing spaces. This is because the URI.getPath()
does perform URL decoding of that
path (decoding %20 sequences to spaces) whereas URL.getPath()
does not.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
getResourceURI
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.URI
at which the named resource is located, null
if the
named resource could not be found.ResourceAccessException
- if a failure occurs in accessing the resourcepublic String getResourceFilePath(String aKey) throws ResourceAccessException
UimaContext
This only works if the resource is a local file. If the resource is not a local file (for
example, it could be an http
URL, then an exception will be thrown.
URL decoding will be done on the file path, so it is safe to use this method for file paths
that contain spaces.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
getResourceFilePath
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.null
if the
named resource could not be found.ResourceAccessException
- if the resource is not a local file, or if a failure occurs in accessing the resourcepublic InputStream getResourceAsStream(String aKey) throws ResourceAccessException
getResourceAsStream
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.InputStream
for reading from the named resource, null
if
the named resource could not be found. It is the caller's responsibility to close this
stream once it is no longer needed.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceAsStream(java.lang.String)
public Object getResourceObject(String aKey) throws ResourceAccessException
getResourceObject
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aName
, null
if none.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceObject(java.lang.String)
public InputStream getResourceAsStream(String aKey, String[] aParams) throws ResourceAccessException
UimaContext
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
getResourceAsStream
in interface UimaContext
aKey
- the key by which the resource is identified. This key should bd declared in the
<externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language
for a <fileLanguageResourceSpecifier>, this array should contain a single
element, the ISO language code for the language of the document (e.g. "en", "de").InputStream
for reading from the named resource, null
if
the named resource could not be found. It is the caller's responsibility to close this
stream once it is no longer needed.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceAsStream(java.lang.String,
java.lang.String[])
public Object getResourceObject(String aKey, String[] aParams) throws ResourceAccessException
UimaContext
This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
getResourceObject
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language
for a <fileLanguageResourceSpecifier>, this array should contain a single
element, the ISO language code for the language of the document (e.g. "en", "de").aName
, null
if none.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceObject(java.lang.String,
java.lang.String[])
public URL getResourceURL(String aKey, String[] aParams) throws ResourceAccessException
UimaContext
Note that if the URL contains spaces they may be encoded as %20. The URL.getPath()
method does NOT decode these sequences, therefore it is not safe to call
getResourceURL().getPath()
and attempt to use the result as a file path. Instead,
you may use UimaContext.getResourceURI(String)
or UimaContext.getResourceFilePath(String)
.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
getResourceURL
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language
for a <fileLanguageResourceSpecifier>, this array should contain a single
element, the ISO language code for the language of the document (e.g. "en", "de").URL
at which the named resource is located, null
if the
named resource could not be found.ResourceAccessException
- if a failure occurs in accessing the resourceAnnotatorContext.getResourceURL(java.lang.String,
java.lang.String[])
public URI getResourceURI(String aKey, String[] aParams) throws ResourceAccessException
UimaContext
This method is safer than UimaContext.getResourceURL(String)
in its treatment of file paths
containing spaces. This is because the URI.getPath()
does perform URL decoding of that
path (decoding %20 sequences to spaces) whereas URL.getPath()
does not.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
getResourceURI
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language
for a <fileLanguageResourceSpecifier>, this array should contain a single
element, the ISO language code for the language of the document (e.g. "en", "de").URI
at which the named resource is located, null
if the
named resource could not be found.ResourceAccessException
- if a failure occurs in accessing the resourcepublic String getResourceFilePath(String aKey, String[] aParams) throws ResourceAccessException
UimaContext
This only works if the resource is a local file. If the resource is not a local file (for
example, it could be an http
URL, then an exception will be thrown.
URL decoding will be done on the file path, so it is safe to use this method for file paths that contain spaces.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked
up directly in the data path
and the class path. However, this
usage is deprecated and support may be dropped in future versions. ALL external resource
dependencies should be declared in the descriptor.
This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
getResourceFilePath
in interface UimaContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language
for a <fileLanguageResourceSpecifier>, this array should contain a single
element, the ISO language code for the language of the document (e.g. "en", "de").null
if the
named resource could not be found.ResourceAccessException
- if the resource is not a local file, or if a failure occurs in accessing the resource@Deprecated public String getDataPath()
UimaContext
path.separator
character (; on windows, : on UNIX).
This method is intended to be used only for integration of legacy or third-party components
that have their own resource management facility. If possible, it is recommended that you use
the getResoureXXX
methods instead.
getDataPath
in interface UimaContext
public List<String> getDataPathElements()
UimaContext
getDataPathElements
in interface UimaContext
public String getQualifiedContextName()
UimaContextAdmin
/MyTopLevelAnalysisEngine/MyComponentAnalysisEngine/MyAnnotator/
.getQualifiedContextName
in interface UimaContextAdmin
public String[] getConfigurationGroupNames()
UimaContext
getConfigurationGroupNames
in interface UimaContext
public String[] getConfigParameterNames()
UimaContext
getConfigParameterNames
in interface UimaContext
public String[] getConfigParameterNames(String aGroup)
UimaContext
getConfigParameterNames
in interface UimaContext
aGroup
- the group nameaGroup
. Note that this does include parameters with null values. Returns
an empty array if there are none (including if the group does not exist).public Settings getExternalOverrides()
getExternalOverrides
in interface UimaContext
getExternalOverrides
in interface UimaContextAdmin
UimaContextAdmin.getExternalOverrides()
public void setExternalOverrides(Settings externalOverrides)
setExternalOverrides
in interface UimaContextAdmin
externalOverrides
- the external overrides settingsUimaContextAdmin.setExternalOverrides(org.apache.uima.util.Settings)
public SofaID mapToSofaID(String aSofaName)
mapToSofaID
in interface UimaContext
aSofaName
- this component's name for a SofAUimaContext.mapToSofaID(java.lang.String)
public String mapSofaIDToComponentSofaName(String aSofaID)
mapSofaIDToComponentSofaName
in interface UimaContext
aSofaID
- absolute SofA IDUimaContext.mapSofaIDToComponentSofaName(java.lang.String)
public SofaID[] getSofaMappings()
getSofaMappings
in interface UimaContext
UimaContext.getSofaMappings()
public Map<String,String> getSofaMap()
UimaContextAdmin
getSofaMap
in interface UimaContextAdmin
public void defineCasPool(int aSize, Properties aPerformanceTuningSettings, boolean aSofaAware) throws ResourceInitializationException
UimaContextAdmin
UimaContext.getEmptyCas(Class)
may be called.defineCasPool
in interface UimaContextAdmin
aSize
- the minimum CAS pool size requiredaPerformanceTuningSettings
- settings, including initial CAS heap size, for the AEaSofaAware
- whether the component that will receive these CASes is sofa aware. This is needed to
determine which view to get. Sofa-aware components get the base view; sofa-unaware
components get the default text sofa view (or whatever is mapped to it).ResourceInitializationException
- if a CAS could not be created.public void returnedCAS(AbstractCas aCAS)
UimaContextAdmin
returnedCAS
in interface UimaContextAdmin
aCAS
- the CAS that was returned or releasedUimaContextAdmin.returnedCAS(AbstractCas)
public <T extends AbstractCas> T getEmptyCas(Class<T> aCasInterface)
UimaContext
CasMultiplier_ImplBase.getEmptyCAS()
or
JCasMultiplier_ImplBase.getEmptyJCas()
method.
This method may maintain a pool of CASes and may block if none are currently available.
getEmptyCas
in interface UimaContext
T
- the type of the CAS interface (CAS or JCas)aCasInterface
- the specific CAS interface that the component wants to use (e.g. CAS or JCas). Must
specify a subtype of AbstractCas
.aCasInterface
. The CAS
will be unlocked (can be reset) but will have switched Class Loaders if needed.public ComponentInfo getComponentInfo()
UimaContextAdmin
CAS.setCurrentComponentInfo(ComponentInfo)
.getComponentInfo
in interface UimaContextAdmin
public AnalysisEngineManagement getManagementInterface()
UimaContextAdmin
getManagementInterface
in interface UimaContextAdmin
public void setLoggingThrottleLimit(Integer v)
public String getMdcId()
Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.