cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Upayavira>
Subject Re: App level variable in flow
Date Tue, 06 Jan 2004 09:22:04 GMT
Stefan Klein wrote:

>>How do I store a java object in some application context or an 
>>application level variable, just once during servlet container startup,
>>when I'm writing an app that uses flow?
>Could you not write it as I component, include it in cocoon.roles so that
>it'll be loaded automatically at startup and access it in flow via
Yes, but flow is supposed to be lightweight, and doing that is a lot of 
work to do, and I'd like to avoid, if poss, any changes to the Cocoon 
webapp (otherwise, installing on new machines is hassle).

Jeremy suggested (on the dev list)  instantiating the object in the 
opening lines (outside methods) in flowscript:

if (cocoon.context.myObject == null) {
  cocoon.context.myObject = new Packages.mypackage.MyObject();

Then, the first time a flow is accessed after servlet startup, my object 
is created. From then on, it is available in memory.

That should be good enough for me, and it is only 2 1/2 lines of code, 
which is the kind of thing I had in mind!!

Reinhard also suggested using Context listeners that can be configured 
using web.xml, although I haven't looked into that approach.

Regards, Upayavira

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message