Il giorno 12/dic/04, alle 08:38, Reinhard Poetz ha scritto:


For a quick hack I wrote a singleton (simple Java class) that manages the Hibernate SessionFactory. As it is only a Cocoon/Hibernate-demo I haven't thought much about it, but if I use Hibernate in production, I would write a SingleThreaded Avalon component. I would do it because Cocoon is based on Avalon, but are there any technical reasons?

I think you mean ThreadSafe instead of SingleThreaded. A single-threaded component won't usually be a singleton, unless you want to severely compromise the scalability of your app. Single-threaded components are typically instantiated per-request or are pooled.

Thread-safe components can be used safely by many threads at once and as such can be singletons.

The Hibernate SessionFactory object is meant to be a singleton and you could wrap it inside an Avalon ThreadSafe component in order to have it managed by the Excalibur component manager inside Cocoon.

        HTH,

                Ugo

--
Ugo Cei - http://beblogging.com/

Attachment: smime.p7s
Description: S/MIME cryptographic signature



Reply via email to