cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-07-07 Thread sylvain
sylvain 2004/07/06 22:56:04

  Modified:src/java/org/apache/cocoon/components/flow
AbstractInterpreter.java
   src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Replace getSitemapPath() by getInterpreterID() to distinguish user value 
scopes as several sitemaps can be mounted on the same path
  
  Revision  ChangesPath
  1.22  +30 -1 
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AbstractInterpreter.java  26 May 2004 01:31:06 -  1.21
  +++ AbstractInterpreter.java  7 Jul 2004 05:56:04 -   1.22
  @@ -44,6 +44,12 @@
* reload script files if they get modified (useful when doing
* development), and passing the control to Cocoon's sitemap for
* result page generation.
  + * 
  + * Flow intrepreters belonging to different sitemaps should be isolated. To 
achieve this,
  + * class implements the [EMAIL PROTECTED] 
org.apache.avalon.framework.thread.SingleThreaded}. Since
  + * the sitemap engine looks up the flow intepreter once at sitemap build 
time, this ensures
  + * that each sitemap will use a different instance of this class. But that 
instance will
  + * handle all flow calls for a given sitemap, and must therefore be thread 
safe.
*
* @author mailto:[EMAIL PROTECTED]">Ovidiu Predescu
* @since March 15, 2002
  @@ -53,6 +59,12 @@
 implements Component, Serviceable, Contextualizable, Interpreter,
