You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Oscar Picasso <os...@yahoo.com> on 2004/04/09 19:19:56 UTC

What make cocoon call the 'configure' method?

Hi,

1- On one hand I have a custom generator that extends the velocity generator
and implements 'Configurable' and 'CacheableProcessingComponent'. It works fine
and in particular the 'configure' method is called one time only.

2- On the other hand I have an action that implements 'Configurable'. But in
that case each time I use the action, its 'configure' method is called. As the
'configure' method makes some expensive processing I would like my action to
behave like the generator above ==> configure method called only the first time
it is used.

So my question is: what are suppose to do to 'tell' cocoon to configure our
component only the first time it used?


Thanks 

Oscar

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

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


Re: What make cocoon call the 'configure' method? [Follow-up]

Posted by Bruno Dumon <br...@outerthought.org>.
Actions can usually be marked as "Threadsafe", which means the same
instance of the action may be used by multiple threads concurrently. In
practice, this means there will be only one instance of the Action (per
component container).

On Fri, 2004-04-09 at 21:33, Oscar Picasso wrote:
> I have tried Poolable more carefully and it works. Finally I think Poolable, as
> you stated, is a better approach. 
> 
> Thanks.
> 
> 
> --- Oscar Picasso <os...@yahoo.com> wrote:
> > 
> > --- Gianugo Rabellino <gi...@apache.org> wrote:
> > > Oscar Picasso wrote:
> > > 
> > > > Hi,
> > > > 
> > > > 1- On one hand I have a custom generator that extends the velocity
> > > generator
> > > > and implements 'Configurable' and 'CacheableProcessingComponent'. It
> > works
> > > fine
> > > > and in particular the 'configure' method is called one time only.
> > > > 
> > > > 2- On the other hand I have an action that implements 'Configurable'. But
> > > in
> > > > that case each time I use the action, its 'configure' method is called.
> > As
> > > the
> > > > 'configure' method makes some expensive processing I would like my action
> > > to
> > > > behave like the generator above ==> configure method called only the
> > first
> > > time
> > > > it is used.
> > > > 
> > > > So my question is: what are suppose to do to 'tell' cocoon to configure
> > our
> > > > component only the first time it used?
> > > 
> > > This is not Cocoon but Avalon. The Avalon contracts state that 
> > > configure() will be called only once during the lifecycle of the 
> > > component, and you can take that for granted. What seems to be to you a 
> > > repeated configure() call is probably due to the container that doesn't 
> > > use object pools on your component but creates them on demand. So, 
> > > actually, configure() is called only once but in your Generator case 
> > > your instances are reused (configure() was already called), while your 
> > > Action instances are created (and destroyed) on every call. Consider 
> > > implementing Poolable.
> > 
> > If have tested with Poolable but it didn't work (I didn't test that solution
> > extensivly though).
> > 
> > Finally, if I implement 'Recyclable', with a recycle method that does
> > nothing.,
> > I get the right behaviour.
> > 
> > Is there some danger in using 'Recyclable' that way?
> > 
> > Thanks 
> > 
> > Oscar
> > 
-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


AW: What make cocoon call the 'configure' method? [Follow-up]

Posted by Marco Rolappe <m_...@web.de>.
not really better, actually, just different ;-)

Recyclable is an extension of Poolable, with the additional contract that
the component's recycle() method (to reinitialize it) is called before being
put back into the pool.

> -----Ursprungliche Nachricht-----
> Von: users-return-65705-m_rolappe=web.de@cocoon.apache.org
> [mailto:users-return-65705-m_rolappe=web.de@cocoon.apache.org]Im Auftrag
> von Oscar Picasso
> Gesendet: Freitag, 9. April 2004 21:33
> An: users@cocoon.apache.org
> Betreff: Re: What make cocoon call the 'configure' method? [Follow-up]
>
>
> I have tried Poolable more carefully and it works. Finally I
> think Poolable, as
> you stated, is a better approach.
>
> Thanks.
>
>


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


Re: What make cocoon call the 'configure' method? [Follow-up]

Posted by Oscar Picasso <os...@yahoo.com>.
I have tried Poolable more carefully and it works. Finally I think Poolable, as
you stated, is a better approach. 

Thanks.


