diff --git a/images/src/org/intellij/images/ImagesBundle.java b/images/src/org/intellij/images/ImagesBundle.java index 2e03ddd8518f..149ba9a8cb51 100644 --- a/images/src/org/intellij/images/ImagesBundle.java +++ b/images/src/org/intellij/images/ImagesBundle.java @@ -15,36 +15,19 @@ */ package org.intellij.images; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; - -/** - * @author max - */ -public class ImagesBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class ImagesBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "org.intellij.images.ImagesBundle"; + private static final ImagesBundle INSTANCE = new ImagesBundle(); - private ImagesBundle() { - } + private ImagesBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/projectModel-api/src/com/intellij/openapi/project/ProjectBundle.java b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectBundle.java index f12415547e5f..f59d8c3b08fa 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/project/ProjectBundle.java +++ b/platform/projectModel-api/src/com/intellij/openapi/project/ProjectBundle.java @@ -15,33 +15,19 @@ */ package com.intellij.openapi.project; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; - -public class ProjectBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class ProjectBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.ProjectBundle"; + private static final ProjectBundle INSTANCE = new ProjectBundle(); - private ProjectBundle() { - } + private ProjectBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestsRunnerBundle.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestsRunnerBundle.java index f56b9cca54c7..ec6ad00e1ca1 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestsRunnerBundle.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestsRunnerBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.execution.testframework.sm; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; - -/** - * @author Roman Chernyatchik - */ -public class SMTestsRunnerBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class SMTestsRunnerBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.SMTestsRunnerBundle"; + private static final SMTestsRunnerBundle INSTANCE = new SMTestsRunnerBundle(); - private SMTestsRunnerBundle() { - } + private SMTestsRunnerBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java b/platform/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java index 505bf7448fa7..c649e8cf4dac 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java @@ -1,32 +1,18 @@ package com.intellij.structuralsearch; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; - -public class SSRBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class SSRBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.SSRBundle"; + private static final SSRBundle INSTANCE = new SSRBundle(); - private SSRBundle() { - } + private SSRBundle() { super(BUNDLE); } - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } } \ No newline at end of file diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesBundle.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesBundle.java index d0d2f8cf0519..c081351dcb24 100644 --- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesBundle.java +++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesBundle.java @@ -15,33 +15,19 @@ */ package com.intellij.lang.properties; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; +public class PropertiesBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.PropertiesBundle"; + private static final PropertiesBundle INSTANCE = new PropertiesBundle(); -public class PropertiesBundle { + private PropertiesBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls protected static final String PATH_TO_BUNDLE = "messages.PropertiesBundle"; - - private PropertiesBundle() { - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } }