summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2011-11-18 14:02:21 -0500
committerAdam Young <ayoung@redhat.com>2012-01-04 11:24:45 -0500
commite06776464042c557f2a66cbca874507e2be521a8 (patch)
tree5a1ebab738e9a643e4fc388a841e084c963706a8
parent04de68d946118b7c56691da707a01334799f17e8 (diff)
downloadpki-e06776464042c557f2a66cbca874507e2be521a8.tar.gz
pki-e06776464042c557f2a66cbca874507e2be521a8.tar.xz
pki-e06776464042c557f2a66cbca874507e2be521a8.zip
typesafety cron and jobscheduler
-rw-r--r--pki/base/common/src/com/netscape/certsrv/jobs/IJobsScheduler.java4
-rw-r--r--pki/base/common/src/com/netscape/cmscore/jobs/CronItem.java4
-rw-r--r--pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java6
-rw-r--r--pki/base/common/src/com/netscape/cmscore/jobs/JobsScheduler.java32
4 files changed, 23 insertions, 23 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/jobs/IJobsScheduler.java b/pki/base/common/src/com/netscape/certsrv/jobs/IJobsScheduler.java
index fefa8cc9..844250de 100644
--- a/pki/base/common/src/com/netscape/certsrv/jobs/IJobsScheduler.java
+++ b/pki/base/common/src/com/netscape/certsrv/jobs/IJobsScheduler.java
@@ -99,13 +99,13 @@ public interface IJobsScheduler extends ISubsystem {
* Retrieves all the job implementations.
* @return a Hashtable of available job plugin implementations
*/
- public Hashtable getPlugins();
+ public Hashtable<String, JobPlugin> getPlugins();
/**
* Retrieves all the job instances.
* @return a Hashtable of job instances
*/
- public Hashtable getInstances();
+ public Hashtable<String, IJob> getInstances();
/**
* Retrieves the configuration parameters of the given
diff --git a/pki/base/common/src/com/netscape/cmscore/jobs/CronItem.java b/pki/base/common/src/com/netscape/cmscore/jobs/CronItem.java
index fda9069b..4b248954 100644
--- a/pki/base/common/src/com/netscape/cmscore/jobs/CronItem.java
+++ b/pki/base/common/src/com/netscape/cmscore/jobs/CronItem.java
@@ -48,7 +48,7 @@ public class CronItem {
// store all elements in a field.
// elements can either be numbers or ranges (CronRange)
- protected Vector mElements = new Vector();
+ protected Vector<CronRange> mElements = new Vector<CronRange>();
public CronItem(int min, int max) {
mMin = min;
@@ -151,7 +151,7 @@ public class CronItem {
* represented as CronRange
* @return a vector of CronRanges
*/
- public Vector getElements() {
+ public Vector<CronRange> getElements() {
return mElements;
}
diff --git a/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java b/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
index 13ef7f25..8272c448 100644
--- a/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
+++ b/pki/base/common/src/com/netscape/cmscore/jobs/JobCron.java
@@ -209,10 +209,10 @@ public class JobCron implements IJobCron {
* @return boolean (true/false) on whether the element is one of
* the elements in the item
*/
- boolean isElement(int element, Vector item) {
+ boolean isElement(int element, Vector<CronRange> item) {
// loop through all of the elements of an item
- for (Enumeration e = item.elements(); e.hasMoreElements();) {
- CronRange cElement = (CronRange) e.nextElement();
+ for (Enumeration<CronRange> e = item.elements(); e.hasMoreElements();) {
+ CronRange cElement = e.nextElement();
// is a number
if (cElement.getBegin() == cElement.getEnd()) {
diff --git a/pki/base/common/src/com/netscape/cmscore/jobs/JobsScheduler.java b/pki/base/common/src/com/netscape/cmscore/jobs/JobsScheduler.java
index 5d1d3668..ad6cf898 100644
--- a/pki/base/common/src/com/netscape/cmscore/jobs/JobsScheduler.java
+++ b/pki/base/common/src/com/netscape/cmscore/jobs/JobsScheduler.java
@@ -69,9 +69,9 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
protected String mId = ID;
protected Thread mScheduleThread = null;
- public Hashtable mJobPlugins = new Hashtable();
- public Hashtable mJobs = new Hashtable();
- private Hashtable mJobThreads = new Hashtable();
+ public Hashtable<String, JobPlugin> mJobPlugins = new Hashtable<String, JobPlugin>();
+ public Hashtable<String, IJob> mJobs = new Hashtable<String, IJob>();
+ private Hashtable<String, Thread> mJobThreads = new Hashtable<String, Thread>();
private IConfigStore mConfig = null;
private ILogger mLogger = null;
@@ -122,7 +122,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
setInterval(i);
IConfigStore c = mConfig.getSubStore(PROP_IMPL);
- Enumeration mImpls = c.getSubStoreNames();
+ Enumeration<String> mImpls = c.getSubStoreNames();
// register all job plugins
while (mImpls.hasMoreElements()) {
@@ -136,7 +136,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
// register all jobs
c = config.getSubStore(PROP_JOB);
- Enumeration jobs = c.getSubStoreNames();
+ Enumeration<String> jobs = c.getSubStoreNames();
while (jobs.hasMoreElements()) {
String jobName = (String) jobs.nextElement();
@@ -196,11 +196,11 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
}
}
- public Hashtable getPlugins() {
+ public Hashtable<String, JobPlugin> getPlugins() {
return mJobPlugins;
}
- public Hashtable getInstances() {
+ public Hashtable<String, IJob> getInstances() {
return mJobs;
}
@@ -278,8 +278,8 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
IJob job = null;
- for (Enumeration e = mJobs.elements(); e.hasMoreElements();) {
- job = (IJob) e.nextElement();
+ for (Enumeration<IJob> e = mJobs.elements(); e.hasMoreElements();) {
+ job = e.nextElement();
// is it enabled?
IConfigStore cs = job.getConfigStore();
@@ -337,7 +337,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
/**
* is it the right month?
*/
- Vector moy =
+ Vector<CronRange> moy =
jcron.getItem(JobCron.CRON_MONTH_OF_YEAR).getElements();
int cronMoy = jcron.MOY_cal2cron(now);
@@ -350,8 +350,8 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
/**
* is it the right date?
*/
- Vector dow = jcron.getItem(JobCron.CRON_DAY_OF_WEEK).getElements();
- Vector dom = jcron.getItem(JobCron.CRON_DAY_OF_MONTH).getElements();
+ Vector<CronRange> dow = jcron.getItem(JobCron.CRON_DAY_OF_WEEK).getElements();
+ Vector<CronRange> dom = jcron.getItem(JobCron.CRON_DAY_OF_MONTH).getElements();
// can't be both empty
if ((dow.isEmpty()) && dom.isEmpty()) {
@@ -369,7 +369,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
/**
* is it the right hour?
*/
- Vector hour = jcron.getItem(JobCron.CRON_HOUR).getElements();
+ Vector<CronRange> hour = jcron.getItem(JobCron.CRON_HOUR).getElements();
if (jcron.isElement(now.get(Calendar.HOUR_OF_DAY), hour) == false) {
return false;
@@ -379,7 +379,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
/**
* is it the right minute?
*/
- Vector minute = jcron.getItem(JobCron.CRON_MINUTE).getElements();
+ Vector<CronRange> minute = jcron.getItem(JobCron.CRON_MINUTE).getElements();
if (jcron.isElement(now.get(Calendar.MINUTE), minute) == false) {
return false;
@@ -436,7 +436,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
mJobs.clear();
mJobs = null;
- Enumeration enums = mJobThreads.keys();
+ Enumeration<String> enums = mJobThreads.keys();
while (enums.hasMoreElements()) {
String id = (String)enums.nextElement();
Thread currthread = (Thread)mJobThreads.get(id);
@@ -537,7 +537,7 @@ public class JobsScheduler implements Runnable, IJobsScheduler {
level, msg);
}
- public Hashtable getJobPlugins() {
+ public Hashtable<String, JobPlugin> getJobPlugins() {
return mJobPlugins;
}
}