Check if Server singleton exists before trying to get the list of extensions from it.
This commit is contained in:
parent
c583133234
commit
5c9df59014
2 changed files with 37 additions and 28 deletions
|
@ -269,16 +269,18 @@ public final class Application implements IPathElement, Runnable {
|
||||||
*/
|
*/
|
||||||
public void init()
|
public void init()
|
||||||
throws DatabaseException, ScriptingException, MalformedURLException {
|
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++) {
|
for (int i = 0; i < extensions.size(); i++) {
|
||||||
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ext.applicationStarted(this);
|
ext.applicationStarted(this);
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
logEvent("couldn't init extension " + ext.getName() + ": " +
|
logEvent("couldn't init extension " + ext.getName() + ": " +
|
||||||
e.toString());
|
e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,12 +389,14 @@ public final class Application implements IPathElement, Runnable {
|
||||||
typemgr = null;
|
typemgr = null;
|
||||||
|
|
||||||
// tell the extensions that we're stopped.
|
// 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++) {
|
for (int i = 0; i < extensions.size(); i++) {
|
||||||
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
||||||
|
|
||||||
ext.applicationStopped(this);
|
ext.applicationStopped(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the sessions if wanted
|
// store the sessions if wanted
|
||||||
|
@ -1630,14 +1634,17 @@ public final class Application implements IPathElement, Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update extensions
|
// update extensions
|
||||||
Vector extensions = Server.getServer().getExtensions();
|
if (Server.getServer() != null) {
|
||||||
|
Vector extensions = Server.getServer().getExtensions();
|
||||||
|
|
||||||
for (int i = 0; i < extensions.size(); i++) {
|
for (int i = 0; i < extensions.size(); i++) {
|
||||||
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ext.applicationUpdated(this);
|
ext.applicationUpdated(this);
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
|
logEvent("Error updating extension "+ext+": "+e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,20 +92,22 @@ public class RhinoEngine implements ScriptingEngine {
|
||||||
// context.putThreadLocal ("engine", this);
|
// context.putThreadLocal ("engine", this);
|
||||||
extensionGlobals = new HashMap();
|
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++) {
|
for (int i = 0; i < extVec.size(); i++) {
|
||||||
HelmaExtension ext = (HelmaExtension) extVec.get(i);
|
HelmaExtension ext = (HelmaExtension) extVec.get(i);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HashMap tmpGlobals = ext.initScripting(app, this);
|
HashMap tmpGlobals = ext.initScripting(app, this);
|
||||||
|
|
||||||
if (tmpGlobals != null) {
|
if (tmpGlobals != null) {
|
||||||
extensionGlobals.putAll(tmpGlobals);
|
extensionGlobals.putAll(tmpGlobals);
|
||||||
}
|
}
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
app.logEvent("Couldn't initialize extension " + ext.getName() + ": " +
|
app.logEvent("Couldn't initialize extension " + ext.getName() + ": " +
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue