From 5c9df59014ee462231f2f8c3e95193d40dff7b98 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 18 Aug 2003 14:50:18 +0000 Subject: [PATCH] Check if Server singleton exists before trying to get the list of extensions from it. --- src/helma/framework/core/Application.java | 43 +++++++++++++--------- src/helma/scripting/rhino/RhinoEngine.java | 22 ++++++----- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index d5dd0a0d..76a22bf4 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -269,16 +269,18 @@ public final class Application implements IPathElement, Runnable { */ public void init() throws DatabaseException, ScriptingException, MalformedURLException { - Vector extensions = Server.getServer().getExtensions(); + if (Server.getServer() != null) { + Vector extensions = Server.getServer().getExtensions(); - for (int i = 0; i < extensions.size(); i++) { - HelmaExtension ext = (HelmaExtension) extensions.get(i); + for (int i = 0; i < extensions.size(); i++) { + HelmaExtension ext = (HelmaExtension) extensions.get(i); - try { - ext.applicationStarted(this); - } catch (ConfigurationException e) { - logEvent("couldn't init extension " + ext.getName() + ": " + - e.toString()); + try { + ext.applicationStarted(this); + } catch (ConfigurationException e) { + logEvent("couldn't init extension " + ext.getName() + ": " + + e.toString()); + } } } @@ -387,12 +389,14 @@ public final class Application implements IPathElement, Runnable { typemgr = null; // tell the extensions that we're stopped. - Vector extensions = Server.getServer().getExtensions(); + if (Server.getServer() != null) { + Vector extensions = Server.getServer().getExtensions(); - for (int i = 0; i < extensions.size(); i++) { - HelmaExtension ext = (HelmaExtension) extensions.get(i); + for (int i = 0; i < extensions.size(); i++) { + HelmaExtension ext = (HelmaExtension) extensions.get(i); - ext.applicationStopped(this); + ext.applicationStopped(this); + } } // store the sessions if wanted @@ -1630,14 +1634,17 @@ public final class Application implements IPathElement, Runnable { } // update extensions - Vector extensions = Server.getServer().getExtensions(); + if (Server.getServer() != null) { + Vector extensions = Server.getServer().getExtensions(); - for (int i = 0; i < extensions.size(); i++) { - HelmaExtension ext = (HelmaExtension) extensions.get(i); + for (int i = 0; i < extensions.size(); i++) { + HelmaExtension ext = (HelmaExtension) extensions.get(i); - try { - ext.applicationUpdated(this); - } catch (ConfigurationException e) { + try { + ext.applicationUpdated(this); + } catch (ConfigurationException e) { + logEvent("Error updating extension "+ext+": "+e); + } } } diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index afe2982b..b9634282 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -92,20 +92,22 @@ public class RhinoEngine implements ScriptingEngine { // context.putThreadLocal ("engine", this); extensionGlobals = new HashMap(); - Vector extVec = Server.getServer().getExtensions(); + if (Server.getServer() != null) { + Vector extVec = Server.getServer().getExtensions(); - for (int i = 0; i < extVec.size(); i++) { - HelmaExtension ext = (HelmaExtension) extVec.get(i); + for (int i = 0; i < extVec.size(); i++) { + HelmaExtension ext = (HelmaExtension) extVec.get(i); - try { - HashMap tmpGlobals = ext.initScripting(app, this); + try { + HashMap tmpGlobals = ext.initScripting(app, this); - if (tmpGlobals != null) { - extensionGlobals.putAll(tmpGlobals); - } - } catch (ConfigurationException e) { - app.logEvent("Couldn't initialize extension " + ext.getName() + ": " + + if (tmpGlobals != null) { + extensionGlobals.putAll(tmpGlobals); + } + } catch (ConfigurationException e) { + app.logEvent("Couldn't initialize extension " + ext.getName() + ": " + e.getMessage()); + } } }