giacomo 2003/09/05 03:22:21
Modified: src/blocks/cron/java/org/apache/cocoon/components/cron
QuartzJobSchedulerEntry.java
Log:
implemented new interface method
Revision Changes Path
1.3 +54 -27
cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java
Index: QuartzJobSchedulerEntry.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobSchedulerEntry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -b -u -r1.2 -r1.3
--- QuartzJobSchedulerEntry.java 5 Sep 2003 07:04:36 -0000 1.2
+++ QuartzJobSchedulerEntry.java 5 Sep 2003 10:22:21 -0000 1.3
@@ -50,14 +50,17 @@
*/
package org.apache.cocoon.components.cron;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.quartz.CronTrigger;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
+import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
-import java.util.Date;
-
/**
* Implementation of the JobSchedulerEntry interface for the
QuartzJobScheduler
@@ -67,40 +70,34 @@
*/
public class QuartzJobSchedulerEntry
implements JobSchedulerEntry {
+ /** The data map */
+ private final JobDataMap m_data;
+
+ /** The detail */
+ private final JobDetail m_detail;
+
/** The scheduler reference */
private final Scheduler m_scheduler;
+ /** The date formatter */
+ private final SimpleDateFormat m_formatter = new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
/** The name */
private final String m_name;
- /** The detail */
- private final JobDetail m_detail;
-
/** The trigger */
private final Trigger m_trigger;
- /** The data map */
- private final JobDataMap m_data;
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.components.cron.JobSchedulerEntry#isRunning()
- */
- public boolean isRunning()
- {
- Boolean runs =
(Boolean)m_data.get(QuartzJobExecutor.DATA_MAP_KEY_ISRUNNING);
- if( null != runs )
- {
- return runs.booleanValue();
- }
- return false;
- }
-
/**
* Construct an JobSchedulerEntry
*
- * @param scheduler DOCUMENT ME!
+ * @param name The name of the job
+ * @param scheduler The QuartzJobScheduler
+ *
+ * @throws SchedulerException in case of failures
*/
- public QuartzJobSchedulerEntry(final String name, final Scheduler
scheduler) throws SchedulerException {
+ public QuartzJobSchedulerEntry(final String name, final Scheduler
scheduler)
+ throws SchedulerException {
m_scheduler = scheduler;
m_name = name;
m_detail = m_scheduler.getJobDetail(name,
QuartzJobScheduler.DEFAULT_QUARTZ_JOB_GROUP);
@@ -113,8 +110,8 @@
*/
public String getJobName() {
String name = (String)m_data.get(QuartzJobScheduler.DATA_MAP_ROLE);
- if( null == name )
- {
+
+ if (null == name) {
name =
m_data.get(QuartzJobScheduler.DATA_MAP_OBJECT).getClass().getName();
}
@@ -133,5 +130,35 @@
*/
public Date getNextTime() {
return m_trigger.getNextFireTime();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.components.cron.JobSchedulerEntry#isRunning()
+ */
+ public boolean isRunning() {
+ Boolean runs =
(Boolean)m_data.get(QuartzJobExecutor.DATA_MAP_KEY_ISRUNNING);
+
+ if (null != runs) {
+ return runs.booleanValue();
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.components.cron.JobSchedulerEntry#getSchedule()
+ */
+ public String getSchedule() {
+ if (m_trigger instanceof CronTrigger) {
+ return "cron: " + ((CronTrigger)m_trigger).getCronExpression();
+ } else if (m_trigger instanceof SimpleTrigger) {
+ if (((SimpleTrigger)m_trigger).getRepeatInterval() == 0) {
+ return "once: at " +
m_formatter.format(m_trigger.getFinalFireTime());
+ }
+
+ return "periodic: every " +
(((SimpleTrigger)m_trigger).getRepeatInterval() / 1000) + "s";
+ } else {
+ return "next: " +
m_formatter.format(m_trigger.getNextFireTime());
+ }
}
}