Leo Sutic wrote:



From: news [mailto:[EMAIL PROTECTED] 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 }



Reply via email to