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

(backport from main trunk (helma 1.3))
This commit is contained in:
hns 2003-08-19 14:19:36 +00:00
parent 1e609f3ec6
commit 90439a58d9
2 changed files with 36 additions and 28 deletions

View file

@ -259,16 +259,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());
}
}
}
@ -377,12 +379,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
@ -1590,14 +1594,16 @@ 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) {
}
}
}

View file

@ -116,20 +116,22 @@ public class FesiEngine implements ScriptingEngine {
// load extensions defined in server.properties:
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);
if (tmpGlobals != null) {
extensionGlobals.putAll(tmpGlobals);
}
} catch (ConfigurationException e) {
app.logEvent("Couldn't initialize extension " + ext.getName() + ": " +
e.getMessage());
}
} catch (ConfigurationException e) {
app.logEvent("Couldn't initialize extension " + ext.getName() + ": " +
e.getMessage());
}
}