uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spico Florin <spicoflo...@gmail.com>
Subject Re: Dependency injection support in UIMA
Date Tue, 20 Nov 2012 15:58:56 GMT
Hello!
  Thank you for your response Richard.  As far as I know (please correct me
if I'm wrong) the scale out is referring to create many instances of the
same analyzing engine that will process CASes. The Analyzing engine should
be also remote AE.
 Can you please provide more details why adding how the objects created
with Spring affect the scale-out capability?

Regards,
  Florin



On Tue, Nov 20, 2012 at 5:07 PM, Richard Eckart de Castilho <
eckart@ukp.informatik.tu-darmstadt.de> wrote:

> Hello Florin,
>
> first of all, UIMA does not support injections of pre-existing instances.
> You are not supposed to access any object instances that are not created
> within the context of UIMA. If you can live with the consequences of doing
> this (i.e. no UIMA supported scale-out), you can have a look at the
> following possibilities that I have implemented as proof-of-concept in
> uimaFIT:
>
>
>
> == SimpleNamedResourceManager ==
>
> The uimaFIT SimpleNamedResourceManager takes a key-value map of names and
> instances. When you create your analysis instance with this resource
> manager, you can fetch the instances via the UIMA external resource
> mechanism. Example:
>
>
>  // Create a custom resource manager that allows to inject any Java object
> as an external
>  // dependency
>  final Map<String, Object> externalContext = new HashMap<String, Object>();
>  externalContext.put("pojoName2", new AtomicInteger(5));
>
>  // Create resource manager
>  SimpleNamedResourceManager resMgr = new SimpleNamedResourceManager();
>  resMgr.setExternalContext(externalContext);
>
>  // Instantiate component
>  AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(desc, resMgr,
> null);
>
> More test code is here:
>
>
> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT/src/test/java/org/uimafit/factory/ExternalResourceFactoryTest.java
>
>
>
> == SpringContextResourceManager ==
>
> The uimaFIT SpringContextResourceManager makes all Spring beans from a
> given Spring application context available via the UIMA external resource
> mechanism. Example:
>
>  // Acquire application context
>  ApplicationContext ctx = getApplicationContext();
>
>  // Create resource manager
>  SpringContextResourceManager resMgr = new SpringContextResourceManager();
>  resMgr.setApplicationContext(ctx);
>
>  // Instantiate component
>  AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(desc, resMgr,
> null);
>
> See also:
>
>
> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/SpringContextResourceManagerTest.java
>
>
>
> == UIMA Factory Patching ==
>
> This is an invasive mechanism that patches the UIMA framework at runtime
> so that every UIMA component that is created is post-processed by a Spring
> application context. This means, UIMA components can directly use any
> annotations supported by Spring (e.g. @PersistenceContext, …). Only one
> application context is supported per JVM because the UIMA framework is
> (unfortunately) internally statically configured. This should work, but I
> didn't really test it yet beyond the proof-of-concept unit test.
>
> Example code:
>
>
> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/UimaFactoryInjectionTest.java
>
> Cheers,
>
> -- Richard
>
> Am 20.11.2012 um 14:22 schrieb Spico Florin <spicoflorin@gmail.com>:
>
> > Hello!
> >   I have a connection to data source (triplestore) that is used by
> > multiple annotators. With the current implementation of UIMA I have to
> > provide this connection in for all these annotators descriptors, making
> the
> > deployment very tedious when switching from one environment to another
> (for
> > example test env to production env).
> > I have read the  posts from
> > http://comments.gmane.org/gmane.comp.apache.uima.general/3340 but still
> is
> > not clear for me how to handle the DI. Basically I would like to inject
> > this connection to all of annotators that need it from a single
> > configuration file, thus eliminating the mentioned inconvenience.
> >  Can you please provide what is the best approach for handling this kind
> > of problems?
> >
> > I look forward for your answers.
> >
> > Regards,
> >  Florin
> >
> > P.S. I was thinking to use Spring and ApplicationContext and its
> > configuration file. Is this a suitable solution?
>
>
> --
> -------------------------------------------------------------------
> Richard Eckart de Castilho
> Technical Lead
> Ubiquitous Knowledge Processing Lab (UKP-TUD)
> FB 20 Computer Science Department
> Technische Universität Darmstadt
> Hochschulstr. 10, D-64289 Darmstadt, Germany
> phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
> eckart@ukp.informatik.tu-darmstadt.de
> www.ukp.tu-darmstadt.de
> Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
> -------------------------------------------------------------------
>
>
>
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message