Package org.apache.uima.util
Class SimpleResourceFactory
- java.lang.Object
-
- org.apache.uima.util.SimpleResourceFactory
-
- All Implemented Interfaces:
ResourceFactory
public class SimpleResourceFactory extends java.lang.Object implements ResourceFactory
A simple implementation of aResourceFactory. This implementation maintains a Map between theResourceSpecifiersub-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
Resources orResourceSpecifiers 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. TheSimpleResourceFactoryshould then be registered with the framework by callingUIMAFramework.getResourceFactory().registerFactory(Class,ResourceFactory);
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Class<SimpleResourceFactory>CLASS_NAMEcurrent classprivate static java.lang.StringLOG_RESOURCE_BUNDLEresource bundle for log messagesprotected java.util.Map<java.lang.Class<? extends ResourceSpecifier>,java.util.List<java.lang.Class<? extends Resource>>>mClassMapMap from ResourceSpecifier Class to List of Resource Classes.
-
Constructor Summary
Constructors Constructor Description SimpleResourceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapping(java.lang.Class<? extends ResourceSpecifier> aSpecifierInterface, java.lang.Class<? extends Resource> aResourceClass)Configures thisSimpleResourceFactoryby adding a new mapping between aResourceSpecifierclass and aResourceclass.voidaddMapping(java.lang.String aSpecifierInterfaceName, java.lang.String aResourceClassName)Configures thisSimpleResourceFactoryby adding a new mapping between aResourceSpecifierclass and aResourceclass.ResourceproduceResource(java.lang.Class<? extends Resource> aResourceClass, ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams)Produces an appropriateResourceinstance from aResourceSpecifier.
-
-
-
Field Detail
-
LOG_RESOURCE_BUNDLE
private static final java.lang.String LOG_RESOURCE_BUNDLE
resource bundle for log messages- See Also:
- Constant Field Values
-
CLASS_NAME
private static final java.lang.Class<SimpleResourceFactory> CLASS_NAME
current class
-
mClassMap
protected java.util.Map<java.lang.Class<? extends ResourceSpecifier>,java.util.List<java.lang.Class<? extends Resource>>> mClassMap
Map from ResourceSpecifier Class to List of Resource Classes. Resource initialization is attempted in reverse order through this List, so more recently registered classes are tried first.
-
-
Method Detail
-
produceResource
public Resource produceResource(java.lang.Class<? extends Resource> aResourceClass, ResourceSpecifier aSpecifier, java.util.Map<java.lang.String,java.lang.Object> aAdditionalParams) throws ResourceInitializationException
Produces an appropriateResourceinstance from aResourceSpecifier.- Specified by:
produceResourcein interfaceResourceFactory- Parameters:
aResourceClass- the interface of the resource to be produced. This is intended to be a standard UIMA interface such asTextAnalysisEngineorASB.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 benullif there are no parameters.- Returns:
- a
Resourceinstance. Returnsnullif this factory does not know how to create a Resource from theResourceSpecifierprovided. - Throws:
ResourceInitializationException- if a failure occurred during production of the resource- See Also:
ResourceFactory.produceResource(Class, ResourceSpecifier,Map)
-
addMapping
public void addMapping(java.lang.Class<? extends ResourceSpecifier> aSpecifierInterface, java.lang.Class<? extends Resource> aResourceClass)
Configures thisSimpleResourceFactoryby adding a new mapping between aResourceSpecifierclass and aResourceclass.- Parameters:
aSpecifierInterface- the subinterface ofResourceSpecifier.aResourceClass- a subclass ofResourcethat is to be instantiated from resource specifiers of the given class.
-
addMapping
public void addMapping(java.lang.String aSpecifierInterfaceName, java.lang.String aResourceClassName) throws java.lang.ClassNotFoundExceptionConfigures thisSimpleResourceFactoryby adding a new mapping between aResourceSpecifierclass and aResourceclass.- Parameters:
aSpecifierInterfaceName- name of the subinterface ofResourceSpecifier.aResourceClassName- the name of a subclass ofResourcethat is to be instantiated from resource specifiers of the given class.- Throws:
java.lang.ClassNotFoundException- -
-
-