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 |
bindResource(ExternalResourceDescription aRes,
String aBindTo,
ExternalResourceDescription aNestedRes)
|
static void |
bindResource(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
ExternalResourceDescription aRes)
|
static void |
bindResource(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
String aRes)
|
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<? 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,
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,
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)
Deprecated.
|
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 |
bindResourceOnce(ExternalResourceDescription aRes,
String aBindTo,
ExternalResourceDescription aNestedRes)
Create a binding for the given external resource in the given resource.
|
static void |
bindResourceOnce(ResourceCreationSpecifier aDesc,
String aBindTo,
ExternalResourceDescription aRes)
Create a binding for the given external resource in the resource manager configuration of the
given resource.
|
static void |
bindResourceOnce(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
ExternalResourceDescription aRes)
Create a binding for the given external resource in the given resource manager.
|
static void |
bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc,
String aBindTo,
String aRes)
Create a binding for the given external resource in resource manager configuration of the given
resource creation specified.
|
static void |
bindResourceOnceWithoutNested(ResourceManagerConfiguration aResMgrCfg,
String aBindTo,
String aRes)
Create a binding for the given external resource in the given resource manager configuration.
|
static void |
bindResourceUsingUrl(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 |
bindResourceUsingUrl(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 |
bindResourceUsingUrl(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 |
bindResourceUsingUrl(ResourceSpecifier aDesc,
String aKey,
String aUrl)
Scan the given resource specifier for external resource dependencies and whenever a dependency
is encountered 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(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 void |
createDependencyAndBindUsingUrl(AnalysisEngineDescription aDesc,
String aKey,
Class<? extends SharedResourceObject> aImpl,
String aUrl,
Object... aParams)
Create a new dependency for the specified resource and bind it.
|
static ExternalResourceDescription |
createNamedFileResourceDescription(String aName,
String aUrl)
Create an external resource description for a file addressable via an URL.
|
static ExternalResourceDescription |
createNamedResourceDescription(String aName,
Class<? extends Resource> aInterface,
Object... aParams)
Create an external resource description for a custom resource.
|
static ExternalResourceDescription |
createNamedResourceDescriptionUsingUrl(String aName,
Class<? extends SharedResourceObject> aInterface,
String aUrl,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static <R extends Resource> |
createResource(Class<R> resourceClass,
Object... params)
Create an instance of a UIMA shared/external resource class.
|
static <R extends Resource> |
createResource(Class<R> resourceClass,
ResourceManager resMgr,
Object... params)
Create an instance of a UIMA shared/external resource class.
|
static ExternalResourceBinding |
createResourceBinding(String aKey,
ExternalResourceDescription aResource)
Create an external resource binding.
|
static ExternalResourceBinding |
createResourceBinding(String aKey,
String aResourceKey)
Create an external resource binding.
|
static ExternalResourceDependency[] |
createResourceDependencies(Class<?> cls) |
static ExternalResourceDependency |
createResourceDependency(Field field)
Creates an
ExternalResourceDependency for a field annotated with
ExternalResource . |
static ExternalResourceDependency |
createResourceDependency(String aKey,
Class<?> aInterface,
boolean aOptional,
String aDescription)
Creates an ExternalResourceDependency for a given key and interface.
|
static ExternalResourceDescription |
createResourceDescription(Class<? extends Resource> aInterface,
Object... aParams)
Create an external resource description for a custom resource.
|
static ExternalResourceDescription |
createSharedResourceDescription(File aFile,
Class<? extends SharedResourceObject> aInterface,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createSharedResourceDescription(String aUrl,
Class<? extends SharedResourceObject> aInterface,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
static ExternalResourceDescription |
createSharedResourceDescription(URL aUrl,
Class<? extends SharedResourceObject> aInterface,
Object... aParams)
Create an external resource description for a
SharedResourceObject . |
protected static Map<String,ExternalResourceDescription> |
extractResourceParameters(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
.field
- the field to analyzepublic static ExternalResourceDescription createResourceDescription(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 createNamedResourceDescription(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 createSharedResourceDescription(String aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams)
SharedResourceObject
.aUrl
- the URL from which the resource is initialized.aInterface
- the interface the resource should implement.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createSharedResourceDescription(URL aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams)
SharedResourceObject
.aUrl
- the URL from which the resource is initialized.aInterface
- the interface the resource should implement.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createSharedResourceDescription(File aFile, Class<? extends SharedResourceObject> aInterface, Object... aParams)
SharedResourceObject
.aFile
- the file from which the resource is initialized.aInterface
- the interface the resource should implement.aParams
- parameters passed to the resource when it is created.ConfigurableDataResourceSpecifier
,
SharedResourceObject
public static ExternalResourceDescription createNamedResourceDescriptionUsingUrl(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 createNamedFileResourceDescription(String aName, String aUrl)
aName
- the name of the resource (the key).aUrl
- a URL.FileResourceSpecifier
public static ExternalResourceBinding createResourceBinding(String aKey, ExternalResourceDescription aResource)
aKey
- the key to bind to.aResource
- the resource to bind.public static ExternalResourceBinding createResourceBinding(String aKey, String aResourceKey)
ExternalResourceBinding
than calling
ResourceSpecifierFactory.createExternalResourceBinding()
and setting the resource name
and key manually.aKey
- the key to bind to.aResourceKey
- the resource key to bind.public static ExternalResourceDependency createResourceDependency(Field field)
ExternalResourceDependency
for a field annotated with
ExternalResource
.field
- the field to analyzepublic static ExternalResourceDependency createResourceDependency(String aKey, Class<?> aInterface, boolean aOptional, String aDescription)
ExternalResourceDependency
than calling
ResourceSpecifierFactory.createExternalResourceDependency()
and setting the fields
manually.aKey
- the resource keyaInterface
- the resource interfaceaOptional
- determines whether the dependency is optionalaDescription
- a description of the resourcepublic static ExternalResourceDependency[] createResourceDependencies(Class<?> cls) throws ResourceInitializationException
cls
- the class to analyzeResourceInitializationException
- if the external resource dependencies could not be createdpublic 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
- if import resolution failedFileResourceSpecifier
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
- if import resolution failedFileResourceSpecifier
@Deprecated public static void bindResource(ResourceSpecifier aDesc, String aKey, String aUrl) throws InvalidXMLException
bindResourceUsingUrl(ResourceSpecifier, String, String)
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
- if import resolution failedFileResourceSpecifier
public static void bindResourceUsingUrl(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
- if import resolution failedFileResourceSpecifier
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
- if import resolution failedClassNotFoundException
- if the resource implementation class or interface class could not be accessedCustomResourceSpecifier
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
- if import resolution failedClassNotFoundException
- if the resource implementation class or interface class could not be accessedCustomResourceSpecifier
public static void bindResourceUsingUrl(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
- if import resolution failedClassNotFoundException
- if the resource implementation class or interface class could not be accessedSharedResourceObject
public static void bindResourceUsingUrl(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
- if import resolution failedSharedResourceObject
public static void bindResourceUsingUrl(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
- if import resolution failedSharedResourceObject
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
- if import resolution failedCustomResourceSpecifier
public static void bindResource(ResourceSpecifier aDesc, ExternalResourceDescription aResDesc) throws InvalidXMLException, ClassNotFoundException
aDesc
- a description.aResDesc
- the resource description.InvalidXMLException
- if import resolution failedClassNotFoundException
- if the resource implementation class or interface class could not be accessedpublic 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
- if import resolution failedpublic 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
- if import resolution failedpublic 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.aApi
- the resource interfaceaParams
- additional parameters supported by the resource.InvalidXMLException
- if import resolution failedpublic 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 createDependencyAndBindUsingUrl(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
- if import resolution failed@Deprecated public static void bindResource(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 bindResourceOnce(ResourceManagerConfiguration aResMgrCfg, String aBindTo, ExternalResourceDescription aRes)
NOTE:If you use this method on resource manager configurations of aggregate analysis
engine descriptions because it will not have any effects on the delegate analysis
engines of the aggregate. If you want to recursively bind an external resource to the
delegates in an aggregate engine, use e.g.
bindResource(ResourceSpecifier, String, ExternalResourceDescription)
.
aResMgrCfg
- the resource manager to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.@Deprecated public static void bindResource(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 bindResourceOnce(ExternalResourceDescription aRes, String aBindTo, ExternalResourceDescription aNestedRes)
NOTE: This method only works on ExtendedExternalResourceDescription_impl
instances. Any ExternalResourceDescription
instances created with uimaFIT use this
implementation. For reasons of convenience, the method signature uses
ExternalResourceDescription
but will thrown an IllegalArgumentException
if the
wrong implementations are provided.
aRes
- the resource to bind toaBindTo
- what key to bind to.aNestedRes
- the resource that should be bound.IllegalArgumentException
- if the given resource description is not an instance of
ExtendedExternalResourceDescription_impl
.public static void bindResourceOnce(ResourceCreationSpecifier aDesc, String aBindTo, ExternalResourceDescription aRes)
NOTE:IF you use this method with aggregate analysis engine descriptions because it will
not have any effects on the delegate analysis engines of the aggregate. If you want to
recursively bind an external resource to the delegates in an aggregate engine, use e.g.
bindResource(ResourceSpecifier, String, ExternalResourceDescription)
.
aDesc
- the specifier to create the binding in.aBindTo
- what key to bind to.aRes
- the resource that should be bound.@Deprecated public static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo, String aRes)
bindResourceOnce(ResourceCreationSpecifier, String, ExternalResourceDescription)
if
you wish to bind nested resources as well.
NOTE:If you use this method on resource manager configurations of aggregate analysis
engine descriptions because it will not have any effects on the delegate analysis
engines of the aggregate. If you want to recursively bind an external resource to the
delegates in an aggregate engine, use e.g.
bindResource(ResourceSpecifier, String, ExternalResourceDescription)
.
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 bindResourceOnceWithoutNested(ResourceManagerConfiguration aResMgrCfg, String aBindTo, String aRes)
bindResourceOnce(ResourceCreationSpecifier, String, ExternalResourceDescription)
if
you wish to bind nested resources as well.
NOTE:If you use this method on resource manager configurations of aggregate analysis
engine descriptions because it will not have any effects on the delegate analysis
engines of the aggregate. If you want to recursively bind an external resource to the
delegates in an aggregate engine, use e.g.
bindResource(ResourceSpecifier, String, ExternalResourceDescription)
.
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 bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc, String aBindTo, String aRes)
bindResourceOnce(ResourceCreationSpecifier, String, ExternalResourceDescription)
if
you wish to bind nested resources as well.
NOTE:If you use this method on an aggregate analysis engine description, it will not
have any effects on the delegate analysis engines of the aggregate. If you want to
recursively bind an external resource to the delegates in an aggregate engine, use e.g.
bindResource(ResourceSpecifier, String, ExternalResourceDescription)
.
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> extractResourceParameters(Object[] configurationData)
configurationData
- the configuration parameters.public static <R extends Resource> R createResource(Class<R> resourceClass, Object... params) throws ResourceInitializationException
R
- the resource type.resourceClass
- the class implementing the resource.params
- parameters passed to the resource when it is created. Each parameter consists of two
arguments, the first being the name and the second being the parameter valueResourceInitializationException
- if there was a problem instantiating the resource.public static <R extends Resource> R createResource(Class<R> resourceClass, ResourceManager resMgr, Object... params) throws ResourceInitializationException
R
- the resource type.resourceClass
- the class implementing the resource.resMgr
- a resource manager (optional).params
- parameters passed to the resource when it is created. Each parameter consists of two
arguments, the first being the name and the second being the parameter valueResourceInitializationException
- if there was a problem instantiating the resource.Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.