You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Robert Leftwich <ro...@leftwich.info> on 2002/09/07 12:50:31 UTC
SourceFactory lifecycles
I am implementing a source (for Prevayler) based on the
FileSource/URISource. I have implemented a SourceFactory that extends
AbstractLogEnabled and implements SourceFactory and Configurable.
Everything is working ok with the exception that configure() on the
SourceFactory appears to be called once per request. I was under the
impression (from the Avalon docs [1]) that configure() would only be
'called once in the entire life of a Component:'. So, it appears my
understanding/expectation that the lifetime of a SourceFactory is basically
the same as for the Cocoon servlet/context (i.e. I expect to see
configure() called only once) is wrong.
Can someone please enlighten me as to the actual lifecycle of a
SourceFactory as I want to do some one-off setup based on the parameters
passed to the configure() method?
Robert
[1] http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Robert Leftwich <ro...@leftwich.info>.
At 10:22 PM 7/09/2002, Vadim Gritsenko wrote:
>Are you implementing ThreadSafe, as FileSourceFactory.java does?
No, I wasn't, as I had actually used XMLDBSourceFactory as the basis for my
factory and it doesn't implement ThreadSafe.
Adding ThreadSafe was the missing piece - thanks.
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Stephen McConnell <mc...@apache.org>.
Robert Leftwich wrote:
> At 03:48 AM 8/09/2002, Stephen McConnell wrote:
>
>> What I actually mean was - which "component container" are you using
>> and the answer is the ECM (Excalibur Componnet Manager varient on
>> which Cocoon is based).
>
>
> Excuse my newbie misunderstanding :-)
Hey - I'm only just starting to look inside Cocoon - we are both newbies!
>
>> Which means that the lifestyle declaration is the issue you need to
>> deal with (thread-safe, per-thread, etc.).
>
>
> Yep, what threw me was that there is no mention of thread-based
> lifecycle interactions in the Avalon page on the component lifecycles,
> so I made a (bad) assumption.
The Avalon framework content is almost exclusively a client view of a
component. In the past there were a number of marker interfaces that
were used to signal a lifestyle towards the container managing the
component. More recently the focus is shifting towards the formal
declaration of component characteristics through metadata. This is the
approach used by both the Merlin and Phoenix containers, and the
approach favoured from Fortress development (Merlin, Fortress and
Phoenix different Avalon component containers). You are more likely to
find information about lifestyle support under the container documentation.
For example:
Fortress
http://jakarta.apache.org/avalon/excalibur/fortress/
Merlin
http://jakarta.apache.org/avalon/excalibur/merlin/
>
>
>> My guess is that you have a configuration which is declaring a
>> lifestyle policy of a new instance per request and you actually want
>> something like per-thread of a singleton policy.
>
>
> Spot on - ThreadSafe appears to do it for me, is that the correct
> declaration for singleton behavior?
I tend to break things down into the following:
singleton : a single instance shared across mutliple threads
per-thread : a instance per thread of execution
pooled : a pool of instances that are recycled back to
pool by the client
transient : a new instance per request
At least that the model implementated within the Merlin container.
Cheers, Steve.
>
>
> Robert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
--
Stephen J. McConnell
OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Robert Leftwich <ro...@leftwich.info>.
At 03:48 AM 8/09/2002, Stephen McConnell wrote:
>What I actually mean was - which "component container" are you using and
>the answer is the ECM (Excalibur Componnet Manager varient on which Cocoon
>is based).
Excuse my newbie misunderstanding :-)
>Which means that the lifestyle declaration is the issue you need to deal
>with (thread-safe, per-thread, etc.).
Yep, what threw me was that there is no mention of thread-based lifecycle
interactions in the Avalon page on the component lifecycles, so I made a
(bad) assumption.
>My guess is that you have a configuration which is declaring a lifestyle
>policy of a new instance per request and you actually want something like
>per-thread of a singleton policy.
Spot on - ThreadSafe appears to do it for me, is that the correct
declaration for singleton behavior?
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Stephen McConnell <mc...@apache.org>.
Robert Leftwich wrote:
> At 09:00 PM 7/09/2002, Stephen McConnell wrote:
>
>> A couple of questions:
>>
>> 1. which container are you using?
>
>
> If you mean servlet container, it's Resin 2.1.4 (on W2000) using the
> snapshot xml-cocoon2_20020905222323 with patch 12115 applied (for a
> NPE in AbstractCachingProcessingPipeline.java)
What I actually mean was - which "component container" are you using and
the answer is the ECM (Excalibur Componnet Manager varient on which
Cocoon is based). Which means that the lifestyle declaration is the
issue you need to deal with (thread-safe, per-thread, etc.).
>
>
>> 2. is it really the case that the same instance is being configured
>> twice (or is it two instance with one configuration invocation for
>> each instance)
>
>
> I was checking this even as you wrote :-) It's actually a new instance
> per request with each being configured once.
My guess is that you have a configuration which is declaring a lifestyle
policy of a new instance per request and you actually want something
like per-thread of a singleton policy.
Cheers, Steve.
>
> Robert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
--
Stephen J. McConnell
OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Vadim Gritsenko <va...@verizon.net>.
Robert Leftwich wrote:
> At 09:00 PM 7/09/2002, Stephen McConnell wrote:
>
>> A couple of questions:
>>
>> 1. which container are you using?
>
>
> If you mean servlet container, it's Resin 2.1.4 (on W2000) using the
> snapshot xml-cocoon2_20020905222323 with patch 12115 applied (for a
> NPE in AbstractCachingProcessingPipeline.java)
>
>> 2. is it really the case that the same instance is being configured
>> twice (or is it two instance with one configuration invocation for
>> each instance)
>
>
> I was checking this even as you wrote :-) It's actually a new instance
> per request with each being configured once.
Are you implementing ThreadSafe, as FileSourceFactory.java does?
Vadim
> Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Robert Leftwich <ro...@leftwich.info>.
At 09:00 PM 7/09/2002, Stephen McConnell wrote:
>A couple of questions:
>
> 1. which container are you using?
If you mean servlet container, it's Resin 2.1.4 (on W2000) using the
snapshot xml-cocoon2_20020905222323 with patch 12115 applied (for a NPE in
AbstractCachingProcessingPipeline.java)
> 2. is it really the case that the same instance is being configured
> twice (or is it two instance with one configuration invocation for each
> instance)
I was checking this even as you wrote :-) It's actually a new instance per
request with each being configured once.
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: SourceFactory lifecycles
Posted by Stephen McConnell <mc...@apache.org>.
Robert Leftwich wrote:
> I am implementing a source (for Prevayler) based on the
> FileSource/URISource. I have implemented a SourceFactory that extends
> AbstractLogEnabled and implements SourceFactory and Configurable.
> Everything is working ok with the exception that configure() on the
> SourceFactory appears to be called once per request. I was under the
> impression (from the Avalon docs [1]) that configure() would only be
> 'called once in the entire life of a Component:'. So, it appears my
> understanding/expectation that the lifetime of a SourceFactory is
> basically the same as for the Cocoon servlet/context (i.e. I expect to
> see configure() called only once) is wrong.
> Can someone please enlighten me as to the actual lifecycle of a
> SourceFactory as I want to do some one-off setup based on the
> parameters passed to the configure() method?
Hi Robert:
A couple of questions:
1. which container are you using?
2. is it really the case that the same instance is being configured
twice (or is it two instance with one configuration invocation for each
instance)
Cheers, Steve.
>
>
> Robert
>
> [1]
> http://jakarta.apache.org/avalon/framework/reference-the-lifecycle.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
--
Stephen J. McConnell
OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org