diff --git a/plugins/ant/src/com/intellij/lang/ant/AntBundle.java b/plugins/ant/src/com/intellij/lang/ant/AntBundle.java index adae4412bc5e..419e006907a7 100644 --- a/plugins/ant/src/com/intellij/lang/ant/AntBundle.java +++ b/plugins/ant/src/com/intellij/lang/ant/AntBundle.java @@ -15,33 +15,19 @@ */ package com.intellij.lang.ant; -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 AntBundle extends DynamicBundle { + @NonNls protected static final String BUNDLE = "messages.AntBundle"; + private static final AntBundle INSTANCE = new AntBundle(); -public class AntBundle { - public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } + private AntBundle() { super(BUNDLE); } - private static Reference ourBundle; - @NonNls - protected static final String PATH_TO_BUNDLE = "messages.AntBundle"; - - private AntBundle() { - } - - 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); } } diff --git a/plugins/ant/src/com/intellij/lang/ant/resources/AntActionsBundle.java b/plugins/ant/src/com/intellij/lang/ant/resources/AntActionsBundle.java index 1d4593e01856..06c2e77c169a 100644 --- a/plugins/ant/src/com/intellij/lang/ant/resources/AntActionsBundle.java +++ b/plugins/ant/src/com/intellij/lang/ant/resources/AntActionsBundle.java @@ -15,43 +15,19 @@ */ package com.intellij.lang.ant.resources; -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 AntActionsBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "com.intellij.lang.ant.resources.AntActionsBundle"; + private static final AntActionsBundle INSTANCE = new AntActionsBundle(); -public final class AntActionsBundle { + private AntActionsBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = IDEA_ACTIONS_BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls private static final String IDEA_ACTIONS_BUNDLE = "com.intellij.lang.ant.resources.AntActionsBundle"; - - private AntActionsBundle() { - } - - @SuppressWarnings({"UnresolvedPropertyKey"}) - public static String actionText(@NonNls String actionId) { - return message("action." + actionId + ".text"); - } - - @SuppressWarnings({"UnresolvedPropertyKey"}) - public static String actionDescription(@NonNls String actionId) { - return message("action." + actionId + ".description"); - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(IDEA_ACTIONS_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/eclipse/src/org/jetbrains/idea/eclipse/EclipseBundle.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/EclipseBundle.java index e7ef07cec246..c4ed2ac55391 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/EclipseBundle.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/EclipseBundle.java @@ -15,34 +15,19 @@ */ package org.jetbrains.idea.eclipse; -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 EclipseBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "EclipseBundle"; + private static final EclipseBundle INSTANCE = new EclipseBundle(); -public class EclipseBundle { + private EclipseBundle() { super(BUNDLE); } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "EclipseBundle"; - - private EclipseBundle() { - } - - 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; + return INSTANCE.getMessage(key, params); } }