ovidiu 2002/08/16 18:14:18
Modified: src/java/org/apache/cocoon/components/flow
AbstractInterpreter.java
Log:
Moved the reading of scripts in the JavaScriptInterpreter class,
because it became too specific to it.
Revision Changes Path
1.6 +20 -107
xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java
Index: AbstractInterpreter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractInterpreter.java 31 Jul 2002 13:13:22 -0000 1.5
+++ AbstractInterpreter.java 17 Aug 2002 01:14:18 -0000 1.6
@@ -42,32 +42,31 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
*/
package org.apache.cocoon.components.flow;
-import java.lang.System;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
import java.util.Iterator;
-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.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.components.source.SourceFactory;
-import org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode;
-import org.apache.cocoon.environment.Context;
-import org.apache.cocoon.environment.Environment;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.lang.System;
+import java.io.InputStream;
+
+import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.ForwardRedirector;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode;
+import org.apache.cocoon.components.source.SourceFactory;
+import org.apache.cocoon.Constants;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.component.Component;
/**
* Abstract superclass for various scripting languages used by Cocoon
@@ -83,21 +82,10 @@
implements Component, Composable, Contextualizable, Interpreter, ThreadSafe
{
/**
- * Hash table of source locations -> ScriptSource instances
- */
- protected HashMap scripts = new HashMap();
-
- /**
* List of source locations that need to be resolved.
*/
protected ArrayList needResolve = new ArrayList();
- /**
- * When was the last time we checked for script modifications. Used
- * only if {@link #reloadScripts} is true.
- */
- protected long lastTimeCheck = 0;
-
protected org.apache.cocoon.environment.Context context;
protected ComponentManager manager;
protected ContinuationsManager continuationsMgr;
@@ -174,81 +162,6 @@
synchronized(this) {
needResolve.add(source);
}
- }
-
- /**
- * Unregister the source file. Called from <code>ScriptNode</code>
- * when a tree corresponding to a sitemap is decommissioned.
- *
- * @param source a <code>String</code> value
- */
- public void unregister(String source)
- {
- synchronized(this) {
- scripts.remove(source);
- int index = needResolve.indexOf(source);
- if (index != -1)
- needResolve.remove(index);
- }
- }
-
- /**
- * Reloads any modified script files.
- *
- * <p>It checks to see if any of the files already read in (those
- * present in the <code>scripts</code> hash map) have been
- * modified.
- *
- * <p>It also checks to see if any script files have been registered
- * with the interpreter since the last call to
- * <code>checkForModifiedScripts</code>. These files are stored in
- * the temporary array <code>needResolve</code>. If any such files
- * are found, they are read in.
- *
- * @param environment an <code>Environment</code> value
- */
- public void checkForModifiedScripts(Environment environment)
- throws Exception
- {
- if (reloadScripts
- && System.currentTimeMillis() >= lastTimeCheck + checkTime) {
- // FIXME: should we worry about synchronization?
- Iterator iter = scripts.values().iterator();
- while (iter.hasNext()) {
- ScriptSource src = (ScriptSource)iter.next();
- if (src.getLastModified() > lastTimeCheck) {
- try {
- src.refresh(environment);
- }
- catch (Exception ex) {
- System.out.println("Error reading script " + src.getSourceName()
- + ", ignoring!");
- }
- }
- }
- }
-
- // FIXME: remove the need for synchronization
- synchronized (this) {
- int size = needResolve.size();
- for (int i = 0; i < size; i++) {
- String source = (String)needResolve.get(0);
- ScriptSource src = new ScriptSource(this, source);
- scripts.put(source, src);
- needResolve.remove(0);
- try {
- src.refresh(environment);
- }
- catch (Exception ex) {
- System.out.println("Error reading script " + source + ", ignoring!");
- }
- }
- }
-
- // Update the time of the last check. If an exception occurs, this
- // is not executed, so the next request will force a reparse of
- // the script files because of an old time stamp.
- lastTimeCheck = System.currentTimeMillis();
}
public void forwardTo(String uri, Object bizData,
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]