You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Steven Gong <st...@gmail.com> on 2004/10/30 11:11:47 UTC

cross-reference problem in cocoon 2.1.5 release

Hi all, 
    Maybe it's an avalon issue and maybe I should post it to user
list, but I think it may be a problem with ECM which is deprecated in
avalon (or excalibur) and used by cocoon.
    I developed and declared two components CompA and CompB in
cocoon.xconf. Both are Serviceable and in the service method CompA
lookups up CompB and vice versa.  When I use cocoon.getComponent to
get CompA in js, StackOverflowError occurs.  It's caused by lookup's
implementation of the component container of ECM.
    I know it's not a good design using cross-reference of components,
but in some cases, they are useful and this error can be avoided if
lookup is implementated carefully, right?
    Is this a problem or is there a work-around for it? (I've noticed
ECM++ will be introduced into cocoon, has the implementation noticed
this point?)
                                    Steven Gong

Re: cross-reference problem in cocoon 2.1.5 release

Posted by Giacomo Pati <gi...@apache.org>.
On Sat, 30 Oct 2004, Steven Gong wrote:

> Vadim, Thank you for your advice!
> But, don't you think if the circular-dependency is supported in
> component container, we can avoid this problem downright? And the
> implementation is not quite difficult. Simply put some signal to tell
> the container not to create an already created component which has
> invoked lookup method in the stack trace.
> Is this right?

The ECM pattern is that lookups should happen where you need the component 
(in the business method) and they should be released as soon as they 
aren't needed anymore. This is because you don't know the implementation 
of the component (ThreadSafe vs. Poolable).

-- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com

Re: cross-reference problem in cocoon 2.1.5 release

Posted by Steven Gong <st...@gmail.com>.
Vadim, Thank you for your advice!
But, don't you think if the circular-dependency is supported in
component container, we can avoid this problem downright? And the
implementation is not quite difficult. Simply put some signal to tell
the container not to create an already created component which has
invoked lookup method in the stack trace.
Is this right?
                  Steven Gong

Re: cross-reference problem in cocoon 2.1.5 release

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Steven Gong wrote:
> Hi all, 
>     Maybe it's an avalon issue and maybe I should post it to user
> list, but I think it may be a problem with ECM which is deprecated in
> avalon (or excalibur) and used by cocoon.
>     I developed and declared two components CompA and CompB in
> cocoon.xconf. Both are Serviceable and in the service method CompA
> lookups up CompB and vice versa.  When I use cocoon.getComponent to
> get CompA in js, StackOverflowError occurs.  It's caused by lookup's
> implementation of the component container of ECM.
>     I know it's not a good design using cross-reference of components,
> but in some cases, they are useful and this error can be avoided if
> lookup is implementated carefully, right?

Yes, it's not a good idea. IIUC, this error can be avoided only if you postpone 
lookup, by moving it into one of the business methods.

Vadim


>     Is this a problem or is there a work-around for it? (I've noticed
> ECM++ will be introduced into cocoon, has the implementation noticed
> this point?)
>                                     Steven Gong