> My current annotators have 
> @ExternalResource(api=ExternalResourceLocator.class).

Your example does not work due to the following issues:

- if you do did not already do so, you must use uimaFIT trunk (1.1.0 will not 
work)
- you must not specify the api parameter otherwise UIMA will barf because your 
field type does not implement the specified API (Number does not implement 
ExternalResourceLocator)
- FooAE must be static if it is an inner class.

Below the modified source code that works for me:

---

        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 static class FooAE extends 
org.uimafit.component.JCasAnnotator_ImplBase {
                static final String RES_INJECTED_POJO = "InjectedPojo";

                @ExternalResource(key = RES_INJECTED_POJO)
                Number pojo;

                @Override
                public void process(JCas aJCas) throws 
AnalysisEngineProcessException {
                        System.out.println(pojo);
                }
        }

---

Cheers,

Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone +49 (6151) 16-7477, fax -5455, room S2/02/E225
[email protected] 
www.ukp.tu-darmstadt.de 
------------------------------------------------------------------- 





Reply via email to