|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.uima.resource.impl.ResourceManager_impl
public class ResourceManager_impl
Reference implementation of ResourceManager
.
Field Summary | |
---|---|
protected static java.lang.String |
LOG_RESOURCE_BUNDLE
resource bundle for log messages |
protected 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. |
protected java.util.Map<java.lang.String,org.apache.uima.resource.impl.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 ArrayList(0:String,1:DataResource) keys to Resource objects. |
protected java.util.Map<java.lang.String,java.lang.Object> |
mResourceMap
Map from qualified key names (declared in resource dependency XML) to Resource objects. |
Constructor Summary | |
---|---|
ResourceManager_impl()
Creates a new ResourceManager_impl . |
|
ResourceManager_impl(java.lang.ClassLoader aClassLoader)
Creates a new ResourceManager_impl with a custom ClassLoader to use for locating
resources. |
Method Summary | |
---|---|
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.lang.ClassLoader |
getExtensionClassLoader()
Returns the UIMA extension class loader. |
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. |
protected RelativePathResolver |
getRelativePathResolver()
|
java.lang.Object |
getResource(java.lang.String aName)
Gets the Resource that has been registered under the specified name. |
java.lang.Object |
getResource(java.lang.String aName,
java.lang.String[] aParams)
Gets an instance of a parameterized Resource. |
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. |
java.lang.Class<? extends Resource> |
getResourceClass(java.lang.String aName)
Gets the Class of the Resource that will be returned by a call to ResourceManager.getResource(String)
or ResourceManager.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. |
void |
resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies,
java.lang.String aQualifiedContextName)
Resolves a component's external resource dependencies 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 |
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)
Sets the classpath for the UIMA extension ClassLoader and specifies if the extension ClassLoader should also be used to resolve resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String LOG_RESOURCE_BUNDLE
protected java.util.Map<java.lang.String,java.lang.Object> mResourceMap
protected java.util.Map<java.lang.String,org.apache.uima.resource.impl.ResourceManager_impl.ResourceRegistration> mInternalResourceRegistrationMap
protected java.util.Map<java.lang.String,java.lang.Class<?>> mParameterizedResourceImplClassMap
protected java.util.Map<java.lang.String,java.lang.Class<?>> mInternalParameterizedResourceImplClassMap
protected java.util.Map<java.util.List<java.lang.Object>,java.lang.Object> mParameterizedResourceInstanceMap
protected CasManager mCasManager
Constructor Detail |
---|
public ResourceManager_impl()
ResourceManager_impl
.
public ResourceManager_impl(java.lang.ClassLoader aClassLoader)
ResourceManager_impl
with a custom ClassLoader to use for locating
resources.
Method Detail |
---|
public void setExtensionClassPath(java.lang.String classpath, boolean resolveResource) throws java.net.MalformedURLException
ResourceManager
setExtensionClassPath
in interface ResourceManager
classpath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources
java.net.MalformedURLException
- if a malformed URL has occurred in the classpath string.ResourceManager.setExtensionClassPath(java.lang.String, boolean)
public void setExtensionClassPath(java.lang.ClassLoader parent, java.lang.String classpath, boolean resolveResource) throws java.net.MalformedURLException
ResourceManager
setExtensionClassPath
in interface ResourceManager
parent
- parent ClassLoader for the extension ClassLoaderclasspath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resources
java.net.MalformedURLException
- if a malformed URL has occurred in the classpath string.ResourceManager.setExtensionClassPath(ClassLoader,java.lang.String,
boolean)
public java.lang.ClassLoader getExtensionClassLoader()
ResourceManager
getExtensionClassLoader
in interface ResourceManager
ResourceManager.getExtensionClassLoader()
public java.lang.String getDataPath()
ResourceManager
path.separator
character (; on windows, : on
UNIX).
getDataPath
in interface ResourceManager
ResourceManager.getDataPath()
public void setDataPath(java.lang.String aPath) throws java.net.MalformedURLException
ResourceManager
path.separator
character (; on windows, : on
UNIX). The elements of this path may be URLs or File paths.
setDataPath
in interface ResourceManager
aPath
- the data path
java.net.MalformedURLException
- if an element of the path is neither a valid URL or a valid file pathResourceManager.setDataPath(String)
public java.net.URL resolveRelativePath(java.lang.String aRelativePath) throws java.net.MalformedURLException
ResourceManager
resolveRelativePath
in interface ResourceManager
aRelativePath
- a relative URL or file path
aRelativePath
is found.
java.net.MalformedURLException
public java.lang.Object getResource(java.lang.String aName) throws ResourceAccessException
ResourceManager
getResource
in interface ResourceManager
aName
- the name of the resource to retrieve
aName
, null
if none
exists.
ResourceAccessException
ResourceManager.getResource(String)
public java.lang.Object getResource(java.lang.String aName, java.lang.String[] aParams) throws ResourceAccessException
ResourceManager
getResource
in interface ResourceManager
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
.
ResourceAccessException
ResourceManager.getResource(java.lang.String, java.lang.String[])
public java.lang.Class<? extends Resource> getResourceClass(java.lang.String aName)
ResourceManager
ResourceManager.getResource(String)
or ResourceManager.getResource(String,String[])
.
getResourceClass
in interface ResourceManager
aName
- the name of a resource
aName
, null
if there is
no resource registered under that name.ResourceManager.getResourceClass(java.lang.String)
public java.io.InputStream getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessException
ResourceManager
getResourceAsStream
in interface ResourceManager
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 resourcepublic java.io.InputStream getResourceAsStream(java.lang.String aKey) throws ResourceAccessException
ResourceManager
getResourceAsStream
in interface ResourceManager
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 resourcepublic java.net.URL getResourceURL(java.lang.String aKey, java.lang.String[] aParams) throws ResourceAccessException
ResourceManager
getResourceURL
in interface ResourceManager
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 resourcepublic java.net.URL getResourceURL(java.lang.String aKey) throws ResourceAccessException
ResourceManager
getResourceURL
in interface ResourceManager
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 resourcepublic void initializeExternalResources(ResourceManagerConfiguration aConfiguration, java.lang.String aQualifiedContextName, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams) throws ResourceInitializationException
ResourceManager
initializeExternalResources
in interface ResourceManager
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 occurspublic void resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies, java.lang.String aQualifiedContextName) throws ResourceInitializationException
ResourceManager
resolveAndValidateResourceDependencies
in interface ResourceManager
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 satisfiedpublic CasManager getCasManager()
ResourceManager
getCasManager
in interface ResourceManager
public void setCasManager(CasManager aCasManager)
ResourceManager
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).
setCasManager
in interface ResourceManager
aCasManager
- CAS Manager instance to plug inprotected RelativePathResolver getRelativePathResolver()
public java.util.Map<java.lang.String,XMLizable> getImportCache()
ResourceManager
getImportCache
in interface ResourceManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |