uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <eck...@ukp.informatik.tu-darmstadt.de>
Subject Re: Sessions
Date Mon, 07 Jan 2013 17:28:52 GMT
Am 07.01.2013 um 14:57 schrieb "Kline, Larry D" <Larry.Kline@USONCOLOGY.COM>:

> The reason I want to use a session object to store my properties is that
> the API says these sessions are per client.  My UIMA app is running in a
> JBoss container that is accessed by a web service call.  So multiple
> clients could be accessing it simultaneously, each one passing slightly
> different parameters.  In the web service method I do this:
> 	protected AnalysisEngine recognitionAE;
> 	...
> recognitionAE.getUimaContext().getSession().put(STEMMER_KEY_NAME,
> stemmerAlgorithmKey);
> Then later in my custom flow controller I want to get this property and
> use it to control the flow.
> I'm not familiar with the external resource support.  Can I do something
> similar using that?

The external resource mechanism allows you to share an object between UIMA components. You
tell UIMA how to instantiate this object as part of your analysis engine description (or aggregate
AE description). The object is instantiated once per UIMA root context, so should have the
same scope as the session. I have no idea if external resources can be accessed from a FlowController.

Your concept of "client" and that used in the documentation of the session may be slightly
different. I am pretty sure the session documentation refers to a UIMA deployment which is
distributed on a network. Every node (client) in that network, e.g. every UIMA-AS deployment,
has its own session - they are not in any way synchronized across the network.

In your case, to make sure a session (or external resource below) is not shared between clients
accessing your web application, you need to make sure that your recognitionAE instance is
not shared between web clients - or put it otherwise - it is not thread-safe when you store
data in the session.

I'd probably create a new UIMA type which holds such information and add it to the CAS. That
way, the CAS has some metadata on how it was processed and it can be accessed by the FlowController.
This also restores the thread-safety and if your annotator is programmed in a thread-safe
way, you can instantiate it once and share it between all your clients. Since the instantiation
of an analysis engine can be a costly process, you may want to consider that.


-- Richard

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
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de

View raw message