SingleThreaded, Configurable, Disposable
   {
  +// The instance counters, used to produce unique IDs 
  +private static int instanceCounter = 0;
  +
  +// The instance ID of this interpreter, used to identify user scopes
  +private String instanceID;
  +
   protected org.apache.avalon.framework.context.Context avalonContext;
   
   /**
  @@ -75,6 +87,23 @@
* through the "check-time" XML attribute in flow.xmap.
*/
   protected long checkTime;
  +
  +public AbstractInterpreter() {
  +synchronized(AbstractInterpreter.class) {
  +instanceCounter++;
  +this.instanceID = String.valueOf(instanceCounter);
  +}
  +}
  +
  +/**
  + * Get the unique ID for this interpreter, which can be used to 
distinguish user value scopes
  + * attached to the session.
  + * 
  + * @return a unique ID for this interpreter
  + */
  +protected String getInterpreterID() {
  +return this.instanceID;
  +}
   
   public void configure(Configuration config) throws 
ConfigurationException {
   reloadScripts = 
config.getChild("reload-scripts").getValueAsBoolean(false);
  
  
  
  1.31  +3 -12 
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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- FOM_JavaScriptInterpreter.java17 May 2004 18:39:58 -  1.30
  +++ FOM_JavaScriptInterpreter.java7 Jul 2004 05:56:04 -   1.31
  @@ -351,7 +351,7 @@
   (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
   if (userScopes != null) {
   // Get the scope attached to the current context
  -scope = (ThreadScope)userScopes.get(getSitemapPath());
  +scope = (ThreadScope)userScopes.get(getInterpreterID());
   }
   }
   if (scope == null) {
  @@ -388,7 +388,7 @@
   }
   
   // Attach the scope to the current context
  -userScopes.put(getSitemapPath(), scope);
  +userScopes.put(getInterpreterID(), scope);
   } catch (IllegalStateException e) {
   // Session might be invalidated already.
   if (getLogger().isDebugEnabled()) {
  @@ -396,15 +396,6 @@
   }
   }
   return scope;
  -}
  -
  -private String getSitemapPath() throws Exception {
  -Source src = this.sourceresolver.resolveURI(".");
  -try {
  -return src.getURI();
  -} finally {
  -this.sourceresolver.release(src);
  -}
   }
   
   public static class ThreadScope extends ScriptableObject {
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-05-17 Thread vgritsenko
vgritsenko2004/05/17 11:39:58

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Replace check for session with try/catch block
  
  Revision  ChangesPath
  1.30  +8 -3  
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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- FOM_JavaScriptInterpreter.java5 May 2004 17:08:05 -   1.29
  +++ FOM_JavaScriptInterpreter.java17 May 2004 18:39:58 -  1.30
  @@ -377,8 +377,8 @@
   private Scriptable setSessionScope(Scriptable scope) throws Exception {
   Request request = ContextHelper.getRequest(this.avalonContext);
   
  -// Check that session is available (avoids IllegalStateException)
  -if (request.isRequestedSessionIdValid()) {
  +// FIXME: Where "session scope" should go when session is 
invalidated?
  +try {
   Session session = request.getSession(true);
   
   HashMap userScopes = 
(HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
  @@ -389,6 +389,11 @@
   
   // Attach the scope to the current context
   userScopes.put(getSitemapPath(), scope);
  +} catch (IllegalStateException e) {
  +// Session might be invalidated already.
  +if (getLogger().isDebugEnabled()) {
  +getLogger().debug("Got '" + e + "' while trying to set 
session scope.", e);
  +}
   }
   return scope;
   }
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-05-05 Thread vgritsenko
vgritsenko2004/05/05 10:08:05

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Check for valid session. Fixes exception running in Tomcat:
  ERROR   (2004-05-05) 12:06.15:469   [sitemap.handled-errors] 
(/cc/samples/blocks/slide/logout.do) http8080-Processor5/PipelineNode: Cannot 
create a session after the response has been committed
  java.lang.IllegalStateException: Cannot create a session after the response 
has been committed
at 
org.apache.coyote.tomcat5.CoyoteRequest.doGetSession(CoyoteRequest.java:2281)
  
  Revision  ChangesPath
  1.29  +13 -9 
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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- FOM_JavaScriptInterpreter.java5 May 2004 16:00:11 -   1.28
  +++ FOM_JavaScriptInterpreter.java5 May 2004 17:08:05 -   1.29
  @@ -376,16 +376,20 @@
*/
   private Scriptable setSessionScope(Scriptable scope) throws Exception {
   Request request = ContextHelper.getRequest(this.avalonContext);
  -Session session = request.getSession(true);
   
  -HashMap userScopes = 
(HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
  -if (userScopes == null) {
  -userScopes = new HashMap();
  -session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
  -}
  +// Check that session is available (avoids IllegalStateException)
  +if (request.isRequestedSessionIdValid()) {
  +Session session = request.getSession(true);
  +
  +HashMap userScopes = 
(HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
  +if (userScopes == null) {
  +userScopes = new HashMap();
  +session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
  +}
   
  -// Attach the scope to the current context
  -userScopes.put(getSitemapPath(), scope);
  +// Attach the scope to the current context
  +userScopes.put(getSitemapPath(), scope);
  +}
   return scope;
   }
   
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-05-05 Thread vgritsenko
vgritsenko2004/05/05 09:00:11

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Refactor duplicate code into the method, javadoc fixes.
  
  Revision  ChangesPath
  1.28  +39 -41
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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- FOM_JavaScriptInterpreter.java25 Apr 2004 12:12:08 -  1.27
  +++ FOM_JavaScriptInterpreter.java5 May 2004 16:00:11 -   1.28
  @@ -1,12 +1,12 @@
   /*
* Copyright 1999-2004 The Apache Software Foundation.
  - * 
  + *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
  - * 
  + *
*  http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -338,11 +338,8 @@
   
   /**
* Returns the JavaScript scope, a Scriptable object, from the user
  - * session instance. Each URI prefix, as returned by the [EMAIL 
PROTECTED]
  - * org.apache.cocoon.environment.Environment#getURIPrefix} method,
  - * can have a scope associated with it.
  + * session instance. Each sitemap can have a scope associated with it.
*
  - * @param environment an Environment value
* @return a Scriptable value
*/
   private ThreadScope getSessionScope() throws Exception {
  @@ -354,10 +351,7 @@
   (HashMap)session.getAttribute(USER_GLOBAL_SCOPE);
   if (userScopes != null) {
   // 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);
  +scope = (ThreadScope)userScopes.get(getSitemapPath());
   }
   }
   if (scope == null) {
  @@ -374,15 +368,13 @@
   }
   
   /**
  - * Associates a JavaScript scope, a Scriptable object, with the URI
  - * prefix of the current sitemap, as returned by the [EMAIL PROTECTED]
  - * org.apache.cocoon.environment.Environment#getURIPrefix} method.
  + * Associates a JavaScript scope, a Scriptable object, with the
  + * directory path of the current sitemap, as resolved by the
  + * source resolver.
*
  - * @param environment an Environment value
* @param scope a Scriptable value
*/
  -private Scriptable setSessionScope(Scriptable scope)
  -throws Exception {
  +private Scriptable setSessionScope(Scriptable scope) throws Exception {
   Request request = ContextHelper.getRequest(this.avalonContext);
   Session session = request.getSession(true);
   
  @@ -391,16 +383,22 @@
   userScopes = new HashMap();
   session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
   }
  +
   // Attach the scope to the current context
  -Source src = this.sourceresolver.resolveURI(".");
  -String contextPrefix = src.getURI();
  -this.sourceresolver.release(src);
  -userScopes.put(contextPrefix, scope);
  +userScopes.put(getSitemapPath(), scope);
   return scope;
   }
   
  -public static class ThreadScope extends ScriptableObject {
  +private String getSitemapPath() throws Exception {
  +Source src = this.sourceresolver.resolveURI(".");
  +try {
  +return src.getURI();
  +} finally {
  +this.sourceresolver.release(src);
  +}
  +}
   
  +public static class ThreadScope extends ScriptableObject {
   static final String[] builtinPackages = {"javax", "org", "com"};
   
   ClassLoader classLoader;
  @@ -513,7 +511,6 @@
* newly create Scriptable object in the user's session, where it
* will be retrieved from at the next invocation of [EMAIL PROTECTED] 
#callFunction}.
*
  - * @param environment an Environment value
* @exception Exception if an error occurs
*/
   private void setupContext(Redirector redirector, Context context,
  @@ -658,18 +655,19 @@
   context.setGeneratingDebug(true);
   context.setCompileFunctionsWithDynamicScope(true);
   c

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-04-24 Thread coliver
coliver 2004/04/24 10:38:32

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Set up the thread context class loader to be the compiling class loader if 
reload-scripts is on: this will allow java code (called from a flowscript) that 
does its own dynamic class loading to have access to your source classes
  
  Revision  ChangesPath
  1.26  +120 -99   
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- FOM_JavaScriptInterpreter.java5 Mar 2004 13:02:46 -   1.25
  +++ FOM_JavaScriptInterpreter.java24 Apr 2004 17:38:32 -  1.26
  @@ -116,7 +116,9 @@
   Global scope;
   
   CompilingClassLoader classLoader;
  +
   MyClassRepository javaClassRepository = new MyClassRepository();
  +
   String[] javaSourcePath;
   
   /**
  @@ -467,6 +469,10 @@
   }
   }
   }
  +
  +public ClassLoader getClassLoader() {
  +return classLoader;
  +}
   }
   
   private ThreadScope createThreadScope() throws Exception {
  @@ -511,8 +517,8 @@
* @exception Exception if an error occurs
*/
   private void setupContext(Redirector redirector, Context context,
  -  ThreadScope thrScope, CompilingClassLoader classLoader)
  -  throws Exception {
  +  ThreadScope thrScope)
  +throws Exception {
   // Try to retrieve the scope object from the session instance. If
   // no scope is found, we create a new one, but don't place it in
   // the session.
  @@ -536,7 +542,9 @@
   }
   // We need to setup the FOM_Cocoon object according to the current
   // request. Everything else remains the same.
  -thrScope.setupPackages(getClassLoader(needsRefresh));
  +ClassLoader classLoader = getClassLoader(needsRefresh);
  +Thread.currentThread().setContextClassLoader(classLoader);
  +thrScope.setupPackages(classLoader);
   cocoon.pushCallContext(this, redirector, manager,
  avalonContext, getLogger(), null);
   
  @@ -653,64 +661,69 @@
   FOM_Cocoon cocoon = null;
   ThreadScope thrScope = getSessionScope();
   synchronized (thrScope) {
  +ClassLoader savedClassLoader = 
  +Thread.currentThread().getContextClassLoader();
   try {
  -setupContext(redirector, context, thrScope, classLoader);
  -cocoon = (FOM_Cocoon)thrScope.get("cocoon", thrScope);
  -
  -// Register the current scope for scripts indirectly called 
from this function
  -cocoon.getRequest().setAttribute(
  -FOM_JavaScriptFlowHelper.FOM_SCOPE, thrScope);
  -if (enableDebugger) {
  -if (!getDebugger().isVisible()) {
  -// only raise the debugger window if it isn't 
already visible
  -getDebugger().setVisible(true);
  +try {
  +setupContext(redirector, context, thrScope);
  +cocoon = (FOM_Cocoon)thrScope.get("cocoon", thrScope);
  +
  +// Register the current scope for scripts indirectly 
called from this function
  +cocoon.getRequest().setAttribute(
  + 
FOM_JavaScriptFlowHelper.FOM_SCOPE, thrScope);
  +if (enableDebugger) {
  +if (!getDebugger().isVisible()) {
  +// only raise the debugger window if it isn't 
already visible
  +getDebugger().setVisible(true);
  +}
   }
  -}
  -int size = (params != null ? params.size() : 0);
  -Object[] funArgs = new Object[size];
  -Scriptable parameters = context.newObject(thrScope);
  -for (int i = 0; i < size; i++) {
  -Interpreter.Argument arg = 
(Interpreter.Argument)params.get(i);
  -funArgs[i] = arg.value;
  -if (arg.name == null) {
  -arg.name = "";
  +int size = (params != null ? params.size() : 0);
  +Object[] funArgs = new Object[size];
  +Scriptable parameters = context.newObject(thrScope);
  +   

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-02-24 Thread joerg
joerg   2004/02/24 02:33:34

  Modified:src/java/org/apache/cocoon/environment/wrapper
MutableEnvironmentFacade.java
   
src/blocks/scratchpad/java/org/apache/cocoon/components/flow/javascript/fom
AO_FOM_JavaScriptInterpreter.java
   src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  fixed javadoc warnings
  
  Revision  ChangesPath
  1.5   +2 -2  
cocoon-2.1/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
  
  Index: MutableEnvironmentFacade.java
  ===
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MutableEnvironmentFacade.java 29 Oct 2003 14:39:08 -  1.4
  +++ MutableEnvironmentFacade.java 24 Feb 2004 10:33:32 -  1.5
  @@ -70,7 +70,7 @@
* SitemapSource.
* 
* @see org.apache.cocoon.components.source.impl.SitemapSource
  - * @see 
org.apache.cocoon.components.treeprocessor.TreeProcessor#handleCocoonRedirect(String,
 Environment, InvokeContext)
  + * @see 
org.apache.cocoon.components.treeprocessor.TreeProcessor#handleCocoonRedirect(String,
 Environment, org.apache.cocoon.components.treeprocessor.InvokeContext)
*
* @author http://www.apache.org/~sylvain/";>Sylvain Wallez
* @version CVS $Id$
  
  
  
  1.8   +2 -3  
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AO_FOM_JavaScriptInterpreter.java 20 Feb 2004 18:48:23 -  1.7
  +++ AO_FOM_JavaScriptInterpreter.java 24 Feb 2004 10:33:33 -  1.8
  @@ -551,7 +551,6 @@
* Compile filename as JavaScript code
* 
* @param cx Rhino context
  - * @param environment source resolver
* @param fileName resource uri
* @return compiled script
*/
  @@ -615,7 +614,7 @@
*
* @param funName a String value
* @param params a List value
  - * @param environment an Environment value
  + * @param redirector
* @exception Exception if an error occurs
*/
   public void callFunction(String funName, List params,
  
  
  
  1.24  +2 -3  
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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- FOM_JavaScriptInterpreter.java20 Feb 2004 18:48:23 -  1.23
  +++ FOM_JavaScriptInterpreter.java24 Feb 2004 10:33:33 -  1.24
  @@ -626,7 +626,6 @@
* Compile filename as JavaScript code
*
* @param cx Rhino context
  - * @param environment source resolver
* @param fileName resource uri
* @return compiled script
*/
  @@ -676,7 +675,7 @@
*
* @param funName a String value
* @param params a List value
  - * @param environment an Environment value
  + * @param redirector
* @exception Exception if an error occurs
*/
   public void callFunction(String funName, List params,
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-02-13 Thread vgritsenko
vgritsenko2004/02/12 16:24:31

  Modified:src/java/org/apache/cocoon/generation
JXTemplateGenerator.java
   src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Removed: src/java/org/apache/cocoon/components/flow/javascript
JSCocoon.java JSGlobal.java JSLog.java
JSWebContinuation.java JavaScriptFlow.java
JavaScriptInterpreter.java system.js
  Log:
  Remove non-FOM flow classes and system.js
  
  Revision  ChangesPath
  1.37  +23 -22
cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- JXTemplateGenerator.java  5 Feb 2004 19:32:18 -   1.36
  +++ JXTemplateGenerator.java  13 Feb 2004 00:24:31 -  1.37
  @@ -78,7 +78,6 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.flow.FlowHelper;
   import org.apache.cocoon.components.flow.WebContinuation;
  -import org.apache.cocoon.components.flow.javascript.JavaScriptFlow;
   import 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -974,7 +973,7 @@
   location, exc);
   } catch (Error err) {
   throw new SAXParseException(errorPrefix + err.getMessage(),
  -location, 
  +location,
   new ErrorHolder(err));
   }
   }
  @@ -1257,7 +1256,7 @@
   throw new 
SAXParseException(err.getMessage(),
   
this.location,
   new 
ErrorHolder(err));
  -
  +
   }
   substitutions.add(new Expression(str,

compiledExpression));
  @@ -2884,7 +2883,7 @@
   }
   cocoon.put("context",
  FOM_JavaScriptFlowHelper.getFOM_Context(objectModel));
  -cocoon.put("continuation", 
  +cocoon.put("continuation",
  
FOM_JavaScriptFlowHelper.getFOM_WebContinuation(objectModel));
   cocoon.put("parameters", Parameters.toProperties(parameters));
   this.variables = new MyVariables(cocoon, contextObject, kont, 
request,
  @@ -2909,8 +2908,8 @@
   // FIXME (VG): Is this required (what it's used for - examples)?
   // Here I use Rhino's live-connect objects to allow Jexl to call
   // java constructors
  -Object javaPkg = JavaScriptFlow.getJavaPackage(objectModel);
  -Object pkgs = JavaScriptFlow.getPackages(objectModel);
  +Object javaPkg = 
FOM_JavaScriptFlowHelper.getJavaPackage(objectModel);
  +Object pkgs = FOM_JavaScriptFlowHelper.getPackages(objectModel);
   map.put("java", javaPkg);
   map.put("Packages", pkgs);
   }
  @@ -2986,7 +2985,7 @@
   event.location, e);
   } catch (Error err) {
   throw new SAXParseException(err.getMessage(),
  -event.location, 
  +event.location,
   new ErrorHolder(err));
   }
   }
  @@ -3082,9 +3081,11 @@
   }
   }
   */
  +
   private void executeDOM(final XMLConsumer consumer,
  -MyJexlContext jexlContext, JXPathContext jxpathContext,
  -Node node) throws SAXException {
  +MyJexlContext jexlContext,
  +JXPathContext jxpathContext,
  +Node node) throws SAXException {
   DOMStreamer streamer = new DOMStreamer(consumer);
   streamer.stream(node);
  }
  @@ -3196,7 +3197,7 @@
   ev.location, e);
   } catch (Error err) {
   throw new SAXParseException(err.getMessage(),
  -ev.location, 
  + 

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-02-11 Thread coliver
coliver 2004/02/11 10:15:29

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Ensure complete recompilation of compilation unit containing inner classes
  
  Revision  ChangesPath
  1.21  +25 -12
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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- FOM_JavaScriptInterpreter.java31 Jan 2004 16:50:56 -  1.20
  +++ FOM_JavaScriptInterpreter.java11 Feb 2004 18:15:29 -  1.21
  @@ -63,6 +63,8 @@
   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;
  @@ -179,7 +181,13 @@
   byte[] contents) {
   javaSource.put(src.getURI(), src.getValidity());
   javaClass.put(className, contents);
  -sourceToClass.put(src.getURI(), className);
  +String uri = src.getURI();
  +Set set = (Set)sourceToClass.get(uri);
  +if (set == null) {
  +set = new HashSet();
  +sourceToClass.put(uri, set);
  +}
  +set.add(className);
   classToSource.put(className, src.getURI());
   }
   
  @@ -217,11 +225,16 @@
   iter = invalid.iterator();
   while (iter.hasNext()) {
   String uri = (String)iter.next();
  -String className = (String)sourceToClass.get(uri);
  -sourceToClass.remove(className);
  -javaClass.remove(className);
  +Set set = (Set)sourceToClass.get(uri);
  +Iterator ii = set.iterator();
  +while (ii.hasNext()) {
  +String className = (String)ii.next();
  +sourceToClass.remove(className);
  +javaClass.remove(className);
  +classToSource.remove(className);
  +}
  +set.clear();
   javaSource.remove(uri);
  -classToSource.remove(className);
   }
   return invalid.size() == 0;
   }
  @@ -332,15 +345,15 @@
   classLoader.addSourceListener(
   new CompilingClassLoader.SourceListener() {
   public void sourceCompiled(Source src) {
  -// no action
  +// no action
   }
   
   public void sourceCompilationError(Source src,
  -String errMsg) {
  -throw Context.reportRuntimeError(
  -ToolErrorReporter.getMessage(
  -"msg.uncaughtJSException",
  -errMsg));
  +   String 
errMsg) {
  +
  +if (src != null) {
  +throw Context.reportRuntimeError(errMsg);
  +}
   }
   });
   updateSourcePath();
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-01-31 Thread bruno
bruno   2004/01/31 08:50:56

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Fix JDK 1.3 runtime errors (NoSuchMethodError on referencing protected
  member from parent of outer class)
  
  Revision  ChangesPath
  1.20  +11 -2 
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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FOM_JavaScriptInterpreter.java19 Jan 2004 17:53:38 -  1.19
  +++ FOM_JavaScriptInterpreter.java31 Jan 2004 16:50:56 -  1.20
  @@ -66,6 +66,7 @@
   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;
  @@ -159,6 +160,14 @@
   JSErrorReporter errorReporter;
   boolean enableDebugger = false;
   
  +/**
  + * Needed to get things working with JDK 1.3. Can be removed once we
  + * don't support that platform any more.
  + */
  +private ComponentManager getComponentManager() {
  +return manager;
  +}
  +
   class MyClassRepository implements CompilingClassLoader.ClassRepository {
   
   Map javaSource = new HashMap();
  @@ -180,7 +189,7 @@
   
   public synchronized boolean upToDateCheck() throws Exception {
   SourceResolver sourceResolver = (SourceResolver)
  -manager.lookup(SourceResolver.ROLE);
  +getComponentManager().lookup(SourceResolver.ROLE);
   Iterator iter = javaSource.entrySet().iterator();
   List invalid = new LinkedList();
   while (iter.hasNext()) {
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2004-01-06 Thread joerg
joerg   2004/01/06 04:37:21

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  removed unused local variable
  
  Revision  ChangesPath
  1.18  +1 -2  
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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FOM_JavaScriptInterpreter.java31 Dec 2003 08:47:37 -  1.17
  +++ FOM_JavaScriptInterpreter.java6 Jan 2004 12:37:21 -   1.18
  @@ -455,7 +455,6 @@
   }
   String s = ((NativeJavaClass) cl).getClassObject().getName();
   String n = s.substring(s.lastIndexOf('.')+1);
  -Object val = thisObj.get(n, thisObj);
   thisObj.put(n, thisObj, cl);
   }
   }
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2003-12-31 Thread antonio
antonio 2003/12/31 00:47:37

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Formatting code
  
  Revision  ChangesPath
  1.17  +145 -176  
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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FOM_JavaScriptInterpreter.java29 Dec 2003 17:51:38 -  1.16
  +++ FOM_JavaScriptInterpreter.java31 Dec 2003 08:47:37 -  1.17
  @@ -50,6 +50,8 @@
   */
   package org.apache.cocoon.components.flow.javascript.fom;
   
  +import java.awt.Dimension;
  +import java.awt.Toolkit;
   import java.io.BufferedReader;
   import java.io.InputStream;
   import java.io.InputStreamReader;
  @@ -101,6 +103,7 @@
   import org.mozilla.javascript.Wrapper;
   import org.mozilla.javascript.continuations.Continuation;
   import org.mozilla.javascript.tools.ToolErrorReporter;
  +import org.mozilla.javascript.tools.debugger.Main;
   import org.mozilla.javascript.tools.shell.Global;
   
   /**
  @@ -112,8 +115,7 @@
* @version CVS $Id$
*/
   public class FOM_JavaScriptInterpreter extends CompilingInterpreter
  -implements Configurable, Initializable
  -{
  +implements Configurable, Initializable {
   
   /**
* LAST_EXEC_TIME
  @@ -158,15 +160,14 @@
   boolean enableDebugger = false;
   
   class MyClassRepository implements CompilingClassLoader.ClassRepository {
  -
  +
   Map javaSource = new HashMap();
   Map javaClass = new HashMap();
   Map sourceToClass = new HashMap();
   Map classToSource = new HashMap();
   
  -public synchronized void addCompiledClass(String className,
  -  Source src,
  -  byte[] contents) {
  +public synchronized void addCompiledClass(String className, Source 
src,
  +byte[] contents) {
   javaSource.put(src.getURI(), src.getValidity());
   javaClass.put(className, contents);
   sourceToClass.put(src.getURI(), className);
  @@ -221,15 +222,13 @@
* JavaScript debugger: there's only one of these: it can debug multiple
* threads executing JS code.
*/
  -static org.mozilla.javascript.tools.debugger.Main debugger;
  +static Main debugger;
   
  -static synchronized org.mozilla.javascript.tools.debugger.Main 
getDebugger() {
  +static synchronized Main getDebugger() {
   if (debugger == null) {
  -final org.mozilla.javascript.tools.debugger.Main db
  -= new org.mozilla.javascript.tools.debugger.Main("Cocoon 
Flow Debugger");
  +final Main db = new Main("Cocoon Flow Debugger");
   db.pack();
  -java.awt.Dimension size =
  -java.awt.Toolkit.getDefaultToolkit().getScreenSize();
  +Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
   size.width *= 0.75;
   size.height *= 0.75;
   db.setSize(size);
  @@ -246,9 +245,7 @@
   return debugger;
   }
   
  -public void configure(Configuration config)
  -throws ConfigurationException
  -{
  +public void configure(Configuration config) throws 
ConfigurationException {
   super.configure(config);
   
   String loadOnStartup
  @@ -257,36 +254,31 @@
   register(loadOnStartup);
   }
   
  -String debugger
  -= config.getChild("debugger").getValue(null);
  +String debugger = config.getChild("debugger").getValue(null);
   if ("enabled".equalsIgnoreCase(debugger)) {
   enableDebugger = true;
   }
   
   if (reloadScripts) {
  -String classPath 
  -= config.getChild("classpath").getValue(null);
  +String classPath = config.getChild("classpath").getValue(null);
   synchronized (javaClassRepository) {
  -if (classPath == null) {
  -javaSourcePath = new String[]{""};
  -} else {
  -StringTokenizer izer = 
  -new StringTokenizer(classPath, ";");
  +if (classPath != null) {
  +StringTokenizer izer = new StringTokenizer(classPath, 
";");
   int i = 0;
  -javaSourcePath = new String[izer.countTokens()+ 1];
  +javaSourcePath = new String[izer.countTokens() + 1];
   javaSourcePath[javaSourcePath.length - 

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2003-09-24 Thread sylvain
sylvain 2003/09/24 13:38:09

  Modified:src/java/org/apache/cocoon/components/flow/javascript
JavaScriptInterpreter.java
   src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Always close script sources
  
  Revision  ChangesPath
  1.21  +10 -6 
cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java
  
  Index: JavaScriptInterpreter.java
  ===
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JavaScriptInterpreter.java18 May 2003 16:36:40 -  1.20
  +++ JavaScriptInterpreter.java24 Sep 2003 20:38:09 -  1.21
  @@ -524,11 +524,15 @@
   if (is == null) {
   throw new ResourceNotFoundException(src.getURI() + ": not 
found");
   }
  -Reader reader = new BufferedReader(new InputStreamReader(is));
  -Script compiledScript = cx.compileReader(scope, reader,
  - src.getURI(),
  - 1, null);
  -return compiledScript;
  +try {
  +Reader reader = new BufferedReader(new InputStreamReader(is));
  +Script compiledScript = cx.compileReader(scope, reader,
  + src.getURI(),
  + 1, null);
  +return compiledScript;
  +} finally {
  +is.close();
  +}
   }
   
   /**
  
  
  
  1.9   +10 -6 
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FOM_JavaScriptInterpreter.java23 Sep 2003 22:46:44 -  1.8
  +++ FOM_JavaScriptInterpreter.java24 Sep 2003 20:38:09 -  1.9
  @@ -493,11 +493,15 @@
   if (is == null) {
   throw new ResourceNotFoundException(src.getURI() + ": not 
found");
   }
  -Reader reader = new BufferedReader(new InputStreamReader(is));
  -Script compiledScript = cx.compileReader(scope, reader,
  - src.getURI(),
  - 1, null);
  -return compiledScript;
  +try {
  +Reader reader = new BufferedReader(new InputStreamReader(is));
  +Script compiledScript = cx.compileReader(scope, reader,
  + src.getURI(),
  + 1, null);
  +return compiledScript;
  +} finally {
  +is.close();
  +}
   }
   
   /**
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2003-08-14 Thread sylvain
sylvain 2003/08/14 14:48:40

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  Fix NPE occuring when a script source does not exist
  
  Revision  ChangesPath
  1.7   +2 -2  
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FOM_JavaScriptInterpreter.java6 Aug 2003 15:37:18 -   1.6
  +++ FOM_JavaScriptInterpreter.java14 Aug 2003 21:48:40 -  1.7
  @@ -576,7 +576,7 @@
   throw new CascadingRuntimeException(ee.getMessage(), ee);
   } finally {
   updateSession(environment, thrScope);
  -cocoon.invalidate();
  +if (cocoon != null) cocoon.invalidate();
   Context.exit();
   }
   }
  
  
  


cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow/javascript/fom FOM_JavaScriptInterpreter.java

2003-08-06 Thread bruno
bruno   2003/08/06 08:37:19

  Modified:src/java/org/apache/cocoon/components/flow/javascript/fom
FOM_JavaScriptInterpreter.java
  Log:
  fixed javadoc error
  
  Revision  ChangesPath
  1.6   +1 -2  
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FOM_JavaScriptInterpreter.java20 Jul 2003 21:28:26 -  1.5
  +++ FOM_JavaScriptInterpreter.java6 Aug 2003 15:37:18 -   1.6
  @@ -383,7 +383,6 @@
* will be retrieved from at the next invocation of [EMAIL PROTECTED] 
#callFunction}.
*
* @param environment an Environment value
  - * @return a Scriptable value
* @exception Exception if an error occurs
*/
   private void setupContext(Environment environment,