starting to test object store
authorrk <rk>
Thu, 21 Feb 2002 19:23:24 +0000 (19:23 +0000)
committerrk <rk>
Thu, 21 Feb 2002 19:23:24 +0000 (19:23 +0000)
source/mir/servlet/ServletModuleDispatch.java
source/mir/storage/store/ObjectStore.java
source/mir/storage/store/StoreContainer.java
source/mir/storage/store/StoreContainerType.java
source/mir/storage/store/StoreIdentifier.java
source/mir/storage/store/test/EntityC1.java [new file with mode: 0755]
source/mir/storage/store/test/TestStore.java [new file with mode: 0755]

index 76570e0..ee84259 100755 (executable)
@@ -16,67 +16,68 @@ import  mir.misc.*;
  */
 public final class ServletModuleDispatch {
 
-  static Logfile theLog;
+       private static Logfile theLog;
+       private static final    Class[] SIGNATURE =
+                                                                                                               { HttpServletRequest.class, HttpServletResponse.class };
 
-  static {
-    theLog = Logfile.getInstance("/tmp/smod.dispatch");
-  }
 
-  /**
-   * privater Konstruktor, um versehentliche Instantiierung zu verhindern
-   */
-  private ServletModuleDispatch () {
-  }
+       static {
+               theLog = Logfile.getInstance("/tmp/smod.dispatch");
+       }
 
-  /**
-   *  Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
-   *  mit dem per HttpServletRequest angegebenen Paramter <code>do</code> auf.
-   *  Ist kein Parameter angegeben, so wird versucht, in die <code>defaultAction</code>
-   *  des ServletModules zu springen.
-   *
-   * @param req Http-Request, das vom Dispatcher an die Methode des
-   *    ServletModules durchgereicht wird
-   * @param res Http-Response, die vom Dispatcher an die Methode des
-   *    ServletModules durchgereicht wird
-   * @param sMod ServletModule, an das dispatched wird.
-   * @param mod Name des Modules als String (für Logfile)
-   */
+       /**
+        * privater Konstruktor, um versehentliche Instantiierung zu verhindern
+        */
+       private ServletModuleDispatch () {
+       }
 
-  public static void dispatch(ServletModule sMod, HttpServletRequest req,
-    HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
-  {
-      //sMod.predeliver(req,res);
+       /**
+        *  Die Dispatch-Routine ruft das von dem Hauptservlet kommende ServletModule
+        *  mit dem per HttpServletRequest angegebenen Paramter <code>do</code> auf.
+        *  Ist kein Parameter angegeben, so wird versucht, in die <code>defaultAction</code>
+        *  des ServletModules zu springen.
+        *
+        * @param req Http-Request, das vom Dispatcher an die Methode des
+        *    ServletModules durchgereicht wird
+        * @param res Http-Response, die vom Dispatcher an die Methode des
+        *    ServletModules durchgereicht wird
+        * @param sMod ServletModule, an das dispatched wird.
+        * @param mod Name des Modules als String (für Logfile)
+        */
 
-      String doParam = req.getParameter("do");
-      theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam);
-      if (doParam == null) {
-        if (sMod.defaultAction() != null) doParam = sMod.defaultAction();
-        else throw new ServletModuleException("no parameter do supplied!");
-      }
+       public static void dispatch(ServletModule sMod, HttpServletRequest req,
+               HttpServletResponse res) throws ServletModuleException, ServletModuleUserException
+       {
+                       //sMod.predeliver(req,res);
 
-      Class[] params= { HttpServletRequest.class, HttpServletResponse.class};
+                       String doParam = req.getParameter("do");
+                       theLog.printInfo("SerletModuleDispatch: " + sMod.toString() + " with method " + doParam);
+                       if (doParam == null) {
+                               if (sMod.defaultAction() != null) doParam = sMod.defaultAction();
+                               else throw new ServletModuleException("no parameter do supplied!");
+                       }
 
-      try {
-        Method method = sMod.getClass().getMethod(doParam,params);
-        if (method != null) {
-          method.invoke(sMod,new Object[] {req,res} );
-          return;
-        }
-        else theLog.printDebugInfo("method lookup unsuccesful");
-      }
-      catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
-      catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
-      catch ( InvocationTargetException e) {
-        if (e.getTargetException().getClass().getName().equals("mir.servlet.ServletModuleUserException")) {
-            throw new ServletModuleUserException(((ServletModuleUserException)e.getTargetException()).getMsg());
-        } else {
-            e.printStackTrace();
-            throw new ServletModuleException(e.getTargetException().toString());
-        }
-      }
-      catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
-      //catch ( ServletModuleException e ) { throw new ServletModuleException(e.toString()); }
+                       try {
+                               Method method = sMod.getClass().getMethod(doParam,SIGNATURE);
+                               if (method != null) {
+                                       method.invoke(sMod,new Object[] {req,res} );
+                                       return;
+                               }
+                               else theLog.printDebugInfo("method lookup unsuccesful");
+                       }
+                       catch ( NoSuchMethodException e) { throw new ServletModuleException("no such method!" + e.toString());}
+                       catch ( SecurityException e) { throw new ServletModuleException("method not allowed!" + e.toString());}
+                       catch ( InvocationTargetException e) {
+                               if (e.getTargetException().getClass().getName().equals("mir.servlet.ServletModuleUserException")) {
+                                               throw new ServletModuleUserException(((ServletModuleUserException)e.getTargetException()).getMsg());
+                               } else {
+                                               e.printStackTrace();
+                                               throw new ServletModuleException(e.getTargetException().toString());
+                               }
+                       }
+                       catch ( IllegalAccessException e) { throw new ServletModuleException("illegal method not allowed!" + e.toString());}
 
-      throw new ServletModuleException("delivery failed! -- ");
-  }
+                       //hopefully we don't get here ...
+                       throw new ServletModuleException("delivery failed! -- ");
+       }
 }
