Package org.apache.uima.resource
Class Resource_ImplBase
- java.lang.Object
-
- org.apache.uima.resource.Resource_ImplBase
-
- All Implemented Interfaces:
Resource
- Direct Known Subclasses:
ASB_impl,ConfigurableDataResource_impl,ConfigurableResource_ImplBase,DataResource_impl,FileLanguageResource_impl,ProcessingContainer,ResourceCreationSpecifier_impl.DummyResource,ResourceServiceAdapter
public abstract class Resource_ImplBase extends java.lang.Object implements Resource
Implementation base class forResources. Provides access to resource metadata and the UIMA Context, which in turn provides access to framework facilities such as logging and resource management.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanmInitializedWhether this Resource'sinitialize(ResourceSpecifier,Map)method has been called.private ResourceMetaDatamMetaDataMetadata for this Resource.private UimaContextAdminmUimaContextAdminAdmin interface to the UIMA Context-
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 Resource_ImplBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Releases all resources held by thisResource.CasManagergetCasManager()Get the CasManager for this Resource.LoggergetLogger()Get the logger for this UIMA framework class.ResourceMetaDatagetMetaData()Gets the metadata that describes thisResource.RelativePathResolvergetRelativePathResolver(java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)ResourceManagergetResourceManager()Gets theResourceManagerthat this Resource uses to locate other Resources.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.java.lang.Class<?>loadUserClass(java.lang.String name)java.lang.Class<?>loadUserClassOrThrow(java.lang.String name, ResourceSpecifier aSpecifier)UimaContextsetContextHolder()voidsetContextHolderX(Runnable_withException userCode)voidsetLogger(Logger aLogger)Set the logger in the current UimaContext for use by user annotators.protected voidsetMetaData(ResourceMetaData aMetaData)Sets theResourceMetaDataobject associated with thisResource.voidwithContextHolder(java.lang.Runnable userCode)
-
-
-
Field Detail
-
mMetaData
private ResourceMetaData mMetaData
Metadata for this Resource.
-
mUimaContextAdmin
private UimaContextAdmin mUimaContextAdmin
Admin interface to the UIMA Context
-
mInitialized
private boolean mInitialized
Whether this Resource'sinitialize(ResourceSpecifier,Map)method has been called.
-
-
Method Detail
-
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 interfaceResource- 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
-
destroy
public void destroy()
Description copied from interface:ResourceReleases all resources held by thisResource.- Specified by:
destroyin interfaceResource- See Also:
Resource.destroy()
-
getMetaData
public ResourceMetaData getMetaData()
Description copied from interface:ResourceGets the metadata that describes thisResource.- Specified by:
getMetaDatain interfaceResource- Returns:
- an object containing all metadata for this resource.
- See Also:
Resource.getMetaData()
-
setMetaData
protected void setMetaData(ResourceMetaData aMetaData)
Sets 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
getMetaData()are made.- Parameters:
aMetaData- metadata to assign to thisResource
-
getLogger
public Logger getLogger()
Get the logger for this UIMA framework class. Note that this is NOT the user's logger in the UimaContext
-
setLogger
public void setLogger(Logger aLogger)
Set the logger in the current UimaContext for use by user annotators.
-
getResourceManager
public ResourceManager getResourceManager()
Description copied from interface:ResourceGets theResourceManagerthat this Resource uses to locate other Resources.- Specified by:
getResourceManagerin interfaceResource- Returns:
- the ResourceManager
- See Also:
Resource.getResourceManager()
-
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- Returns:
- the UimaContext for use by this Resource
-
getUimaContextAdmin
public UimaContextAdmin getUimaContextAdmin()
Gets the Admin interface to this Resource's UimaContext.- Specified by:
getUimaContextAdminin interfaceResource- Returns:
- the administrative interface to this Resource's UimaContext
-
getCasManager
public CasManager getCasManager()
Get the CasManager for this Resource. The CasManager manages the creation and pooling of CASes.- Returns:
- the CasManager
-
loadUserClass
public java.lang.Class<?> loadUserClass(java.lang.String name) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
loadUserClassOrThrow
public java.lang.Class<?> loadUserClassOrThrow(java.lang.String name, ResourceSpecifier aSpecifier) throws ResourceInitializationException- Throws:
ResourceInitializationException
-
getRelativePathResolver
public RelativePathResolver getRelativePathResolver(java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)
-
withContextHolder
public void withContextHolder(java.lang.Runnable userCode)
-
setContextHolderX
public void setContextHolderX(Runnable_withException userCode) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setContextHolder
public UimaContext setContextHolder()
-
-