[136463] Updated status and name of cache job.
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
index 9f5b97e..20cd05f 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/Cache.java
@@ -173,7 +173,7 @@
*/
protected void addUncachedURI(String uri)
{
- CachePlugin.getDefault().startJob();
+ CacheJob.startJob();
uncached.add(uri);
}
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheJob.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheJob.java
index 4af46f8..34c3943 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheJob.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CacheJob.java
@@ -27,6 +27,7 @@
{
private static final long SCHEDULE_TIME = 3600000;
+ private static CacheJob job = null;
/**
* Constructor.
*/
@@ -60,14 +61,14 @@
return Status.CANCEL_STATUS;
}
String uri = uncachedURIs[i];
- monitor.subTask(MessageFormat.format(CacheMessages._UI_CACHE_MONITOR_CACHING, new Object[]{uri}));
+ monitor.setTaskName(MessageFormat.format(CacheMessages._UI_CACHE_MONITOR_CACHING, new Object[]{uri}));
+
String cachedURI = cache.getResource(uri);
if(cachedURI == null)
{
allSuccessful = false;
}
monitor.worked(1);
- monitor.subTask("");
}
monitor.done();
return Status.OK_STATUS;
@@ -78,10 +79,48 @@
// schedule the next time the job should run.
if(!allSuccessful)
{
- schedule(SCHEDULE_TIME);
+ startJob(SCHEDULE_TIME);
}
}
}
+
+ /**
+ * Start the cache job. The cache job caches resources that were not able to be previously
+ * downloaded. Only one job is run at a time.
+ */
+ protected static void startJob()
+ {
+ if(job == null)
+ {
+ startJob(0);
+ }
+ }
+
+ /**
+ * Start a new cache job with the specified delay.
+ *
+ * @param delay
+ * The start delay for the cache job.
+ */
+ private static void startJob(long delay)
+ {
+ job = new CacheJob();
+ job.setPriority(CacheJob.DECORATE);
+ job.schedule(delay); // start as soon as possible
+ }
+
+ /**
+ * Stop the current cache job. The cache job caches resources that were not able to be previously
+ * downloaded.
+ */
+ protected static void stopJob()
+ {
+ if (job != null)
+ {
+ job.cancel();
+ }
+ job = null;
+ }
}
diff --git a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java
index 62da7d4..704f0e0 100644
--- a/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java
+++ b/plugins/org.eclipse.wst.internet.cache/src/org/eclipse/wst/internet/cache/internal/CachePlugin.java
@@ -33,11 +33,6 @@
private static CachePlugin plugin;
/**
- * The cache job caches resources that were not able to be downloaded when requested.
- */
- private CacheJob job = null;
-
- /**
* The constructor.
*/
public CachePlugin()
@@ -106,7 +101,7 @@
}
Cache.getInstance().close();
- stopJob();
+ CacheJob.stopJob();
super.stop(context);
plugin = null;
}
@@ -129,7 +124,7 @@
public void setCacheEnabled(boolean enabled)
{
getPluginPreferences().setValue(PreferenceConstants.CACHE_ENABLED, enabled);
- stopJob();
+ CacheJob.stopJob();
}
/**
@@ -167,31 +162,4 @@
return getPluginPreferences().getBoolean(PreferenceConstants.PROMPT_DISAGREED_LICENSES);
return true;
}
-
- /**
- * Start the cache job. The cache job caches resources that were not able to be previously
- * downloaded. Only one job is run at a time.
- */
- protected void startJob()
- {
- if (job == null)
- {
- job = new CacheJob();
- job.setPriority(CacheJob.DECORATE);
- job.schedule(); // start as soon as possible
- }
- }
-
- /**
- * Stop the cache job. The cache job caches resources that were not able to be previously
- * downloaded.
- */
- protected void stopJob()
- {
- if (job != null)
- {
- job.cancel();
- }
- job = null;
- }
}