Richard Eckart de Castilho <eckartde@...> writes:
>
>
> > I've been playing with your example, and it seems to break my existing code
>
> Could you explain how it broke your code? I was thinking of an approach
similar to yours first,
> but when I looked into the UIMA sources, I figured that an extra
ExternalResourceLocator would
> not be necessary and then I could exploit standard UIMA initialization logic
by slightly changing
> the ResourceManager.
>
> Richard
>
My current annotators have @ExternalResource(api=ExternalResourceLocator.class).
So the following example breaks:
-- start --
public static void main(String[] args) throws Exception {
Map<String, Object> context = new HashMap<String, Object>();
context.put("key", 1);
SimpleNamedResourceManager rm = new SimpleNamedResourceManager();
rm.setAutoWireEnabled(true);
rm.setExternalContext(context);
AnalysisEngineDescription aed = createPrimitiveDescription(FooAE.class);
bindExternalResource(aed, FooAE.RES_INJECTED_POJO, "key");
AnalysisEngine ae = produceAnalysisEngine(aed, rm, null);
ae.process(ae.newJCas());
}
public class FooAE extends org.uimafit.component.JCasAnnotator_ImplBase {
static final String RES_INJECTED_POJO = "InjectedPojo";
@ExternalResource(
key = RES_INJECTED_POJO,
api = ExternalResourceLocator.class)
Number pojo;
public void process(JCas aJCas) throws AnalysisEngineProcessException {}
}
-- end --
This occurs because in the SVN version of
ExternalResourceInitializer#getApi(...), you force the api to be Object.class if
it happens to be on the default of Resource.class.
For other types (E.G. ExternalResourceLocator.class), it breaks because the api
is checked in ResourceManager_impl.