cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@apache.org>
Subject tying continuations to the interpreter
Date Tue, 16 Nov 2004 11:59:19 GMT
I am in the middle of implementing a constraint that a continuation may 
be invoked only for interpreter it was created for. The way to do it is 
to store interpreterId in continuation itself and do not allow 
continuation manager to return a continuation other than with matching 
interpreterId

Main changes are:
1. org.apache.cocoon.components.flow.Interpreter interface has been 
extended with getInterpreterId(). Every Interpreter exposes it's id to 
the outside world.

2. ContinuationsManager.createWebContinuation and 
ContinuationsManager.lookupWebContinuation has been extended with 
interpreterId parameter that has to be passed along with other data.

Thing is I've been able to update all FOMs' implementations but there is 
one place I do not know where to get Interpreter reference from. This is 
org.apache.cocoon.components.flow.javascript.fom.FOM_WebContinuation:

>     public static Object jsConstructor(Context cx, Object[] args,
>                                        Function ctorObj,
>                                        boolean inNewExpr)
>         throws Exception {
>         FOM_WebContinuation result = null;
>         if (args.length < 1) {
>             // error
>         }
>         Continuation c = (Continuation)unwrap(args[0]);
>         FOM_WebContinuation parent = null;
>         if (args.length > 1) {
>             parent = (FOM_WebContinuation)args[1];
>         }
>         int timeToLive = 0;
>         if (args.length > 2) {
>             timeToLive =
>                 (int)org.mozilla.javascript.Context.toNumber(args[2]);
>         }
>         WebContinuation wk;
>         Scriptable scope = getTopLevelScope(c);
>         FOM_Cocoon cocoon = (FOM_Cocoon)getProperty(scope, "cocoon");
>         ServiceManager componentManager =  cocoon.getServiceManager();
>         ContinuationsManager contMgr = (ContinuationsManager)
>             componentManager.lookup(ContinuationsManager.ROLE);
>         wk = contMgr.createWebContinuation(c,
>                                            (parent == null ? null : parent.getWebContinuation()),
>                                            timeToLive,
>                                            null);
>         result = new FOM_WebContinuation(wk);
>         result.setParentScope(getTopLevelScope(scope));
>         result.setPrototype(getClassPrototype(scope, result.getClassName()));
>         return result;
>     }

how do I fetch an interpreter here?

-- 
Leszek Gawron                                                 MobileBox
lgawron@apache.org                              http://www.mobilebox.pl

Mime
View raw message