synchronize singleton constructor static getInstance method. dangerous otherwise
authormh <mh>
Sun, 7 Apr 2002 21:01:23 +0000 (21:01 +0000)
committermh <mh>
Sun, 7 Apr 2002 21:01:23 +0000 (21:01 +0000)
21 files changed:
source/mircoders/storage/DatabaseArticleType.java
source/mircoders/storage/DatabaseAudio.java
source/mircoders/storage/DatabaseBreaking.java
source/mircoders/storage/DatabaseComment.java
source/mircoders/storage/DatabaseFeature.java
source/mircoders/storage/DatabaseImageColor.java
source/mircoders/storage/DatabaseImageFormat.java
source/mircoders/storage/DatabaseImageLayout.java
source/mircoders/storage/DatabaseImageType.java
source/mircoders/storage/DatabaseImages.java
source/mircoders/storage/DatabaseLanguage.java
source/mircoders/storage/DatabaseLinksImcs.java
source/mircoders/storage/DatabaseMedia.java
source/mircoders/storage/DatabaseMediaType.java
source/mircoders/storage/DatabaseMediafolder.java
source/mircoders/storage/DatabaseMessages.java
source/mircoders/storage/DatabaseOther.java
source/mircoders/storage/DatabaseRights.java
source/mircoders/storage/DatabaseTopics.java
source/mircoders/storage/DatabaseUsers.java
source/mircoders/storage/DatabaseVideo.java

