Ugo Cei wrote:
Il giorno 11/ago/04, alle 20:34, Leszek Gawron ha scritto:

did it like this :

public WebApplicationContext fetchContext() throws ContextException {


In which class did you put this?

    Ugo

my own :


/** * @author lgawron */ public class SpringApplicationContextFetcher implements Contextualizable { }

so I can register this as an avalon component or do cocoon.createObject:


function main( action, home ) {
cocoon.response.setHeader( "Expires", "-1" );
cocoon.response.setHeader( "Cache-Control", "no-cache" );
cocoon.response.setHeader( "Pragma", "no-cache" );
baseURL = home;
cocoon.session.setAttribute( "baseURL", baseURL );

if ( springContext == null ) setupSpringContext();

if ( cocoon.session.user == null ) {
loginInternal();
}
invoke( action );
}


function invoke( action ) {
func = this[ action ];
if ( func != undefined ) func.apply( this );
else cocoon.sendPage( action, {} );
}


function setupSpringContext() {
var fetcher = null;
try {
fetcher = cocoon.createObject( Packages.com.mobilebox.components.SpringApplicationContextFetcher );
springContext = fetcher.fetchContext();
} catch ( ex ) {
cocoon.log.error( ex );
throw ex;
} finally {
if ( fetcher != null ) cocoon.disposeObject( fetcher );
}
}

All request go through main function. it is easy the to access spring context anywhere in flowscript. My project uses spring only for business/db layer. This way I can do a lot of offline testing and change my web application layer from cocoon to sth else - which of course I will not do!


--
Leszek Gawron                                      [EMAIL PROTECTED]
Chief Technology Officer                           MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Reply via email to