bugfixes mainly...
[mir.git] / source / mircoders / storage / DatabaseContentToMedia.java
index 1569bb4..5807ea5 100755 (executable)
@@ -23,7 +23,10 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
 
   private static DatabaseContentToMedia instance;
 
-  public static DatabaseContentToMedia getInstance()
+  // 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 DatabaseContentToMedia getInstance()
     throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseContentToMedia();
@@ -38,6 +41,8 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
     super();
     this.hasTimestamp = false;
     this.theTable="content_x_media";
+    try { this.theEntityClass = Class.forName("mir.entity.GenericEntity"); }
+    catch (Exception e) { throw new StorageObjectException(e.toString()); }
   }
 
   /**
@@ -81,7 +86,7 @@ public class DatabaseContentToMedia extends Database implements StorageObject{
       throw new StorageObjectException("-- hasMedia failed: content is NULL");
     }
   }
-      
+