Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-04-07 17:35:00 -0400
committerSimon Kaegi2008-04-07 17:35:00 -0400
commitf4c7de405b87d286d12f19d41a052a18de54ac85 (patch)
treef763c42637338edf1dff722f2c0c73f092d35bc4 /bundles/org.eclipse.equinox.p2.directorywatcher
parent53ab0bf9d3571bbbe6d3e6848846cd0640d076a0 (diff)
downloadrt.equinox.p2-f4c7de405b87d286d12f19d41a052a18de54ac85.tar.gz
rt.equinox.p2-f4c7de405b87d286d12f19d41a052a18de54ac85.tar.xz
rt.equinox.p2-f4c7de405b87d286d12f19d41a052a18de54ac85.zip
Bug 222565 Strings need to be externalized
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.directorywatcher')
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties11
5 files changed, 62 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
index f2ec50394..b105ba6e0 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.provisional.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.p2.query,
org.eclipse.osgi.service.resolver;version="1.1.0",
+ org.eclipse.osgi.util,
org.osgi.framework;version="1.4.0",
org.osgi.service.cm;version="1.2.0";resolution:=optional,
org.osgi.service.packageadmin;version="1.2.0",
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
index b621c986f..9cbd6efab 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
@@ -13,16 +13,19 @@ package org.eclipse.equinox.internal.provisional.p2.directorywatcher;
import java.io.File;
import java.util.*;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
public class DirectoryWatcher {
+ private static final String DEL_EXT = ".del"; //$NON-NLS-1$
+
public class WatcherThread extends Thread {
private final long pollFrequency;
private boolean done = false;
public WatcherThread(long pollFrequency) {
- super("Directory Watcher");
+ super("Directory Watcher"); //$NON-NLS-1$
this.pollFrequency = pollFrequency;
}
@@ -36,8 +39,7 @@ public class DirectoryWatcher {
} catch (InterruptedException e) {
// ignore
} catch (Throwable e) {
- e.printStackTrace();
- log("In main loop, we have serious trouble", e);
+ log(Messages.error_main_loop, e);
done = true;
}
} while (!done);
@@ -49,12 +51,12 @@ public class DirectoryWatcher {
}
}
- public final static String POLL = "eclipse.p2.directory.watcher.poll";
- public final static String DIR = "eclipse.p2.directory.watcher.dir";
+ public final static String POLL = "eclipse.p2.directory.watcher.poll"; //$NON-NLS-1$
+ public final static String DIR = "eclipse.p2.directory.watcher.dir"; //$NON-NLS-1$
private static final long DEFAULT_POLL_FREQUENCY = 2000;
public static void log(String string, Throwable e) {
- System.err.println(string + ": " + e);
+ System.err.println(string + ": " + e); //$NON-NLS-1$
}
final File[] directories;
@@ -69,7 +71,7 @@ public class DirectoryWatcher {
public DirectoryWatcher(Dictionary properties, BundleContext context) {
String dir = (String) properties.get(DIR);
if (dir == null)
- dir = "./load";
+ dir = "./load"; //$NON-NLS-1$
File targetDirectory = new File(dir);
targetDirectory.mkdirs();
@@ -78,14 +80,14 @@ public class DirectoryWatcher {
public DirectoryWatcher(File directory) {
if (directory == null)
- throw new IllegalArgumentException("Folder must not be null");
+ throw new IllegalArgumentException(Messages.null_folder);
this.directories = new File[] {directory};
}
public DirectoryWatcher(File[] directories) {
if (directories == null)
- throw new IllegalArgumentException("Folder must not be null");
+ throw new IllegalArgumentException(Messages.null_folder);
this.directories = directories;
}
@@ -109,7 +111,7 @@ public class DirectoryWatcher {
public synchronized void start(final long pollFrequency) {
if (watcher != null)
- throw new IllegalStateException("Already Started");
+ throw new IllegalStateException(Messages.thread_started);
watcher = new WatcherThread(pollFrequency);
watcher.start();
@@ -117,7 +119,7 @@ public class DirectoryWatcher {
public synchronized void stop() {
if (watcher == null)
- throw new IllegalStateException("Not Started");
+ throw new IllegalStateException(Messages.thread_not_started);
watcher.done();
watcher = null;
@@ -144,7 +146,7 @@ public class DirectoryWatcher {
for (int i = 0; i < list.length; i++) {
File file = list[i];
// if this is a deletion marker then add to the list of pending deletions.
- if (list[i].getPath().endsWith(".del")) {
+ if (list[i].getPath().endsWith(DEL_EXT)) {
File target = new File(file.getPath().substring(0, file.getPath().length() - 4));
removals.add(target);
pendingDeletions.add(target);
@@ -203,7 +205,7 @@ public class DirectoryWatcher {
listener.changed(file);
}
} catch (Exception e) {
- log("Processing : " + listener, e);
+ log(NLS.bind(Messages.error_processing, listener), e);
}
}
@@ -215,7 +217,7 @@ public class DirectoryWatcher {
File file = (File) iterator.next();
if (!file.exists() || file.delete())
iterator.remove();
- new File(file.getPath() + ".del").delete();
+ new File(file.getPath() + DEL_EXT).delete();
}
}
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java
new file mode 100644
index 000000000..1c5ded922
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Messages.java
@@ -0,0 +1,26 @@
+package org.eclipse.equinox.internal.provisional.p2.directorywatcher;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.provisional.p2.directorywatcher.messages"; //$NON-NLS-1$
+ public static String artifact_repo_manager_not_registered;
+ public static String error_main_loop;
+ public static String error_processing;
+ public static String failed_create_artifact_repo;
+ public static String failed_create_metadata_repo;
+ public static String metadata_repo_manager_not_registered;
+ public static String multiple_bundle_ius;
+ public static String null_folder;
+ public static String platformadmin_not_registered;
+ public static String thread_not_started;
+ public static String thread_started;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ //
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
index ba5baf51c..5ab7e7659 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
@@ -25,6 +25,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadata
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.query.Query;
import org.eclipse.osgi.service.resolver.*;
+import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -85,10 +86,10 @@ public class RepositoryListener extends DirectoryChangeListener {
ServiceReference reference = context.getServiceReference(PlatformAdmin.class.getName());
if (reference == null)
- throw new IllegalStateException("PlatformAdmin not registered."); //$NON-NLS-1$
+ throw new IllegalStateException(Messages.platformadmin_not_registered);
PlatformAdmin platformAdmin = (PlatformAdmin) context.getService(reference);
if (platformAdmin == null)
- throw new IllegalStateException("PlatformAdmin not registered."); //$NON-NLS-1$
+ throw new IllegalStateException(Messages.platformadmin_not_registered);
try {
StateObjectFactory stateObjectFactory = platformAdmin.getFactory();
@@ -104,7 +105,7 @@ public class RepositoryListener extends DirectoryChangeListener {
if (reference != null)
manager = (IArtifactRepositoryManager) context.getService(reference);
if (manager == null)
- throw new IllegalStateException("ArtifactRepositoryManager not registered."); //$NON-NLS-1$
+ throw new IllegalStateException(Messages.artifact_repo_manager_not_registered);
try {
try {
@@ -125,7 +126,7 @@ public class RepositoryListener extends DirectoryChangeListener {
return repository;
} catch (ProvisionException e) {
LogHelper.log(e);
- throw new IllegalStateException("Couldn't create artifact repository for: " + stateDirURL); //$NON-NLS-1$
+ throw new IllegalStateException(NLS.bind(Messages.failed_create_artifact_repo, stateDirURL));
}
} finally {
context.ungetService(reference);
@@ -138,7 +139,7 @@ public class RepositoryListener extends DirectoryChangeListener {
if (reference != null)
manager = (IMetadataRepositoryManager) context.getService(reference);
if (manager == null)
- throw new IllegalStateException("MetadataRepositoryManager not registered."); //$NON-NLS-1$
+ throw new IllegalStateException(Messages.metadata_repo_manager_not_registered);
try {
try {
@@ -157,7 +158,7 @@ public class RepositoryListener extends DirectoryChangeListener {
return repository;
} catch (ProvisionException e) {
LogHelper.log(e);
- throw new IllegalStateException("Couldn't create metadata repository for: " + stateDirURL); //$NON-NLS-1$
+ throw new IllegalStateException(NLS.bind(Messages.failed_create_metadata_repo, stateDirURL));
} finally {
context.ungetService(reference);
}
@@ -405,7 +406,7 @@ public class RepositoryListener extends DirectoryChangeListener {
if (!ius[i].isFragment())
return new IInstallableUnit[] {ius[i]};
}
- throw new IllegalStateException("There should be exactly one Bundle IU"); //$NON-NLS-1$
+ throw new IllegalStateException(Messages.multiple_bundle_ius);
}
public IMetadataRepository getMetadataRepository() {
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties
new file mode 100644
index 000000000..858807af3
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/messages.properties
@@ -0,0 +1,11 @@
+artifact_repo_manager_not_registered=ArtifactRepositoryManager not registered.
+error_main_loop=Error in watcher thread main loop.
+error_processing=Error Processing: {0}
+failed_create_artifact_repo=Could not create artifact repository for: {0}
+failed_create_metadata_repo=Could not create metadata repository for: {0}
+metadata_repo_manager_not_registered=MetadataRepositoryManager not registered.
+multiple_bundle_ius=There should be exactly one Bundle IU
+null_folder=Folder must not be null
+platformadmin_not_registered=PlatformAdmin not registered.
+thread_not_started=Watcher thread not Started
+thread_started=Watcher thread already Started

Back to the top