Package org.apache.uima.util
Class SimpleResourceFactory
- java.lang.Object
-
- org.apache.uima.util.SimpleResourceFactory
-
- All Implemented Interfaces:
ResourceFactory
public class SimpleResourceFactory extends Object implements ResourceFactory
A simple implementation of aResourceFactory
. This implementation maintains a Map between theResourceSpecifier
sub-interface name (e.g.AnalysisEngineDescription
) and the class name of the resource to be constructed from specifiers of that type.UIMA developers who introduce new types of
Resource
s orResourceSpecifier
s may create an instance of this class and use theaddMapping(Class,Class)
method to register a mapping between the ResourceSpecifier interface and the Class of the Resource that is to be constructed from it. TheSimpleResourceFactory
should then be registered with the framework by callingUIMAFramework.getResourceFactory()
.registerFactory(Class,ResourceFactory)
;
-
-
Constructor Summary
Constructors Constructor Description SimpleResourceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(Class<? extends ResourceSpecifier> aSpecifierInterface, Class<? extends Resource> aResourceClass)
Configures thisSimpleResourceFactory
by adding a new mapping between aResourceSpecifier
class and aResource
class.void
addMapping(String aSpecifierInterfaceName, String aResourceClassName)
Configures thisSimpleResourceFactory
by adding a new mapping between aResourceSpecifier
class and aResource
class.Resource
produceResource(Class<? extends Resource> aResourceClass, ResourceSpecifier aSpecifier, Map<String,Object> aAdditionalParams)
Produces an appropriateResource
instance from aResourceSpecifier
.
-
-
-
Method Detail
-
produceResource
public Resource produceResource(Class<? extends Resource> aResourceClass, ResourceSpecifier aSpecifier, Map<String,Object> aAdditionalParams) throws ResourceInitializationException
Produces an appropriateResource
instance from aResourceSpecifier
.- Specified by:
produceResource
in interfaceResourceFactory
- Parameters:
aResourceClass
- the interface of the resource to be produced. This is intended to be a standard UIMA interface such asTextAnalysisEngine
orASB
.aSpecifier
- an object that specifies how to acquire an instance of aResource
.aAdditionalParams
- a Map containing additional parameters to pass to theResource.initialize(ResourceSpecifier,Map)
method. May benull
if there are no parameters.- Returns:
- a
Resource
instance. Returnsnull
if this factory does not know how to create a Resource from theResourceSpecifier
provided. - Throws:
ResourceInitializationException
- if a failure occurred during production of the resource- See Also:
ResourceFactory.produceResource(Class, ResourceSpecifier,Map)
-
addMapping
public void addMapping(Class<? extends ResourceSpecifier> aSpecifierInterface, Class<? extends Resource> aResourceClass)
Configures thisSimpleResourceFactory
by adding a new mapping between aResourceSpecifier
class and aResource
class.- Parameters:
aSpecifierInterface
- the subinterface ofResourceSpecifier
.aResourceClass
- a subclass ofResource
that is to be instantiated from resource specifiers of the given class.
-
addMapping
public void addMapping(String aSpecifierInterfaceName, String aResourceClassName) throws ClassNotFoundException
Configures thisSimpleResourceFactory
by adding a new mapping between aResourceSpecifier
class and aResource
class.- Parameters:
aSpecifierInterfaceName
- name of the subinterface ofResourceSpecifier
.aResourceClassName
- the name of a subclass ofResource
that is to be instantiated from resource specifiers of the given class.- Throws:
ClassNotFoundException
- -
-
-