basic test run working, next step incorporating into db-layer
[mir.git] / source / mir / storage / store / ObjectStore.java
index 5c55482..0bf8dbd 100755 (executable)
@@ -55,12 +55,16 @@ public class ObjectStore {
         *                StoreIdentifier sid is found.
         */
        public StorableObject use(StoreIdentifier sid) {
-               StorableObject storeObject=null;
-               StoreContainer stoc = getStoreContainerForSid( sid );
-               if (stoc!=null) storeObject=stoc.use(sid);
-    else System.out.println("Warning: container not found for: " + sid.toString());
-               if (storeObject==null) storeMiss++; else storeHit++;
-               return storeObject;
+    if (sid!=null ) {
+      StorableObject storeObject=null;
+      StoreContainer stoc = getStoreContainerForSid( sid );
+      if (stoc!=null) storeObject=stoc.use(sid);
+      else System.out.println("Warning: container not found for: " + sid.toString());
+      if (storeObject!=null) storeHit++;
+                 return storeObject;
+    }
+    storeMiss++; return null;
+
        }
 
        /**
@@ -119,17 +123,29 @@ public class ObjectStore {
         *                sto and invalidates all relevant cache entries.
         */
 
-       public void invalidate(StorableObject sto) {
+       public void invalidate(StoreIdentifier sid) {
                // propagate invalidation to StoreContainer
-               if (sto!=null) {
-                       StoreIdentifier sid = sto.getStoreIdentifier();
-                       if (sto!=null) {
-                               StoreContainer stoc = getStoreContainerForSid(sid);
-                               stoc.invalidate(sto);
-                       }
+               if (sid!=null) {
+      StoreContainer stoc = getStoreContainerForSid(sid);
+      stoc.invalidate(sid);
                }
        }
 
+  /**
+   *  Method:       invalidate(StoreContainerType)
+   *  Description:  serves to invalidate a whole StoreContainer
+   *
+   *  @return
+   */
+  public void invalidate(StoreContainerType stoc_type) {
+    if ( stoc_type != null ) {
+      StoreContainer stoc = getStoreContainerForStocType(stoc_type);
+      if ( stoc!=null )
+        stoc.invalidate();
+    }
+
+  }
+
        // internal methods for StoreContainer managment
 
        /**
@@ -143,12 +159,17 @@ public class ObjectStore {
                // find apropriate container for a specific sid
                if (sid!=null) {
                        StoreContainerType stoc_type = sid.getStoreContainerType();
-                       if ( containerMap.containsKey(stoc_type) )
-                               return (StoreContainer)containerMap.get(stoc_type);
+                       return getStoreContainerForStocType(stoc_type);
                }
                return null;
        }
 
+  private StoreContainer getStoreContainerForStocType(StoreContainerType stoc_type) {
+    if ( stoc_type!=null && containerMap.containsKey(stoc_type) )
+                               return (StoreContainer)containerMap.get(stoc_type);
+    return null;
+  }
+
        /**
         *  Method:       implementsStorableObject
         *  Description:  internall helper method to find out if a class implements
@@ -181,5 +202,5 @@ public class ObjectStore {
         *
         *  @return       String
         */
-       private String version() { return "00.d4";}
+       private String version() { return "00.d5";}
 }
\ No newline at end of file