You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by David Legg <da...@searchevent.co.uk> on 2005/10/13 01:33:43 UTC

Where's the best place to run code at Cocoon startup?

I've got some singleton Java classes that I'd rather configure and init at 
Cocoon init time instead of the first time a page is requested.  Where's the 
best place to do this?

I've looked at the xconf file but I'm not sure if this is what I need.

David Legg






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Where's the best place to run code at Cocoon startup?

Posted by Geert Josten <Ge...@daidalos.nl>.
>> Another solution I use is to inherit the Cocoon servlet and override 
>> the standard servlet init method.
> 
> 
> Thanks for the suggestion.  I need to configure the component before use 
> so it makes sense to use the Avalon framework.
> 
> Actually, doing this has given me the excuse I needed to explore the 
> murky world of the Avalon component manager.  I'm finding it tough going 
> though because there is little documentation to help with integrating a 
> component into Cocoon.  Until I started researching this I had no idea 
> of the history and conflict involved with Avalon.  I had heard of  
> 'Inversion of Control' (IoC) but little clue about what that meant.  Now 
> I've got images in my head of syringes injecting things into classes!

You probably already found out, but there are (at least) three stages to configure/init you 
component. At 'creation' time, at configure time and at run time. I may be wrong as I didn't dive 
into the depths of Avalon, but I believe what you are looking for is part of the Serviceable 
interfaces. This adds a recycle and setup function..

HTH,
Geert


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Where's the best place to run code at Cocoon startup?

Posted by David Legg <da...@searchevent.co.uk>.
David Perez wrote:
> Another solution I use is to inherit the Cocoon servlet and override the 
> standard servlet init method.

Thanks for the suggestion.  I need to configure the component before use so 
it makes sense to use the Avalon framework.

Actually, doing this has given me the excuse I needed to explore the murky 
world of the Avalon component manager.  I'm finding it tough going though 
because there is little documentation to help with integrating a component 
into Cocoon.  Until I started researching this I had no idea of the history 
and conflict involved with Avalon.  I had heard of  'Inversion of Control' 
(IoC) but little clue about what that meant.  Now I've got images in my head 
of syringes injecting things into classes!

David Legg 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Where's the best place to run code at Cocoon startup?

Posted by Sylvain Wallez <sy...@apache.org>.
David Perez wrote:

> Sylvain Wallez schrieb:
>
>> David Legg wrote:
>>
>>> I've got some singleton Java classes that I'd rather configure and 
>>> init at Cocoon init time instead of the first time a page is 
>>> requested.  Where's the best place to do this?
>>>
>>> I've looked at the xconf file but I'm not sure if this is what I need.
>>
>>
>> Yes, this is the right place. Make sure your class implements the 
>> Avalon ThreadSafe interface and declare it in cocoon.xconf
>>
> Another solution I use is to inherit the Cocoon servlet and override 
> the standard servlet init method.


Works also. However, this prevents it to access any of the 
Cocoon-provided components.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Where's the best place to run code at Cocoon startup?

Posted by David Perez <cr...@yahoo.es>.
Sylvain Wallez schrieb:

> David Legg wrote:
>
>> I've got some singleton Java classes that I'd rather configure and 
>> init at Cocoon init time instead of the first time a page is 
>> requested.  Where's the best place to do this?
>>
>> I've looked at the xconf file but I'm not sure if this is what I need.
>
>
>
> Yes, this is the right place. Make sure your class implements the 
> Avalon ThreadSafe interface and declare it in cocoon.xconf
>
> Sylvain
>
Another solution I use is to inherit the Cocoon servlet and override the 
standard servlet init method.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Where's the best place to run code at Cocoon startup?

Posted by Sylvain Wallez <sy...@apache.org>.
David Legg wrote:

> I've got some singleton Java classes that I'd rather configure and 
> init at Cocoon init time instead of the first time a page is 
> requested.  Where's the best place to do this?
>
> I've looked at the xconf file but I'm not sure if this is what I need.


Yes, this is the right place. Make sure your class implements the Avalon 
ThreadSafe interface and declare it in cocoon.xconf

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org