--- Oscar Picasso <os...@yahoo.com> wrote:
> 
> --- Gianugo Rabellino <gi...@apache.org> wrote:
> > Oscar Picasso wrote:
> > 
> > > Hi,
> > > 
> > > 1- On one hand I have a custom generator that extends the velocity
> > generator
> > > and implements 'Configurable' and 'CacheableProcessingComponent'. It
> works
> > fine
> > > and in particular the 'configure' method is called one time only.
> > > 
> > > 2- On the other hand I have an action that implements 'Configurable'. But
> > in
> > > that case each time I use the action, its 'configure' method is called.
> As
> > the
> > > 'configure' method makes some expensive processing I would like my action
> > to
> > > behave like the generator above ==> configure method called only the
> first
> > time
> > > it is used.
> > > 
> > > So my question is: what are suppose to do to 'tell' cocoon to configure
> our
> > > component only the first time it used?
> > 
> > This is not Cocoon but Avalon. The Avalon contracts state that 
> > configure() will be called only once during the lifecycle of the 
> > component, and you can take that for granted. What seems to be to you a 
> > repeated configure() call is probably due to the container that doesn't 
> > use object pools on your component but creates them on demand. So, 
> > actually, configure() is called only once but in your Generator case 
> > your instances are reused (configure() was already called), while your 
> > Action instances are created (and destroyed) on every call. Consider 
> > implementing Poolable.
> 
> If have tested with Poolable but it didn't work (I didn't test that solution
> extensivly though).
> 
> Finally, if I implement 'Recyclable', with a recycle method that does
> nothing.,
> I get the right behaviour.
> 
> Is there some danger in using 'Recyclable' that way?
> 
> Thanks 
> 
> Oscar
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway 
> http://promotions.yahoo.com/design_giveaway/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

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


Re: What make cocoon call the 'configure' method?

Posted by Oscar Picasso <os...@yahoo.com>.
--- Gianugo Rabellino <gi...@apache.org> wrote:
> Oscar Picasso wrote:
> 
> > Hi,
> > 
> > 1- On one hand I have a custom generator that extends the velocity
> generator
> > and implements 'Configurable' and 'CacheableProcessingComponent'. It works
> fine
> > and in particular the 'configure' method is called one time only.
> > 
> > 2- On the other hand I have an action that implements 'Configurable'. But
> in
> > that case each time I use the action, its 'configure' method is called. As
> the
> > 'configure' method makes some expensive processing I would like my action
> to
> > behave like the generator above ==> configure method called only the first
> time
> > it is used.
> > 
> > So my question is: what are suppose to do to 'tell' cocoon to configure our
> > component only the first time it used?
> 
> This is not Cocoon but Avalon. The Avalon contracts state that 
> configure() will be called only once during the lifecycle of the 
> component, and you can take that for granted. What seems to be to you a 
> repeated configure() call is probably due to the container that doesn't 
> use object pools on your component but creates them on demand. So, 
> actually, configure() is called only once but in your Generator case 
> your instances are reused (configure() was already called), while your 
> Action instances are created (and destroyed) on every call. Consider 
> implementing Poolable.

If have tested with Poolable but it didn't work (I didn't test that solution
extensivly though).

Finally, if I implement 'Recyclable', with a recycle method that does nothing.,
I get the right behaviour.

Is there some danger in using 'Recyclable' that way?

Thanks 

Oscar

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

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


Re: What make cocoon call the 'configure' method?

Posted by Gianugo Rabellino <gi...@apache.org>.
Oscar Picasso wrote:

> Hi,
> 
> 1- On one hand I have a custom generator that extends the velocity generator
> and implements 'Configurable' and 'CacheableProcessingComponent'. It works fine
> and in particular the 'configure' method is called one time only.
> 
> 2- On the other hand I have an action that implements 'Configurable'. But in
> that case each time I use the action, its 'configure' method is called. As the
> 'configure' method makes some expensive processing I would like my action to
> behave like the generator above ==> configure method called only the first time
> it is used.
> 
> So my question is: what are suppose to do to 'tell' cocoon to configure our
> component only the first time it used?

This is not Cocoon but Avalon. The Avalon contracts state that 
configure() will be called only once during the lifecycle of the 
component, and you can take that for granted. What seems to be to you a 
repeated configure() call is probably due to the container that doesn't 
use object pools on your component but creates them on demand. So, 
actually, configure() is called only once but in your Generator case 
your instances are reused (configure() was already called), while your 
Action instances are created (and destroyed) on every call. Consider 
implementing Poolable.

HTH,

-- 
Gianugo Rabellino
Pro-netics s.r.l. -  http://www.pro-netics.com
Orixo, the XML business alliance - http://www.orixo.com
     (Blogging at: http://www.rabellino.it/blog/)

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