Package org.apache.uima.resource.impl
Class ResourceManager_impl
- java.lang.Object
-
- org.apache.uima.resource.impl.ResourceManager_impl
-
- All Implemented Interfaces:
ResourceManager
public class ResourceManager_impl extends java.lang.Object implements ResourceManager
Reference implementation ofResourceManager
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ResourceManager_impl.ResourceRegistration
Ties an External Resource instance to - its description -- name -- textual description -- a ResourceSpecifier describing how to create it -- (optional) the String name of the Java class that implements the resource) - its defining UIMA Context These are used to validate multiple declarations, and to get a resource to tie it to a binding
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
casManagerMonitor
a monitor lock for synchronizing get/set of casManager refprotected static java.lang.Class<Resource>
EMPTY_RESOURCE_CLASS
private static java.net.URL[]
emptyURLarray
private static java.util.concurrent.atomic.AtomicInteger
IMPORT_URL_CACHE_WARNING_THROTTLE
private java.util.Map<java.lang.String,XMLizable>
importCache
Cache of imported descriptors, so that parsed objects can be reused if the same URL is imported more than once.private java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
importUrlsCache
Cache of imported descriptor URLs from which the parsed objects in importCache were created, so that these URLs are not re-parsed if the same URL is imported again.private java.util.concurrent.atomic.AtomicBoolean
isDestroyed
protected static java.lang.String
LOG_RESOURCE_BUNDLE
resource bundle for log messagesprotected CasManager
mCasManager
CasManager - manages creation and pooling of CASes.protected java.util.Map<java.lang.String,java.lang.Class<?>>
mInternalParameterizedResourceImplClassMap
Internal map from resource names (declared in resource declaration XML) to Class objects for parameterized Resource.protected java.util.Map<java.lang.String,ResourceManager_impl.ResourceRegistration>
mInternalResourceRegistrationMap
Internal map from resource names (declared in resource declaration XML) to ResourceRegistration objects.protected java.util.Map<java.lang.String,java.lang.Class<?>>
mParameterizedResourceImplClassMap
Map from String keys to Class objects.protected java.util.Map<java.util.List<java.lang.Object>,java.lang.Object>
mParameterizedResourceInstanceMap
Map from ParameterizedResourceKey to SharedResourceObject or DataResource instances.private RelativePathResolver
mRelativePathResolver
Object used for resolving relative paths.protected java.util.Map<java.lang.String,java.lang.Object>
mResourceMap
Map from qualified key names (declared in resource dependency XML) to either DataResource objects or SharedResourceObjects that impl Resource.private UIMAClassLoader
uimaCL
UIMA extension ClassLoader.
-
Constructor Summary
Constructors Constructor Description ResourceManager_impl()
Creates a newResourceManager_impl
.ResourceManager_impl(java.lang.ClassLoader aClassLoader)
Creates a newResourceManager_impl
with a custom ClassLoader to use for locating resources.ResourceManager_impl(java.util.Map<java.lang.String,java.lang.Object> resourceMap, java.util.Map<java.lang.String,ResourceManager_impl.ResourceRegistration> internalResourceRegistrationMap, java.util.Map<java.lang.String,java.lang.Class<?>> parameterizedResourceImplClassMap, java.util.Map<java.lang.String,java.lang.Class<?>> internalParameterizedResourceImplClassMap, java.util.Map<java.util.List<java.lang.Object>,java.lang.Object> parameterizedResourceInstanceMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
checkDestroyed()
ResourceManager_impl
copy()
void
destroy()
Frees all resources held by this ResourceManager, and marks the ResourceManager as having been destroyed.CasManager
getCasManager()
Gets the CasManager, which manages the creation and pooling of CASes.java.lang.String
getDataPath()
Gets the data path used to resolve relative paths.java.util.List<java.lang.String>
getDataPathElements()
Gets the data path elements used to resolve relative paths.java.lang.ClassLoader
getExtensionClassLoader()
Returns the UIMA extension class loader.java.util.List<java.lang.Object>
getExternalResources()
java.util.Map<java.lang.String,XMLizable>
getImportCache()
Gets a cache of imported descriptors, so that the parsed objects can be reused if the same URL is imported more than once.java.util.Map<java.lang.String,java.util.Set<java.lang.String>>
getImportUrlsCache()
Deprecated.No longer used.protected RelativePathResolver
getRelativePathResolver()
java.lang.Object
getResource(java.lang.String aName)
Gets the instance of the implementation object for a resource that has been registered under the specified name.java.lang.Object
getResource(java.lang.String aName, java.lang.String[] aParams)
Returns one of two kinds of objects (or null): - an instance of the implementation object for a resource, that has been loaded with a DataResource resource produced by the resource given the aParms - (if there is no implementation defined for this resource) returns an instance of the DataResource, itself, produced by the resource given the aParms An example of a parameterized Resource is a dictionary whose data depend on a specified language identifier.java.io.InputStream
getResourceAsStream(java.lang.String aKey)
Retrieves an InputStream for reading from the named resource.java.io.InputStream
getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams)
Retrieves an InputStream for reading from the named resource.private java.io.InputStream
getResourceAsStreamCommon(java.lang.Object resource)
private java.net.URL
getResourceAsStreamCommonUrl(java.lang.Object resource)
java.lang.Class<?>
getResourceClass(java.lang.String aName)
Gets the Class of the Resource that will be returned by a call toResourceManager.getResource(String)
orResourceManager.getResource(String,String[])
.java.net.URL
getResourceURL(java.lang.String aKey)
Retrieves the URL to the named resource.java.net.URL
getResourceURL(java.lang.String aKey, java.lang.String[] aParams)
Retrieves the URL to the named resource.void
initializeExternalResources(ResourceManagerConfiguration aConfiguration, java.lang.String aQualifiedContextName, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)
Initializes all external resources declared in a ResourceCreationSpecifier.<N> java.lang.Class<N>
loadUserClass(java.lang.String name)
Loads a user class using either the UIMA extension class loader (if specified) or the ThreadLocal Context Class Loader (if available) or the loader the UIMA framework is running in.static java.lang.Class<?>
loadUserClass(java.lang.String name, ResourceManager rm)
static java.lang.Class<?>
loadUserClassOrThrow(java.lang.String name, ResourceManager rm, ResourceSpecifier aSpecifier)
private void
registerResource(java.lang.String aName, ExternalResourceDescription aResourceDescription, java.lang.String aDefiningContext, java.util.Map<java.lang.String,java.lang.Object> aResourceInitParams)
Instantiates a resource and inserts it in the internal resource map.void
resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies, java.lang.String aQualifiedContextName)
Resolves a component's external resource dependencies (bindings) using this resource manager.java.net.URL
resolveRelativePath(java.lang.String aRelativePath)
Attempts to resolve a relative path to an absolute path using the same mechanism that the ResourceManager uses to find resources -- a lookup in the datapath followed by a lookup in the classpath.void
setCasManager(CasManager aCasManager)
Sets the CasManager, which manages the creation and pooling of CASes.void
setDataPath(java.lang.String aPath)
Sets the data path used to resolve relative paths.void
setDataPathElements(java.io.File... aElements)
Sets the data path elements used to resolve relative paths.void
setDataPathElements(java.lang.String... aElements)
Sets the data path elements used to resolve relative paths.void
setExtensionClassLoaderImpl(java.lang.ClassLoader classLoader, boolean resolveResource)
void
setExtensionClassPath(java.lang.ClassLoader parent, java.lang.String classpath, boolean resolveResource)
Sets the classpath for the UIMA extension ClassLoader and specifies if the extension ClassLoader should also be used to resolve resources.void
setExtensionClassPath(java.lang.String classpath, boolean resolveResource)
/**void
setExtensionClassPath(UIMAClassLoader uimaCL, boolean resolveResource)
Support reusing UIMA Class Loader instances to speed up things including the Component Description Editor when obtaining info from CustomResourceSpecifiers https://issues.apache.org/jira/browse/UIMA-1722-
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.resource.ResourceManager
setExtensionClassLoader
-
-
-
-
Field Detail
-
IMPORT_URL_CACHE_WARNING_THROTTLE
private static final java.util.concurrent.atomic.AtomicInteger IMPORT_URL_CACHE_WARNING_THROTTLE
-
LOG_RESOURCE_BUNDLE
protected static final java.lang.String LOG_RESOURCE_BUNDLE
resource bundle for log messages- See Also:
- Constant Field Values
-
EMPTY_RESOURCE_CLASS
protected static final java.lang.Class<Resource> EMPTY_RESOURCE_CLASS
-
emptyURLarray
private static final java.net.URL[] emptyURLarray
-
isDestroyed
private java.util.concurrent.atomic.AtomicBoolean isDestroyed
-
casManagerMonitor
private final java.lang.Object casManagerMonitor
a monitor lock for synchronizing get/set of casManager ref
-
mRelativePathResolver
private final RelativePathResolver mRelativePathResolver
Object used for resolving relative paths. This is built by parsing the data path.
-
mResourceMap
protected final java.util.Map<java.lang.String,java.lang.Object> mResourceMap
Map from qualified key names (declared in resource dependency XML) to either DataResource objects or SharedResourceObjects that impl Resource. This map is many to one (multiple keys may refer to the same Resource object) Can't be concurrentMap because it (currently) depends on storing nulls Keeping the Map's 2nd argument as Object, although it could be Resource, for backwards compatibility
-
mInternalResourceRegistrationMap
protected final java.util.Map<java.lang.String,ResourceManager_impl.ResourceRegistration> mInternalResourceRegistrationMap
Internal map from resource names (declared in resource declaration XML) to ResourceRegistration objects. Uses: for detecting if multiple declarations are made for the same resource name .values() for list of all resources that have been registered This is a one-to-one map.
-
mParameterizedResourceImplClassMap
protected final java.util.Map<java.lang.String,java.lang.Class<?>> mParameterizedResourceImplClassMap
Map from String keys to Class objects. For ParameterizedResources only, stores the implementation class (not a Resource) corresponding to each resource name. These class objects may or may not be Resource instances. They may be arbitrary classes, except that they must implement SharedResourceObject. This is a many to one map; many keys may refer to the same class key = aQualifiedContextName + the key name in an external resource binding
-
mInternalParameterizedResourceImplClassMap
protected final java.util.Map<java.lang.String,java.lang.Class<?>> mInternalParameterizedResourceImplClassMap
Internal map from resource names (declared in resource declaration XML) to Class objects for parameterized Resource. These class objects may or may not be Resource instances. They may be arbitrary classes, except that they must implement SharedResourceObject. These are "customized" when referenced, by parameter strings (such as language, for a Dictionary resource). Used internally during resource initialization. key = external resource declared name.
-
mParameterizedResourceInstanceMap
protected final java.util.Map<java.util.List<java.lang.Object>,java.lang.Object> mParameterizedResourceInstanceMap
Map from ParameterizedResourceKey to SharedResourceObject or DataResource instances. Note: SharedResourceObjects are not "Resource" instances, but rather arbitrary Java classes that are the "implementations" of Resources. The only requirement on these Java classes is that they implement SharedResourceObject interface. This map is for ParameterizedResources only, and stores the SharedResourceObjects or DataResource objects that have already been instantiated and loaded.
-
uimaCL
private volatile UIMAClassLoader uimaCL
UIMA extension ClassLoader. ClassLoader is created if an extension classpath is specified at the ResourceManager volatile might be better than synch sets/gets
-
mCasManager
protected volatile CasManager mCasManager
CasManager - manages creation and pooling of CASes.
-
importCache
private java.util.Map<java.lang.String,XMLizable> importCache
Cache of imported descriptors, so that parsed objects can be reused if the same URL is imported more than once. All callers of this synchronize on the importCache object before doing a get ... put sequence Use Case where synchronization is needed: running multiple instances on multiple threads, sharing a common resource manager, the initialization that merges typePriorities happens lazily, when using Cas Multipliers, and occurs when the first getCas call happens on a thread. Although these calls are synchronized among themselves, any other use of this map that might occur simultaneously is not.
-
importUrlsCache
private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> importUrlsCache
Cache of imported descriptor URLs from which the parsed objects in importCache were created, so that these URLs are not re-parsed if the same URL is imported again.
-
-
Constructor Detail
-
ResourceManager_impl
public ResourceManager_impl()
Creates a newResourceManager_impl
.
-
ResourceManager_impl
public ResourceManager_impl(java.lang.ClassLoader aClassLoader)
Creates a newResourceManager_impl
with a custom ClassLoader to use for locating resources.- Parameters:
aClassLoader
- -
-
ResourceManager_impl
public ResourceManager_impl(java.util.Map<java.lang.String,java.lang.Object> resourceMap, java.util.Map<java.lang.String,ResourceManager_impl.ResourceRegistration> internalResourceRegistrationMap, java.util.Map<java.lang.String,java.lang.Class<?>> parameterizedResourceImplClassMap, java.util.Map<java.lang.String,java.lang.Class<?>> internalParameterizedResourceImplClassMap, java.util.Map<java.util.List<java.lang.Object>,java.lang.Object> parameterizedResourceInstanceMap)
-
-
Method Detail
-
copy
public ResourceManager_impl copy()
-
setExtensionClassPath
public void setExtensionClassPath(UIMAClassLoader uimaCL, boolean resolveResource)
Support reusing UIMA Class Loader instances to speed up things including the Component Description Editor when obtaining info from CustomResourceSpecifiers https://issues.apache.org/jira/browse/UIMA-1722- Parameters:
uimaCL
- -resolveResource
- -
-
setExtensionClassPath
public void setExtensionClassPath(java.lang.String classpath, boolean resolveResource) throws java.net.MalformedURLException
/**- Specified by:
setExtensionClassPath
in interfaceResourceManager
- Parameters:
classpath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources- Throws:
java.net.MalformedURLException
- if a malformed URL has occurred in the classpath string.- See Also:
ResourceManager.setExtensionClassPath(java.lang.String, boolean)
-
setExtensionClassPath
public void setExtensionClassPath(java.lang.ClassLoader parent, java.lang.String classpath, boolean resolveResource) throws java.net.MalformedURLException
Description copied from interface:ResourceManager
Sets the classpath for the UIMA extension ClassLoader and specifies if the extension ClassLoader should also be used to resolve resources. Also allows a parent ClassLoader to be specified.- Specified by:
setExtensionClassPath
in interfaceResourceManager
- Parameters:
parent
- parent ClassLoader for the extension ClassLoaderclasspath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources- Throws:
java.net.MalformedURLException
- if a malformed URL has occurred in the classpath string.- See Also:
ResourceManager.setExtensionClassPath(ClassLoader,java.lang.String, boolean)
-
setExtensionClassLoaderImpl
public void setExtensionClassLoaderImpl(java.lang.ClassLoader classLoader, boolean resolveResource)
-
getExtensionClassLoader
public java.lang.ClassLoader getExtensionClassLoader()
Description copied from interface:ResourceManager
Returns the UIMA extension class loader.- Specified by:
getExtensionClassLoader
in interfaceResourceManager
- Returns:
- ClassLoader - returns the UIMA extension class loader of null if it is not available.
- See Also:
ResourceManager.getExtensionClassLoader()
-
getDataPath
public java.lang.String getDataPath()
Description copied from interface:ResourceManager
Gets the data path used to resolve relative paths. More than one directory may be specified by separating them with the Systempath.separator
character (; on windows, : on UNIX).- Specified by:
getDataPath
in interfaceResourceManager
- Returns:
- the data path
- See Also:
ResourceManager.getDataPath()
-
getDataPathElements
public java.util.List<java.lang.String> getDataPathElements()
Description copied from interface:ResourceManager
Gets the data path elements used to resolve relative paths.- Specified by:
getDataPathElements
in interfaceResourceManager
- Returns:
- the data path elements
-
setDataPath
public void setDataPath(java.lang.String aPath) throws java.net.MalformedURLException
Description copied from interface:ResourceManager
Sets the data path used to resolve relative paths. More than one directory may be specified by separating them with the Systempath.separator
character (; on windows, : on UNIX). Elements of this path may be absolute or relative file paths.- Specified by:
setDataPath
in interfaceResourceManager
- Parameters:
aPath
- the data path- Throws:
java.net.MalformedURLException
- if an element of the path is neither a valid URL or a valid file path- See Also:
ResourceManager.setDataPath(String)
-
setDataPathElements
public void setDataPathElements(java.lang.String... aElements) throws java.net.MalformedURLException
Description copied from interface:ResourceManager
Sets the data path elements used to resolve relative paths. Elements of this path may be absolute or relative file paths.- Specified by:
setDataPathElements
in interfaceResourceManager
- Parameters:
aElements
- the data path- Throws:
java.net.MalformedURLException
- if an element of the path is neither a valid URL or a valid file path
-
setDataPathElements
public void setDataPathElements(java.io.File... aElements) throws java.net.MalformedURLException
Description copied from interface:ResourceManager
Sets the data path elements used to resolve relative paths. Elements of this path may be absolute or relative file paths.- Specified by:
setDataPathElements
in interfaceResourceManager
- Parameters:
aElements
- the data path- Throws:
java.net.MalformedURLException
- if an element of the path is neither a valid URL or a valid file path
-
resolveRelativePath
public java.net.URL resolveRelativePath(java.lang.String aRelativePath) throws java.net.MalformedURLException
Description copied from interface:ResourceManager
Attempts to resolve a relative path to an absolute path using the same mechanism that the ResourceManager uses to find resources -- a lookup in the datapath followed by a lookup in the classpath.- Specified by:
resolveRelativePath
in interfaceResourceManager
- Parameters:
aRelativePath
- a relative URL or file path- Returns:
- the absolute URL of an actual file in the datapath or classpath, null if no file
matching
aRelativePath
is found. - Throws:
java.net.MalformedURLException
- if the path cannot be converted to a URL
-
checkDestroyed
private void checkDestroyed()
-
getResource
public java.lang.Object getResource(java.lang.String aName) throws ResourceAccessException
Description copied from interface:ResourceManager
Gets the instance of the implementation object for a resource that has been registered under the specified name.- Specified by:
getResource
in interfaceResourceManager
- Parameters:
aName
- the name of the resource to retrieve- Returns:
- the instance of the implementation object for the resource, registered under
aName
,null
if none exists. - Throws:
ResourceAccessException
- if the requested resource could not be initialized. A common cause is that it requires parameters and theResourceManager.getResource(String,String[])
method should have been called instead of this method.- See Also:
ResourceManager.getResource(String)
-
getResource
public java.lang.Object getResource(java.lang.String aName, java.lang.String[] aParams) throws ResourceAccessException
Description copied from interface:ResourceManager
Returns one of two kinds of objects (or null): - an instance of the implementation object for a resource, that has been loaded with a DataResource resource produced by the resource given the aParms - (if there is no implementation defined for this resource) returns an instance of the DataResource, itself, produced by the resource given the aParms An example of a parameterized Resource is a dictionary whose data depend on a specified language identifier. If the implementation object class exists, but no instance has been created (yet) for the particular data resource corresponding to the parameters, then this method will create and register a new instance and call its load() api using the data resource corresponding to the parameters, and return that.- Specified by:
getResource
in interfaceResourceManager
- Parameters:
aName
- the name of the parameterized resource to retrieveaParams
- the parameters determining which particular instance is returned and specifying a particular DataResource instance to use in initializing the implementation of the resource (if there is an implementation). If there is no implementation, the DataResource instance produced from the named Resource given these parameters is returned instead.- Returns:
- one of two kinds of objects (or null): an instance of the requested implementation of
the named resource where that instance has been initialized by calling its load method
with the DataResource instance produced from the Resource given aParams,
or, (if the named resource has no implementation) the DataResource instance
corresponding to the named Resource, given aParams,
or if no resource with this name exists,
null
. - Throws:
ResourceAccessException
- if there is a resource registered underaName
but it could not be instantiated for the specified parameters.- See Also:
ResourceManager.getResource(java.lang.String, java.lang.String[])
-
getResourceClass
public java.lang.Class<?> getResourceClass(java.lang.String aName)
Description copied from interface:ResourceManager
Gets the Class of the Resource that will be returned by a call toResourceManager.getResource(String)
orResourceManager.getResource(String,String[])
. For those resource specifications which include an implementation class, this call returns that class.- Specified by:
getResourceClass
in interfaceResourceManager
- Parameters:
aName
- the name of a resource- Returns:
- the Class for the resource named
aName
,null
if there is no resource registered under that name. - See Also:
ResourceManager.getResourceClass(java.lang.String)
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessException
Description copied from interface:ResourceManager
Retrieves an InputStream for reading from the named resource. This can be used, for example, to read configuration or authority files. 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.- Specified by:
getResourceAsStream
in interfaceResourceManager
- Parameters:
aKey
- the key by which the resource is identified. If this key was declared in the <externalResourceDependencies> section of the annotator's descriptor, then the resource manager is used to locate the resource. If not, the key is assumed to be the resource name and is looked up in thedata path
or in the class path usingClassLoader.getResource(String)
.aParams
- parameters used to further identify the resource- Returns:
- an
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. - Throws:
ResourceAccessException
- if a failure occurs in accessing the resource
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey) throws ResourceAccessException
Description copied from interface:ResourceManager
Retrieves an InputStream for reading from the named resource. This can be used, for example, to read configuration or authority files.- Specified by:
getResourceAsStream
in interfaceResourceManager
- Parameters:
aKey
- the key by which the resource is identified. If this key was declared in the <externalResourceDependencies> section of the annotator's descriptor, then the resource manager is used to locate the resource. If not, the key is assumed to be the resource name and is looked up in thedata path
or in the class path usingClassLoader.getResource(String)
.- Returns:
- an
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. - Throws:
ResourceAccessException
- if a failure occurs in accessing the resource
-
getResourceAsStreamCommon
private java.io.InputStream getResourceAsStreamCommon(java.lang.Object resource) throws ResourceAccessException
- Throws:
ResourceAccessException
-
getResourceAsStreamCommonUrl
private java.net.URL getResourceAsStreamCommonUrl(java.lang.Object resource)
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessException
Description copied from interface:ResourceManager
Retrieves the URL to the named resource. This can be used, for example, to locate configuration or authority files. 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.- Specified by:
getResourceURL
in interfaceResourceManager
- Parameters:
aKey
- the key by which the resource is identified. If this key was declared in the <externalResourceDependencies> section of the annotator's descriptor, then the resource manager is used to locate the resource. If not, the key is assumed to be the resource name and is looked up in thedata path
or in the class path usingClassLoader.getResource(String)
.aParams
- parameters used to further identify the resource- Returns:
- the
URL
at which the named resource is located,null
if the named resource could not be found. - Throws:
ResourceAccessException
- if a failure occurs in accessing the resource
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey) throws ResourceAccessException
Description copied from interface:ResourceManager
Retrieves the URL to the named resource. This can be used, for example, to locate configuration or authority files.- Specified by:
getResourceURL
in interfaceResourceManager
- Parameters:
aKey
- the key by which the resource is identified. If this key was declared in the <externalResourceDependencies> section of the descriptor, then the resource manager is used to locate the resource. If not, the key is assumed to be the resource name and is looked up in thedata path
or in the class path usingClassLoader.getResource(String)
.- Returns:
- the
URL
at which the named resource is located,null
if the named resource could not be found. - Throws:
ResourceAccessException
- if a failure occurs in accessing the resource
-
initializeExternalResources
public void initializeExternalResources(ResourceManagerConfiguration aConfiguration, java.lang.String aQualifiedContextName, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams) throws ResourceInitializationException
Description copied from interface:ResourceManager
Initializes all external resources declared in a ResourceCreationSpecifier. Multi-threading: may be called on multiple threads. Initialization should be done once, on the first call External resources have a Container class representing the resource, which are instances of Resource. This may act as the implementation class, or they may also have a separately specified implementation class, which may or may not implement Resource. As part of the initialization of the Container class, by default, External Resource Bindings are processed to hook them up with defined External Resources, using the default implementation of resolveAndValidateResourceDependencies.- Specified by:
initializeExternalResources
in interfaceResourceManager
- Parameters:
aConfiguration
- the ResourceManagerConfiguration containing resource declarations and bindingsaQualifiedContextName
- qualified name of UimaContext for the component (e.g. analysis engine) that is declaring these external resourcesaAdditionalParams
- additional parameters to be passed to resource initialize methods- Throws:
ResourceInitializationException
- if an initialization failure occurs
-
resolveAndValidateResourceDependencies
public void resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies, java.lang.String aQualifiedContextName) throws ResourceInitializationException
Description copied from interface:ResourceManager
Resolves a component's external resource dependencies (bindings) using this resource manager. The default implementation has special defaulting logic: If a binding specifies a non-existing resource, an attempt is made to interpret the key as a file name, looked up using the current context for relative path resolution. - If successfully found, a FileResourceSpecifier is created using the file and used as the implementing class. If no resource can be found at all, then unless the dependency is marked "optional", an ResourceInitializationException is thrown. Multi-threading: may be called on multiple threads, repeatedly for the same set of resources. Implementations should recognize this and skip repeated resolutions.- Specified by:
resolveAndValidateResourceDependencies
in interfaceResourceManager
- Parameters:
aDependencies
- declarations of a component's dependencies on external resourcesaQualifiedContextName
- qualified name of UimaContext for the component (e.g. analysis engine) that is declaring these dependencies- Throws:
ResourceInitializationException
- if a required dependency is not satisfied
-
registerResource
private void registerResource(java.lang.String aName, ExternalResourceDescription aResourceDescription, java.lang.String aDefiningContext, java.util.Map<java.lang.String,java.lang.Object> aResourceInitParams) throws ResourceInitializationException
Instantiates a resource and inserts it in the internal resource map.- Throws:
ResourceInitializationException
-
getCasManager
public CasManager getCasManager()
Description copied from interface:ResourceManager
Gets the CasManager, which manages the creation and pooling of CASes.- Specified by:
getCasManager
in interfaceResourceManager
- Returns:
- the CasManager
-
setCasManager
public void setCasManager(CasManager aCasManager)
Description copied from interface:ResourceManager
Sets the CasManager, which manages the creation and pooling of CASes. This method does not normally need to be called by an application. It allows a custom CAS Manager implementation to be substituted for the default one, which may be useful when embedding UIMA in other middleware where a different CAS Manager implementation may be desired.This method can only be called once, and must be called before creating any AnalysisEngines that use this ResourceManager. An Exception will be thrown if this method is called twice or is called after
ResourceManager.getCasManager()
has already been called (which happens during AE initialization).- Specified by:
setCasManager
in interfaceResourceManager
- Parameters:
aCasManager
- CAS Manager instance to plug in
-
getRelativePathResolver
protected RelativePathResolver getRelativePathResolver()
-
getImportCache
public java.util.Map<java.lang.String,XMLizable> getImportCache()
Description copied from interface:ResourceManager
Gets a cache of imported descriptors, so that the parsed objects can be reused if the same URL is imported more than once.- Specified by:
getImportCache
in interfaceResourceManager
- Returns:
- A map from absolute URL to the XMLizable object that was parsed from that URL
-
getImportUrlsCache
@Deprecated public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getImportUrlsCache()
Deprecated.No longer used. Scheduled for removal in UIMA 4.0.Was used during import resolving until UIMA 3.2.0. Is no longer used since since import resolving has been migrated to theorg.apache.uima.resource.metadata.impl.ImportResolver
.
-
loadUserClass
public <N> java.lang.Class<N> loadUserClass(java.lang.String name) throws java.lang.ClassNotFoundException
Description copied from interface:ResourceManager
Loads a user class using either the UIMA extension class loader (if specified) or the ThreadLocal Context Class Loader (if available) or the loader the UIMA framework is running in. If the class is not found in the ThreadLocal COntext Class Loader, then the loader the UIMA framework is running in will be searched.- Specified by:
loadUserClass
in interfaceResourceManager
- Type Parameters:
N
- generic class of class- Parameters:
name
- the class to load- Returns:
- the class
- Throws:
java.lang.ClassNotFoundException
- -
-
loadUserClass
public static java.lang.Class<?> loadUserClass(java.lang.String name, ResourceManager rm) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
loadUserClassOrThrow
public static java.lang.Class<?> loadUserClassOrThrow(java.lang.String name, ResourceManager rm, ResourceSpecifier aSpecifier) throws ResourceInitializationException
- Throws:
ResourceInitializationException
-
destroy
public void destroy()
Description copied from interface:ResourceManager
Frees all resources held by this ResourceManager, and marks the ResourceManager as having been destroyed. A destroyed ResourceManager will throw an exception if an attempt is made to continue using it. Resources managed by a ResourceManager include all of the external shared Resources. If there is an extension class loader in use, it will be closed. Any class loaders (including PEAR class loaders) that might use this as a parent will be affected by this closure. Any streams opened using getResourceAsStream will also be closed. The Resources managed by this manager will have their destroy() methods called, as part of the execution of this API. The framework does not call this method; it is up to the containing application to decide if and when a ResourceManager instance should be destroyed. This is because the containing application is the only knowledgeable source; for example a single ResourceManager might be used for multiple UIMA Pipelines.- Specified by:
destroy
in interfaceResourceManager
-
getExternalResources
public java.util.List<java.lang.Object> getExternalResources()
- Specified by:
getExternalResources
in interfaceResourceManager
- Returns:
- a List of External Shared Resource instances instantiated by this Resource Manager. For parameterized resources, those which have been asked for (having unique parameter sets) are included.
-
-