Class UimaContext_ImplBase
- java.lang.Object
-
- org.apache.uima.impl.UimaContext_ImplBase
-
- All Implemented Interfaces:
UimaContext,UimaContextAdmin
- Direct Known Subclasses:
ChildUimaContext_impl,RootUimaContext_impl
public abstract class UimaContext_ImplBase extends java.lang.Object implements UimaContextAdmin
Instances of this class shared by multiple threads
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classUimaContext_ImplBase.ComponentInfoImplImplementation of the ComponentInfo interface that allows the CAS to access information from this context- currently just the Sofa mappings.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringLOG_RESOURCE_BUNDLEresource bundle for log messagesprotected intloggingThrottleLimitA 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.private booleanmCasPoolCreatedKeeps track of whether we've created a CAS pool yet, which happens on the first call togetEmptyCas(Class).protected intmCasPoolSizeSize of the CAS pool used to support thegetEmptyCas(Class)method.private ComponentInfomComponentInfoThe ComponentInfoImpl class (an inner non-static class) has no fields and just one method that refers to fields in this (containing, outer) class.private static java.util.concurrent.atomic.AtomicIntegerMDC_NEXT_IDprivate java.lang.StringmdcUniqueIdprotected AnalysisEngineManagementImplmMBeanObject that implements management interface to the AE.protected java.util.Set<CAS>mOutstandingCASesCASes that have been requested viagetEmptyCas(Class)minus the number calls the framework has made toreturnedCAS(AbstractCas)(which indicate that the AnalysisComponent has returned a CAS from its next() method or released the CAS.private java.util.PropertiesmPerformanceTuningSettingsPerformance tuning settings.protected java.lang.StringmQualifiedContextNameFully-qualified name of this context.private booleanmSofaAwareWhether the component that accesses the CAS pool is sofa-aware.protected java.util.Map<java.lang.String,java.lang.String>mSofaMappingsMapping between sofa names assigned by an aggregate engine to sofa names assigned by the component engines.private java.lang.StringuniqueIdentifier
-
Constructor Summary
Constructors Constructor Description UimaContext_ImplBase()Default constructor.UimaContext_ImplBase(java.lang.String contextName, java.util.Map<java.lang.String,java.lang.String> sofaMappings)Constructor for non Root instances
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>combineSofaMappings(java.util.Map<java.lang.String,java.lang.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 aSofaMappingsprivate java.lang.StringconstructUniqueName()UimaContextAdmincreateChild(java.lang.String aContextName, java.util.Map<java.lang.String,java.lang.String> aSofaMappings)Creates a UimaContext that is a child of this UimaContext.voiddefineCasPool(int aSize, java.util.Properties aPerformanceTuningSettings, boolean aSofaAware)Defines the CAS pool that this UimaContext must support.ComponentInfogetComponentInfo()Gets the ComponentInfo object for this component, which can be passed toCAS.setCurrentComponentInfo(ComponentInfo).java.lang.String[]getConfigParameterNames()Gets the names of all configuration parameters that are not declared in a group.java.lang.String[]getConfigParameterNames(java.lang.String aGroup)Gets the names of all configuration parameters in the specified group.java.lang.ObjectgetConfigParameterValue(java.lang.String aName)Retrieves the value for a configuration parameter that is not defined in any group or is defined in the default group.java.lang.ObjectgetConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName)Retrieves the value for a configuration parameter in a particular group.java.lang.String[]getConfigurationGroupNames()Gets the names of all configuration parameter groups.java.lang.StringgetDataPath()Deprecated.java.util.List<java.lang.String>getDataPathElements()Gets the data path elements used to resolve relative paths.<T extends AbstractCas>
TgetEmptyCas(java.lang.Class<T> aCasInterface)Get an empty CAS.SettingsgetExternalOverrides()(non-Javadoc)AnalysisEngineManagementgetManagementInterface()Gets an object that can be used to do monitoring or management of this AnalysisEngine.java.lang.StringgetMdcId()java.lang.StringgetQualifiedContextName()Gets the fully-qualified name of this context.java.io.InputStreamgetResourceAsStream(java.lang.String aKey)Acquires Resource InputStreams using the ResourceManager.java.io.InputStreamgetResourceAsStream(java.lang.String aKey, java.lang.String[] aParams)Retrieves an InputStream for reading from the named resource.java.lang.StringgetResourceFilePath(java.lang.String aKey)Retrieves the absolute file path to the named resource.java.lang.StringgetResourceFilePath(java.lang.String aKey, java.lang.String[] aParams)Retrieves the absolute file path to the named resource.java.lang.ObjectgetResourceObject(java.lang.String aKey)Acquires a Resource object using the ResourceManager.java.lang.ObjectgetResourceObject(java.lang.String aKey, java.lang.String[] aParams)Retrieves the named resource object.java.net.URIgetResourceURI(java.lang.String aKey)Retrieves the URI to the named resource.java.net.URIgetResourceURI(java.lang.String aKey, java.lang.String[] aParams)Retrieves the URI to the named resource.private java.net.URIgetResourceURIfromURL(java.net.URL resourceUrl)java.net.URLgetResourceURL(java.lang.String aKey)Locates Resource URL's using the ResourceManager.java.net.URLgetResourceURL(java.lang.String aKey, java.lang.String[] aParams)Retrieves the URL to the named resource.java.lang.String[]getSharedSettingArray(java.lang.String name)Get the array of values for a shared configuration parameter from the external override settings.java.lang.String[]getSharedSettingNames()Get the names of all the external override settings available.java.lang.StringgetSharedSettingValue(java.lang.String name)Get the value of a shared configuration parameter from the external override settings.java.util.Map<java.lang.String,java.lang.String>getSofaMap()Gets an unmodifiable Map containing the mapping of component sofa name to absolute sofa ID.SofaID[]getSofaMappings()(non-Javadoc)java.lang.StringgetUniqueName()Returns a UUID-like unique name of this component.protected java.lang.StringmakeQualifiedName(java.lang.String name)java.lang.StringmapSofaIDToComponentSofaName(java.lang.String aSofaID)(non-Javadoc)SofaIDmapToSofaID(java.lang.String aSofaName)Changes here should also be made in UimaContext_ImplBase.mapToSofaID (non-Javadoc)protected LoggermaybeThrottleLogger(Logger logger)voidreturnedCAS(AbstractCas aCAS)Called internally by the framework whenever the AnalysisComponent returns a CAS from its next() method or calls cas.release().voidsetExternalOverrides(Settings externalOverrides)(non-Javadoc)voidsetLoggingThrottleLimit(java.lang.Integer v)-
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.UimaContext
getInstrumentationFacility, getLogger, getSession
-
Methods inherited from interface org.apache.uima.UimaContextAdmin
getConfigurationManager, getResourceManager, getRootContext, initializeRoot, setLogger, setProcessTrace, setSession
-
-
-
-
Field Detail
-
LOG_RESOURCE_BUNDLE
private static final java.lang.String LOG_RESOURCE_BUNDLE
resource bundle for log messages- See Also:
- Constant Field Values
-
MDC_NEXT_ID
private static java.util.concurrent.atomic.AtomicInteger MDC_NEXT_ID
-
mComponentInfo
private final ComponentInfo mComponentInfo
The ComponentInfoImpl class (an inner non-static class) has no fields and just one method that refers to fields in this (containing, outer) class. So it seems the method could just be used directly, and putting it into an inner class is silly.
-
mQualifiedContextName
protected final java.lang.String mQualifiedContextName
Fully-qualified name of this context.
-
mSofaMappings
protected final java.util.Map<java.lang.String,java.lang.String> mSofaMappings
Mapping between sofa names assigned by an aggregate engine to sofa names assigned by the component engines. The key is the component sofa name and the value is the absolute sofa name assigned by a top level aggregate in this process. Multi-threading: This map is constructed at Constructor time, and never updated, only referenced, subsequently.
-
mCasPoolSize
protected volatile int mCasPoolSize
Size of the CAS pool used to support thegetEmptyCas(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.
-
mPerformanceTuningSettings
private volatile java.util.Properties mPerformanceTuningSettings
Performance tuning settings. Needed to specify CAS heap size forgetEmptyCas(Class)method. Set during initialize calls for Analysis Engine components. Referenced during later lazy creation of Cas Pool upon first getEmptyCas call. Not expected to be modified after set.
-
mSofaAware
private volatile boolean mSofaAware
Whether the component that accesses the CAS pool is sofa-aware. Needed to determine which view is returned by thegetEmptyCas(Class)method. Set during initialize calls for Analysis Engine components. Referenced during later lazy creation of Cas Pool upon first getEmptyCas call. Not expected to be modified after set.
-
mCasPoolCreated
private volatile boolean mCasPoolCreated
Keeps track of whether we've created a CAS pool yet, which happens on the first call togetEmptyCas(Class). See http://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java for why this is volatile Ref'd and set inside getEmptyCas, part of lazy initialization of cas pool
-
mOutstandingCASes
protected final java.util.Set<CAS> mOutstandingCASes
CASes that have been requested viagetEmptyCas(Class)minus the number calls the framework has made toreturnedCAS(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).
-
mMBean
protected final AnalysisEngineManagementImpl mMBean
Object that implements management interface to the AE.
-
uniqueIdentifier
private final java.lang.String uniqueIdentifier
-
mdcUniqueId
private final java.lang.String mdcUniqueId
-
loggingThrottleLimit
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. This value is set from an Additional Parameters key AnalysisEngine.PARAM_SUPPRESS_EXCESSIVE_ANNOTATOR_LOGGING passed in as part of the additional parameters
-
-
Constructor Detail
-
UimaContext_ImplBase
public UimaContext_ImplBase()
Default constructor. Only Called for creating a "Root" instance.
-
UimaContext_ImplBase
public UimaContext_ImplBase(java.lang.String contextName, java.util.Map<java.lang.String,java.lang.String> sofaMappings)Constructor for non Root instances- Parameters:
contextName- -sofaMappings- -
-
-
Method Detail
-
constructUniqueName
private java.lang.String constructUniqueName()
-
getUniqueName
public java.lang.String getUniqueName()
Description copied from interface:UimaContextAdminReturns a UUID-like unique name of this component.- Specified by:
getUniqueNamein interfaceUimaContextAdmin- Returns:
- - unique name of this component
-
createChild
public UimaContextAdmin createChild(java.lang.String aContextName, java.util.Map<java.lang.String,java.lang.String> aSofaMappings)
Description copied from interface:UimaContextAdminCreates a UimaContext that is a child of this UimaContext.- Specified by:
createChildin interfaceUimaContextAdmin- Parameters:
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.- Returns:
- the Administrative interface to the UIMA Context
-
combineSofaMappings
public java.util.Map<java.lang.String,java.lang.String> combineSofaMappings(java.util.Map<java.lang.String,java.lang.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- Parameters:
aSofaMappings- -- Returns:
- the combined absolute sofamappings
-
getConfigParameterValue
public java.lang.Object getConfigParameterValue(java.lang.String aName)
Description copied from interface:UimaContextRetrieves the value for a configuration parameter that is not defined in any group or is defined in the default group.This method returns
nullif 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 returnsnullif there is no declared configuration parameter with the specified name.- Specified by:
getConfigParameterValuein interfaceUimaContext- Parameters:
aName- the name of the parameter to look up- Returns:
- the value of the parameter with the given name. The caller is expected to know the data
type of the parameter. Returns
nullif the parameter does not exist or has not been assigned a value. - See Also:
AnnotatorContext.getConfigParameterValue(java.lang.String)
-
getConfigParameterValue
public java.lang.Object getConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName)Description copied from interface:UimaContextRetrieves the value for a configuration parameter in a particular group. If that group contains no value for the specified parameter, the fallback strategy specified by the Analysis Engine'sConfigurationParameterDeclarations.getSearchStrategy()property will be used. The search strategy can be specified in the descriptor.This method returns
nullif 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 returnsnullif there is no declared configuration parameter with the specified name.- Specified by:
getConfigParameterValuein interfaceUimaContext- Parameters:
aGroupName- the name of the group containing the parameteraParamName- the name of the parameter to look up- Returns:
- the value of the parameter with the given name. The caller is expected to know the data
type of the parameter. Returns
nullif the parameter does not exist or has not been assigned a value. - See Also:
AnnotatorContext.getConfigParameterValue(java.lang.String, java.lang.String)
-
getSharedSettingValue
public java.lang.String getSharedSettingValue(java.lang.String name) throws ResourceConfigurationExceptionDescription copied from interface:UimaContextGet the value of a shared configuration parameter from the external override settings.- Specified by:
getSharedSettingValuein interfaceUimaContext- Parameters:
name- - the name of the parameter- Returns:
- - the value found in the shared settings file(s), or null if missing.
- Throws:
ResourceConfigurationException- if the value references an undefined parameter, or the value is an array
-
getSharedSettingArray
public java.lang.String[] getSharedSettingArray(java.lang.String name) throws ResourceConfigurationExceptionDescription copied from interface:UimaContextGet the array of values for a shared configuration parameter from the external override settings.- Specified by:
getSharedSettingArrayin interfaceUimaContext- Parameters:
name- - the name of the parameter- Returns:
- - an array of values found in the shared settings file(s), or null if missing.
- Throws:
ResourceConfigurationException- if the value references an undefined parameter, or the value is not an array
-
getSharedSettingNames
public java.lang.String[] getSharedSettingNames()
Description copied from interface:UimaContextGet the names of all the external override settings available.- Specified by:
getSharedSettingNamesin interfaceUimaContext- Returns:
- - an array containing the names of all the external override settings.
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey) throws ResourceAccessExceptionLocates Resource URL's using the ResourceManager.- Specified by:
getResourceURLin interfaceUimaContext- Parameters:
aKey- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the
URLat which the named resource is located,nullif the named resource could not be found. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceURL(java.lang.String)
-
getResourceURI
public java.net.URI getResourceURI(java.lang.String aKey) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the URI to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This method is safer than
UimaContext.getResourceURL(String)in its treatment of file paths containing spaces. This is because theURI.getPath()does perform URL decoding of that path (decoding %20 sequences to spaces) whereasURL.getPath()does not.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data pathand 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.- Specified by:
getResourceURIin interfaceUimaContext- Parameters:
aKey- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the
URIat which the named resource is located,nullif the named resource could not be found. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource
-
getResourceURIfromURL
private java.net.URI getResourceURIfromURL(java.net.URL resourceUrl) throws ResourceAccessException- Throws:
ResourceAccessException
-
getResourceFilePath
public java.lang.String getResourceFilePath(java.lang.String aKey) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the absolute file path to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This only works if the resource is a local file. If the resource is not a local file (for example, it could be an
httpURL, 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 pathand 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.- Specified by:
getResourceFilePathin interfaceUimaContext- Parameters:
aKey- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the absolute file path at which the named resource is located,
nullif the named resource could not be found. - Throws:
ResourceAccessException- if the resource is not a local file, or if a failure occurs in accessing the resource
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey) throws ResourceAccessExceptionAcquires Resource InputStreams using the ResourceManager.- Specified by:
getResourceAsStreamin interfaceUimaContext- Parameters:
aKey- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- an
InputStreamfor reading from the named resource,nullif the named resource could not be found. It is the caller's responsibility to close this stream once it is no longer needed. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceAsStream(java.lang.String)
-
getResourceObject
public java.lang.Object getResourceObject(java.lang.String aKey) throws ResourceAccessExceptionAcquires a Resource object using the ResourceManager.- Specified by:
getResourceObjectin interfaceUimaContext- Parameters:
aKey- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the object bound to
aName,nullif none. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceObject(java.lang.String)
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves an InputStream for reading from the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data pathand 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.
- Specified by:
getResourceAsStreamin interfaceUimaContext- Parameters:
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").- Returns:
- an
InputStreamfor reading from the named resource,nullif the named resource could not be found. It is the caller's responsibility to close this stream once it is no longer needed. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceAsStream(java.lang.String, java.lang.String[])
-
getResourceObject
public java.lang.Object getResourceObject(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the named resource object. This can be used to acquire references to external resources. The resource should be declared in the <externalResourceDependencies> section of 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.
- Specified by:
getResourceObjectin interfaceUimaContext- Parameters:
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").- Returns:
- the object bound to
aName,nullif none. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceObject(java.lang.String, java.lang.String[])
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the URL to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.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 callgetResourceURL().getPath()and attempt to use the result as a file path. Instead, you may useUimaContext.getResourceURI(String)orUimaContext.getResourceFilePath(String).For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data pathand 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.
- Specified by:
getResourceURLin interfaceUimaContext- Parameters:
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").- Returns:
- the
URLat which the named resource is located,nullif the named resource could not be found. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource- See Also:
AnnotatorContext.getResourceURL(java.lang.String, java.lang.String[])
-
getResourceURI
public java.net.URI getResourceURI(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the URI to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This method is safer than
UimaContext.getResourceURL(String)in its treatment of file paths containing spaces. This is because theURI.getPath()does perform URL decoding of that path (decoding %20 sequences to spaces) whereasURL.getPath()does not.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data pathand 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.
- Specified by:
getResourceURIin interfaceUimaContext- Parameters:
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").- Returns:
- the
URIat which the named resource is located,nullif the named resource could not be found. - Throws:
ResourceAccessException- if a failure occurs in accessing the resource
-
getResourceFilePath
public java.lang.String getResourceFilePath(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessExceptionDescription copied from interface:UimaContextRetrieves the absolute file path to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This only works if the resource is a local file. If the resource is not a local file (for example, it could be an
httpURL, 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 pathand 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.
- Specified by:
getResourceFilePathin interfaceUimaContext- Parameters:
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").- Returns:
- the absolute file path at which the named resource is located,
nullif the named resource could not be found. - Throws:
ResourceAccessException- if the resource is not a local file, or if a failure occurs in accessing the resource
-
getDataPath
@Deprecated public java.lang.String getDataPath()
Deprecated.Description copied from interface:UimaContextGets the data path used to locate resources. This path may contain more than one directory, separated by the Systempath.separatorcharacter (; 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
getResoureXXXmethods instead.- Specified by:
getDataPathin interfaceUimaContext- Returns:
- the data path
-
getDataPathElements
public java.util.List<java.lang.String> getDataPathElements()
Description copied from interface:UimaContextGets the data path elements used to resolve relative paths.- Specified by:
getDataPathElementsin interfaceUimaContext- Returns:
- the data path elements
-
makeQualifiedName
protected java.lang.String makeQualifiedName(java.lang.String name)
-
getQualifiedContextName
public java.lang.String getQualifiedContextName()
Description copied from interface:UimaContextAdminGets the fully-qualified name of this context. This is a slash-separated name consisting of each containing context name back to the root. It always begins and ends with a slash. For example, the context name for an annotator nested within two AnalysisEngines might look like:/MyTopLevelAnalysisEngine/MyComponentAnalysisEngine/MyAnnotator/.- Specified by:
getQualifiedContextNamein interfaceUimaContextAdmin- Returns:
- the qualified context name
-
getConfigurationGroupNames
public java.lang.String[] getConfigurationGroupNames()
Description copied from interface:UimaContextGets the names of all configuration parameter groups.- Specified by:
getConfigurationGroupNamesin interfaceUimaContext- Returns:
- an array containing the names of all configuration groups that exist for this component. Returns an empty array if no groups are declared.
-
getConfigParameterNames
public java.lang.String[] getConfigParameterNames()
Description copied from interface:UimaContextGets the names of all configuration parameters that are not declared in a group.- Specified by:
getConfigParameterNamesin interfaceUimaContext- Returns:
- an array containing the names of all configuration parameters not declared in any group. Returns an empty array if there are none.
-
getConfigParameterNames
public java.lang.String[] getConfigParameterNames(java.lang.String aGroup)
Description copied from interface:UimaContextGets the names of all configuration parameters in the specified group.- Specified by:
getConfigParameterNamesin interfaceUimaContext- Parameters:
aGroup- the group name- Returns:
- an array containing the names of all configuration parameters declared in
aGroup. Note that this does include parameters with null values. Returns an empty array if there are none (including if the group does not exist).
-
getExternalOverrides
public Settings getExternalOverrides()
(non-Javadoc)- Specified by:
getExternalOverridesin interfaceUimaContext- Specified by:
getExternalOverridesin interfaceUimaContextAdmin- Returns:
- the Settings object
- See Also:
UimaContextAdmin.getExternalOverrides()
-
setExternalOverrides
public void setExternalOverrides(Settings externalOverrides)
(non-Javadoc)- Specified by:
setExternalOverridesin interfaceUimaContextAdmin- Parameters:
externalOverrides- the external overrides settings- See Also:
UimaContextAdmin.setExternalOverrides(org.apache.uima.util.Settings)
-
mapToSofaID
public SofaID mapToSofaID(java.lang.String aSofaName)
Changes here should also be made in UimaContext_ImplBase.mapToSofaID (non-Javadoc)- Specified by:
mapToSofaIDin interfaceUimaContext- Parameters:
aSofaName- this component's name for a SofA- Returns:
- absolute SofA ID
- See Also:
UimaContext.mapToSofaID(java.lang.String)
-
mapSofaIDToComponentSofaName
public java.lang.String mapSofaIDToComponentSofaName(java.lang.String aSofaID)
(non-Javadoc)- Specified by:
mapSofaIDToComponentSofaNamein interfaceUimaContext- Parameters:
aSofaID- absolute SofA ID- Returns:
- this component's name for that SofA
- See Also:
UimaContext.mapSofaIDToComponentSofaName(java.lang.String)
-
getSofaMappings
public SofaID[] getSofaMappings()
(non-Javadoc)- Specified by:
getSofaMappingsin interfaceUimaContext- Returns:
- array of SofaID objects containing mapping of component sofa name to absolute sofa id
- See Also:
UimaContext.getSofaMappings()
-
getSofaMap
public java.util.Map<java.lang.String,java.lang.String> getSofaMap()
Description copied from interface:UimaContextAdminGets an unmodifiable Map containing the mapping of component sofa name to absolute sofa ID.- Specified by:
getSofaMapin interfaceUimaContextAdmin- Returns:
- the Sofa map for this component
-
defineCasPool
public void defineCasPool(int aSize, java.util.Properties aPerformanceTuningSettings, boolean aSofaAware) throws ResourceInitializationExceptionDescription copied from interface:UimaContextAdminDefines the CAS pool that this UimaContext must support. This method must be called beforeUimaContext.getEmptyCas(Class)may be called.- Specified by:
defineCasPoolin interfaceUimaContextAdmin- Parameters:
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).- Throws:
ResourceInitializationException- if a CAS could not be created.
-
returnedCAS
public void returnedCAS(AbstractCas aCAS)
Description copied from interface:UimaContextAdminCalled internally by the framework whenever the AnalysisComponent returns a CAS from its next() method or calls cas.release(). Used to monitor the number of CASes that the AnalysisComponent is using at any one time.- Specified by:
returnedCASin interfaceUimaContextAdmin- Parameters:
aCAS- the CAS that was returned or released- See Also:
UimaContextAdmin.returnedCAS(AbstractCas)
-
getEmptyCas
public <T extends AbstractCas> T getEmptyCas(java.lang.Class<T> aCasInterface)
Description copied from interface:UimaContextGet an empty CAS. This method can only be called from CAS Multipliers, and typically a CAS Multiplier would call this indirectly through itsCasMultiplier_ImplBase.getEmptyCAS()orJCasMultiplier_ImplBase.getEmptyJCas()method.This method may maintain a pool of CASes and may block if none are currently available.
- Specified by:
getEmptyCasin interfaceUimaContext- Type Parameters:
T- the type of the CAS interface (CAS or JCas)- Parameters:
aCasInterface- the specific CAS interface that the component wants to use (e.g. CAS or JCas). Must specify a subtype ofAbstractCas.- Returns:
- an empty CAS. This will be an implementation of
aCasInterface. The CAS will be unlocked (can be reset) but will have switched Class Loaders if needed.
-
getComponentInfo
public ComponentInfo getComponentInfo()
Description copied from interface:UimaContextAdminGets the ComponentInfo object for this component, which can be passed toCAS.setCurrentComponentInfo(ComponentInfo).- Specified by:
getComponentInfoin interfaceUimaContextAdmin- Returns:
- the component info
-
getManagementInterface
public AnalysisEngineManagement getManagementInterface()
Description copied from interface:UimaContextAdminGets an object that can be used to do monitoring or management of this AnalysisEngine.- Specified by:
getManagementInterfacein interfaceUimaContextAdmin- Returns:
- an object exposing a management interface to this AE
-
setLoggingThrottleLimit
public void setLoggingThrottleLimit(java.lang.Integer v)
-
getMdcId
public java.lang.String getMdcId()
-
-