cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <res1c...@verizon.net>
Subject Re: Flow Database stuff ( The new FOM? )
Date Tue, 15 Jul 2003 06:37:55 GMT
Reinhard Pötz wrote:

>From: Jeremy Quinn 
>
>  
>
>>What I do not grok ATM, how does the Hibernate Session automatically 
>>get closed at the appropriate time (ie. after the view layer has 
>>completed)?
>>    
>>
>
>IIU the current flow implementation correctly you have no chance but to
>use lazy initializiation as implemented by you because after reaching
>sendPageAndWait() the flow interpreter has no chance to react. Maybe
>we need something like a "finalize" in pipeline processing where those
>things (releasing of components) are done.
>
>HTH
>Reinhard
>
>
>  
>
Actually, although not particularly user-friendly, there is a way to do 
this, even now, with the extended "catch" syntax supported by Rhino 
(which is intended to provide functionality similar to "dynamic-wind" in 
Scheme):


var hibSession = null;

function getSession() {
    if (hibSession == null) {
        hibSession = cocoon.getComponent("hibernateSession");
    }
}

function releaseSession() {
     if (hibSession != null) {
          cocoon.releaseComponent(hibSession);
          hibSession = null;
     }
}

catch (break) {
          // a continuation is being captured,  
          // code to handle that goes here
         releaseSession();
}

catch (continue) {
         // a continuation is being restored
         // code to handle that goes here
}

function myFlow() {
     var custBean = getSession().blah;
     sendPageAndWait("cust.xml", custBean);
     var anotherBean = getSession().blahblah
}


Mime
View raw message