You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/09/21 00:57:55 UTC
cvs commit: jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule JobEntry.java
jon 01/09/20 15:57:55
Modified: src/services/java/org/apache/fulcrum/schedule JobEntry.java
Log:
added compareTo method because the JobQueue tries to sort the JobEntries
which are stored in an internal vector. The problem with the sort is that
JobEntry didn't have a compareTo method so we were seeing
ClassCastExceptions. how the hell did anyone have this code working
before?
-jon
Revision Changes Path
1.3 +23 -4 jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule/JobEntry.java
Index: JobEntry.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/src/services/java/org/apache/fulcrum/schedule/JobEntry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JobEntry.java 2001/08/02 05:31:12 1.2
+++ JobEntry.java 2001/09/20 22:57:55 1.3
@@ -55,6 +55,7 @@
*/
import java.util.Calendar;
+import java.lang.Comparable;
import java.util.Date;
import org.apache.torque.om.Persistent;
@@ -63,11 +64,11 @@
* Unix scheduler cron.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: JobEntry.java,v 1.2 2001/08/02 05:31:12 jvanzyl Exp $
+ * @version $Id: JobEntry.java,v 1.3 2001/09/20 22:57:55 jon Exp $
*/
public class JobEntry
extends org.apache.fulcrum.schedule.BaseJobEntry
- implements Persistent
+ implements Persistent, Comparable
{
/** indicates if job is currently running */
@@ -131,8 +132,11 @@
throws Exception
{
if ( task == null || task.length() == 0 )
- throw new Exception("Error in JobEntry. Bad Job parameter. Task not set.");
-
+ {
+ throw new Exception("Error in JobEntry. " +
+ "Bad Job parameter. Task not set.");
+ }
+
setSecond(sec);
setMinute(min);
setHour(hour);
@@ -141,6 +145,21 @@
setTask(task);
calcRunTime();
+ }
+
+ /**
+ * Compares one JobEntry to another JobEntry based on the JobId
+ */
+ public int compareTo(Object je)
+ {
+ int result = -1;
+ if (je instanceof JobEntry)
+ {
+ result = getJobId().getBigDecimal()
+ .compareTo(
+ ((JobEntry)je).getJobId().getBigDecimal());
+ }
+ return result;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org