As Tom mentioned, Cans are meant to be used for this purpose, but they
may be overkill if you are just trying to save a little state. A quick
and easy solution is to just add your data to Application. However,
you'll need to watch out for threading issues if you do that. More than
one instance of your Servlet could be trying to change or use that data
at the same time.
I guess what I'm saying is there isn't a perfect solution right now.
Before 1.0, we will be adding ZODB as the way to do this safely. This
will have the benefit of working for a single AppServer or for a Load
Balanced setup, and it will be transparent to you.
For now, I would probably write a Can that has some threadsafety built
into it.
Jay
Tom Schwaller wrote:
> Albert Brandl wrote:
>
>> Hi!
>>
>> It would sometimes be useful to have objects that exist only
>> once per application. I'd e.g. like to have a factory object
>> that returns objects with unique id numbers. Of course, this
>> could be implemented using a database, but for prototyping
>> purposes that's an overkill.
>
>
>
> I was sure you where going to ask that, because
> you Controller objectzs sometime need to
> stay there between requests :-)
>
>
>> I've seen that Application allows to add "cans". Can they be
>> used to implement factory objects? Could someone explain the
>> concept - maybe with an example?
>
>
>
> Take a look at
>
> PSPTests.psp TrackingExample.psp
>
> in the PSS/Examples directory
>
> and in WebKit/Cans. There you will probably find your answers.
> Maybe one should make yet another exaple in the WebKit/Examples
> directory....
>
|