index 86f2c4a..844ad1a 100755 (executable)
@@ -35,145 +35,145 @@ import mir.misc.Logfile;
 
 public class ObjectStore {
 
-  private static ObjectStore    INSTANCE=new ObjectStore();
-  private static HashMap        containerMap=new HashMap(); // StoreContainerType/StoreContainer
-  private static Logfile        storeLog;
-  private static long           storeHit=0,storeMiss=0;
-  private static Class          storableObjectInterface=StorableObject.class;
-
-  private ObjectStore() {
-  }
-  public static ObjectStore getInstance() { return INSTANCE; }
-
-
-  /**
-   *  Method:       use
-   *  Description:  The ObjectStore tries to find the @see StoreIdentifier sid
-   *                and returns the stored Object.
-   *
-   *  @return       StorableObject is null when no StorableObject for the
-   *                StoreIdentifier sid is found.
-   */
-  public StorableObject use(StoreIdentifier sid) {
-    StorableObject storeObject=null;
-    StoreContainer stoc = getStoreContainerForSid( sid );
-    if (stoc!=null) storeObject=stoc.use(sid);
-    if (storeObject==null) storeMiss++; else storeHit++;
-    return storeObject;
-  }
-
-  /**
-   *  Method:       add
-   *  Description:  A StoreIdentifier is added to the ObjectStore, if it
-   *                contains a reference to a @see StorableObject.
-   */
-  public void add(StoreIdentifier sid) {
-    if ( sid!=null && sid.hasReference() ) {
-      // find the right StoreContainer for sid
-      StoreContainer stoc = getStoreContainerForSid(sid);
-      if (stoc==null) {
-        // we have to make new StoreContainer
-        StoreContainerType stocType = sid.getStoreContainerType();
-        stoc = new StoreContainer(stocType);
-        containerMap.put(stocType, stoc);
-      }
-      stoc.add(sid);
-    }
-  }
-
-  /**
-   *  Method:       toString()
-   *  Description:  Displays statistical information about the ObjectStore.
-   *                Further information is gathered from all @see StoreContainer
-   *
-   *  @return       String
-   */
-  public String toString() {
-
-    StringBuffer sb = new StringBuffer("Mir-ObjectStore v_");
-    sb.append(version()).append("\n");
-    sb.append("\nObjectStore hits  : ").append(storeHit);
-    sb.append("\nObjectStore misses: ").append(storeMiss);
-    sb.append("\nCurrently ").append(containerMap.size());
-    sb.append("\nStoreContainer in use - listing information:\n");
-
-    // ask container for information
-    StoreContainer currentStoc;
-    for(Iterator it=containerMap.keySet().iterator();it.hasNext();) {
-      currentStoc=(StoreContainer)it.next();
-      sb.append(currentStoc.toString());
-    }
-
-    return sb.toString();
-  }
-
-  /**
-   *  Method:       invalidate(StorableObject sto)
-   *  Description:  ObjectStore is notified of change of a @see StorableObject
-   *                sto and invalidates all relevant cache entries.
-   */
-
-  public void invalidate(StorableObject sto) {
-    // propagate invalidation to StoreContainer
-    if (sto!=null) {
-      StoreIdentifier sid = sto.getStoreIdentifier();
-      if (sto!=null) {
-        StoreContainer stoc = getStoreContainerForSid(sid);
-        stoc.invalidate(sto);
-      }
-    }
-  }
-
-  // internal methods for StoreContainer managment
-
-  /**
-   *  Method:       getStoreContainerForSid
-   *  Description:  private method to find the right @see StoreContainer for
-   *                the @see StoreIdentifier sid.
-   *
-   *  @return       StoreContainer is null when no Container is found.
-   */
-  private StoreContainer getStoreContainerForSid(StoreIdentifier sid){
-    // 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 null;
-  }
-
-  /**
-   *  Method:       implementsStorableObject
-   *  Description:  internall helper method to find out if a class implements
-   *                interface StorableObject.
-   *
-   *  @return       true if yes, otherwise no.
-   */
-  private final static boolean implementsStorableObject(Class aClass) {
-    if (aClass!=null) {
-      Class[] interfaces = aClass.getInterfaces();
-      if (interfaces.length>0) {
-        for (int i=0;i<interfaces.length;i++) {
-          if (interfaces[i]==storableObjectInterface) return true;
-        }
-      }
-    }
-    return false;
-  }
-
-
-  private boolean has(StoreIdentifier sid) {
-    StoreContainer stoc = getStoreContainerForSid( sid );
-    return ( stoc != null && stoc.has(sid) ) ? true:false;
-  }
-
-
-  /**
-   *  Method:       version()
-   *  Description:  returns ObjectStore version as String
-   *
-   *  @return       String
-   */
-  private String version() { return "prototype_daytwo";}
+       private static ObjectStore    INSTANCE=new ObjectStore();
+       private static HashMap        containerMap=new HashMap(); // StoreContainerType/StoreContainer
+       private static Logfile        storeLog;
+       private static long           storeHit=0,storeMiss=0;
+       private static Class          storableObjectInterface=StorableObject.class;
+
+       private ObjectStore() {
+       }
+       public static ObjectStore getInstance() { return INSTANCE; }
+
+
+       /**
+        *  Method:       use
+        *  Description:  The ObjectStore tries to find the @see StoreIdentifier sid
+        *                and returns the stored Object.
+        *
+        *  @return       StorableObject is null when no StorableObject for the
+        *                StoreIdentifier sid is found.
+        */
+       public StorableObject use(StoreIdentifier sid) {
+               StorableObject storeObject=null;
+               StoreContainer stoc = getStoreContainerForSid( sid );
+               if (stoc!=null) storeObject=stoc.use(sid);
+               if (storeObject==null) storeMiss++; else storeHit++;
+               return storeObject;
+       }
+
+       /**
+        *  Method:       add
+        *  Description:  A StoreIdentifier is added to the ObjectStore, if it
+        *                contains a reference to a @see StorableObject.
+        */
+       public void add(StoreIdentifier sid) {
+               if ( sid!=null && sid.hasReference() ) {
+                       // find the right StoreContainer for sid
+                       StoreContainer stoc = getStoreContainerForSid(sid);
+                       if (stoc==null) {
+                               // we have to make new StoreContainer
+                               StoreContainerType stocType = sid.getStoreContainerType();
+                               stoc = new StoreContainer(stocType);
+                               containerMap.put(stocType, stoc);
+                       }
+                       stoc.add(sid);
+               }
+       }
+
+       /**
+        *  Method:       toString()
+        *  Description:  Displays statistical information about the ObjectStore.
+        *                Further information is gathered from all @see StoreContainer
+        *
+        *  @return       String
+        */
+       public String toString() {
+
+               StringBuffer sb = new StringBuffer("Mir-ObjectStore v_");
+               sb.append(version()).append("\n");
+               sb.append("\nObjectStore hits/misses: ").append(storeHit);
+               sb.append("/").append(storeMiss);
+               sb.append("\nCurrently ").append(containerMap.size());
+               sb.append(" StoreContainer in use - listing information:\n");
+
+               // ask container for information
+               StoreContainer currentStoc;
+               for(Iterator it=containerMap.keySet().iterator();it.hasNext();) {
+                       currentStoc=(StoreContainer)containerMap.get(it.next());
+                       sb.append(currentStoc.toString());
+               }
+
+               return sb.toString();
+       }
+
+       /**
+        *  Method:       invalidate(StorableObject sto)
+        *  Description:  ObjectStore is notified of change of a @see StorableObject
+        *                sto and invalidates all relevant cache entries.
+        */
+
+       public void invalidate(StorableObject sto) {
+               // propagate invalidation to StoreContainer
+               if (sto!=null) {
+                       StoreIdentifier sid = sto.getStoreIdentifier();
+                       if (sto!=null) {
+                               StoreContainer stoc = getStoreContainerForSid(sid);
+                               stoc.invalidate(sto);
+                       }
+               }
+       }
+
+       // internal methods for StoreContainer managment
+
+       /**
+        *  Method:       getStoreContainerForSid
+        *  Description:  private method to find the right @see StoreContainer for
+        *                the @see StoreIdentifier sid.
+        *
+        *  @return       StoreContainer is null when no Container is found.
+        */
+       private StoreContainer getStoreContainerForSid(StoreIdentifier sid){
+               // 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 null;
+       }
+
+       /**
+        *  Method:       implementsStorableObject
+        *  Description:  internall helper method to find out if a class implements
+        *                interface StorableObject.
+        *
+        *  @return       true if yes, otherwise no.
+        */
+       private final static boolean implementsStorableObject(Class aClass) {
+               if (aClass!=null) {
+                       Class[] interfaces = aClass.getInterfaces();
+                       if (interfaces.length>0) {
+                               for (int i=0;i<interfaces.length;i++) {
+                                       if (interfaces[i]==storableObjectInterface) return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+
+       private boolean has(StoreIdentifier sid) {
+               StoreContainer stoc = getStoreContainerForSid( sid );
+               return ( stoc != null && stoc.has(sid) ) ? true:false;
+       }
+
+
+       /**
+        *  Method:       version()
+        *  Description:  returns ObjectStore version as String
+        *
+        *  @return       String
+        */
+       private String version() { return "00_daythree";}
 }
\ No newline at end of file
index 897cf78..4713530 100755 (executable)
@@ -20,95 +20,109 @@ import mir.misc.Logfile;
 
 public class StoreContainer {
 
-  private final static int    DEFAULT_SIZE=10;
-  private static Logfile      storeLog;
-  private static int          uniqueCounter=10000;
+       private final static int    DEFAULT_SIZE=10;
+       private static Logfile      storeLog;
+       private static int          uniqueCounter=10000;
 
-  private LinkedList          container;
-  private StoreContainerType  stocType;
-  private int                 maxSize=DEFAULT_SIZE;
-  private int                 uniqueId;
+       private LinkedList          container;
+       private StoreContainerType  stocType;
+       private int                 maxSize=DEFAULT_SIZE;
+       private int                 uniqueId;
 
-  private StoreContainer() {};
+       private StoreContainer() {};
 
-  public StoreContainer(StoreContainerType stoc_type) {
-    this.uniqueId=++uniqueCounter;
-    this.stocType=stoc_type;
-    this.container=new LinkedList();
-  }
+       public StoreContainer(StoreContainerType stoc_type) {
+               this.uniqueId=++uniqueCounter;
+               this.stocType=stoc_type;
+               this.container=new LinkedList();
+       }
 
-  public StoreContainer(StoreContainerType stoc_type, int maxSize) {
-    this();
-    this.maxSize=maxSize;
-  }
+       public StoreContainer(StoreContainerType stoc_type, int maxSize) {
+               this();
+               this.maxSize=maxSize;
+       }
 
-  public StorableObject use(StoreIdentifier sid) {
-    // find sid in LinkedList or die
-    // move sid to head of linked list
-    // return reference on object
-    return null;
-  }
+       public StorableObject use(StoreIdentifier sid) {
+               // find sid in LinkedList or die
+               // move sid to head of linked list
+               // return reference on object
+               return null;
+       }
 
-  public boolean has(StoreIdentifier sid) {
-    return true; // yes yes
-  }
+       public boolean has(StoreIdentifier sid) {
+               return true; // yes yes
+       }
 
-  public void add(StoreIdentifier sid) {
-    // add to head of linkedlist, if size is exeded throw away tail until
-    // size ok.
-  }
+       public void add(StoreIdentifier sid) {
+               if ( sid != null && sid.hasReference() ) {
+                       //if ( has(sid) )
+                       //      moveToHead(sid);
+                       //else
+                               container.addFirst(sid);
+               }
+               // add to head of linkedlist, if size is exceded throw away tail until
+               // size ok.
+       }
 
-  /**
-   *  Method:       invalidate(StorableObject sto)
-   *  Description:  finds @see StorableObject, propagates invalidation to
-   *                @see StoreIdentifier and removes StoreIdentifier from
-   *                list.
-   */
-  public void invalidate(StorableObject sto) {
-    if (sto!=null) {
-      StoreIdentifier sid = sto.getStoreIdentifier();
-      if (sid!=null) {
-        if ( container.contains(sid) ) {
-          sid.invalidate();
-          container.remove(sid);
-        }
-      }
-    }
-  }
+       /**
+        *  Method:       invalidate(StorableObject sto)
+        *  Description:  finds @see StorableObject, propagates invalidation to
+        *                @see StoreIdentifier and removes StoreIdentifier from
+        *                list.
+        */
+       public void invalidate(StorableObject sto) {
+               if (sto!=null) {
+                       StoreIdentifier sid = sto.getStoreIdentifier();
+                       if (sid!=null) {
+                               if ( container.contains(sid) ) {
+                                       sid.invalidate();
+                                       container.remove(sid);
+                               }
+                       }
+               }
+       }
 
-  /**
-   *  Method:       setSize
-   *  Description:  readjusts StoreContainer size to value.
-   *
-   */
-  public void setSize(int size) {
-    if (size <0) return;
-    if ( size<maxSize && size > container.size() ) {
-      // shrink
-      while (size > container.size() ) {
-        StoreIdentifier sid = (StoreIdentifier)container.getLast();
-        sid.release();
-        container.remove(sid);
-      }
-    }
-    this.maxSize=size;
-  }
+       /**
+        *  Method:       setSize
+        *  Description:  readjusts StoreContainer size to value.
+        *
+        */
+       public void setSize(int size) {
+               if (size <0) return;
+    shrinkToSize(size);
+               this.maxSize=size;
+       }
 
-  /**
-   *  Method:       toString()
-   *  Description:  gives out statistical Information, viewable via
-   *                @see ServletStoreInfo.
-   *
-   *  @return       String
-   */
-  public String toString() {
-    StringBuffer sb = new StringBuffer("StoreContainer id: ");
-    sb.append(uniqueId).append(" for ");
-    sb.append(stocType.toString()).append("\nCurrent size: ");
-    sb.append(container.size()).append("\nMaximum size:");
-    sb.append(maxSize).append("\n");
-    /** @todo list members ? */
-    return sb.toString();
+       private void shrink() {
+               shrinkToSize(maxSize);
+       }
+
+  private void shrinkToSize(int size) {
+    if ( size<maxSize && size < container.size() ) {
+                       // shrink
+                       while (size < container.size() ) {
+                               StoreIdentifier sid = (StoreIdentifier)container.getLast();
+                               sid.release();
+                               container.remove(sid);
+                       }
+               }
   }
 
+       /**
+        *  Method:       toString()
+        *  Description:  gives out statistical Information, viewable via
+        *                @see ServletStoreInfo.
+        *
+        *  @return       String
+        */
+       public String toString() {
+               StringBuffer sb = new StringBuffer("StoreContainer id: ");
+               sb.append(uniqueId).append(" for ");
+               sb.append(stocType.toString()).append(" // Current/Max size: ");
+               sb.append(container.size()).append(" / ");
+               sb.append(maxSize).append("\n");
+               /** @todo list members ? */
+               return sb.toString();
+       }
+
 }
\ No newline at end of file
index 841c16f..a2d3aeb 100755 (executable)
@@ -43,13 +43,19 @@ public class StoreContainerType {
 
                        // inner class for hashlookup
                         class StoreKey {
-                               int   storeType;
-                               Class storeClass;
+                               int   storeType; Class storeClass;
+        public boolean equals(Object o) {
+          if ( o instanceof StoreKey &&
+               ((StoreKey)o).storeType==storeType &&
+               ((StoreKey)o).storeClass==storeClass )
+            return true;
+          return false;
+        }
                        }
 
                StoreKey key = new StoreKey();
                key.storeClass = stoc_class; key.storeType = stoc_type;
-               if (uniqueTypes.containsKey(key))
+               if ( uniqueTypes.containsKey(key) )
                        returnStocType=(StoreContainerType)uniqueTypes.get(key);
                else {
                        returnStocType=new StoreContainerType(stoc_class,stoc_type);
@@ -61,7 +67,7 @@ public class StoreContainerType {
        public String toString() {
                StringBuffer sb = new StringBuffer("StoreContainerType: ");
                sb.append(this.stocClass.toString()).append("@");
-               sb.append(stringForStoreType(stocType)).append("\n");
+               sb.append(stringForStoreType(stocType));
                return sb.toString();
        }
 
index f10179b..dbaac62 100755 (executable)
@@ -13,75 +13,78 @@ import mir.misc.Logfile;
 
 public class StoreIdentifier {
 
-  /** @todo check if invalidating already to avoid deadlocks
-   *  what about concurrency? */
-
-  private static Logfile      storeLog;
-
-  private StoreContainerType  stocType=null;
-  private StorableObject      reference=null;
-  private String              uniqueIdentifier=null; // id for Entity & sql for EntityList
-  private long                timesUsed;
-  private boolean             invalidating=false;
-
-  /** @todo initialize logfile  */
-
-  private StoreIdentifier() {}
-
-  public StoreIdentifier(StorableObject reference, int storeType, String uniqueIdentifier) {
-    this.reference=reference;
-    this.uniqueIdentifier=uniqueIdentifier;
-    this.stocType = StoreContainerType.valueOf(reference.getClass(), storeType);
-  }
-
-  /**
-   *  Method:       ivalidate
-   *  Description:
-   *
-   *  @return
-   */
-  public void invalidate() {
-    // avoid deadlock due to propagation.
-    if (!invalidating) {
-      invalidating=true;
-      Set set = reference.notifyOnReleaseSet();
-      /** @todo here we should propagate the invalidation all members of Set
-      *    @see StoreContainer. The set may contain objects of different type.*/
-      release();
-    }
-  }
-
-  public void release() {
-    this.reference=null;
-    this.uniqueIdentifier=null;
-    this.stocType=null;
-  }
-
-  public Object use() {
-    timesUsed++;
-    return reference;
-  }
-
-  /**
-   *  Method equals for comparison between two identifier
-   *
-   *  @return true if yes otherwise false
-   *
-   */
-  public boolean equals(StoreIdentifier sid) {
-    // compare al relevant fields, most likely difference first
-    /** @todo doubecheck with book */
-
-    return false;
-  }
-
-  public StoreContainerType getStoreContainerType() { return stocType; }
-  public boolean hasReference() { return (reference==null) ? false:true; }
-
-  public String toString() {
-    return reference.getClass()+"@storetype"+stocType.toString()+"."
-                +uniqueIdentifier+" ("+timesUsed+") times used )";
-  }
+       /** @todo check if invalidating already to avoid deadlocks
+        *  what about concurrency? */
+
+       private static Logfile      storeLog;
+
+       private StoreContainerType  stocType=null;
+       private StorableObject      reference=null;
+       private String              uniqueIdentifier=null; // id for Entity & sql for EntityList
+       private long                timesUsed;
+       private boolean             invalidating=false;
+
+       /** @todo initialize logfile  */
+
+       private StoreIdentifier() {}
+
+       public StoreIdentifier(StorableObject reference, int storeType, String uniqueIdentifier) {
+               this.reference=reference;
+               this.uniqueIdentifier=uniqueIdentifier;
+               this.stocType = StoreContainerType.valueOf(reference.getClass(), storeType);
+       }
+
+       /**
+        *  Method:       ivalidate
+        *  Description:
+        *
+        *  @return
+        */
+       public void invalidate() {
+               // avoid deadlock due to propagation.
+               if (!invalidating) {
+                       invalidating=true;
+                       Set set = reference.notifyOnReleaseSet();
+                       /** @todo here we should propagate the invalidation all members of Set
+                       *    @see StoreContainer. The set may contain objects of different type.*/
+                       release();
+               }
+       }
+
+       public void release() {
+               this.reference=null;
+               this.uniqueIdentifier=null;
+               this.stocType=null;
+       }
+
+       public Object use() {
+               timesUsed++;
+               return reference;
+       }
+
+       /**
+        *  Method equals for comparison between two identifier
+        *
+        *  @return true if yes otherwise false
+        *
+        */
+       public boolean equals(Object sid) {
+               if ( sid instanceof StoreIdentifier) {
+                       if ( ((StoreIdentifier)sid).getStoreContainerType().equals(stocType) &&
+                                        ((StoreIdentifier)sid).getUniqueIdentifier().equals(uniqueIdentifier) )
+                               return true;
+               }
+               return false;
+       }
+
+       public StoreContainerType getStoreContainerType() { return stocType; }
+       public String getUniqueIdentifier() { return uniqueIdentifier; }
+       public boolean hasReference() { return (reference==null) ? false:true; }
+
+       public String toString() {
+               return reference.getClass()+"@storetype"+stocType.toString()+"."
+                                                               +uniqueIdentifier+" ("+timesUsed+") times used )";
+       }
 
 
 }
\ No newline at end of file
diff --git a/source/mir/storage/store/test/EntityC1.java b/source/mir/storage/store/test/EntityC1.java
new file mode 100755 (executable)
index 0000000..635ca31
--- /dev/null
@@ -0,0 +1,30 @@
+package mir.storage.store.test;
+
+/**
+ * Title:
+ * Description:
+ * Copyright:    Copyright (c) 2002
+ * Company:
+ * @author
+ * @version 1.0
+ */
+
+import java.util.*;
+import mir.storage.store.*;
+
+public class EntityC1 implements StorableObject {
+
+       String id;
+
+       public EntityC1(String id) {
+               this.id=id;
+       }
+
+       public StoreIdentifier getStoreIdentifier() {
+               return new StoreIdentifier(this, StoreContainerType.STOC_TYPE_ENTITY,id);
+       }
+
+       public Set notifyOnReleaseSet() {
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/source/mir/storage/store/test/TestStore.java b/source/mir/storage/store/test/TestStore.java
new file mode 100755 (executable)
index 0000000..e8903b4
--- /dev/null
@@ -0,0 +1,46 @@
+package mir.storage.store.test;
+
+/**
+ * Title:
+ * Description:
+ * Copyright:    Copyright (c) 2002
+ * Company:
+ * @author
+ * @version 1.0
+ */
+
+import mir.storage.store.*;
+
+public class TestStore {
+
+       private static ObjectStore o_store = ObjectStore.getInstance();
+
+       public TestStore() {
+
+       }
+
+       public static void main(String[] args) {
+               long startTime = System.currentTimeMillis();
+               System.out.println("Starting testrun on ObjectStore...");
+               TestStore testStore1 = new TestStore();
+               testStore1.startTest();
+               System.out.println("Finished testrun on ObjectStore. ("
+                               + (System.currentTimeMillis() - startTime) + " ms)");
+       }
+
+       public void startTest() {
+               //System.out.println(o_store.toString());
+               EntityC1 c1 = new EntityC1("1");
+               o_store.add(c1.getStoreIdentifier());
+               EntityC1 c2 = new EntityC1("2");
+               o_store.add(c2.getStoreIdentifier());
+
+               System.out.println(o_store.toString());
+    /** @todo compare values of store and state failed if values are not
+     *  right*/
+
+    /** @todo test cycle: search in store */
+    /** @todo test cycle: invalidation */
+
+       }
+}
\ No newline at end of file