On Fri, Nov 16, 2012 at 6:04 PM, Thiago H de Paula Figueiredo <
[email protected]> wrote:

> On Fri, 16 Nov 2012 14:28:17 -0200, Lenny Primak <[email protected]>
> wrote:
>
>  Any kind of a singleton service can be used as a data pool
>> See 
>> http://tapestry.apache.org/**defining-tapestry-ioc-**services.html<http://tapestry.apache.org/defining-tapestry-ioc-services.html>
>>
>
> In other words: put the application-scoped data as fields in a class,
> write some methods to read and write them, declare it as a Tapestry-IoC
> singleton service (which is the same as declaring it as a service, as
> singleton is the default service scope in Tapestry-IoC), use the service,
> that's it. The application scope in JSP and servlets is a very bad idea
> from times in which webapps were a huge mess in terms of architecture.


But please be aware that you get exactly what you ask for, a Java singleton
object.

It means:
- It is shared between all process threads,
  so you must properly handle multi-threading issues.
- It is shared by different users.
  so you must ensure that you don't accidentally leak one user-specific
data to another user.
- It is NOT shared between different Java processes,
  so if you run your application using a cluster of servers and you really
need to share data,
  you should implement such sharing somehow yourself.
- It is NOT saved/restored in case of a server restart (like data stored in
user sessions might be),
  so if you need to have such ability, you need to implement it yourself.

I know that everything above is obvious to a seasoned Java developer,
but not everybody might understand all implications at first glance.

Best regards,
Cezary

Reply via email to