Tapestry services lifecycle

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Tapestry services lifecycle

Christopher
Hi all, just a quick question...

Once a Tapestry service implementation gets instantiated, and that
service's status moves to "realised", at what point does that
implementation get destroyed?

Tapestry instantiates a service implementation the first time a service
method gets called, and I'm just wondering whether the reverse is also
true - eg. released for garbage collection if no method has been called
after a period of time.

In some cases it's needed for a service to retain state, such as keeping
a 'static final' map of connected users.  This is thread safe, but would
be lost without a single service implementation instance.

Regards,

Chris.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away." - Antoine de Saint-Exupéry.
Reply | Threaded
Open this post in threaded view
|

Re: Tapestry services lifecycle

Thiago H de Paula Figueiredo
On Tue, Sep 15, 2020 at 7:50 PM Christopher Dodunski (Tapestry) <
[hidden email]> wrote:

> Hi all, just a quick question...
>

Hello!


> Once a Tapestry service implementation gets instantiated, and that
> service's status moves to "realised", at what point does that
> implementation get destroyed?
>

Only when Tapestry-IoC's Registry instance gets shutdown (i..e. by calling
its shutdown() method), since it keeps references to all service instances.


> Tapestry instantiates a service implementation the first time a service
> method gets called, and I'm just wondering whether the reverse is also
> true - eg. released for garbage collection if no method has been called
> after a period of time.
>

Tapestry-IoC doesn't track whether a service hasn't been called after a
period of time.


>
> In some cases it's needed for a service to retain state, such as keeping
> a 'static final' map of connected users.  This is thread safe, but would
> be lost without a single service implementation instance.
>
> Regards,
>
> Chris.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Thiago