From 23a1e10672276ea4dfe813a11623b0c1bc9fb226 Mon Sep 17 00:00:00 2001 From: idfx Date: Sun, 15 Jun 2003 22:58:00 +0000 Subject: [PATCH] now using MirPropertiesConfiguration --- source/default.properties | 5 ++++ source/mir/storage/store/ObjectStore.java | 38 +----------------------- source/mir/storage/store/StoreContainer.java | 12 ++++++-- source/mir/storage/store/StoreContainerType.java | 13 +++++++- 4 files changed, 28 insertions(+), 40 deletions(-) diff --git a/source/default.properties b/source/default.properties index ef6d5bf6..3f92e207 100755 --- a/source/default.properties +++ b/source/default.properties @@ -511,3 +511,8 @@ Producer.ExtLinkName=extlink.gif Producer.IntLinkName=intlink.gif Producer.MailLinkName=maillink.gif +#objectstore +StoreContainer.EntityDefaultSize=45 +StoreContainer.EntityListDefaultSize=15 +StorableObjectEntity.Entity.DefaultSize=5000 +StorableObjectEntity.EntityList.DefaultSize=400 diff --git a/source/mir/storage/store/ObjectStore.java b/source/mir/storage/store/ObjectStore.java index f84206df..72b3400e 100755 --- a/source/mir/storage/store/ObjectStore.java +++ b/source/mir/storage/store/ObjectStore.java @@ -59,17 +59,12 @@ package mir.storage.store; * @version 1.0 */ -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.MissingResourceException; -import java.util.Properties; import javax.servlet.http.HttpServletRequest; -import mir.config.MirPropertiesConfiguration; import mir.log.LoggerWrapper; public class ObjectStore { @@ -77,28 +72,10 @@ public class ObjectStore { private final static ObjectStore INSTANCE = new ObjectStore(); private final static Map containerMap = new HashMap(); // StoreContainerType/StoreContainer private static long storeHit = 0, storeMiss = 0; - private Properties ostoreConf; private LoggerWrapper logger; private ObjectStore() { - String confName = null; - - logger = new LoggerWrapper("Database.ObjectStore"); - Properties conf = new Properties(); - - try { - confName = - MirPropertiesConfiguration.instance().getString("Home") + - "etc/objectstore.properties"; - conf.load(new BufferedInputStream(new FileInputStream(confName))); - } - catch (java.io.FileNotFoundException fnfe) { - logger.error("could not read config file. not found: " + confName); - } - catch (Throwable t) { - logger.error("could not get config: " + t.getMessage()); - } - ostoreConf = conf; + logger = new LoggerWrapper("Database"); } public static ObjectStore getInstance() { @@ -213,19 +190,6 @@ public class ObjectStore { return (stoc != null && stoc.has(sid)) ? true : false; } - public String getConfProperty(String name) { - if (name != null) { - String returnValue = ""; - try { - return ostoreConf.getProperty(name); - } - catch (MissingResourceException e) { - logger.error("getConfProperty: " + e.toString()); - } - } - return null; - } - /** * Method: toString() * Description: Displays statistical information about the ObjectStore. diff --git a/source/mir/storage/store/StoreContainer.java b/source/mir/storage/store/StoreContainer.java index dafe1419..9ad70f70 100755 --- a/source/mir/storage/store/StoreContainer.java +++ b/source/mir/storage/store/StoreContainer.java @@ -50,6 +50,8 @@ import java.util.ListIterator; import javax.servlet.http.HttpServletRequest; +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; import mir.log.LoggerWrapper; import mir.misc.StringUtil; @@ -64,7 +66,8 @@ public class StoreContainer { private int hitCount = 0, missCount = 0; private static ObjectStore o_store = ObjectStore.getInstance(); - protected LoggerWrapper logger = new LoggerWrapper("Database.ObjectStore"); + protected LoggerWrapper logger = new LoggerWrapper("Database"); + private MirPropertiesConfiguration configuration; // avoid construction without parameters private StoreContainer() {}; @@ -74,9 +77,14 @@ public class StoreContainer { this.uniqueId = ++uniqueCounter; this.stocType = stoc_type; this.container = new LinkedList(); + try { + configuration = MirPropertiesConfiguration.instance(); + } catch (PropertiesConfigExc e) { + e.printStackTrace(logger.asPrintWriter(LoggerWrapper.ERROR_MESSAGE)); + } int defaultSize = stoc_type.getDefaultSize(); String confProperty = stoc_type.getConfPrefix() + ".DefaultSize"; - String confedSize = o_store.getConfProperty(confProperty); + String confedSize = configuration.getString(confProperty); if (confedSize != null) { this.maxSize = StringUtil.parseInt(confedSize, defaultSize); } diff --git a/source/mir/storage/store/StoreContainerType.java b/source/mir/storage/store/StoreContainerType.java index 4f913c3e..9443e084 100755 --- a/source/mir/storage/store/StoreContainerType.java +++ b/source/mir/storage/store/StoreContainerType.java @@ -47,6 +47,9 @@ package mir.storage.store; import java.util.HashMap; import java.util.Map; +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; +import mir.log.LoggerWrapper; import mir.misc.StringUtil; public class StoreContainerType { @@ -60,6 +63,8 @@ public class StoreContainerType { private static ObjectStore o_store = ObjectStore.getInstance(); private Class stocClass = null; private int stocType = STOC_TYPE_UNKNOWN; + private MirPropertiesConfiguration configuration; + private LoggerWrapper logger; static { uniqueTypes[STOC_TYPE_ENTITY] = new HashMap(); @@ -71,6 +76,12 @@ public class StoreContainerType { private StoreContainerType(Class stocClass, int stocType) { this.stocClass = stocClass; this.stocType = stocType; + logger = new LoggerWrapper("Database"); + try { + configuration = MirPropertiesConfiguration.instance(); + } catch (PropertiesConfigExc e) { + e.printStackTrace(logger.asPrintWriter(LoggerWrapper.ERROR_MESSAGE)); + } } public static StoreContainerType valueOf(Class stoc_class, int stoc_type) { @@ -104,7 +115,7 @@ public class StoreContainerType { String confProperty = "StoreContainer." + stringForStoreType(stocType) + ".DefaultSize"; return - StringUtil.parseInt(o_store.getConfProperty(confProperty), 10); + StringUtil.parseInt(configuration.getString(confProperty), 10); } public String toString() { -- 2.11.0