Hi
I have to load a set of files as external resources in uima. The annotator
reads a file containing the list of files to load in the engine as shared
resource. Since the number of files may change, I cannot bind them in the
descriptor.
To accomplish this I used the following snippet of code. However it throws
an exception of invalid class cast.
ExternalResourceDescription extDesc = ExternalResourceFactory.
createExternalResourceDescription(key,MyResource_impl.class,
fileName);
Map<String, Object> initParams = new HashMap<String, Object>() ;
MyResource file =
(MyResource_impl)UIMAFramework.produceResource(extDep..getResourceSpecifier(),
initParams);
Now the error is as follows :
Caused by: java.lang.ClassCastException:
org.apache.uima.resource.impl.ConfigurableDataResource_impl cannot be cast
to org.my.project.resource.MyResource_impl
I tried an alternate approach too wherein I declared
ExternalResourceDependency but I do not know how to create an external
resource object using this dependency. The code is as follows
ExternalResourceDependency extDep =
UIMAFramework.getResourceSpecifierFactory().createExternalResourceDependency();
extDep.setDescription("file for "+key);
extDep.setInterfaceName(MyResource_impl.class.toString());
extDep.setKey(key+"File");
extDep.setOptional(false);
extDep.setSourceUrl(new URL(fileName));
Thanks
Manisha