You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Stéphane MOR <st...@yahoo.fr> on 2002/03/20 20:38:04 UTC

Turbine 2.1 - Services - Instantiation - Singleton

Hello,

I am trying to move my code from a "classic" Screen
+ Action model to a Service + Pull Tool, but I have a
problem which I can't solve.

I try to have a service run as a singleton, so that it
wouldn't be reinitialized after each request, but I can't.

I will post a fake example as the real one would be way
too long to explain here, but it reflects what I need :

Say that I want to keep a track of a fruit basket, so I have:
- FruitsTool which is referenced in my templates as $fruits
- FruitsService (and TurbineFruitService) which has addFruit(Fruit) ,
countFruits() and eatFruit(Fruit).

I add this to TR.props :
services.FruitService.classname =
my.company.modules.services.TurbineFruitsService
tool.global.fruits = my.company.modules.services.FruitsTool .

Now when I use this in my templates (for instance
$fruits.addFruit($anotherFruit) ), the service will initialize
on each request, so that when I use :
$fruits.countFruits() it won't return all the fruits that i added
to the basket along the templates.

I tried and use TurbineGlobalCacheService as a model
with no success, so if you could please help me, it would
be nice !

Thanks,
Stephane


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>