public class ResourceManager_impl extends Object implements ResourceManager
ResourceManager
.Modifier and Type | Class and Description |
---|---|
protected static class |
ResourceManager_impl.ResourceRegistration |
Modifier and Type | Field and Description |
---|---|
protected static String |
LOG_RESOURCE_BUNDLE
resource bundle for log messages
|
protected CasManager |
mCasManager
CasManager - manages creation and pooling of CASes.
|
protected Map<String,Class<?>> |
mInternalParameterizedResourceImplClassMap
Internal map from resource names (declared in resource declaration XML) to Class objects.
|
protected Map<String,ResourceManager_impl.ResourceRegistration> |
mInternalResourceRegistrationMap
Internal map from resource names (declared in resource declaration XML) to ResourceRegistration
objects.
|
protected Map<String,Class<?>> |
mParameterizedResourceImplClassMap
Map from String keys to Class objects.
|
protected Map<List<Object>,Object> |
mParameterizedResourceInstanceMap
Map from ArrayList(0:String,1:DataResource) keys to Resource objects.
|
protected Map<String,Object> |
mResourceMap
Map from qualified key names (declared in resource dependency XML) to Resource objects.
|
Constructor and Description |
---|
ResourceManager_impl()
Creates a new
ResourceManager_impl . |
ResourceManager_impl(ClassLoader aClassLoader)
Creates a new
ResourceManager_impl with a custom ClassLoader to use for locating
resources. |
Modifier and Type | Method and Description |
---|---|
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.
|
protected RelativePathResolver |
getRelativePathResolver() |
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
ResourceManager.getResource(String)
or ResourceManager.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)
/**
|
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
|
protected static final String LOG_RESOURCE_BUNDLE
protected Map<String,Object> mResourceMap
protected Map<String,ResourceManager_impl.ResourceRegistration> mInternalResourceRegistrationMap
protected Map<String,Class<?>> mParameterizedResourceImplClassMap
protected Map<String,Class<?>> mInternalParameterizedResourceImplClassMap
protected Map<List<Object>,Object> mParameterizedResourceInstanceMap
protected CasManager mCasManager
public ResourceManager_impl()
ResourceManager_impl
.public ResourceManager_impl(ClassLoader aClassLoader)
ResourceManager_impl
with a custom ClassLoader to use for locating
resources.public void setExtensionClassPath(UIMAClassLoader uimaCL, boolean resolveResource)
uimaCL
- resolveResource
- public void setExtensionClassPath(String classpath, boolean resolveResource) throws MalformedURLException
setExtensionClassPath
in interface ResourceManager
classpath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resourcesMalformedURLException
- if a malformed URL has occurred in the classpath string.ResourceManager.setExtensionClassPath(java.lang.String, boolean)
public void setExtensionClassPath(ClassLoader parent, String classpath, boolean resolveResource) throws MalformedURLException
ResourceManager
setExtensionClassPath
in interface ResourceManager
parent
- parent ClassLoader for the extension ClassLoaderclasspath
- extension ClassLoader classpathresolveResource
- if true ClassLoad resolves resourcesMalformedURLException
- if a malformed URL has occurred in the classpath string.ResourceManager.setExtensionClassPath(ClassLoader,java.lang.String,
boolean)
public ClassLoader getExtensionClassLoader()
ResourceManager
getExtensionClassLoader
in interface ResourceManager
ResourceManager.getExtensionClassLoader()
public String getDataPath()
ResourceManager
path.separator
character (; on windows, : on
UNIX).getDataPath
in interface ResourceManager
ResourceManager.getDataPath()
public void setDataPath(String aPath) throws 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 pathMalformedURLException
- if an element of the path is neither a valid URL or a valid file pathResourceManager.setDataPath(String)
public URL resolveRelativePath(String aRelativePath) throws MalformedURLException
ResourceManager
resolveRelativePath
in interface ResourceManager
aRelativePath
- a relative URL or file pathaRelativePath
is found.MalformedURLException
- if the path cannot be converted to a URLpublic Object getResource(String aName) throws ResourceAccessException
ResourceManager
getResource
in interface ResourceManager
aName
- the name of the resource to retrieveaName
, null
if none
exists.ResourceAccessException
- if the requested resource could not be initialized. A common cause is that it
requires parameters and the ResourceManager.getResource(String,String[])
method should have
been called instead of this method.ResourceManager.getResource(String)
public Object getResource(String aName, String[] aParams) throws ResourceAccessException
ResourceManager
getResource
in interface ResourceManager
aName
- the name of the resource to retrieveaParams
- the parameters determining which particular instance is returnednull
if there is no resource registered under
the name aName
.ResourceAccessException
- if there is a resource registered under aName
but it could not be
instantiated for the specified parameters.ResourceManager.getResource(java.lang.String, java.lang.String[])
public Class<? extends Resource> getResourceClass(String aName)
ResourceManager
ResourceManager.getResource(String)
or ResourceManager.getResource(String,String[])
.getResourceClass
in interface ResourceManager
aName
- the name of a resourceaName
, null
if there is
no resource registered under that name.ResourceManager.getResourceClass(java.lang.String)
public InputStream getResourceAsStream(String aKey, 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 resourceInputStream
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 InputStream getResourceAsStream(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 URL getResourceURL(String aKey, 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 resourceURL
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 URL getResourceURL(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, String aQualifiedContextName, Map<String,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 methodsResourceInitializationException
- if an initialization failure occurspublic void resolveAndValidateResourceDependencies(ExternalResourceDependency[] aDependencies, 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 dependenciesResourceInitializationException
- 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 Map<String,XMLizable> getImportCache()
ResourceManager
getImportCache
in interface ResourceManager
Copyright © 2006–2014 The Apache Software Foundation. All rights reserved.