bugfixes mainly...
[mir.git] / source / mircoders / storage / DatabaseMediafolder.java
index d2609f7..6cb5312 100755 (executable)
@@ -24,31 +24,30 @@ import mir.misc.*;
 
 public class DatabaseMediafolder extends Database implements StorageObject{
 
-       private static DatabaseMediafolder instance;
-
-       public static DatabaseMediafolder getInstance() throws StorageObjectException {
-               if (instance == null) {
-                       instance = new DatabaseMediafolder();
-                       instance.myselfDatabase = instance;
-               }
-               return instance;
-       }
-
-       private DatabaseMediafolder() throws StorageObjectException
-       {
-               super();
-               this.hasTimestamp = false;
-               this.cache = new HashMap();
-               this.theTable="media_folder";
-               try {
-                       this.theEntityClass = Class.forName("mir.entity.EntityMediafolder");
-               }
-               catch (Exception e) {   throw new StorageObjectException(e.toString());
-               }
-       }
-
-       public SimpleList getPopupData() {
-               return getPopupData("name",true);
-       }
+  private static DatabaseMediafolder instance;
+
+  // the following *has* to be sychronized cause this static method
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..
+  // see the "Singletons with needles and thread" article at JavaWorld -mh
+  public synchronized static DatabaseMediafolder getInstance() 
+    throws StorageObjectException {
+    if (instance == null) {
+      instance = new DatabaseMediafolder();
+      instance.myselfDatabase = instance;
+    }
+    return instance;
+  }
+
+  private DatabaseMediafolder() throws StorageObjectException
+  {
+    super();
+    this.hasTimestamp = false;
+    //this.cache = new DatabaseCache(20);
+    this.theTable="media_folder";
+  }
+
+  public SimpleList getPopupData() throws StorageObjectException {
+    return getPopupData("name",true);
+  }
 
 }