Simple {@link ResourceManager} allowing for direct injection of Java objects into UIMA componentsas external resources.
This implementation uses a simple map to look up an Java object by key. If any component using this resource manager declares an external resource by the given key, the Java object will be bound to that external resource.
Example:
Per default it is necessary to explicitly bind a objects from the external context to external resource keys used by the UIMA component:class MyComponent extends JCasAnnotator_ImplBase { static final String RES_INJECTED_POJO = "InjectedPojo"; {@code @ExternalResource(key = RES_INJECTED_POJO)}private String injectedString; public void process(JCas aJCas) throws AnalysisEngineProcessException { ... } }
With autowireing enabled, an explicit binding is not necessary:Map<String, Object> context = new HashMap<String, Object>(); context("myString", "Just an injected POJO"); SimpleNamedResourceManager resMgr = new SimpleNamedResourceManager(); resMgr.setExternalContext(externalContext); AnalysisEngineDescription desc = createPrimitiveDescription(MyComponent.class); bindExternalResource(desc, MyComponent.RES_INJECTED_POJO, "myString"); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(desc, resMgr, null);
Map<String, Object> context = new HashMap<String, Object>(); context(MyComponent.RES_INJECTED_POJO, "Just an injected POJO"); SimpleNamedResourceManager resMgr = new SimpleNamedResourceManager(); resMgr.setAutoWireEnabled(true); resMgr.setExternalContext(externalContext); AnalysisEngineDescription desc = createPrimitiveDescription(MyComponent.class); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(desc, resMgr, null);
|
|
|
|
|
|
|
|