From 4e073785ab9828b81bc5b01d0bd51c42dac5c4d8 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 25 Oct 2004 18:27:42 +0000 Subject: [PATCH] * Added NodeManager.init() to separate initialization from the constructor. * Added ObjectCache.shutdown() to allow object caches to be closed. * Catch exceptions and errors thrown by NodeChangeListeners. --- src/helma/framework/core/Application.java | 3 +- src/helma/objectmodel/ObjectCache.java | 5 ++++ src/helma/objectmodel/db/NodeManager.java | 35 ++++++++++++++--------- src/helma/util/CacheMap.java | 6 ++++ 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/helma/framework/core/Application.java b/src/helma/framework/core/Application.java index 77a66d2a..6499f4c1 100644 --- a/src/helma/framework/core/Application.java +++ b/src/helma/framework/core/Application.java @@ -359,7 +359,8 @@ public final class Application implements IPathElement, Runnable { userRootMapping.update(); // create the node manager - nmgr = new NodeManager(this, dbDir.getAbsolutePath(), props); + nmgr = new NodeManager(this); + nmgr.init(dbDir.getAbsolutePath(), props); // reset the classloader to the parent/system/server classloader. Thread.currentThread().setContextClassLoader(typemgr.getClassLoader().getParent()); diff --git a/src/helma/objectmodel/ObjectCache.java b/src/helma/objectmodel/ObjectCache.java index d19a2205..375a92e8 100644 --- a/src/helma/objectmodel/ObjectCache.java +++ b/src/helma/objectmodel/ObjectCache.java @@ -33,6 +33,11 @@ public interface ObjectCache { */ void init(Application app); + /** + * Called when the application holding the cache is stopped. + */ + void shutdown(); + /** * Called when the application's properties have been updated to let * the cache implementation update its settings. diff --git a/src/helma/objectmodel/db/NodeManager.java b/src/helma/objectmodel/db/NodeManager.java index 055d9c46..c929d711 100644 --- a/src/helma/objectmodel/db/NodeManager.java +++ b/src/helma/objectmodel/db/NodeManager.java @@ -47,21 +47,26 @@ public final class NodeManager { public final WrappedNodeManager safe; /** - * Create a new NodeManager for Application app. An embedded database will be + * Create a new NodeManager for Application app. + */ + public NodeManager(Application app) { + this.app = app; + safe = new WrappedNodeManager(this); + } + + /** + * Initialize the NodeManager for the given dbHome and + * application properties. An embedded database will be * created in dbHome if one doesn't already exist. */ - public NodeManager(Application app, String dbHome, Properties props) + public void init(String dbHome, Properties props) throws DatabaseException, ClassNotFoundException, IllegalAccessException, InstantiationException { - this.app = app; - String cacheImpl = props.getProperty("cacheimpl", "helma.util.CacheMap"); cache = (ObjectCache) Class.forName(cacheImpl).newInstance(); cache.init(app); - safe = new WrappedNodeManager(this); - logSql = "true".equalsIgnoreCase(props.getProperty("logsql")); logReplication = "true".equalsIgnoreCase(props.getProperty("logReplication")); @@ -162,17 +167,15 @@ public final class NodeManager { } /** - * Shut down this node manager. This is called when the application using this - * node manager is stopped. + * Shut down this node manager. This is called when the application + * using this node manager is stopped. */ public void shutdown() throws DatabaseException { db.shutdown(); if (cache != null) { - synchronized (cache) { - cache.clear(); - cache = null; - } + cache.shutdown(); + cache = null; } } @@ -1830,7 +1833,13 @@ public final class NodeManager { int l = listeners.size(); for (int i=0; i