cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: [Kernel22] How to develop a component?
Date Thu, 08 Apr 2004 14:28:14 GMT
Leo Sutic wrote:

>  
>
>>From: news [mailto:news@sea.gmane.org] On Behalf Of Leo Simons
>>
>>Stefano Mazzocchi wrote:
>>    
>>
>>>If you have two blocks in the avalon sandbox, you could share them
>>>between them, but there is no (easy? elegant?) way you can 
>>>      
>>>
>>pass them 
>>    
>>
>>>arond *OUTSIDE* the sandbox and still allow blocks to be 
>>>      
>>>
>>hotswappable 
>>    
>>
>>>and runtime polymorphic.
>>>
>>>[I would gladly be proven wrong here!]
>>>      
>>>
>>write a failing testcase that doens't require me to understand every 
>>little detail of cocoon internals and I could try.
>>    
>>
>
>Easy.
>
>interface StatefulComponent {
>    public void login (); // never throws any exception, ever.
>    public void doOperation (); // never throws any exception, ever.
>    public void logout (); // never throws any exception, ever.
>}
>
>Client.java:
>
>    StatefulComponent comp = (StatefulComponent) 
>        manager.lookup(StatefulComponent.ROLE);
>    try {
>        comp.login ();
>        // (1)
>        comp.doOperation ();
>        comp.logout ();
>    } finally {
>        manager.release (comp);
>    }
>
>If a block reload of the implementation of StatefulComponent
>occurs at (1), the comp proxy will be invalidated while in use,
>and the operation will fail.
>
>This is contrary to Avalon semantics, where a component reference,
>once obtained, remains valid until it is released.
>
>Of course there are ways to code around this (or ignore it) in 
>the vast majority of cases.
>  
>

A way to solve this problem is by deferring the actual swapping until 
the component is released.
See http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108033164725441&w=2 
where I discussed this.

Of course, there should be a means to force component swap (either 
manually or automatically) in case a release has been forgotten.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Mime
View raw message