From 11257b476519072746f2c611772a3382ce9b05f0 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 23 Mar 2005 12:32:50 +0000 Subject: [PATCH] * Make TypeManager.createPrototypes() and TypeManager.checkPrototypes() throw IOException * Propagate IOException in the callers of the above methods --- src/helma/framework/core/Application.java | 6 +++++- src/helma/framework/core/TypeManager.java | 22 ++++++++-------------- src/helma/scripting/ScriptingEngine.java | 2 +- src/helma/scripting/rhino/RhinoCore.java | 2 +- src/helma/scripting/rhino/RhinoEngine.java | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 436911b5..70f41238 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -277,7 +277,11 @@ public final class Application implements IPathElement, Runnable { // create and init type mananger typemgr = new TypeManager(this); - typemgr.createPrototypes(); + try { + typemgr.createPrototypes(); + } catch (Exception x) { + logError("Error creating prototypes", x); + } // set the context classloader. Note that this must be done before // using the logging framework so that a new LogFactory gets created diff --git a/src/helma/framework/core/TypeManager.java b/src/helma/framework/core/TypeManager.java index eafb1b70..bc10748b 100644 --- a/src/helma/framework/core/TypeManager.java +++ b/src/helma/framework/core/TypeManager.java @@ -94,14 +94,14 @@ public final class TypeManager { * Run through application's prototype directories and create prototypes, but don't * compile or evaluate any scripts. */ - public void createPrototypes() { + public void createPrototypes() throws IOException { // create standard prototypes. for (int i = 0; i < standardTypes.length; i++) { createPrototype(standardTypes[i], null); } // loop through directories and create prototypes - checkFiles(); + checkRepositories(); } /** @@ -109,14 +109,12 @@ public final class TypeManager { * has been updated. * If so, update prototypes and scripts. */ - public synchronized void checkPrototypes() { + public synchronized void checkPrototypes() throws IOException { if ((System.currentTimeMillis() - lastCheck) < 1000L) { return; } - try { - checkFiles(); - } catch (Exception ignore) {} + checkRepositories(); lastCheck = System.currentTimeMillis(); } @@ -162,17 +160,13 @@ public final class TypeManager { * Run through application's prototype sources and check if * there are any prototypes to be created. */ - private void checkFiles() { + private void checkRepositories() throws IOException { // check if any files have been created/removed since last time we checked... for (int i = 0; i < repositories.length; i++) { - try { - if (repositories[i].lastModified() > modified[i]) { - modified[i] = repositories[i].lastModified(); + if (repositories[i].lastModified() > modified[i]) { + modified[i] = repositories[i].lastModified(); - checkRepository(repositories[i]); - } - } catch (IOException iox) { - iox.printStackTrace(); + checkRepository(repositories[i]); } } diff --git a/src/helma/scripting/ScriptingEngine.java b/src/helma/scripting/ScriptingEngine.java index aecf5ab9..b59e082c 100644 --- a/src/helma/scripting/ScriptingEngine.java +++ b/src/helma/scripting/ScriptingEngine.java @@ -61,7 +61,7 @@ public interface ScriptingEngine { * evaluation is entered to let the Engine know it should update * its prototype information */ - public void updatePrototypes(); + public void updatePrototypes() throws IOException, ScriptingException; /** * This method is called when an execution context for a request diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java index f66acf5e..381dcd32 100644 --- a/src/helma/scripting/rhino/RhinoCore.java +++ b/src/helma/scripting/rhino/RhinoCore.java @@ -310,7 +310,7 @@ public final class RhinoCore implements ScopeProvider { * here is to check for update those prototypes which already have been compiled * before. Others will be updated/compiled on demand. */ - public synchronized void updatePrototypes() { + public synchronized void updatePrototypes() throws IOException { if ((System.currentTimeMillis() - lastUpdate) < 1000L) { return; } diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index 19aa4dbe..c0440c49 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -149,7 +149,7 @@ public class RhinoEngine implements ScriptingEngine { * This method is called before an execution context is entered to let the * engine know it should update its prototype information. */ - public void updatePrototypes() { + public void updatePrototypes() throws IOException { context = Context.enter(); context.setCompileFunctionsWithDynamicScope(true); context.setApplicationClassLoader(app.getClassLoader());