public final class ExternalResourceFactory extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_RESOURCE_NAME |
static String |
PREFIX_SEPARATOR
Used to separate resource name from key for nested resource.
|
Modifier and Type | Method and Description |
---|---|
static void |
bindExternalResource(ExternalResourceDescription aRes,
String aBindTo,
ExternalResourceDescription aNestedRes)
Create a new external resource binding.
|
static void |
bindExternalResource(ResourceCreationSpecifier aDesc,
String aBindTo,
ExternalResourceDescription aRes)
Create a new external resource binding.
|
static void |
bindExternalResource(ResourceCreationSpecifier aDesc,
String aBindTo,
String aRes)
Create a new external resource binding.
|
static void |
bindExternalResource(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
ExternalResourceDescription aRes)
Create a new external resource binding.
|
static void |
bindExternalResource(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
String aRes)
Create a new external resource binding.
|
static void |
bindResource(ResourceSpecifier aDesc,
Class<?> aApi,
Class<? extends Resource> aRes,
String... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with a compatible type is found, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
Class<?> aApi,
Class<? extends SharedResourceObject> aRes,
String aUrl,
Object... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
is encountered that has a key equal to the API class name, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
Class<? extends Resource> aRes,
String... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with a compatible type is found, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
Class<? extends SharedResourceObject> aRes,
String aUrl,
Object... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with a compatible type is found, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
ExternalResourceDescription aResDesc)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with a compatible type is found, the given resource is bound to it.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
Class<? extends Resource> aRes,
String... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with the given key is encountered, the given resource is bound to it.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
Class<? extends SharedResourceObject> aRes,
String aUrl,
Object... aParams)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with the given key is encountered the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
ExternalResourceDescription aResDesc)
Scan the given resource specifier for external resource dependencies and whenever a dependency
with the given key is encountered, the given resource is bound to it.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
File aFile)
Scan the given resource specifier for external resource dependencies and whenever a dependency
is encounter that has the specified key, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
String aUrl)
Scan the given resource specifier for external resource dependencies and whenever a dependency
is encounter that has the specified key, the resource will be bound.
|
static void |
bindResource(ResourceSpecifier aDesc,
String aKey,
URL aUrl)
Scan the given resource specifier for external resource dependencies and whenever a dependency
is encounter that has the specified key, the resource will be bound.
|
static void |
createDependency(ResourceSpecifier aDesc,
String aKey,
Class<?> aApi)
Create a new dependency for the specified resource and bind it.
|
static void |
createDependencyAndBind(AnalysisEngineDescription aDesc,
String aKey,
Class<? extends SharedResourceObject> aImpl,
String aUrl,
Object... aParams)
Create a new dependency for the specified resource and bind it.
|
static void |
createDependencyAndBind(ResourceSpecifier aDesc,
String aKey,
Class<? extends Resource> aImpl,
Class<?> aApi,
String... aParams)
Create a new dependency for the specified resource and bind it.
|
static void |
createDependencyAndBind(ResourceSpecifier aDesc,
String aKey,
Class<? extends Resource> aImpl,
String... aParams)
Create a new dependency for the specified resource and bind it.
|
static ExternalResourceBinding |
createExternalResourceBinding(String aKey,
ExternalResourceDescription aResource)
Create an external resource binding.
|
static ExternalResourceBinding |
createExternalResourceBinding(String aKey,
String aResourceKey)
Create an external resource binding.
|
static ExternalResourceDependency[] |
createExternalResourceDependencies(Class<?> cls) |
static ExternalResourceDependency |
createExternalResourceDependency(Field field)
Creates an ExternalResourceDependency for a field annotated with
ExternalResource . |
static ExternalResourceDependency |
createExternalResourceDependency(String aKey,
Class<?> aInterface,
boolean aOptional,
String aDescription)
Creates an ExternalResourceDependency for a given key and interface
|
static ExternalResourceDescription |
createExternalResourceDescription(Class<? extends Resource> aInterface,
Object... aParams)
Create an external resource description for a custom resource.
|
static ExternalResourceDescription |
createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface,
File aFile,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface,
String aUrl,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface,
URL aUrl,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createExternalResourceDescription(String aName,
Class<? extends Resource> aInterface,
Object... aParams)
Create an external resource description for a custom resource.
|
static ExternalResourceDescription |
createExternalResourceDescription(String aName,
Class<? extends SharedResourceObject> aInterface,
String aUrl,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createExternalResourceDescription(String aName,
String aUrl)
Create an external resource description for a file addressable via an URL.
|
protected static Map<String,ExternalResourceDescription> |
extractExternalResourceParameters(Object[] configurationData)
Extracts the external resource from the configuration parameters and nulls out these
parameters.
|
protected static String |
getImplementationName(ExternalResourceDescription aDesc)
Find the name of the class implementing this resource.
|
static boolean |
isExternalResourceField(Field field)
This method determines if the field is annotated with
ExternalResource . |
public static final String PARAM_RESOURCE_NAME
public static final String PREFIX_SEPARATOR
public static boolean isExternalResourceField(Field field)
ExternalResource
.public static ExternalResourceDescription createExternalResourceDescription(Class<? extends Resource> aInterface, Object... aParams)
aInterface
- the interface the resource should implement.aParams
- parameters passed to the resource when it is created.CustomResourceSpecifier
public static ExternalResourceDescription createExternalResourceDescription(String aName, Class<? extends Resource> aInterface, Object... aParams)
aName
- the name of the resource (the key).aInterface
- the interface the resource should implement.aParams
- parameters passed to the resource when it is created.CustomResourceSpecifier
public static ExternalResourceDescription createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams)
SharedResourceObject
.aInterface
- the interface the resource should implement.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface, URL aUrl, Object... aParams)
SharedResourceObject
.aInterface
- the interface the resource should implement.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createExternalResourceDescription(Class<? extends SharedResourceObject> aInterface, File aFile, Object... aParams)
SharedResourceObject
.aInterface
- the interface the resource should implement.aFile
- the file from which the resource is initialized.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createExternalResourceDescription(String aName, Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams)
SharedResourceObject
.aName
- the name of the resource (the key).aInterface
- the interface the resource should implement.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createExternalResourceDescription(String aName, String aUrl)
aName
- the name of the resource (the key).aUrl
- a URL.FileResourceSpecifier
public static ExternalResourceBinding createExternalResourceBinding(String aKey, ExternalResourceDescription aResource)
aKey
- the key to bind to.aResource
- the resource to bind.public static ExternalResourceBinding createExternalResourceBinding(String aKey, String aResourceKey)
aKey
- the key to bind to.aResourceKey
- the resource key to bind.public static ExternalResourceDependency createExternalResourceDependency(Field field)
ExternalResource
.public static ExternalResourceDependency createExternalResourceDependency(String aKey, Class<?> aInterface, boolean aOptional, String aDescription)
aOptional
- determines whether the dependency is optionalpublic static ExternalResourceDependency[] createExternalResourceDependencies(Class<?> cls) throws ResourceInitializationException
ResourceInitializationException
public static void bindResource(ResourceSpecifier aDesc, String aKey, URL aUrl) throws InvalidXMLException
Caveat: If you use this method, you may expect that DataResource.getUrl()
or
DataResource.getUri()
will return the same URL that you have specified here. This may
NOT be the case. UIMA will internally try to resolve the URL via a
ResourceManager
. If it cannot resolve a remove URL, this mechanism will think it may be
a local file and will return some local path - or it may redirect it to some location as though
fit by the ResourceManager
.
aDesc
- a description.aKey
- the key to bind to.aUrl
- a URL.InvalidXMLException
FileResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, String aKey, File aFile) throws InvalidXMLException
Caveat: If you use this method, you may expect that DataResource.getUrl()
or
DataResource.getUri()
will return the URL of the file that you have specified here.
This may NOT be the case. UIMA will internally try to resolve the URL via a
ResourceManager
. If it cannot resolve a remove URL, this mechanism will think it may be
a local file and will return some local path - or it may redirect it to some location as though
fit by the ResourceManager
.
aDesc
- a description.aKey
- the key to bind to.aFile
- a file.InvalidXMLException
FileResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, String aKey, String aUrl) throws InvalidXMLException
Caveat: If you use this method, you may expect that DataResource.getUrl()
or
DataResource.getUri()
will return the same URL that you have specified here. This is
may NOT be the case. UIMA will internally try to resolve the URL via a
ResourceManager
. If it cannot resolve a remove URL, this mechanism will think it may be
a local file and will return some local path - or it may redirect it to some location as though
fit by the ResourceManager
.
aDesc
- a description.aKey
- the key to bind to.aUrl
- a URL.InvalidXMLException
FileResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException, ClassNotFoundException
aDesc
- a description.aRes
- the resource to bind.aParams
- parameters passed to the resource when it is created.InvalidXMLException
ClassNotFoundException
CustomResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, Class<?> aApi, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException, ClassNotFoundException
aDesc
- a description.aApi
- the resource interface.aRes
- the resource to bind.aParams
- parameters passed to the resource when it is created.InvalidXMLException
ClassNotFoundException
CustomResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams) throws InvalidXMLException, ClassNotFoundException
aDesc
- a description.aRes
- the resource to bind.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.InvalidXMLException
ClassNotFoundException
SharedResourceObject
public static void bindResource(ResourceSpecifier aDesc, Class<?> aApi, Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams) throws InvalidXMLException
aDesc
- a description.aApi
- the resource interface.aRes
- the resource to bind.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.InvalidXMLException
SharedResourceObject
public static void bindResource(ResourceSpecifier aDesc, String aKey, Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams) throws InvalidXMLException
aDesc
- a description.aKey
- the key to bind to.aRes
- the resource to bind.aUrl
- the URL from which the resource is initialized.aParams
- parameters passed to the resource when it is created.InvalidXMLException
SharedResourceObject
public static void bindResource(ResourceSpecifier aDesc, String aKey, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException
aDesc
- a description.aKey
- the key to bind to.aRes
- the resource to bind.aParams
- parameters passed to the resource when it is created.InvalidXMLException
CustomResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, ExternalResourceDescription aResDesc) throws InvalidXMLException, ClassNotFoundException
aDesc
- a description.aResDesc
- the resource description.InvalidXMLException
ClassNotFoundException
public static void bindResource(ResourceSpecifier aDesc, String aKey, ExternalResourceDescription aResDesc) throws InvalidXMLException
aDesc
- a description.aKey
- the key to bind to.aResDesc
- the resource description.InvalidXMLException
public static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey, Class<? extends Resource> aImpl, String... aParams) throws InvalidXMLException
ExternalResource
annotation, because no external
resource dependencies can be automatically generated by uimaFIT for such components.aDesc
- a description.aKey
- the key to bind to.aImpl
- the resource implementation.aParams
- additional parameters supported by the resource.InvalidXMLException
public static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey, Class<? extends Resource> aImpl, Class<?> aApi, String... aParams) throws InvalidXMLException
ExternalResource
annotation, because no external
resource dependencies can be automatically generated by uimaFIT for such components.aDesc
- a description.aKey
- the key to bind to.aImpl
- the resource implementation.aParams
- additional parameters supported by the resource.InvalidXMLException
public static void createDependency(ResourceSpecifier aDesc, String aKey, Class<?> aApi)
ExternalResource
annotation, because no external
resource dependencies can be automatically generated by uimaFIT for such components.aDesc
- a description.aKey
- the key to bind to.aApi
- the resource API.public static void createDependencyAndBind(AnalysisEngineDescription aDesc, String aKey, Class<? extends SharedResourceObject> aImpl, String aUrl, Object... aParams) throws InvalidXMLException
ExternalResource
annotation, because no external
resource dependencies can be automatically generated by uimaFIT for such components.aDesc
- a description.aKey
- the key to bind to.aImpl
- the resource implementation.aUrl
- the resource URL.aParams
- additional parameters supported by the resource.InvalidXMLException
public static void bindExternalResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo, ExternalResourceDescription aRes)
aResMgrCfg
- the resource manager to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.public static void bindExternalResource(ExternalResourceDescription aRes, String aBindTo, ExternalResourceDescription aNestedRes)
aRes
- the resource to bind toaBindTo
- what key to bind to.aNestedRes
- the resource that should be bound.public static void bindExternalResource(ResourceCreationSpecifier aDesc, String aBindTo, ExternalResourceDescription aRes)
aDesc
- the specifier to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.public static void bindExternalResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo, String aRes)
aResMgrCfg
- the resource manager to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.public static void bindExternalResource(ResourceCreationSpecifier aDesc, String aBindTo, String aRes)
aDesc
- the specifier to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.protected static String getImplementationName(ExternalResourceDescription aDesc)
SharedResourceObject
or implements
Resource
.aDesc
- the external resource description.protected static Map<String,ExternalResourceDescription> extractExternalResourceParameters(Object[] configurationData)
configurationData
- the configuration parameters.Copyright © 2012–2013 The Apache Software Foundation. All rights reserved.