index ffd0ec2..952a8ca 100755 (executable)
@@ -26,7 +26,11 @@ public class DatabaseArticleType extends Database implements StorageObject{
        private static DatabaseArticleType instance;
        private static SimpleList articletypePopupData;
 
-       public static DatabaseArticleType getInstance() throws StorageObjectException
+       // 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 DatabaseArticleType getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseArticleType();
index 4b4fd1b..9df2dbb 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseAudio extends Database implements StorageObject{
        private static DatabaseAudio instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseAudio getInstance() throws StorageObjectException
+       // 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 DatabaseAudio getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseAudio();
index 20c8940..50af618 100755 (executable)
@@ -21,7 +21,11 @@ public class DatabaseBreaking extends Database implements StorageObject{
 
   private static DatabaseBreaking instance;
 
-  public static DatabaseBreaking getInstance() throws StorageObjectException {
+  // 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 DatabaseBreaking getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseBreaking();
       instance.myselfDatabase = instance;
index 2b8108c..5420449 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseComment extends Database implements StorageObject{
 
        private static DatabaseComment instance;
 
-       public static DatabaseComment getInstance() throws StorageObjectException {
+       // 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 DatabaseComment getInstance() 
+         throws StorageObjectException {
                if (instance == null) {
                        instance = new DatabaseComment();
                        instance.myselfDatabase = instance;
index c907167..4368007 100755 (executable)
@@ -21,7 +21,11 @@ public class DatabaseFeature extends Database implements StorageObject{
 
   private static DatabaseFeature instance;
 
-  public static DatabaseFeature getInstance() throws StorageObjectException {
+  // 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 DatabaseFeature getInstance() 
+    throws StorageObjectException {
       if (instance == null) {
     instance = new DatabaseFeature();
     instance.myselfDatabase = instance;
index ab798f1..776bb18 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImageColor extends Database implements StorageObject{
        private static DatabaseImageColor instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImageColor getInstance() throws StorageObjectException
+       // 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 DatabaseImageColor getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImageColor();
index 80eda36..346ecb5 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImageFormat extends Database implements StorageObject{
        private static DatabaseImageFormat instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImageFormat getInstance() throws StorageObjectException
+       // 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 DatabaseImageFormat getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImageFormat();
index d67596c..204c0ba 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImageLayout extends Database implements StorageObject{
        private static DatabaseImageLayout instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImageLayout getInstance() throws StorageObjectException
+       // 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 DatabaseImageLayout getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImageLayout();
index 2de500d..9470085 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImageType extends Database implements StorageObject{
        private static DatabaseImageType instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImageType getInstance() throws StorageObjectException
+       // 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 DatabaseImageType getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImageType();
index ede4e15..e61ff38 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImages extends Database implements StorageObject{
        private static DatabaseImages instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImages getInstance() throws StorageObjectException
+  // 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 DatabaseImages getInstance()
+    throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImages();
index 502f326..4b5fa84 100755 (executable)
@@ -26,7 +26,11 @@ public class DatabaseLanguage extends Database implements StorageObject{
        private static DatabaseLanguage instance;
        private static SimpleList languagePopupData;
 
-       public static DatabaseLanguage getInstance() throws StorageObjectException
+       // 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 DatabaseLanguage getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseLanguage();
index eba935e..a2911ef 100755 (executable)
@@ -24,7 +24,11 @@ public class DatabaseLinksImcs extends Database
         * @return
         * @exception StorageObjectException
         */
-       public static DatabaseLinksImcs getInstance () throws StorageObjectException {
+       // 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 DatabaseLinksImcs getInstance () 
+         throws StorageObjectException {
                if (instance == null) {
                        instance = new DatabaseLinksImcs();
                        instance.myselfDatabase = instance;
index de0e294..fa09f08 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseMedia extends Database implements StorageObject{
   private static DatabaseMedia instance;
   private static EntityRelation         relationMediaType;
 
-  public static DatabaseMedia getInstance() throws StorageObjectException {
+  // 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 DatabaseMedia getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseMedia();
       instance.myselfDatabase = instance;
index 8d68ac4..1e014b9 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseMediaType extends Database implements StorageObject{
 
   private static DatabaseMediaType instance;
 
-  public static DatabaseMediaType getInstance() throws StorageObjectException {
+  // 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 DatabaseMediaType getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseMediaType();
       instance.myselfDatabase = instance;
index a3f92be..6cb5312 100755 (executable)
@@ -26,7 +26,11 @@ public class DatabaseMediafolder extends Database implements StorageObject{
 
   private static DatabaseMediafolder instance;
 
-  public static DatabaseMediafolder getInstance() throws StorageObjectException {
+  // 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;
index dc5116c..b37be8d 100755 (executable)
@@ -26,7 +26,11 @@ public class DatabaseMessages extends Database implements StorageObject{
 
   private static DatabaseMessages instance;
 
-  public static DatabaseMessages getInstance() throws StorageObjectException {
+  // 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 DatabaseMessages getInstance() 
+    throws StorageObjectException {
     if (instance == null) {
       instance = new DatabaseMessages();
       instance.myselfDatabase = instance;
index e800175..d236826 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseOther extends Database implements StorageObject{
        private static DatabaseOther instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseOther getInstance() throws StorageObjectException
+       // 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 DatabaseOther getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseOther();
index 71255cc..a77ad3d 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseRights extends Database implements StorageObject{
        private static DatabaseRights instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseRights getInstance() throws StorageObjectException
+       // 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 DatabaseRights getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseRights();
index 3fc0885..2e1210e 100755 (executable)
@@ -21,7 +21,11 @@ public class DatabaseTopics extends Database implements StorageObject{
 
   private static DatabaseTopics instance;
 
-  public static DatabaseTopics getInstance() throws StorageObjectException {
+  // 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 DatabaseTopics getInstance() 
+    throws StorageObjectException {
       if (instance == null) {
     instance = new DatabaseTopics();
     instance.myselfDatabase = instance;
index 8f8c211..69ab256 100755 (executable)
@@ -21,7 +21,11 @@ public class DatabaseUsers extends Database implements StorageObject{
 
        private static DatabaseUsers instance;
 
-       public static DatabaseUsers getInstance() throws StorageObjectException {
+       // 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 DatabaseUsers getInstance() 
+         throws StorageObjectException {
                if (instance == null) {
                        instance = new DatabaseUsers();
                        instance.myselfDatabase = instance;
index 14101ea..f00f7b5 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseVideo extends Database implements StorageObject{
        private static DatabaseVideo instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseVideo getInstance() throws StorageObjectException
+       // 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 DatabaseVideo getInstance() 
+         throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseVideo();