now using MirPropertiesConfiguration
authoridfx <idfx>
Sun, 15 Jun 2003 22:58:00 +0000 (22:58 +0000)
committeridfx <idfx>
Sun, 15 Jun 2003 22:58:00 +0000 (22:58 +0000)
source/default.properties
source/mir/storage/store/ObjectStore.java
source/mir/storage/store/StoreContainer.java
source/mir/storage/store/StoreContainerType.java

index ef6d5bf..3f92e20 100755 (executable)
@@ -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
index f84206d..72b3400 100755 (executable)
@@ -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.
index dafe141..9ad70f7 100755 (executable)
@@ -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);
     }
index 4f913c3..9443e08 100755 (executable)
@@ -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() {