cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Poetz <reinh...@apache.org>
Subject Re: [SOT] SingleThreaded components vs. Singletons
Date Sun, 12 Dec 2004 13:24:07 GMT
Ugo Cei wrote:
> 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. 

yep :-/

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.

As advantages I can think of putting the confiuguration of the component into 
cocoon.xconf and I only have to choose the right interface. Are there other 
advantages of having the ECM manage the component?

-- 
Reinhard

Mime
View raw message