cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap CallFunctionNode.java ContinueNode.java
Date Fri, 20 Feb 2004 18:48:23 GMT
sylvain     2004/02/20 10:48:23

  Modified:    src/blocks/apples/java/org/apache/cocoon/components/flow/apples
                        ApplesProcessor.java
               src/blocks/jxforms/java/org/apache/cocoon/components/jxforms/flow/javascript
                        JXForm.java
               src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom
                        AO_FOM_Cocoon.java
                        AO_FOM_JavaScriptInterpreter.java
                        JavaScriptAspectWeaver.java
               src/java/org/apache/cocoon/components/flow
                        AbstractInterpreter.java CompilingInterpreter.java
                        Interpreter.java
               src/java/org/apache/cocoon/components/flow/javascript/fom
                        FOM_Cocoon.java FOM_JavaScriptInterpreter.java
                        FOM_WebContinuation.java
               src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        CallFunctionNode.java ContinueNode.java
  Log:
  Remove dependency of flow on Environment: replaced by Redirector
  
  Revision  Changes    Path
  1.11      +14 -13    cocoon-2.1/src/blocks/apples/java/org/apache/cocoon/components/flow/apples/ApplesProcessor.java
  
  Index: ApplesProcessor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/apples/java/org/apache/cocoon/components/flow/apples/ApplesProcessor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ApplesProcessor.java	2 Dec 2003 23:04:30 -0000	1.10
  +++ ApplesProcessor.java	20 Feb 2004 18:48:23 -0000	1.11
  @@ -47,18 +47,19 @@
   
   import java.util.List;
   
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.component.WrapperComponentManager;
  +import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.context.DefaultContext;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.components.LifecycleHelper;
   import org.apache.cocoon.components.flow.AbstractInterpreter;
   import org.apache.cocoon.components.flow.ContinuationsDisposer;
   import org.apache.cocoon.components.flow.InvalidContinuationException;
   import org.apache.cocoon.components.flow.WebContinuation;
  -import org.apache.cocoon.environment.Environment;
  -import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
   
   /**
  @@ -74,7 +75,7 @@
       public void callFunction(
           String className,
           List params,
  -        Environment env)
  +        Redirector redirector)
           throws Exception {
   
           AppleController app = instantiateController(className);
  @@ -87,10 +88,10 @@
           getLogger().debug("Pulling fresh apple through the lifecycle... | continuationid=" + wk.getId());
           
           LifecycleHelper.setupComponent( app, getLogger(), appleContext, 
  -                                        this.serviceManager, super.manager,  
  +                                        this.serviceManager, new WrapperComponentManager(this.serviceManager),  
                                           null, null, true);
           
  -        processApple(params, env, app, wk);
  +        processApple(params, redirector, app, wk);
       }
   
   
  @@ -98,7 +99,7 @@
       public void handleContinuation(
           String continuationId,
           List params,
  -        Environment env)
  +        Redirector redirector)
           throws Exception {
   
           WebContinuation wk =
  @@ -116,7 +117,7 @@
           getLogger().debug("found apple from continuation: " + app);
   
           // TODO access control checks? exception to be thrown for illegal access?
  -        processApple(params, env, app, wk);
  +        processApple(params, redirector, app, wk);
   
       }
   
  @@ -136,22 +137,22 @@
   
       private void processApple(
           List params,
  -        Environment env,
  +        Redirector redirector,
           AppleController app,
           WebContinuation wk)
           throws Exception {
   
  -        Request cocoonRequest = ObjectModelHelper.getRequest(env.getObjectModel());
  +        Request cocoonRequest = ContextHelper.getRequest(this.avalonContext);
           AppleRequest req = new DefaultAppleRequest(params, cocoonRequest);
           DefaultAppleResponse res = new DefaultAppleResponse();
           app.process(req, res);
   
           if (res.isRedirect()) {
  -            env.redirect(false, res.getURI());
  +            redirector.redirect(false, res.getURI());
           } else {
               String uri = res.getURI();
               getLogger().debug("Apple forwards to " + uri + " with bizdata= " + res.getData() + " and continuationid= " + wk.getId());
  -            this.forwardTo(uri, res.getData(), wk, env);
  +            this.forwardTo(uri, res.getData(), wk, redirector);
           }
   
           //TODO allow for AppleResponse to set some boolean saying the use case
  
  
  
  1.7       +1 -1      cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/components/jxforms/flow/javascript/JXForm.java
  
  Index: JXForm.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/jxforms/java/org/apache/cocoon/components/jxforms/flow/javascript/JXForm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JXForm.java	5 Sep 2003 07:21:48 -0000	1.6
  +++ JXForm.java	20 Feb 2004 18:48:23 -0000	1.7
  @@ -128,7 +128,7 @@
           form.setAutoValidate(false);
           if (validatorNamespace != null && validatorDocument != null) {
               SourceResolver resolver = (SourceResolver)
  -                getCocoon().getComponentManager().lookup(SourceResolver.ROLE);
  +                getCocoon().getServiceManager().lookup(SourceResolver.ROLE);
               Source schemaSrc = resolver.resolveURI(validatorDocument);
               InputSource is = SourceUtil.getInputSource(schemaSrc);
               SchemaFactory schf = SchemaFactory.lookup(validatorNamespace);
  
  
  
  1.5       +29 -49    cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java
  
  Index: AO_FOM_Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_Cocoon.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AO_FOM_Cocoon.java	28 Oct 2003 17:22:17 -0000	1.4
  +++ AO_FOM_Cocoon.java	20 Feb 2004 18:48:23 -0000	1.5
  @@ -59,16 +59,16 @@
   import java.util.Locale;
   import java.util.Map;
   
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.components.flow.ContinuationsManager;
   import org.apache.cocoon.components.flow.WebContinuation;
   import org.apache.cocoon.components.flow.Interpreter.Argument;
  -import org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode;
   import org.apache.cocoon.environment.Cookie;
  -import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
   import org.apache.cocoon.environment.Session;
  @@ -93,9 +93,10 @@
   
       private AO_FOM_JavaScriptInterpreter interpreter;
   
  -    private Environment environment;
  -    private ComponentManager componentManager;
  +    private Redirector redirector;
  +    private ServiceManager componentManager;
       private Logger logger;
  +    private Context avalonContext;
   
       private FOM_Request request;
       private FOM_Response response;
  @@ -123,11 +124,13 @@
       }
   
       void setup(AO_FOM_JavaScriptInterpreter interp,
  -                      Environment env, 
  -                      ComponentManager manager,
  +                      Redirector redirector, 
  +                      Context avalonContext,
  +                      ServiceManager manager,
                         Logger logger) {
           this.interpreter = interp;
  -        this.environment = env;
  +        this.redirector = redirector;
  +        this.avalonContext = avalonContext;
           this.componentManager = manager;
           this.logger = logger;
       }
  @@ -140,7 +143,7 @@
           this.log = null;
           this.logger = null;
           this.componentManager = null;
  -        this.environment = null;
  +        this.redirector = null;
           this.interpreter = null;
       }
   
  @@ -167,7 +170,7 @@
           fom_wk.setPrototype(getClassPrototype(getParentScope(), 
                                                 fom_wk.getClassName()));
           interpreter.forwardTo(getParentScope(), this, redUri,
  -                              bizData, fom_wk, environment);
  +                              bizData, fom_wk, redirector);
   
           FOM_WebContinuation result = null;
           if (wk != null) {
  @@ -195,14 +198,11 @@
               throw new JavaScriptException("expected a java.io.OutputStream instead of " + outputStream);
           }
           interpreter.process(getParentScope(), this, uri, map, 
  -                            (OutputStream)unwrap(outputStream), 
  -                            environment);
  +                            (OutputStream)unwrap(outputStream));
       }
   
       public void jsFunction_redirectTo(String uri) throws Exception {
  -        // Cannot use environment directly as TreeProcessor uses own version of redirector
  -        // environment.redirect(false, uri);
  -        PipelinesNode.getRedirector(environment).redirect(false, uri);
  +        redirector.redirect(false, uri);
       }
   
       /*
  @@ -237,11 +237,7 @@
        * of <code>org.apache.avalon.framework.component.Component</code>
        */
       public void jsFunction_releaseComponent( Object component ) throws Exception {
  -        try {
  -            this.componentManager.release( (Component) unwrap(component) );
  -        } catch( ClassCastException cce ) {
  -            throw new JavaScriptException( "Only components can be released!" );
  -        }
  +        this.componentManager.release( unwrap(component) );
       }
   
       // (RPO) added by interception layer    
  @@ -272,9 +268,7 @@
           org.mozilla.javascript.Context cx = 
               org.mozilla.javascript.Context.getCurrentContext();
           Scriptable scope = getParentScope();
  -        Script script = interpreter.compileScript( cx, 
  -                                                   environment,
  -                                                   filename );
  +        Script script = interpreter.compileScript( cx, filename );
           return script.exec( cx, scope );
       }    
           
  @@ -773,12 +767,11 @@
           if (request != null) {
               return request;
           }
  -        if (environment == null) {
  +        if (redirector == null) {
               // context has been invalidated
               return null;
           }
  -        Map objectModel = environment.getObjectModel();
  -        request = new FOM_Request(ObjectModelHelper.getRequest(objectModel));
  +        request = new FOM_Request(ContextHelper.getRequest(avalonContext));
           request.setParentScope(getParentScope());
           request.setPrototype(getClassPrototype(getParentScope(), "FOM_Request"));
           return request;
  @@ -788,13 +781,11 @@
           if (response != null) {
               return response;
           }
  -        if (environment == null) {
  +        if (redirector == null) {
               // context has been invalidated
               return null;
           }
  -        Map objectModel = environment.getObjectModel();
  -        response = 
  -            new FOM_Response(ObjectModelHelper.getResponse(objectModel));
  +        response = new FOM_Response(ContextHelper.getResponse(avalonContext));
           response.setParentScope(getParentScope());
           response.setPrototype(getClassPrototype(this, "FOM_Response"));
           return response;
  @@ -814,7 +805,7 @@
           if (context != null) {
               return context;
           }
  -        Map objectModel = environment.getObjectModel();
  +        Map objectModel = ContextHelper.getObjectModel(avalonContext);
           context = 
               new FOM_Context(ObjectModelHelper.getContext(objectModel));
           context.setParentScope(getParentScope());
  @@ -826,13 +817,11 @@
           if (session != null) {
               return session;
           }
  -        if (environment == null) {
  +        if (redirector == null) {
               // session has been invalidated
               return null;
           }
  -        Map objectModel = environment.getObjectModel();
  -        session = 
  -            new FOM_Session(ObjectModelHelper.getRequest(objectModel).getSession(true));
  +        session = new FOM_Session(ContextHelper.getRequest(avalonContext).getSession(true));
           session.setParentScope(getParentScope());
           session.setPrototype(getClassPrototype(this, "FOM_Session"));
           return session;
  @@ -904,16 +893,7 @@
        * @return The object model
        */
       public Map getObjectModel() {
  -        return environment.getObjectModel();
  -    }
  -
  -    /**
  -     * Get the current Sitemap's component manager
  -     * @return The component manager
  -     */
  -
  -    public ComponentManager getComponentManager() {
  -        return componentManager;
  +        return ContextHelper.getObjectModel(avalonContext);
       }
   
       /**
  @@ -932,7 +912,7 @@
                                 uri,
                                 bean,
                                 fom_wk,
  -                              environment);
  +                              redirector);
       }
   
       /**
  @@ -958,7 +938,7 @@
                                           org.mozilla.javascript.Context.toString(getProperty(parameters, name)));
               list.add(arg);
           }
  -        interpreter.handleContinuation(kontId, list, environment);
  +        interpreter.handleContinuation(kontId, list, redirector);
       }
   
       /**
  
  
  
  1.7       +58 -36    cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java
  
  Index: AO_FOM_JavaScriptInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/AO_FOM_JavaScriptInterpreter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AO_FOM_JavaScriptInterpreter.java	24 Sep 2003 22:00:34 -0000	1.6
  +++ AO_FOM_JavaScriptInterpreter.java	20 Feb 2004 18:48:23 -0000	1.7
  @@ -65,8 +65,12 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.components.flow.AbstractInterpreter;
   import org.apache.cocoon.components.flow.Interpreter;
   import org.apache.cocoon.components.flow.InvalidContinuationException;
  @@ -74,14 +78,23 @@
   import org.apache.cocoon.components.flow.javascript.JSErrorReporter;
   import org.apache.cocoon.components.flow.javascript.ScriptablePointerFactory;
   import org.apache.cocoon.components.flow.javascript.ScriptablePropertyHandler;
  -import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   import org.apache.commons.jxpath.JXPathIntrospector;
   import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
   import org.apache.excalibur.source.Source;
  -import org.mozilla.javascript.*;
  +import org.apache.excalibur.source.SourceResolver;
  +import org.mozilla.javascript.Context;
  +import org.mozilla.javascript.EcmaError;
  +import org.mozilla.javascript.EvaluatorException;
  +import org.mozilla.javascript.JavaScriptException;
  +import org.mozilla.javascript.Script;
  +import org.mozilla.javascript.ScriptRuntime;
  +import org.mozilla.javascript.Scriptable;
  +import org.mozilla.javascript.ScriptableObject;
  +import org.mozilla.javascript.Wrapper;
   import org.mozilla.javascript.continuations.Continuation;
   import org.mozilla.javascript.tools.ToolErrorReporter;
   import org.mozilla.javascript.tools.shell.Global;
  @@ -110,9 +123,11 @@
    * @version CVS $Id$
    */
   public class AO_FOM_JavaScriptInterpreter extends AbstractInterpreter
  -    implements Configurable, Initializable
  +    implements Serviceable, Configurable, Initializable
   {
   
  +    private SourceResolver sourceResolver;
  +
       /**
        * LAST_EXEC_TIME
        * A long value is stored under this key in each top level JavaScript
  @@ -244,6 +259,11 @@
       Configuration stopExecutionFunctionsConf = null;
       boolean serializeResultScript = false;
       // --end
  +    
  +    public void service(ServiceManager manager) throws ServiceException {
  +        super.service(manager);
  +        this.sourceResolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
  +    }
   
       public void configure(Configuration config) 
           throws ConfigurationException {
  @@ -312,16 +332,18 @@
        * @param environment an <code>Environment</code> value
        * @return a <code>Scriptable</code> value
        */
  -    private Scriptable getSessionScope(Environment environment)
  +    private Scriptable getSessionScope()
           throws Exception {
  -        Map objectModel = environment.getObjectModel();
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +        Request request = ContextHelper.getRequest(avalonContext);
           Scriptable scope = null;
           Session session = request.getSession(false);
           if (session != null) {
               HashMap userScopes = (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
               if (userScopes != null) {
  -                String uriPrefix = environment.getURIPrefix();
  +                // Get context prefix
  +                Source src = this.sourceResolver.resolveURI(".");
  +                String uriPrefix = src.getURI();
  +                this.sourceResolver.release(src);
                   scope = (Scriptable)userScopes.get(uriPrefix);
               }
           }
  @@ -331,10 +353,10 @@
           return scope;
       }
   
  -    void updateSession(Environment env, Scriptable scope) throws Exception {
  +    void updateSession(Scriptable scope) throws Exception {
           ThreadScope thrScope = (ThreadScope)scope;
           if (thrScope.useSession) {
  -            setSessionScope(env, scope);
  +            setSessionScope(scope);
           }
       }
   
  @@ -346,10 +368,9 @@
        * @param environment an <code>Environment</code> value
        * @param scope a <code>Scriptable</code> value
        */
  -    private Scriptable setSessionScope(Environment environment, Scriptable scope)
  +    private Scriptable setSessionScope(Scriptable scope)
           throws Exception {
  -        Map objectModel = environment.getObjectModel();
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +        Request request = ContextHelper.getRequest(this.avalonContext);
           Session session = request.getSession(true);
   
           HashMap userScopes = (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
  @@ -357,7 +378,10 @@
               userScopes = new HashMap();
               session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
           }
  -        String uriPrefix = environment.getURIPrefix();
  +        // Get context prefix
  +        Source src = this.sourceResolver.resolveURI(".");
  +        String uriPrefix = src.getURI();
  +        this.sourceResolver.release(src);
           userScopes.put(uriPrefix, scope);
           return scope;
       }
  @@ -436,7 +460,7 @@
        * @param environment an <code>Environment</code> value
        * @exception Exception if an error occurs
        */
  -    private void setupContext(Environment environment,
  +    private void setupContext(Redirector redirector,
                                 org.mozilla.javascript.Context context,
                                 Scriptable thrScope)
           throws Exception {
  @@ -455,7 +479,7 @@
                                                   thrScope)).longValue();
           // We need to setup the FOM_Cocoon object according to the current
           // request. Everything else remains the same.
  -        cocoon.setup( this, environment, manager, getLogger());
  +        cocoon.setup( this, redirector, avalonContext, manager, getLogger());
           
           // Check if we need to compile and/or execute scripts
           synchronized (compiledScripts) {
  @@ -488,7 +512,7 @@
                   ScriptSourceEntry entry =
                       (ScriptSourceEntry)compiledScripts.get(sourceURI);
                   if (entry == null) {
  -                    Source src = environment.resolveURI(sourceURI);
  +                    Source src = this.sourceResolver.resolveURI(sourceURI);
                       entry = new ScriptSourceEntry(src);
                       compiledScripts.put(sourceURI, entry);
                   }
  @@ -496,8 +520,8 @@
                   // add interception support
                   if( isInterceptionEnabled ) {
                       JavaScriptAspectWeaver aspectWeaver = new JavaScriptAspectWeaver();
  -                    aspectWeaver.setEnvironment( environment );
                       aspectWeaver.enableLogging( this.getLogger() );
  +                    aspectWeaver.service(this.manager);
                       aspectWeaver.setSerializeResultScriptParam( this.serializeResultScript );
                       aspectWeaver.setStopExecutionFunctionsConf( this.stopExecutionFunctionsConf );
                       entry.setAspectWeaver( aspectWeaver );
  @@ -532,9 +556,8 @@
        * @return compiled script
        */
       Script compileScript(Context cx,
  -                         Environment environment,
                            String fileName) throws Exception {
  -        Source src = environment.resolveURI(fileName);
  +        Source src = sourceResolver.resolveURI(fileName);
           if (src == null) {
               throw new ResourceNotFoundException(fileName + ": not found");
           }
  @@ -596,7 +619,7 @@
        * @exception Exception if an error occurs
        */
       public void callFunction(String funName, List params,
  -                             Environment environment)
  +                             Redirector redirector)
           throws Exception
       {
           Context context = Context.enter();
  @@ -605,10 +628,10 @@
           context.setCompileFunctionsWithDynamicScope(true);
           context.setErrorReporter(errorReporter);
           AO_FOM_Cocoon cocoon = null;
  -        Scriptable thrScope = getSessionScope(environment);
  +        Scriptable thrScope = getSessionScope();
           synchronized (thrScope) {
               try {
  -                setupContext(environment, context, thrScope);
  +                setupContext(redirector, context, thrScope);
                   cocoon = (AO_FOM_Cocoon)thrScope.get("cocoon", thrScope);
                   if (enableDebugger) {
                       if (!getDebugger().isVisible()) {
  @@ -657,7 +680,7 @@
                   }
                   throw new CascadingRuntimeException(ee.getMessage(), ee);
               } finally {
  -                updateSession(environment, thrScope);
  +                updateSession(thrScope);
                   if (cocoon != null) cocoon.invalidate();
                   Context.exit();
               }
  @@ -665,7 +688,7 @@
       }
   
       public void handleContinuation(String id, List params,
  -                                   Environment environment)
  +                                   Redirector redirector)
           throws Exception
       {
           WebContinuation wk = continuationsMgr.lookupWebContinuation(id);
  @@ -691,7 +714,7 @@
           Scriptable kScope = k.getParentScope();
           synchronized (kScope) {
               AO_FOM_Cocoon cocoon = (AO_FOM_Cocoon)kScope.get("cocoon", kScope);
  -            cocoon.setup(this, environment, manager, getLogger());
  +            cocoon.setup(this, redirector, avalonContext, manager, getLogger());
               if (enableDebugger) {
                   getDebugger().setVisible(true);
               }
  @@ -739,7 +762,7 @@
                   }
                   throw new CascadingRuntimeException(ee.getMessage(), ee);
               } finally {
  -                updateSession(environment, kScope);
  +                updateSession(kScope);
                   cocoon.invalidate();
                   Context.exit();
               }
  @@ -760,29 +783,28 @@
       public void forwardTo(Scriptable scope, AO_FOM_Cocoon cocoon,
                             String uri, Object bizData,
                             FOM_WebContinuation fom_wk,
  -                          Environment environment)
  +                          Redirector redirector)
           throws Exception {
  -        setupView(scope, cocoon, environment, fom_wk);
  +        setupView(scope, cocoon, fom_wk);
           super.forwardTo(uri, bizData, 
                           fom_wk == null ? null :
                              fom_wk.getWebContinuation(), 
  -                        environment);
  +                        redirector);
       }
   
       // package access as this is called by FOM_Cocoon
  -    boolean process(Scriptable scope, AO_FOM_Cocoon cocoon,
  +    void process(Scriptable scope, AO_FOM_Cocoon cocoon,
                       String uri, Object bizData, 
  -                    OutputStream out, Environment environment)
  +                    OutputStream out)
           throws Exception {
  -        setupView(scope, cocoon, environment, null);
  -        return super.process(uri, bizData, out, environment);
  +        setupView(scope, cocoon, null);
  +        super.process(uri, bizData, out);
       }
       
       private void setupView(Scriptable scope,
                              AO_FOM_Cocoon cocoon,
  -                           Environment environment,
                              FOM_WebContinuation kont) {
  -        Map objectModel = environment.getObjectModel();
  +        Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
           // Make the JS live-connect objects available to the view layer
           FOM_JavaScriptFlowHelper.setPackages(objectModel,
                                      (Scriptable)ScriptableObject.getProperty(scope,
  
  
  
  1.10      +29 -18    cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/JavaScriptAspectWeaver.java
  
  Index: JavaScriptAspectWeaver.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom/JavaScriptAspectWeaver.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JavaScriptAspectWeaver.java	23 Dec 2003 15:28:32 -0000	1.9
  +++ JavaScriptAspectWeaver.java	20 Feb 2004 18:48:23 -0000	1.10
  @@ -67,8 +67,11 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.cocoon.environment.Environment;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.cocoon.matching.helpers.WildcardHelper;
   
   
  @@ -116,13 +119,13 @@
    * @since Sept, 2003
    * @version CVS $Id$
    */
  -public class JavaScriptAspectWeaver extends AbstractLogEnabled {
  +public class JavaScriptAspectWeaver extends AbstractLogEnabled implements Serviceable {
       
       /** All Interceptors in the right order */
       ArrayList interceptorGroups = new ArrayList();
       
  -    /** The Cocoon environment needed for SourceResolving */
  -    Environment environement = null;
  +    /** The service manager */
  +    ServiceManager manager = null;
       
       /** If debugging is true, the intercepted script is writen to filesystem */
       boolean serializeResultScript = false;
  @@ -144,7 +147,7 @@
        * intercepting scripts) and if scripts are applied those are
        * scanned the code is added to <code>interceptorGroups</code>
        */
  -    public void setBaseScript( Source source ) throws IOException {
  +    public void setBaseScript( Source source ) throws Exception {
           
           this.source = source;
           
  @@ -202,11 +205,19 @@
        * script is added first, ...)
        */
       protected void addInterceptorGroup( String source  ) 
  -        throws IOException {
  +        throws Exception {
           
  -        this.getLogger().info( "applied script: " + source );        
  -        JSTokenList interceptorsTokensList = JSParser.parse( 
  -            readSourceIntoCharArray( this.environement.resolveURI(source).getInputStream() ) );
  +        this.getLogger().info( "applied script: " + source );
  +        SourceResolver resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
  +        Source src = resolver.resolveURI(source);
  +        JSTokenList interceptorsTokensList;
  +        try {
  +            interceptorsTokensList = JSParser.parse( 
  +                readSourceIntoCharArray( src.getInputStream() ) );
  +        } finally {
  +            resolver.release(src);
  +            this.manager.release(resolver);
  +        }
   
           InterceptionList interceptors = interceptorsTokensList.readInterceptionTokens();
           interceptors.setSourceScript( source );
  @@ -220,13 +231,6 @@
       }
       
       /**
  -     * The access to the Cocoon environemnt 
  -     */
  -    public void setEnvironment( Environment env ) {
  -        this.environement = env;
  -    }
  -
  -    /**
        * Should the JavaScriptAspectWeaver write the result script
        * into separate file in the same directory as the basescript?
        */
  @@ -1412,5 +1416,12 @@
           }
   
        }
  -        
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
  +     */
  +    public void service(ServiceManager manager) throws ServiceException
  +    {
  +        this.manager = manager;
  +    }
   }
  
  
  
  1.18      +15 -84    cocoon-2.1/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java
  
  Index: AbstractInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AbstractInterpreter.java	28 Jan 2004 05:46:21 -0000	1.17
  +++ AbstractInterpreter.java	20 Feb 2004 18:48:23 -0000	1.18
  @@ -51,9 +51,6 @@
   
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -64,17 +61,12 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.thread.SingleThreaded;
  -
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.Processor;
  -import org.apache.cocoon.components.CocoonComponentManager;
  +import org.apache.cocoon.components.ContextHelper;
  +import org.apache.cocoon.components.flow.util.PipelineUtil;
   import org.apache.cocoon.environment.Context;
  -import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.Redirector;
  -import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
  -
   import org.apache.excalibur.source.SourceUtil;
  -import org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode;
   
   /**
    * Abstract superclass for various scripting languages used by Cocoon
  @@ -88,7 +80,7 @@
    * @version CVS $Id$
    */
   public abstract class AbstractInterpreter extends AbstractLogEnabled
  -  implements Component, Composable, Serviceable, Contextualizable, Interpreter,
  +  implements Component, Serviceable, Contextualizable, Interpreter,
                SingleThreaded, Configurable, Disposable
   {
       protected org.apache.avalon.framework.context.Context avalonContext;
  @@ -99,8 +91,7 @@
       protected ArrayList needResolve = new ArrayList();
   
       protected org.apache.cocoon.environment.Context context;
  -    protected ComponentManager manager;
  -    protected ServiceManager serviceManager;
  +    protected ServiceManager manager;
       protected ContinuationsManager continuationsMgr;
       
       /**
  @@ -121,19 +112,10 @@
       }
   
       /**
  -     * Composable
  -     */
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        this.manager = manager;
  -        //mpved below in service()
  -        //this.continuationsMgr = (ContinuationsManager)manager.lookup(ContinuationsManager.ROLE);
  -    }
  -
  -    /**
        * Serviceable
        */
       public void service(ServiceManager sm) throws ServiceException {
  -        this.serviceManager = sm;
  +        this.manager = sm;
           this.continuationsMgr = (ContinuationsManager)sm.lookup(ContinuationsManager.ROLE);
       }
   
  @@ -148,7 +130,7 @@
        */
       public void dispose() {
           if ( this.manager != null ) {
  -            this.manager.release( (Component)this.continuationsMgr );
  +            this.manager.release( this.continuationsMgr );
               this.continuationsMgr = null;
               this.manager = null;
           }
  @@ -196,79 +178,28 @@
        * @param uri The URI for which the request should be generated.
        * @param biz Extra data associated with the subrequest.
        * @param out An OutputStream where the output should be written to.
  -     * @param env The environment of the original request.
  -     * @return Whatever the Cocoon processor returns (????).
        * @exception Exception If an error occurs.
        */
  -    public boolean process(String uri, Object biz, OutputStream out, Environment env)
  +    public void process(String uri, Object biz, OutputStream out)
           throws Exception 
       {
  -        if (SourceUtil.indexOfSchemeColon(uri) != -1) {
  -            throw new Exception("uri is not allowed to contain a scheme (cocoon:/ is always automatically used)");
  -        }
  -        // if the uri starts with a slash, then assume that the uri contains an absolute
  -        // path, starting from the root sitemap. Otherwise, the uri is relative to the current
  -        // sitemap.
  -        if (uri.length() > 0 && uri.charAt(0) == '/') {
  -            uri = uri.substring(1);
  -        } else {
  -            uri = env.getURIPrefix() + uri;
  -        }
  -
  -        // Create a wrapper environment for the subrequest to be processed.
  -        EnvironmentWrapper wrapper = new EnvironmentWrapper(env, uri, "", getLogger());
  -        wrapper.setURI("", uri);
  -        if (out != null) {
  -            wrapper.setOutputStream(out);
  -        }
  -        Map objectModel = env.getObjectModel();
  -        FlowHelper.setContextObject(objectModel, biz);
  -
  -        // Attermpt to start processing the wrapper environment
  -        Object key = CocoonComponentManager.startProcessing(wrapper);
  -
  -        Processor processor = null;
  -        boolean result = false;
  -        try {
  -            // Retrieve a processor instance
  -            processor = (Processor)this.manager.lookup(Processor.ROLE);
  -            
  -            // Enter the environment
  -            CocoonComponentManager.enterEnvironment(wrapper, this.manager, processor);
  -            
  -            // Process the subrequest
  -            result = processor.process(wrapper);
  -            if (out != null) {
  -                wrapper.commitResponse();
  -                out.flush();
  -            }
  -            // Return whatever the processor returned us
  -            return(result);
  -        } catch (Exception any) {
  -            throw(any);
  -        } finally {
  -            // Leave the environment, terminate processing and release processor
  -            if ( processor != null ) {
  -                // enterEnvironemnt has only been called if the
  -                // processor has been looked up
  -                CocoonComponentManager.leaveEnvironment();
  -            }
  -            CocoonComponentManager.endProcessing(wrapper, key);
  -            this.manager.release(processor);
  -        }
  +        // FIXME (SW): should we deprecate this method in favor of PipelineUtil?
  +        PipelineUtil pipeUtil = new PipelineUtil();
  +        pipeUtil.contextualize(this.avalonContext);
  +        pipeUtil.service(this.manager);
  +        pipeUtil.processToStream(uri, biz, out);
       }
   
       public void forwardTo(String uri, Object bizData,
                             WebContinuation continuation,
  -                          Environment environment)
  +                          Redirector redirector)
           throws Exception
       {
           if (SourceUtil.indexOfSchemeColon(uri) == -1) {
               uri = "cocoon:/" + uri;
  -            Map objectModel = environment.getObjectModel();
  +            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
               FlowHelper.setWebContinuation(objectModel, continuation);
               FlowHelper.setContextObject(objectModel, bizData);
  -            Redirector redirector = PipelinesNode.getRedirector(environment);
               if (redirector.hasRedirected()) {
                   throw new IllegalStateException("Pipeline has already been processed for this request");
               }
  
  
  
  1.2       +5 -5      cocoon-2.1/src/java/org/apache/cocoon/components/flow/CompilingInterpreter.java
  
  Index: CompilingInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/CompilingInterpreter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompilingInterpreter.java	15 Oct 2003 17:02:05 -0000	1.1
  +++ CompilingInterpreter.java	20 Feb 2004 18:48:23 -0000	1.2
  @@ -49,8 +49,8 @@
   import java.util.Iterator;
   import java.util.Map;
   
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.mozilla.javascript.Context;
  @@ -79,8 +79,8 @@
       /**
        * Composable
        */
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        super.compose(manager);
  +    public void service(ServiceManager manager) throws ServiceException {
  +        super.service(manager);
           this.sourceresolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
       }
   
  
  
  
  1.5       +8 -8      cocoon-2.1/src/java/org/apache/cocoon/components/flow/Interpreter.java
  
  Index: Interpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/Interpreter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Interpreter.java	15 Nov 2003 04:21:29 -0000	1.4
  +++ Interpreter.java	20 Feb 2004 18:48:23 -0000	1.5
  @@ -46,6 +46,7 @@
   package org.apache.cocoon.components.flow;
   
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.Redirector;
   
   import java.util.List;
   
  @@ -172,9 +173,9 @@
      * CallFunctionNode.Argument instances. The interpretation of the
      * parameters is left to the actual implementation of the
      * interpreter.
  -   * @param env an <code>Environment</code> value
  +   * @param redirector a <code>Redirector</code> used to call views
      */
  -  void callFunction(String funName, List params, Environment env)
  +  void callFunction(String funName, List params, Redirector redirector)
       throws Exception;
   
     /**
  @@ -185,12 +186,11 @@
      * to be made available to the forwarded pipeline
      * @param continuation a <code>WebContinuation</code>, the
      * continuation to be called to resume the processing
  -   * @param environment an <code>Environment</code>, the Cocoon environment
  -   * invocation context.
  +   * @param redirector a <code>Redirector</code> used to call views
      * @exception Exception if an error occurs
      */
     void forwardTo(String uri, Object bizData, WebContinuation continuation,
  -                 Environment environment)
  +                 Redirector redirector)
       throws Exception;
   
     /**
  @@ -206,10 +206,10 @@
      * these parameters will only become available in the language's
      * environment, if at all.
      *
  -   * @param environment an <code>Environment</code> value
  +   * @param redirector a <code>Redirector</code> used to call views
      * @exception Exception if an error occurs
      */
     void handleContinuation(String continuationId, List params,
  -                          Environment environment)
  +                          Redirector redirector)
       throws Exception;
   }
  
  
  
  1.30      +34 -54    cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java
  
  Index: FOM_Cocoon.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- FOM_Cocoon.java	10 Feb 2004 23:18:32 -0000	1.29
  +++ FOM_Cocoon.java	20 Feb 2004 18:48:23 -0000	1.30
  @@ -52,8 +52,8 @@
   
   import java.io.InputStream;
   import java.io.OutputStream;
  -import java.net.URL;
   import java.net.MalformedURLException;
  +import java.net.URL;
   import java.security.Principal;
   import java.util.ArrayList;
   import java.util.Enumeration;
  @@ -62,19 +62,18 @@
   import java.util.Locale;
   import java.util.Map;
   
  -import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.WrapperComponentManager;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.components.LifecycleHelper;
   import org.apache.cocoon.components.flow.ContinuationsManager;
   import org.apache.cocoon.components.flow.WebContinuation;
   import org.apache.cocoon.components.flow.Interpreter.Argument;
  -import org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode;
   import org.apache.cocoon.environment.Cookie;
  -import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Response;
   import org.apache.cocoon.environment.Session;
  @@ -104,8 +103,7 @@
           Context avalonContext;
           ServiceManager serviceManager;
           FOM_JavaScriptInterpreter interpreter;
  -        Environment environment;
  -        ComponentManager componentManager;
  +        Redirector redirector;
           Logger logger;
           FOM_Request request;
           FOM_Response response;
  @@ -119,17 +117,15 @@
   
           public CallContext(CallContext caller,
                              FOM_JavaScriptInterpreter interp,
  -                           Environment env,
  -                           ComponentManager manager,
  -                           ServiceManager serviceManager,
  +                           Redirector redirector,
  +                           ServiceManager manager,
                              Context avalonContext,
                              Logger logger,
                              WebContinuation lastContinuation) {
               this.caller = caller;
               this.interpreter = interp;
  -            this.environment = env;
  -            this.componentManager = manager;
  -            this.serviceManager = serviceManager;
  +            this.redirector = redirector;
  +            this.serviceManager = manager;
               this.avalonContext = avalonContext;
               this.logger = logger;
               this.lastContinuation = lastContinuation;
  @@ -167,7 +163,7 @@
               if (session != null) {
                   return session;
               }
  -            Map objectModel = environment.getObjectModel();
  +            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
               session =
                   new FOM_Session(ObjectModelHelper.getRequest(objectModel).getSession(true));
               session.setParentScope(getParentScope());
  @@ -180,7 +176,7 @@
               if (request != null) {
                   return request;
               }
  -            Map objectModel = environment.getObjectModel();
  +            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
               request = new FOM_Request(ObjectModelHelper.getRequest(objectModel));
               request.setParentScope(getParentScope());
               request.setPrototype(getClassPrototype(getParentScope(),
  @@ -192,7 +188,7 @@
               if (context != null) {
                   return context;
               }
  -            Map objectModel = getEnvironment().getObjectModel();
  +            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
               context =
                   new FOM_Context(ObjectModelHelper.getContext(objectModel));
               context.setParentScope(getParentScope());
  @@ -205,7 +201,7 @@
               if (response != null) {
                   return response;
               }
  -            Map objectModel = environment.getObjectModel();
  +            Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
               response =
                   new FOM_Response(ObjectModelHelper.getResponse(objectModel));
               response.setParentScope(getParentScope());
  @@ -255,17 +251,16 @@
       }
   
       void pushCallContext(FOM_JavaScriptInterpreter interp,
  -                         Environment env,
  -                         ComponentManager manager,
  -                         ServiceManager serviceManager,
  +                         Redirector redirector,
  +                         ServiceManager manager,
                            Context avalonContext,
                            Logger logger,
                            WebContinuation lastContinuation) {
           if (pageLocal == null) {
               pageLocal = new PageLocalScopeHolder(getTopLevelScope(this));
           }
  -        this.currentCall = new CallContext(currentCall, interp, env, manager,
  -                                           serviceManager, avalonContext,
  +        this.currentCall = new CallContext(currentCall, interp, redirector, manager,
  +                                           avalonContext,
                                              logger, lastContinuation);
       }
   
  @@ -319,18 +314,15 @@
               throw new JavaScriptException("expected a java.io.OutputStream instead of " + outputStream);
           }
           getInterpreter().process(getParentScope(), this, uri, map,
  -                                 (OutputStream)unwrap(outputStream),
  -                                 getEnvironment());
  +                                 (OutputStream)unwrap(outputStream));
       }
   
       public void jsFunction_redirectTo(String uri) throws Exception {
  -        // Cannot use environment directly as TreeProcessor uses own version of redirector
  -        // environment.redirect(false, uri);
  -        PipelinesNode.getRedirector(getEnvironment()).redirect(false, uri);
  +        this.currentCall.redirector.redirect(false, uri);
       }
   
       public void jsFunction_sendStatus(int sc) {
  -        PipelinesNode.getRedirector(getEnvironment()).sendStatus(sc);
  +        this.currentCall.redirector.sendStatus(sc);
       }
   
   /*
  @@ -360,21 +352,16 @@
        */
       public Object jsFunction_getComponent(String id)
           throws Exception {
  -        return getComponentManager().lookup(id);
  +        return getServiceManager().lookup(id);
       }
   
       /**
        * Release pooled components.
        *
  -     * @param component - an <code>Object</code> that is an instance
  -     * of <code>org.apache.avalon.framework.component.Component</code>
  +     * @param component a component
        */
       public void jsFunction_releaseComponent( Object component ) throws Exception {
  -        try {
  -            this.getComponentManager().release( (Component) unwrap(component) );
  -        } catch( ClassCastException cce ) {
  -            throw new JavaScriptException( "Only components can be released!" );
  -        }
  +        this.getServiceManager().release( unwrap(component) );
       }
   
       /**
  @@ -389,9 +376,7 @@
           org.mozilla.javascript.Context cx =
               org.mozilla.javascript.Context.getCurrentContext();
           Scriptable scope = getParentScope();
  -        Script script = getInterpreter().compileScript( cx,
  -                                                        getEnvironment(),
  -                                                        filename );
  +        Script script = getInterpreter().compileScript(cx, filename);
           return script.exec( cx, scope );
       }
   
  @@ -417,7 +402,7 @@
                this.getLogger(),
                this.getAvalonContext(),
                this.getServiceManager(),
  -             this.getComponentManager(),
  +             new WrapperComponentManager(this.getServiceManager()),
                null,// roleManager
                null,// configuration
                true);
  @@ -1487,7 +1472,7 @@
        * @return The object model
        */
       public Map getObjectModel() {
  -        return getEnvironment().getObjectModel();
  +        return ContextHelper.getObjectModel(currentCall.avalonContext);
       }
   
       /**
  @@ -1495,14 +1480,9 @@
        * @return The component manager
        */
   
  -    public ComponentManager getComponentManager() {
  -        return currentCall.componentManager;
  -    }
  -
  -
  -    private Environment getEnvironment() {
  -        return currentCall.environment;
  -    }
  +//    public ComponentManager getComponentManager() {
  +//        return currentCall.componentManager;
  +//    }
   
       private Context getAvalonContext() {
           return currentCall.avalonContext;
  @@ -1512,7 +1492,7 @@
           return currentCall.logger;
       }
   
  -    private ServiceManager getServiceManager() {
  +    public ServiceManager getServiceManager() {
           return currentCall.serviceManager;
       }
   
  @@ -1536,7 +1516,7 @@
                                      uri,
                                      bean,
                                      fom_wk,
  -                                   getEnvironment());
  +                                   this.currentCall.redirector);
       }
   
       /**
  @@ -1562,7 +1542,7 @@
                                           org.mozilla.javascript.Context.toString(getProperty(parameters, name)));
               list.add(arg);
           }
  -        getInterpreter().handleContinuation(kontId, list, getEnvironment());
  +        getInterpreter().handleContinuation(kontId, list, this.currentCall.redirector);
       }
   
       /**
  @@ -1602,7 +1582,7 @@
           WebContinuation wk;
           ContinuationsManager contMgr;
           contMgr = (ContinuationsManager)
  -            getComponentManager().lookup(ContinuationsManager.ROLE);
  +            getServiceManager().lookup(ContinuationsManager.ROLE);
           wk = contMgr.createWebContinuation(unwrap(k),
                                              (parent == null ? null : parent.getWebContinuation()),
                                              timeToLive,
  
  
  
  1.23      +43 -42    cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java
  
  Index: FOM_JavaScriptInterpreter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_JavaScriptInterpreter.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- FOM_JavaScriptInterpreter.java	13 Feb 2004 00:24:31 -0000	1.22
  +++ FOM_JavaScriptInterpreter.java	20 Feb 2004 18:48:23 -0000	1.23
  @@ -59,22 +59,23 @@
   import java.io.Reader;
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
   import java.util.Map;
  -import java.util.HashSet;
   import java.util.Set;
   import java.util.StringTokenizer;
   
   import org.apache.avalon.framework.CascadingRuntimeException;
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.components.flow.CompilingInterpreter;
   import org.apache.cocoon.components.flow.Interpreter;
   import org.apache.cocoon.components.flow.InvalidContinuationException;
  @@ -82,8 +83,8 @@
   import org.apache.cocoon.components.flow.javascript.JSErrorReporter;
   import org.apache.cocoon.components.flow.javascript.ScriptablePointerFactory;
   import org.apache.cocoon.components.flow.javascript.ScriptablePropertyHandler;
  -import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ObjectModelHelper;
  +import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   import org.apache.commons.jxpath.JXPathIntrospector;
  @@ -166,7 +167,7 @@
        * Needed to get things working with JDK 1.3. Can be removed once we
        * don't support that platform any more.
        */
  -    private ComponentManager getComponentManager() {
  +    protected ServiceManager getServiceManager() {
           return manager;
       }
   
  @@ -197,7 +198,7 @@
   
           public synchronized boolean upToDateCheck() throws Exception {
               SourceResolver sourceResolver = (SourceResolver)
  -                getComponentManager().lookup(SourceResolver.ROLE);
  +                getServiceManager().lookup(SourceResolver.ROLE);
               Iterator iter = javaSource.entrySet().iterator();
               List invalid = new LinkedList();
               while (iter.hasNext()) {
  @@ -377,18 +378,19 @@
        * @param environment an <code>Environment</code> value
        * @return a <code>Scriptable</code> value
        */
  -    private ThreadScope getSessionScope(Environment environment)
  -                    throws Exception {
  -        Map objectModel = environment.getObjectModel();
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +    private ThreadScope getSessionScope() throws Exception {
  +        Request request = ContextHelper.getRequest(this.avalonContext);
           ThreadScope scope = null;
           Session session = request.getSession(false);
           if (session != null) {
               HashMap userScopes =
                       (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
               if (userScopes != null) {
  -                String uriPrefix = environment.getURIPrefix();
  -                scope = (ThreadScope)userScopes.get(uriPrefix);
  +                // Get the scope attached to the current context
  +                Source src = this.sourceresolver.resolveURI(".");
  +                String contextPrefix = src.getURI();
  +                this.sourceresolver.release(src);
  +                scope = (ThreadScope)userScopes.get(contextPrefix);
               }
           }
           if (scope == null) {
  @@ -397,10 +399,10 @@
           return scope;
       }
   
  -    void updateSession(Environment env, Scriptable scope) throws Exception {
  +    void updateSession(Scriptable scope) throws Exception {
           ThreadScope thrScope = (ThreadScope)scope;
           if (thrScope.useSession) {
  -            setSessionScope(env, scope);
  +            setSessionScope(scope);
           }
       }
   
  @@ -412,10 +414,9 @@
        * @param environment an <code>Environment</code> value
        * @param scope a <code>Scriptable</code> value
        */
  -    private Scriptable setSessionScope(Environment environment, Scriptable scope)
  +    private Scriptable setSessionScope(Scriptable scope)
           throws Exception {
  -        Map objectModel = environment.getObjectModel();
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  +        Request request = ContextHelper.getRequest(this.avalonContext);
           Session session = request.getSession(true);
   
           HashMap userScopes = (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
  @@ -423,8 +424,11 @@
               userScopes = new HashMap();
               session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
           }
  -        String uriPrefix = environment.getURIPrefix();
  -        userScopes.put(uriPrefix, scope);
  +        // Attach the scope to the current context
  +        Source src = this.sourceresolver.resolveURI(".");
  +        String contextPrefix = src.getURI();
  +        this.sourceresolver.release(src);
  +        userScopes.put(contextPrefix, scope);
           return scope;
       }
   
  @@ -541,7 +545,7 @@
        * @param environment an <code>Environment</code> value
        * @exception Exception if an error occurs
        */
  -    private void setupContext(Environment environment, Context context,
  +    private void setupContext(Redirector redirector, Context context,
                     ThreadScope thrScope, CompilingClassLoader classLoader)
                     throws Exception {
           // Try to retrieve the scope object from the session instance. If
  @@ -568,7 +572,7 @@
           // We need to setup the FOM_Cocoon object according to the current
           // request. Everything else remains the same.
           thrScope.setupPackages(getClassLoader(needsRefresh));
  -        cocoon.pushCallContext(this, environment, manager, serviceManager,
  +        cocoon.pushCallContext(this, redirector, manager,
                                  avalonContext, getLogger(), null);
   
           // Check if we need to compile and/or execute scripts
  @@ -626,8 +630,7 @@
        * @param fileName resource uri
        * @return compiled script
        */
  -    Script compileScript(Context cx, Environment environment,
  -                         String fileName) throws Exception {
  +    Script compileScript(Context cx, String fileName) throws Exception {
           Source src = this.sourceresolver.resolveURI(fileName);
           if (src != null) {
               synchronized (compiledScripts) {
  @@ -677,17 +680,17 @@
        * @exception Exception if an error occurs
        */
       public void callFunction(String funName, List params,
  -                             Environment environment) throws Exception {
  +                             Redirector redirector) throws Exception {
           Context context = Context.enter();
           context.setOptimizationLevel(OPTIMIZATION_LEVEL);
           context.setGeneratingDebug(true);
           context.setCompileFunctionsWithDynamicScope(true);
           context.setErrorReporter(errorReporter);
           FOM_Cocoon cocoon = null;
  -        ThreadScope thrScope = getSessionScope(environment);
  +        ThreadScope thrScope = getSessionScope();
           synchronized (thrScope) {
               try {
  -                setupContext(environment, context, thrScope, classLoader);
  +                setupContext(redirector, context, thrScope, classLoader);
                   cocoon = (FOM_Cocoon)thrScope.get("cocoon", thrScope);
   
                   // Register the current scope for scripts indirectly called from this function
  @@ -739,7 +742,7 @@
                   }
                   throw new CascadingRuntimeException(ee.getMessage(), ee);
               } finally {
  -                updateSession(environment, thrScope);
  +                updateSession(thrScope);
                   if (cocoon != null) {
                       cocoon.popCallContext();
                   }
  @@ -749,7 +752,7 @@
       }
   
       public void handleContinuation(String id, List params,
  -                                   Environment environment) throws Exception
  +                                   Redirector redirector) throws Exception
       {
           WebContinuation wk = continuationsMgr.lookupWebContinuation(id);
   
  @@ -773,8 +776,8 @@
           Scriptable kScope = k.getParentScope();
           synchronized (kScope) {
               FOM_Cocoon cocoon = (FOM_Cocoon)kScope.get("cocoon", kScope);
  -            cocoon.pushCallContext(this, environment, manager,
  -                                   serviceManager, avalonContext,
  +            cocoon.pushCallContext(this, redirector, manager,
  +                                   avalonContext,
                                      getLogger(), wk);
               // Register the current scope for scripts indirectly called from this function
               cocoon.getRequest().setAttribute(
  @@ -820,7 +823,7 @@
                   }
                   throw new CascadingRuntimeException(ee.getMessage(), ee);
               } finally {
  -                updateSession(environment, kScope);
  +                updateSession(kScope);
                   cocoon.popCallContext();
                   Context.exit();
               }
  @@ -840,25 +843,23 @@
   
       public void forwardTo(Scriptable scope, FOM_Cocoon cocoon, String uri,
               Object bizData, FOM_WebContinuation fom_wk,
  -            Environment environment) throws Exception {
  -        setupView(scope, cocoon, environment, fom_wk);
  +            Redirector redirector) throws Exception {
  +        setupView(scope, cocoon, fom_wk);
           super.forwardTo(uri, bizData,
                           fom_wk == null ? null :
                              fom_wk.getWebContinuation(),
  -                        environment);
  +                        redirector);
       }
   
       // package access as this is called by FOM_Cocoon
  -    boolean process(Scriptable scope, FOM_Cocoon cocoon, String uri,
  -            Object bizData, OutputStream out,
  -            Environment environment) throws Exception {
  -        setupView(scope, cocoon, environment, null);
  -        return super.process(uri, bizData, out, environment);
  +    void process(Scriptable scope, FOM_Cocoon cocoon, String uri,
  +            Object bizData, OutputStream out) throws Exception {
  +        setupView(scope, cocoon, null);
  +        super.process(uri, bizData, out);
       }
   
  -    private void setupView(Scriptable scope, FOM_Cocoon cocoon,
  -                   Environment environment, FOM_WebContinuation kont) {
  -        Map objectModel = environment.getObjectModel();
  +    private void setupView(Scriptable scope, FOM_Cocoon cocoon, FOM_WebContinuation kont) {
  +        Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
           // Make the JS live-connect objects available to the view layer
           FOM_JavaScriptFlowHelper.setPackages(objectModel,
                  (Scriptable)ScriptableObject.getProperty(scope, "Packages"));
  
  
  
  1.6       +5 -4      cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java
  
  Index: FOM_WebContinuation.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_WebContinuation.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FOM_WebContinuation.java	28 Jan 2004 15:33:21 -0000	1.5
  +++ FOM_WebContinuation.java	20 Feb 2004 18:48:23 -0000	1.6
  @@ -54,6 +54,7 @@
   import java.util.List;
   
   import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.cocoon.components.flow.ContinuationsManager;
   import org.apache.cocoon.components.flow.WebContinuation;
   import org.mozilla.javascript.Context;
  @@ -119,7 +120,7 @@
           WebContinuation wk;
           Scriptable scope = getTopLevelScope(c);
           FOM_Cocoon cocoon = (FOM_Cocoon)getProperty(scope, "cocoon");
  -        ComponentManager componentManager =  cocoon.getComponentManager();
  +        ServiceManager componentManager =  cocoon.getServiceManager();
           ContinuationsManager contMgr = (ContinuationsManager)
               componentManager.lookup(ContinuationsManager.ROLE);
           wk = contMgr.createWebContinuation(c,
  @@ -178,8 +179,8 @@
           FOM_Cocoon cocoon =
               (FOM_Cocoon)getProperty(getTopLevelScope(this),
                                       "cocoon");
  -        ComponentManager componentManager =
  -            cocoon.getComponentManager();
  +        ServiceManager componentManager =
  +            cocoon.getServiceManager();
           contMgr = (ContinuationsManager)
               componentManager.lookup(ContinuationsManager.ROLE);
           contMgr.invalidateWebContinuation(wk);
  
  
  
  1.8       +3 -3      cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
  
  Index: CallFunctionNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CallFunctionNode.java	15 Jan 2004 00:36:18 -0000	1.7
  +++ CallFunctionNode.java	20 Feb 2004 18:48:23 -0000	1.8
  @@ -147,7 +147,7 @@
           // If the continuation id is not null, it takes precedence over
           // the function call, so we invoke it here.
           if (continuation != null && continuation.length() > 0) {
  -            interpreter.handleContinuation(continuation, params, env);
  +            interpreter.handleContinuation(continuation, params, PipelinesNode.getRedirector(env));
               return true;
           }
   
  @@ -157,7 +157,7 @@
           String name = functionName.resolve(context, env.getObjectModel());
   
           if (name != null && name.length() > 0) {
  -            interpreter.callFunction(name, params, env);
  +            interpreter.callFunction(name, params, PipelinesNode.getRedirector(env));
               return true;
           }
           
  
  
  
  1.4       +2 -5      cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ContinueNode.java
  
  Index: ContinueNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ContinueNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContinueNode.java	24 Oct 2003 13:36:40 -0000	1.3
  +++ ContinueNode.java	20 Feb 2004 18:48:23 -0000	1.4
  @@ -140,11 +140,8 @@
           // Obtain the Interpreter instance for this language
           Interpreter interpreter = (Interpreter)selector.select(language);
   
  -        // Obtain the redirector
  -        // Redirector redirector = PipelinesNode.getRedirector(env);
  -
           try {
  -            interpreter.handleContinuation(contId, params, env /*, redirector*/);
  +            interpreter.handleContinuation(contId, params, PipelinesNode.getRedirector(env));
           } finally {
               selector.release((Component)interpreter);
           }
  
  
  

Mime
View raw message