From: mh Date: Sun, 7 Apr 2002 21:01:23 +0000 (+0000) Subject: synchronize singleton constructor static getInstance method. dangerous otherwise X-Git-Tag: prexmlproducerconfig~138 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=ad39c6eee58bb0ca40cbdabe191e02ec71d248bf;p=mir.git synchronize singleton constructor static getInstance method. dangerous otherwise --- diff --git a/source/mircoders/storage/DatabaseArticleType.java b/source/mircoders/storage/DatabaseArticleType.java index ffd0ec28..952a8ca0 100755 --- a/source/mircoders/storage/DatabaseArticleType.java +++ b/source/mircoders/storage/DatabaseArticleType.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseAudio.java b/source/mircoders/storage/DatabaseAudio.java index 4b4fd1bd..9df2dbb2 100755 --- a/source/mircoders/storage/DatabaseAudio.java +++ b/source/mircoders/storage/DatabaseAudio.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseBreaking.java b/source/mircoders/storage/DatabaseBreaking.java index 20c89400..50af618a 100755 --- a/source/mircoders/storage/DatabaseBreaking.java +++ b/source/mircoders/storage/DatabaseBreaking.java @@ -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; diff --git a/source/mircoders/storage/DatabaseComment.java b/source/mircoders/storage/DatabaseComment.java index 2b8108c5..5420449e 100755 --- a/source/mircoders/storage/DatabaseComment.java +++ b/source/mircoders/storage/DatabaseComment.java @@ -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; diff --git a/source/mircoders/storage/DatabaseFeature.java b/source/mircoders/storage/DatabaseFeature.java index c907167f..4368007c 100755 --- a/source/mircoders/storage/DatabaseFeature.java +++ b/source/mircoders/storage/DatabaseFeature.java @@ -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; diff --git a/source/mircoders/storage/DatabaseImageColor.java b/source/mircoders/storage/DatabaseImageColor.java index ab798f1c..776bb18e 100755 --- a/source/mircoders/storage/DatabaseImageColor.java +++ b/source/mircoders/storage/DatabaseImageColor.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseImageFormat.java b/source/mircoders/storage/DatabaseImageFormat.java index 80eda36a..346ecb54 100755 --- a/source/mircoders/storage/DatabaseImageFormat.java +++ b/source/mircoders/storage/DatabaseImageFormat.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseImageLayout.java b/source/mircoders/storage/DatabaseImageLayout.java index d67596cf..204c0baa 100755 --- a/source/mircoders/storage/DatabaseImageLayout.java +++ b/source/mircoders/storage/DatabaseImageLayout.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseImageType.java b/source/mircoders/storage/DatabaseImageType.java index 2de500d7..94700857 100755 --- a/source/mircoders/storage/DatabaseImageType.java +++ b/source/mircoders/storage/DatabaseImageType.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseImages.java b/source/mircoders/storage/DatabaseImages.java index ede4e156..e61ff383 100755 --- a/source/mircoders/storage/DatabaseImages.java +++ b/source/mircoders/storage/DatabaseImages.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseLanguage.java b/source/mircoders/storage/DatabaseLanguage.java index 502f3268..4b5fa849 100755 --- a/source/mircoders/storage/DatabaseLanguage.java +++ b/source/mircoders/storage/DatabaseLanguage.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseLinksImcs.java b/source/mircoders/storage/DatabaseLinksImcs.java index eba935e7..a2911ef0 100755 --- a/source/mircoders/storage/DatabaseLinksImcs.java +++ b/source/mircoders/storage/DatabaseLinksImcs.java @@ -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; diff --git a/source/mircoders/storage/DatabaseMedia.java b/source/mircoders/storage/DatabaseMedia.java index de0e2945..fa09f08d 100755 --- a/source/mircoders/storage/DatabaseMedia.java +++ b/source/mircoders/storage/DatabaseMedia.java @@ -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; diff --git a/source/mircoders/storage/DatabaseMediaType.java b/source/mircoders/storage/DatabaseMediaType.java index 8d68ac41..1e014b95 100755 --- a/source/mircoders/storage/DatabaseMediaType.java +++ b/source/mircoders/storage/DatabaseMediaType.java @@ -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; diff --git a/source/mircoders/storage/DatabaseMediafolder.java b/source/mircoders/storage/DatabaseMediafolder.java index a3f92be3..6cb53121 100755 --- a/source/mircoders/storage/DatabaseMediafolder.java +++ b/source/mircoders/storage/DatabaseMediafolder.java @@ -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; diff --git a/source/mircoders/storage/DatabaseMessages.java b/source/mircoders/storage/DatabaseMessages.java index dc5116c6..b37be8db 100755 --- a/source/mircoders/storage/DatabaseMessages.java +++ b/source/mircoders/storage/DatabaseMessages.java @@ -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; diff --git a/source/mircoders/storage/DatabaseOther.java b/source/mircoders/storage/DatabaseOther.java index e8001751..d2368267 100755 --- a/source/mircoders/storage/DatabaseOther.java +++ b/source/mircoders/storage/DatabaseOther.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseRights.java b/source/mircoders/storage/DatabaseRights.java index 71255ccc..a77ad3d3 100755 --- a/source/mircoders/storage/DatabaseRights.java +++ b/source/mircoders/storage/DatabaseRights.java @@ -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(); diff --git a/source/mircoders/storage/DatabaseTopics.java b/source/mircoders/storage/DatabaseTopics.java index 3fc08853..2e1210ea 100755 --- a/source/mircoders/storage/DatabaseTopics.java +++ b/source/mircoders/storage/DatabaseTopics.java @@ -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; diff --git a/source/mircoders/storage/DatabaseUsers.java b/source/mircoders/storage/DatabaseUsers.java index 8f8c211e..69ab2568 100755 --- a/source/mircoders/storage/DatabaseUsers.java +++ b/source/mircoders/storage/DatabaseUsers.java @@ -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; diff --git a/source/mircoders/storage/DatabaseVideo.java b/source/mircoders/storage/DatabaseVideo.java index 14101ea0..f00f7b50 100755 --- a/source/mircoders/storage/DatabaseVideo.java +++ b/source/mircoders/storage/DatabaseVideo.java @@ -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();