|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ResourceManager
A ResourceManager
holds a collection of Resource
objects, each registered under a specified key.
Method Summary | |
---|---|
CasManager |
getCasManager()
Gets the CasManager, which manages the creation and pooling of CASes. |
String |
getDataPath()
Gets the data path used to resolve relative paths. |
ClassLoader |
getExtensionClassLoader()
Returns the UIMA extension class loader. |
Map<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. |
Object |
getResource(String aName)
Gets the Resource that has been registered under the specified name. |
Object |
getResource(String aName,
String[] aParams)
Gets an instance of a parameterized Resource. |
InputStream |
getResourceAsStream(String aKey)
Retrieves an InputStream for reading from the named resource. |
InputStream |
getResourceAsStream(String aKey,
String[] aParams)
Retrieves an InputStream for reading from the named resource. |
Class<? extends Resource> |
getResourceClass(String aName)
Gets the Class of the Resource that will be returned by a call to getResource(String)
or getResource(String,String[]) . |
URL |
getResourceURL(String aKey)
Retrieves the URL to the named resource. |
URL |
getResourceURL(String aKey,
String[] aParams)
Retrieves the URL to the named resource. |
void |
initializeExternalResources(ResourceManagerConfiguration aConfiguration,
String aQualifiedContextName,
Map<String,Object> aAdditionalParams)
Initializes all external resources declared in a ResourceCreationSpecifier. |
void |
resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies,
String aQualifiedContextName)
Resolves a component's external resource dependencies using this resource manager. |
URL |
resolveRelativePath(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(String aPath)
Sets the data path used to resolve relative paths. |
void |
setExtensionClassPath(ClassLoader parent,
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(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. |
Method Detail |
---|
String getDataPath()
path.separator
character (; on windows, : on
UNIX).
void setDataPath(String aPath) throws MalformedURLException
path.separator
character (; on windows, : on
UNIX). The elements of this path may be URLs or File paths.
aPath
- the data path
MalformedURLException
- if an element of the path is neither a valid URL or a valid file pathURL resolveRelativePath(String aRelativePath) throws MalformedURLException
aRelativePath
- a relative URL or file path
aRelativePath
is found.
MalformedURLException
Object getResource(String aName) throws ResourceAccessException
aName
- the name of the resource to retrieve
aName
, null
if none
exists.
ResourceInitializationException
- if the requested resource could not be initialized. A common cause is that it
requires parameters and the getResource(String,String[])
method should have
been called instead of this method.
ResourceAccessException
Object getResource(String aName, String[] aParams) throws ResourceAccessException
aName
- the name of the resource to retrieveaParams
- the parameters determining which particular instance is returned
null
if there is no resource registered under
the name aName
.
ResourceInitializationException
- if there is a resource registered under aName
but it could not be
instantiated for the specified parameters.
ResourceAccessException
Class<? extends Resource> getResourceClass(String aName)
getResource(String)
or getResource(String,String[])
.
aName
- the name of a resource
aName
, null
if there is
no resource registered under that name.URL getResourceURL(String aKey) throws ResourceAccessException
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 the data path
or in the class path
using ClassLoader.getResource(String)
.
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 resourceInputStream getResourceAsStream(String aKey) throws ResourceAccessException
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 the data path
or in the class
path using ClassLoader.getResource(String)
.
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 resourceURL getResourceURL(String aKey, String[] aParams) throws ResourceAccessException
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 the data path
or in the class
path using ClassLoader.getResource(String)
.aParams
- parameters used to further identify the resource
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 resourceInputStream getResourceAsStream(String aKey, String[] aParams) throws ResourceAccessException
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 the data path
or in the class
path using ClassLoader.getResource(String)
.aParams
- parameters used to further identify the resource
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 resourcevoid initializeExternalResources(ResourceManagerConfiguration aConfiguration, String aQualifiedContextName, Map<String,Object> aAdditionalParams) throws ResourceInitializationException
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
ResourceInitializationException
- if an initialization failure occursvoid resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies, String aQualifiedContextName) throws ResourceInitializationException
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
ResourceInitializationException
- if a required dependency is not satisfiedvoid setExtensionClassPath(String classpath, boolean resolveResource) throws MalformedURLException
classpath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources
MalformedURLException
- if a malformed URL has occurred in the classpath string.void setExtensionClassPath(ClassLoader parent, String classpath, boolean resolveResource) throws MalformedURLException
parent
- parent ClassLoader for the extension ClassLoaderclasspath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources
MalformedURLException
- if a malformed URL has occurred in the classpath string.ClassLoader getExtensionClassLoader()
CasManager getCasManager()
void setCasManager(CasManager aCasManager)
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 getCasManager()
has already been called
(which happens during AE initialization).
aCasManager
- CAS Manager instance to plug inMap<String,XMLizable> getImportCache()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |