>From 04026c76a1001b2eb6f1f8b815d5e5dfb779b7cf Mon Sep 17 00:00:00 2001
From: Adam Young <ayoung@redhat.com>
Date: Fri, 18 Nov 2011 14:02:21 -0500
Subject: [PATCH 40/45] typesafety  cron and jobscheduler

---
 .../com/netscape/certsrv/jobs/IJobsScheduler.java  |    4 +-
 .../src/com/netscape/cmscore/jobs/CronItem.java    |    4 +-
 .../src/com/netscape/cmscore/jobs/JobCron.java     |    6 ++--
 .../com/netscape/cmscore/jobs/JobsScheduler.java   |   32 ++++++++++----------
 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 fefa8cc95041c8ff75a5647ed74837db18f7f6fd..f34777f449969df6f83144ea837268a946851087 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 fda9069b343e1fb71cb71c67558ada00fec17403..4b248954fb675fcb599ead5fc0cf8cfc80b63b6f 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 13ef7f2561646caf1e5ab566147d874b2fd79e38..8272c44848ef8b500e085e185c4403f1919512d5 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 5d1d3668ca8c1f33f88102de3b50defcc3b1243f..ad6cf898db8e9b65f9ec3a18ee7ff17d83100005 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;
     }
 }
-- 
1.7.7.3

