Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-01-07 17:01:30 +0000
committerMichael Valenta2005-01-07 17:01:30 +0000
commitee0a6801c6770e5459384294d58c17121491c681 (patch)
tree1504c4c36e81f42db4f2b1d3ff497dd6340e8e19 /examples
parent5eab3b11a24410c3538e0d03606efd9c53330d8e (diff)
downloadeclipse.platform.team-ee0a6801c6770e5459384294d58c17121491c681.tar.gz
eclipse.platform.team-ee0a6801c6770e5459384294d58c17121491c681.tar.xz
eclipse.platform.team-ee0a6801c6770e5459384294d58c17121491c681.zip
Bug 82370 Inline Policy.localize to enable NLS tooling
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java16
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java19
2 files changed, 14 insertions, 21 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java
index 9be45c067..7787f958f 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java
@@ -12,10 +12,7 @@ package org.eclipse.team.examples.filesystem;
import java.io.IOException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.*;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProviderPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -60,17 +57,6 @@ public class FileSystemPlugin extends AbstractUIPlugin {
}
/**
- * This method will get invoked when the plugin is started.
- * Note that this is not necessarily at workbench startup.
- *
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void startup() throws CoreException {
- // localize the string bindings used by the plugins (in order to provide NLS support)
- Policy.localize("org.eclipse.team.examples.filesystem.messages"); //$NON-NLS-1$
- }
-
- /**
* Return the singlton instance of the plugin class to allow other
* classes in the plugin access to plugin instance methods such as
* those for logging errors, etc.
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java
index cfb2db53a..aef6b0d79 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/Policy.java
@@ -24,13 +24,20 @@ import org.eclipse.core.runtime.OperationCanceledException;
*/
public class Policy {
- protected static ResourceBundle bundle = null;
+ private static ResourceBundle bundle = null;
+ private static final String bundleName = "org.eclipse.team.examples.filesystem.messages"; //$NON-NLS-1$
- /**
- * Creates a NLS catalog for the given locale.
+ /*
+ * Returns a resource bundle, creating one if it none is available.
*/
- public static void localize(String bundleName) {
- bundle = ResourceBundle.getBundle(bundleName);
+ private static ResourceBundle getResourceBundle() {
+ // thread safety
+ ResourceBundle tmpBundle = bundle;
+ if (tmpBundle != null)
+ return tmpBundle;
+ // always create a new classloader to be passed in
+ // in order to prevent ResourceBundle caching
+ return bundle = ResourceBundle.getBundle(bundleName);
}
/**
@@ -55,7 +62,7 @@ public class Policy {
*/
public static String bind(String key) {
try {
- return bundle.getString(key);
+ return getResourceBundle().getString(key);
} catch (MissingResourceException e) {
return key;
} catch (NullPointerException e) {

Back to the top