Check if Server singleton exists before trying to get the list of extensions from it.

This commit is contained in:
hns 2003-08-18 14:50:18 +00:00
parent c583133234
commit 5c9df59014
2 changed files with 37 additions and 28 deletions

View file

@ -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);
}
}
}

View file

@ -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());
}
}
}