From fc7abee2e830e6fce590fb70bdf5610428dd8f94 Mon Sep 17 00:00:00 2001
From: Marko Lahma
Date: Sun, 28 Nov 2010 19:27:11 +0000
Subject: [PATCH] Quartz 2.0 migration work
---
Quartz.2008.5.1.ReSharper | 91 +
Quartz.2010.5.1.ReSharper | 3 +
.../CalendarIntervalTriggerTest.cs | 308 ++--
src/Quartz.Tests.Unit/CronExpressionTest.cs | 27 +
src/Quartz.Tests.Unit/CronTriggerTest.cs | 37 +-
.../DateIntervalTriggerTest.cs | 250 ---
.../Impl/AdoJobStore/StdAdoDelegateTest.cs | 3 +-
src/Quartz.Tests.Unit/JobDetailTest.cs | 1 +
src/Quartz.Tests.Unit/PriorityTest.cs | 18 +-
.../Quartz.Tests.Unit.2010.csproj | 1 -
.../Simpl/RAMJobStoreTest.cs | 83 +-
src/Quartz.Tests.Unit/SimpleTriggerTest.cs | 28 +-
src/Quartz/CalendarIntervalScheduleBuilder.cs | 2 +-
src/Quartz/Core/QuartzSchedulerThread.cs | 2 +-
src/Quartz/CronScheduleBuilder.cs | 25 +-
src/Quartz/ICalendarIntervalTrigger.cs | 4 +-
src/Quartz/ICronTrigger.cs | 4 +-
src/Quartz/IScheduleBuilder.cs | 9 +
src/Quartz/ISimpleTrigger.cs | 4 +-
src/Quartz/ITrigger.cs | 7 +-
...endarIntervalTriggerPersistenceDelegate.cs | 8 +-
.../CronTriggerPersistenceDelegate.cs | 4 +-
src/Quartz/Impl/AdoJobStore/DBSemaphore.cs | 4 +-
.../Impl/AdoJobStore/IDriverDelegate.cs | 56 +-
.../ITriggerPersistenceDelegate.cs | 6 +-
src/Quartz/Impl/AdoJobStore/JobStoreCMT.cs | 4 +-
.../Impl/AdoJobStore/JobStoreSupport.cs | 1533 +++++------------
src/Quartz/Impl/AdoJobStore/JobStoreTX.cs | 4 +-
src/Quartz/Impl/AdoJobStore/MySQLDelegate.cs | 8 +-
src/Quartz/Impl/AdoJobStore/OracleDelegate.cs | 8 +-
.../Impl/AdoJobStore/PostgreSQLDelegate.cs | 10 +-
...ertiesTriggerPersistenceDelegateSupport.cs | 101 +-
.../SimpleTriggerPersistenceDelegate.cs | 6 +-
.../Impl/AdoJobStore/SqlServerDelegate.cs | 8 +-
src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs | 146 +-
.../Impl/AdoJobStore/StdRowLockSemaphore.cs | 2 +-
src/Quartz/Impl/AdoJobStore/TriggerStatus.cs | 6 +-
src/Quartz/Impl/JobDetailImpl.cs | 10 +-
src/Quartz/Impl/JobExecutionContextImpl.cs | 2 +-
src/Quartz/Impl/Triggers/AbstractTrigger.cs | 30 +-
.../Triggers/CalendarIntervalTriggerImpl.cs | 18 +-
src/Quartz/Impl/Triggers/CronTriggerImpl.cs | 2 +-
src/Quartz/Impl/Triggers/SimpleTriggerImpl.cs | 2 +-
src/Quartz/JobBuilder.cs | 13 +-
.../Plugin/Xml/JobInitializationPlugin.cs | 469 -----
.../Xml/XMLSchedulingDataProcessorPlugin.cs | 16 +-
src/Quartz/Quartz.2010.csproj | 12 +-
src/Quartz/ScheduleBuilder.cs | 2 +-
src/Quartz/SimpleScheduleBuilder.cs | 301 +++-
src/Quartz/TriggerBuilder.cs | 84 +-
src/Quartz/TriggerConstants.cs | 10 +
src/Quartz/TriggerUtils.cs | 28 +-
src/Quartz/Util/ObjectUtils.cs | 5 +
src/Quartz/Xml/CalendarBundle.cs | 140 --
src/Quartz/Xml/JobSchedulingBundle.cs | 136 --
src/Quartz/Xml/JobSchedulingDataProcessor.cs | 756 --------
src/Quartz/Xml/XMLSchedulingDataProcessor.cs | 89 +-
src/Quartz/Xml/job_scheduling_data_1_0.cs | 676 --------
src/Quartz/Xml/job_scheduling_data_1_0.xsd | 418 -----
src/Quartz/Xml/job_scheduling_data_2_0.cs | 896 ++++++----
src/Quartz/Xml/job_scheduling_data_2_0.xsd | 1 +
61 files changed, 1973 insertions(+), 4964 deletions(-)
create mode 100644 Quartz.2008.5.1.ReSharper
delete mode 100644 src/Quartz.Tests.Unit/DateIntervalTriggerTest.cs
create mode 100644 src/Quartz/IScheduleBuilder.cs
delete mode 100644 src/Quartz/Plugin/Xml/JobInitializationPlugin.cs
create mode 100644 src/Quartz/TriggerConstants.cs
delete mode 100644 src/Quartz/Xml/CalendarBundle.cs
delete mode 100644 src/Quartz/Xml/JobSchedulingBundle.cs
delete mode 100644 src/Quartz/Xml/JobSchedulingDataProcessor.cs
delete mode 100644 src/Quartz/Xml/job_scheduling_data_1_0.cs
delete mode 100644 src/Quartz/Xml/job_scheduling_data_1_0.xsd
diff --git a/Quartz.2008.5.1.ReSharper b/Quartz.2008.5.1.ReSharper
new file mode 100644
index 000000000..a75e8f544
--- /dev/null
+++ b/Quartz.2008.5.1.ReSharper
@@ -0,0 +1,91 @@
+
+
+
+
+ SOLUTION
+
+
+ 1
+
+ - public
+ - protected
+ - internal
+ - private
+ - new
+ - abstract
+ - virtual
+ - override
+ - sealed
+ - static
+ - readonly
+ - extern
+ - unsafe
+ - volatile
+
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $object$_On$event$
+ $event$Handler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Quartz.2010.5.1.ReSharper b/Quartz.2010.5.1.ReSharper
index 00b017b66..491f2e042 100644
--- a/Quartz.2010.5.1.ReSharper
+++ b/Quartz.2010.5.1.ReSharper
@@ -91,6 +91,9 @@
+
+
+
\ No newline at end of file
diff --git a/src/Quartz.Tests.Unit/CalendarIntervalTriggerTest.cs b/src/Quartz.Tests.Unit/CalendarIntervalTriggerTest.cs
index b98c0ef15..0cb3a7085 100644
--- a/src/Quartz.Tests.Unit/CalendarIntervalTriggerTest.cs
+++ b/src/Quartz.Tests.Unit/CalendarIntervalTriggerTest.cs
@@ -20,7 +20,7 @@ public void testYearlyIntervalGetFireTimeAfter()
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateBuilder.IntervalUnit.YEAR;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Year;
yearlyTrigger.RepeatInterval = 2; // every two years;
DateTimeOffset targetCalendar = new DateTimeOffset(2009, 6, 1, 9, 30, 17, TimeSpan.Zero); // jump 4 years (2 intervals)
@@ -35,150 +35,136 @@ public void testYearlyIntervalGetFireTimeAfter()
[Test]
public void testMonthlyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
- yearlyTrigger.setStartTime(startCalendar.getTime());
- yearlyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.MONTH);
- yearlyTrigger.setRepeatInterval(5); // every five months
+ yearlyTrigger.StartTimeUtc = startCalendar;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Month;
+ yearlyTrigger.RepeatInterval = 5; // every five months
+
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddMonths(25); // jump 25 five months (5 intervals)
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.MONTH, 25); // jump 25 five months (5 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
- List fireTimes = TriggerUtils.computeFireTimes(yearlyTrigger, null, 6);
- Date fifthTime = (Date) fireTimes.get(5); // get the sixth fire time
+ IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
+ DateTimeOffset fifthTime = fireTimes[5]; // get the sixth fire time
- Assert.AreEqual("Month increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ Assert.AreEqual(targetCalendar, fifthTime, "Month increment result not as expected.");
}
[Test]
public void testWeeklyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
- yearlyTrigger.setStartTime(startCalendar.getTime());
- yearlyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.WEEK);
- yearlyTrigger.setRepeatInterval(6); // every six weeks
+ yearlyTrigger.StartTimeUtc = startCalendar;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Week;
+ yearlyTrigger.RepeatInterval = 6; // every six weeks
+
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddDays(7*6*4); // jump 24 weeks (4 intervals)
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.DAY_OF_YEAR, 7*6*4); // jump 24 weeks (4 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
- List fireTimes = TriggerUtils.computeFireTimes(yearlyTrigger, null, 7);
- Date fifthTime = (Date) fireTimes.get(4); // get the fifth fire time
+ IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 7);
+ DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
- System.out.
- println("targetCalendar:" + targetCalendar.getTime());
- System.out.
- println("fifthTimee" + fifthTime);
+ Console.Out.WriteLine("targetCalendar:" + targetCalendar);
+ Console.Out.WriteLine("fifthTimee" + fifthTime);
- Assert.AreEqual("Week increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ Assert.AreEqual(targetCalendar, fifthTime, "Week increment result not as expected.");
}
[Test]
public void testDailyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl dailyTrigger = new CalendarIntervalTriggerImpl();
- dailyTrigger.setStartTime(startCalendar.getTime());
- dailyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.DAY);
- dailyTrigger.setRepeatInterval(90); // every ninety days
+ dailyTrigger.StartTimeUtc = startCalendar;
+ dailyTrigger.RepeatIntervalUnit = IntervalUnit.Day;
+ dailyTrigger.RepeatInterval = 90; // every ninety days
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.DAY_OF_YEAR, 360); // jump 360 days (4 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddDays(360); // jump 360 days (4 intervals)
- List fireTimes = TriggerUtils.computeFireTimes(dailyTrigger, null, 6);
- Date fifthTime = (Date) fireTimes.get(4); // get the fifth fire time
- Assert.AreEqual("Day increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ IList fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
+ DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
+
+ Assert.AreEqual(targetCalendar, fifthTime, "Day increment result not as expected.");
}
[Test]
public void testHourlyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
- yearlyTrigger.setStartTime(startCalendar.getTime());
- yearlyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.HOUR);
- yearlyTrigger.setRepeatInterval(100); // every 100 hours
+ yearlyTrigger.StartTimeUtc = startCalendar;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Hour;
+ yearlyTrigger.RepeatInterval = 100; // every 100 hours
+
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddHours(400); // jump 400 hours (4 intervals)
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.HOUR, 400); // jump 400 hours (4 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
- List fireTimes = TriggerUtils.computeFireTimes(yearlyTrigger, null, 6);
- Date fifthTime = (Date) fireTimes.get(4); // get the fifth fire time
+ IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
+ DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
- Assert.AreEqual("Hour increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ Assert.AreEqual(targetCalendar, fifthTime, "Hour increment result not as expected.");
}
[Test]
public void testMinutelyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
- yearlyTrigger.setStartTime(startCalendar.getTime());
- yearlyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.MINUTE);
- yearlyTrigger.setRepeatInterval(100); // every 100 minutes
+ yearlyTrigger.StartTimeUtc = startCalendar;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Minute;
+ yearlyTrigger.RepeatInterval = 100; // every 100 minutes
+
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddMinutes(400); // jump 400 minutes (4 intervals)
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.MINUTE, 400); // jump 400 minutes (4 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
- List fireTimes = TriggerUtils.computeFireTimes(yearlyTrigger, null, 6);
- Date fifthTime = (Date) fireTimes.get(4); // get the fifth fire time
+ IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
+ DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
- Assert.AreEqual("Minutes increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ Assert.AreEqual(targetCalendar, fifthTime, "Minutes increment result not as expected.");
}
[Test]
public void testSecondlyIntervalGetFireTimeAfter()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl yearlyTrigger = new CalendarIntervalTriggerImpl();
- yearlyTrigger.setStartTime(startCalendar.getTime());
- yearlyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.SECOND);
- yearlyTrigger.setRepeatInterval(100); // every 100 seconds
+ yearlyTrigger.StartTimeUtc = startCalendar;
+ yearlyTrigger.RepeatIntervalUnit = IntervalUnit.Second;
+ yearlyTrigger.RepeatInterval = 100; // every 100 seconds
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.set(2005, Calendar.JUNE, 1, 9, 30, 17);
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.SECOND, 400); // jump 400 seconds (4 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
+
+ targetCalendar.AddSeconds(400); // jump 400 seconds (4 intervals)
- List fireTimes = TriggerUtils.computeFireTimes(yearlyTrigger, null, 6);
- Date fifthTime = (Date) fireTimes.get(4); // get the third fire time
- Assert.AreEqual("Seconds increment result not as expected.", targetCalendar.getTime(), fifthTime);
+ IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
+ DateTimeOffset fifthTime = fireTimes[4]; // get the third fire time
+
+ Assert.AreEqual(targetCalendar, fifthTime, "Seconds increment result not as expected.");
}
[Test]
@@ -186,114 +172,102 @@ public void testDaylightSavingsTransitions()
{
// Pick a day before a daylight savings transition...
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2010, Calendar.MARCH, 12, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2010, 3, 12, 9, 30, 17, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl dailyTrigger = new CalendarIntervalTriggerImpl();
- dailyTrigger.setStartTime(startCalendar.getTime());
- dailyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.DAY);
- dailyTrigger.setRepeatInterval(5); // every 5 days
+ dailyTrigger.StartTimeUtc = startCalendar;
+ dailyTrigger.RepeatIntervalUnit = IntervalUnit.Day;
+ dailyTrigger.RepeatInterval = 5; // every 5 days
- Calendar targetCalendar = Calendar.getInstance();
- targetCalendar.setTime(startCalendar.getTime());
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.DAY_OF_YEAR, 10); // jump 10 days (2 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset targetCalendar = startCalendar;
+
+ targetCalendar.AddDays(10); // jump 10 days (2 intervals)
- List fireTimes = TriggerUtils.computeFireTimes(dailyTrigger, null, 6);
- Date testTime = (Date) fireTimes.get(2); // get the third fire time
- Assert.AreEqual("Day increment result not as expected over spring daylight savings transition.", targetCalendar.getTime(), testTime);
+ IList fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
+ DateTimeOffset testTime = fireTimes[2]; // get the third fire time
+
+ Assert.AreEqual(targetCalendar, testTime, "Day increment result not as expected over spring daylight savings transition.");
// Pick a day before a daylight savings transition...
- startCalendar = Calendar.getInstance();
- startCalendar.set(2010, Calendar.OCTOBER, 31, 9, 30, 17);
- startCalendar.clear(Calendar.MILLISECOND);
+ startCalendar = new DateTimeOffset(2010, 10, 31, 9, 30, 17, TimeSpan.Zero);
+
dailyTrigger = new CalendarIntervalTriggerImpl();
- dailyTrigger.setStartTime(startCalendar.getTime());
- dailyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.DAY);
- dailyTrigger.setRepeatInterval(5); // every 5 days
+ dailyTrigger.StartTimeUtc = startCalendar;
+ dailyTrigger.RepeatIntervalUnit = IntervalUnit.Day;
+ dailyTrigger.RepeatInterval = 5; // every 5 days
- targetCalendar = Calendar.getInstance();
- targetCalendar.setTime(startCalendar.getTime());
- targetCalendar.setLenient(true);
- targetCalendar.add(Calendar.DAY_OF_YEAR, 15); // jump 15 days (3 intervals)
- targetCalendar.clear(Calendar.MILLISECOND);
+ targetCalendar = startCalendar;
+
+ targetCalendar.AddDays(15); // jump 15 days (3 intervals)
- fireTimes = TriggerUtils.computeFireTimes(dailyTrigger, null, 6);
- testTime = (Date) fireTimes.get(3); // get the fourth fire time
- Assert.AreEqual("Day increment result not as expected over fall daylight savings transition.", targetCalendar.getTime(), testTime);
+ fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
+ testTime = fireTimes[3]; // get the fourth fire time
+
+ Assert.AreEqual(targetCalendar, testTime, "Day increment result not as expected over fall daylight savings transition.");
}
[Test]
public void testFinalFireTimes()
{
- Calendar startCalendar = Calendar.getInstance();
- startCalendar.set(2010, Calendar.MARCH, 12, 9, 0, 0);
- startCalendar.clear(Calendar.MILLISECOND);
+ DateTimeOffset startCalendar = new DateTimeOffset(2010, 3, 12, 9, 0, 0, TimeSpan.Zero);
+
CalendarIntervalTriggerImpl dailyTrigger = new CalendarIntervalTriggerImpl();
- dailyTrigger.setStartTime(startCalendar.getTime());
- dailyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.DAY);
- dailyTrigger.setRepeatInterval(5); // every 5 days
+ dailyTrigger.StartTimeUtc = startCalendar;
+ dailyTrigger.RepeatIntervalUnit = IntervalUnit.Day;
+ dailyTrigger.RepeatInterval = 5; // every 5 days
+
+ DateTimeOffset endCalendar = startCalendar;
+ endCalendar.AddDays(10); // jump 10 days (2 intervals)
+ dailyTrigger.EndTimeUtc = endCalendar;
- Calendar endCalendar = Calendar.getInstance();
- endCalendar.setTime(startCalendar.getTime());
- endCalendar.setLenient(true);
- endCalendar.add(Calendar.DAY_OF_YEAR, 10); // jump 10 days (2 intervals)
- endCalendar.clear(Calendar.MILLISECOND);
- dailyTrigger.setEndTime(endCalendar.getTime());
+ DateTimeOffset? testTime = dailyTrigger.FinalFireTimeUtc;
- Date testTime = dailyTrigger.getFinalFireTime();
+ Assert.AreEqual(endCalendar, testTime, "Final fire time not computed correctly for day interval.");
- Assert.AreEqual("Final fire time not computed correctly for day interval.", endCalendar.getTime(), testTime);
+ startCalendar = new DateTimeOffset(2010, 3, 12, 9, 0, 0, TimeSpan.Zero);
- startCalendar = Calendar.getInstance();
- startCalendar.set(2010, Calendar.MARCH, 12, 9, 0, 0);
- startCalendar.clear(Calendar.MILLISECOND);
dailyTrigger = new CalendarIntervalTriggerImpl();
- dailyTrigger.setStartTime(startCalendar.getTime());
- dailyTrigger.setRepeatIntervalUnit(DateBuilder.IntervalUnit.MINUTE);
- dailyTrigger.setRepeatInterval(5); // every 5 minutes
+ dailyTrigger.StartTimeUtc = startCalendar;
+ dailyTrigger.RepeatIntervalUnit = IntervalUnit.Minute;
+ dailyTrigger.RepeatInterval = 5; // every 5 minutes
- endCalendar = Calendar.getInstance();
- endCalendar.setTime(startCalendar.getTime());
- endCalendar.setLenient(true);
- endCalendar.add(Calendar.DAY_OF_YEAR, 15); // jump 15 days
- endCalendar.add(Calendar.MINUTE, -2); // back up two minutes
- endCalendar.clear(Calendar.MILLISECOND);
- dailyTrigger.setEndTime(endCalendar.getTime());
+ endCalendar = startCalendar;
+ endCalendar.AddDays(15); // jump 15 days
+ endCalendar.AddMinutes(-2); // back up two minutes
+ dailyTrigger.EndTimeUtc = endCalendar;
- testTime = dailyTrigger.getFinalFireTime();
+ testTime = dailyTrigger.FinalFireTimeUtc;
- Assert.IsTrue("Final fire time not computed correctly for minutely interval.", (endCalendar.getTime().after(testTime)));
+ Assert.IsTrue((endCalendar > (testTime)), "Final fire time not computed correctly for minutely interval.");
- endCalendar.add(Calendar.MINUTE, -3); // back up three more minutes
+ endCalendar.AddMinutes(-3); // back up three more minutes
- Assert.IsTrue("Final fire time not computed correctly for minutely interval.", (endCalendar.getTime().equals(testTime)));
+ Assert.IsTrue((endCalendar.Equals(testTime)), "Final fire time not computed correctly for minutely interval.");
}
protected override object GetTargetObject()
{
JobDataMap jobDataMap = new JobDataMap();
- jobDataMap.put("A", "B");
+ jobDataMap["A"] = "B";
CalendarIntervalTriggerImpl t = new CalendarIntervalTriggerImpl();
- t.setName("test");
- t.setGroup("testGroup");
- t.setCalendarName("MyCalendar");
- t.setDescription("CronTriggerDesc");
- t.setJobDataMap(jobDataMap);
- t.setRepeatInterval(5);
- t.setRepeatIntervalUnit(IntervalUnit.DAY);
+ t.Name = "test";
+ t.Group = "testGroup";
+ t.CalendarName = "MyCalendar";
+ t.Description = "CronTriggerDesc";
+ t.JobDataMap = jobDataMap;
+ t.RepeatInterval = 5;
+ t.RepeatIntervalUnit = IntervalUnit.Day;
return t;
}
@@ -310,17 +284,17 @@ protected override void VerifyMatch(object target, object deserialized)
CalendarIntervalTriggerImpl deserializedCalTrigger = (CalendarIntervalTriggerImpl) deserialized;
Assert.IsNotNull(deserializedCalTrigger);
- Assert.AreEqual(targetCalTrigger.getName(), deserializedCalTrigger.getName());
- Assert.AreEqual(targetCalTrigger.getGroup(), deserializedCalTrigger.getGroup());
- Assert.AreEqual(targetCalTrigger.getJobName(), deserializedCalTrigger.getJobName());
- Assert.AreEqual(targetCalTrigger.getJobGroup(), deserializedCalTrigger.getJobGroup());
-// assertEquals(targetCronTrigger.getStartTime(), deserializedCronTrigger.getStartTime());
- Assert.AreEqual(targetCalTrigger.getEndTime(), deserializedCalTrigger.getEndTime());
- Assert.AreEqual(targetCalTrigger.getCalendarName(), deserializedCalTrigger.getCalendarName());
- Assert.AreEqual(targetCalTrigger.getDescription(), deserializedCalTrigger.getDescription());
- Assert.AreEqual(targetCalTrigger.getJobDataMap(), deserializedCalTrigger.getJobDataMap());
- Assert.AreEqual(targetCalTrigger.getRepeatInterval(), deserializedCalTrigger.getRepeatInterval());
- Assert.AreEqual(targetCalTrigger.getRepeatIntervalUnit(), deserializedCalTrigger.getRepeatIntervalUnit());
+ Assert.AreEqual(targetCalTrigger.Name, deserializedCalTrigger.Name);
+ Assert.AreEqual(targetCalTrigger.Group, deserializedCalTrigger.Group);
+ Assert.AreEqual(targetCalTrigger.JobName, deserializedCalTrigger.JobName);
+ Assert.AreEqual(targetCalTrigger.JobGroup, deserializedCalTrigger.JobGroup);
+// assertEquals(targetCronTrigger.getStartTime), deserializedCronTrigger.getStartTime());
+ Assert.AreEqual(targetCalTrigger.EndTimeUtc, deserializedCalTrigger.EndTimeUtc);
+ Assert.AreEqual(targetCalTrigger.CalendarName, deserializedCalTrigger.CalendarName);
+ Assert.AreEqual(targetCalTrigger.Description, deserializedCalTrigger.Description);
+ Assert.AreEqual(targetCalTrigger.JobDataMap, deserializedCalTrigger.JobDataMap);
+ Assert.AreEqual(targetCalTrigger.RepeatInterval, deserializedCalTrigger.RepeatInterval);
+ Assert.AreEqual(targetCalTrigger.RepeatIntervalUnit, deserializedCalTrigger.RepeatIntervalUnit);
}
}
}
\ No newline at end of file
diff --git a/src/Quartz.Tests.Unit/CronExpressionTest.cs b/src/Quartz.Tests.Unit/CronExpressionTest.cs
index f44127771..432aa2e8e 100644
--- a/src/Quartz.Tests.Unit/CronExpressionTest.cs
+++ b/src/Quartz.Tests.Unit/CronExpressionTest.cs
@@ -101,6 +101,33 @@ public void TestIsSatisfiedBy()
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal.AddDays(1)));
}
+ [Test]
+ public void TestLastDayOffset()
+ {
+ CronExpression cronExpression = new CronExpression("0 15 10 L-2 * ? 2010");
+
+ DateTimeOffset cal =new DateTimeOffset(2010, 10, 29, 10, 15, 0, TimeSpan.Zero); // last day - 2
+ Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
+
+ cal = new DateTimeOffset(2010, 10, 28, 10, 15, 0, TimeSpan.Zero);
+ Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
+
+ cronExpression = new CronExpression("0 15 10 L-5W * ? 2010");
+
+ cal = new DateTimeOffset(2010, 10, 26, 10, 15, 0, TimeSpan.Zero); // last day - 5
+ Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
+
+ cronExpression = new CronExpression("0 15 10 L-1 * ? 2010");
+
+ cal = new DateTimeOffset(2010, 10, 30, 10, 15, 0, TimeSpan.Zero); // last day - 1
+ Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
+
+ cronExpression = new CronExpression("0 15 10 L-1W * ? 2010");
+
+ cal = new DateTimeOffset(2010, 10, 29, 10, 15, 0, TimeSpan.Zero); // nearest weekday to last day - 1 (29th is a friday in 2010)
+ Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
+ }
+
[Test]
public void TestCronExpressionPassingMidnight()
{
diff --git a/src/Quartz.Tests.Unit/CronTriggerTest.cs b/src/Quartz.Tests.Unit/CronTriggerTest.cs
index d6120b779..9f69e2403 100644
--- a/src/Quartz.Tests.Unit/CronTriggerTest.cs
+++ b/src/Quartz.Tests.Unit/CronTriggerTest.cs
@@ -21,6 +21,9 @@
using NUnit.Framework;
+using Quartz.Impl.Triggers;
+using Quartz.Spi;
+
namespace Quartz.Tests.Unit
{
///
@@ -42,7 +45,7 @@ public void TestCronTriggerTimeZone_TimeZoneShouldChangeWhenChanged()
tzStr = "GMT Standard Time";
}
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById(tzStr);
- CronTrigger trigger = new CronTrigger();
+ CronTriggerImpl trigger = new CronTriggerImpl();
trigger.Name = "Quartz-579";
trigger.Group = SchedulerConstants.DefaultGroup;
trigger.TimeZone = tz;
@@ -53,7 +56,7 @@ public void TestCronTriggerTimeZone_TimeZoneShouldChangeWhenChanged()
[Test]
public void BasicCronTriggerTest()
{
- CronTrigger trigger = new CronTrigger();
+ CronTriggerImpl trigger = new CronTriggerImpl();
trigger.Name = "Quartz-Sample";
trigger.Group = SchedulerConstants.DefaultGroup;
trigger.CronExpressionString = "0 0 12 1 1 ? 2099";
@@ -66,10 +69,38 @@ public void BasicCronTriggerTest()
[Test]
public void TestPrecision()
{
- Trigger trigger = new CronTrigger();
+ IOperableTrigger trigger = new CronTriggerImpl();
trigger.StartTimeUtc = new DateTime(1982, 6, 28, 13, 5, 5, 233);
Assert.IsFalse(trigger.HasMillisecondPrecision);
Assert.AreEqual(0, trigger.StartTimeUtc.Millisecond);
}
+
+
+ [Test]
+ public void TestClone()
+ {
+ CronTriggerImpl trigger = new CronTriggerImpl();
+ trigger.Name =("test");
+ trigger.Group = ("testGroup");
+ trigger.CronExpressionString = ("0 0 12 * * ?");
+ ICronTrigger trigger2 = (ICronTrigger)trigger.Clone();
+
+ Assert.AreEqual(trigger, trigger2, "Cloning failed");
+
+ // equals() doesn't test the cron expression
+ Assert.AreEqual("0 0 12 * * ?", trigger2.CronExpressionString, "Cloning failed for the cron expression");
+ }
+
+ // http://jira.opensymphony.com/browse/QUARTZ-558
+ [Test]
+ public void TestQuartz558()
+ {
+ CronTriggerImpl trigger = new CronTriggerImpl();
+ trigger.Name =("test");
+ trigger.Group = ("testGroup");
+ ICronTrigger trigger2 = (ICronTrigger)trigger.Clone();
+
+ Assert.AreEqual(trigger, trigger2, "Cloning failed");
+ }
}
}
\ No newline at end of file
diff --git a/src/Quartz.Tests.Unit/DateIntervalTriggerTest.cs b/src/Quartz.Tests.Unit/DateIntervalTriggerTest.cs
deleted file mode 100644
index ad3cb2b69..000000000
--- a/src/Quartz.Tests.Unit/DateIntervalTriggerTest.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-#region License
-
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-using NUnit.Framework;
-
-namespace Quartz.Tests.Unit
-{
- ///
- /// Unit tests for DateIntervalTrigger.
- ///
- /// Marko Lahma (.NET)
- [TestFixture]
- public class DateIntervalTriggerTest
- {
- [Test]
- public void TestYearlyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startDate = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startDate;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Year;
- yearlyTrigger.RepeatInterval = 2; // every two years;
-
- DateTimeOffset targetDate = new DateTimeOffset(2009, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 4);
- DateTimeOffset secondTime = fireTimes[2]; // get the third fire time
-
- Assert.AreEqual(targetDate, secondTime, "Year increment result not as expected.");
- }
-
-
- [Test]
- public void TestMonthlyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Month;
- yearlyTrigger.RepeatInterval = 5; // every five months
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddMonths(25); // jump 25 five months (5 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
- DateTimeOffset fifthTime = fireTimes[5]; // get the sixth fire time
-
- Assert.AreEqual(targetCalendar, fifthTime, "Month increment result not as expected.");
- }
-
-
- [Test]
- public void TestWeeklyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Week;
- yearlyTrigger.RepeatInterval = 6; // every six weeks
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddDays(7 * 6 * 4); // jump 24 weeks (4 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 7);
- DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
-
- Console.Out.WriteLine("targetCalendar:" + targetCalendar.ToLocalTime());
- Console.Out.WriteLine("fifthTimee" + fifthTime.ToLocalTime());
-
- Assert.AreEqual(targetCalendar, fifthTime, "Week increment result not as expected.");
- }
-
- [Test]
- public void TestDailyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger dailyTrigger = new DateIntervalTrigger();
- dailyTrigger.StartTimeUtc = startCalendar;
- dailyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Day;
- dailyTrigger.RepeatInterval = 90; // every ninety days
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddDays(360); // jump 360 days (4 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
- DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
-
- Assert.AreEqual(targetCalendar, fifthTime, "Day increment result not as expected.");
- }
-
- [Test]
- public void TestHourlyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Hour;
- yearlyTrigger.RepeatInterval = 100; // every 100 hours
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddHours(400); // jump 400 hours (4 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
- DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
-
- Assert.AreEqual(targetCalendar, fifthTime, "Hour increment result not as expected.");
- }
-
- [Test]
- public void TestMinutelyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Minute;
- yearlyTrigger.RepeatInterval = 100; // every 100 minutes
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddMinutes(400); // jump 400 minutes (4 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
- DateTimeOffset fifthTime = fireTimes[4]; // get the fifth fire time
-
- Assert.AreEqual(targetCalendar, fifthTime, "Minutes increment result not as expected.");
- }
-
- [Test]
- public void TestSecondlyIntervalGetFireTimeAfter()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger yearlyTrigger = new DateIntervalTrigger();
- yearlyTrigger.StartTimeUtc = startCalendar;
- yearlyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Second;
- yearlyTrigger.RepeatInterval = 100; // every 100 seconds
-
- DateTimeOffset targetCalendar = new DateTimeOffset(2005, 6, 1, 9, 30, 17, TimeSpan.Zero);
- targetCalendar = targetCalendar.AddSeconds(400); // jump 400 seconds (4 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(yearlyTrigger, null, 6);
- DateTimeOffset fifthTime = fireTimes[4]; // get the third fire time
-
- Assert.AreEqual(targetCalendar, fifthTime, "Seconds increment result not as expected.");
- }
-
- [Test]
- public void TestDaylightSavingsTransitions()
- {
- // Pick a day before a daylight savings transition...
-
- DateTimeOffset startCalendar = new DateTimeOffset(2010, 3, 12, 9, 30, 17, TimeSpan.Zero);
-
- DateIntervalTrigger dailyTrigger = new DateIntervalTrigger();
- dailyTrigger.StartTimeUtc = startCalendar;
- dailyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Day;
- dailyTrigger.RepeatInterval = 5; // every 5 days
-
- DateTimeOffset targetCalendar = startCalendar;
- targetCalendar = targetCalendar.AddDays(10); // jump 10 days (2 intervals)
-
- IList fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
- DateTimeOffset testTime = fireTimes[2]; // get the third fire time
-
- Assert.AreEqual(targetCalendar, testTime, "Day increment result not as expected over spring daylight savings transition.");
-
- // Pick a day before a daylight savings transition...
-
- startCalendar = new DateTimeOffset(2010, 10, 31, 9, 30, 17, TimeSpan.Zero);
-
- dailyTrigger = new DateIntervalTrigger();
- dailyTrigger.StartTimeUtc = startCalendar;
- dailyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Day;
- dailyTrigger.RepeatInterval = 5; // every 5 days
-
- targetCalendar = startCalendar;
- targetCalendar = targetCalendar.AddDays(15); // jump 15 days (3 intervals)
-
- fireTimes = TriggerUtils.ComputeFireTimes(dailyTrigger, null, 6);
- testTime = fireTimes[3]; // get the fourth fire time
-
- Assert.AreEqual(targetCalendar, testTime, "Day increment result not as expected over fall daylight savings transition.");
- }
-
- [Test]
- public void TestFinalFireTimes()
- {
- DateTimeOffset startCalendar = new DateTimeOffset(2010, 3, 12, 9, 0, 0, TimeSpan.Zero);
-
- DateIntervalTrigger dailyTrigger = new DateIntervalTrigger();
- dailyTrigger.StartTimeUtc = startCalendar;
- dailyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Day;
- dailyTrigger.RepeatInterval = 5; // every 5 days
-
- DateTimeOffset endCalendar = startCalendar;
- endCalendar = endCalendar.AddDays(10); // jump 10 days (2 intervals)
- dailyTrigger.EndTimeUtc = endCalendar;
-
- DateTimeOffset? testTime = dailyTrigger.FinalFireTimeUtc;
-
- Assert.AreEqual(endCalendar, testTime, "Final fire time not computed correctly for day interval.");
-
-
- startCalendar = new DateTimeOffset(2010, 3, 12, 9, 0, 0, TimeSpan.Zero);
-
- dailyTrigger = new DateIntervalTrigger();
- dailyTrigger.StartTimeUtc = startCalendar;
- dailyTrigger.RepeatIntervalUnit = DateIntervalTrigger.IntervalUnit.Minute;
- dailyTrigger.RepeatInterval = 5; // every 5 minutes
-
- endCalendar = startCalendar;
- endCalendar = endCalendar.AddDays(15); // jump 15 days
- endCalendar = endCalendar.AddMinutes(-2); // back up two minutes
- dailyTrigger.EndTimeUtc = endCalendar;
-
- testTime = dailyTrigger.FinalFireTimeUtc;
-
- Assert.IsTrue(endCalendar > testTime, "Final fire time not computed correctly for minutely interval.");
-
- endCalendar = endCalendar.AddMinutes(-3); // back up three more minutes
-
- Assert.AreEqual(endCalendar, testTime, "Final fire time not computed correctly for minutely interval.");
- }
- }
-}
\ No newline at end of file
diff --git a/src/Quartz.Tests.Unit/Impl/AdoJobStore/StdAdoDelegateTest.cs b/src/Quartz.Tests.Unit/Impl/AdoJobStore/StdAdoDelegateTest.cs
index 4c412b063..9282ba586 100644
--- a/src/Quartz.Tests.Unit/Impl/AdoJobStore/StdAdoDelegateTest.cs
+++ b/src/Quartz.Tests.Unit/Impl/AdoJobStore/StdAdoDelegateTest.cs
@@ -23,6 +23,7 @@
using NUnit.Framework;
using Quartz.Impl.AdoJobStore;
using Quartz.Impl.AdoJobStore.Common;
+using Quartz.Simpl;
namespace Quartz.Tests.Unit.Impl.AdoJobStore
{
@@ -33,7 +34,7 @@ public class StdAdoDelegateTest
[Test]
public void TestSerializeJobData()
{
- StdAdoDelegate del = new StdAdoDelegate(LogManager.GetLogger(GetType()), "QRTZ_", "INSTANCE", new DbProvider("SqlServer-11", ""));
+ StdAdoDelegate del = new StdAdoDelegate(LogManager.GetLogger(GetType()), "QRTZ_", "TESTSCHED", "INSTANCE", new DbProvider("SqlServer-11", ""), new SimpleTypeLoadHelper());
JobDataMap jdm = new JobDataMap();
del.SerializeJobData(jdm);
diff --git a/src/Quartz.Tests.Unit/JobDetailTest.cs b/src/Quartz.Tests.Unit/JobDetailTest.cs
index 82cc453cf..8a821d3a9 100644
--- a/src/Quartz.Tests.Unit/JobDetailTest.cs
+++ b/src/Quartz.Tests.Unit/JobDetailTest.cs
@@ -19,6 +19,7 @@
using NUnit.Framework;
+using Quartz.Impl;
using Quartz.Job;
namespace Quartz.Tests.Unit
diff --git a/src/Quartz.Tests.Unit/PriorityTest.cs b/src/Quartz.Tests.Unit/PriorityTest.cs
index 8eef935d0..4661feeb6 100644
--- a/src/Quartz.Tests.Unit/PriorityTest.cs
+++ b/src/Quartz.Tests.Unit/PriorityTest.cs
@@ -25,6 +25,8 @@
using NUnit.Framework;
using Quartz.Impl;
+using Quartz.Impl.Triggers;
+using Quartz.Spi;
namespace Quartz.Tests.Unit
{
@@ -58,14 +60,14 @@ public void TestSameDefaultPriority()
DateTime n = DateTime.UtcNow;
DateTime cal = new DateTime(n.Year, n.Month, n.Day, n.Hour, n.Minute, 1, n.Millisecond);
- Trigger trig1 = new SimpleTrigger("T1", null, cal);
- Trigger trig2 = new SimpleTrigger("T2", null, cal);
+ IMutableTrigger trig1 = new SimpleTriggerImpl("T1", null, cal);
+ IMutableTrigger trig2 = new SimpleTriggerImpl("T2", null, cal);
JobDetailImpl jobDetail = new JobDetailImpl("JD", null, typeof (TestJob));
sched.ScheduleJob(jobDetail, trig1);
- trig2.JobName = jobDetail.Name;
+ trig2.JobKey = new JobKey(jobDetail.Key.Name);
sched.ScheduleJob(trig2);
sched.Start();
@@ -89,17 +91,17 @@ public void TestDifferentPriority()
DateTime n = DateTime.UtcNow.AddSeconds(1);
DateTime cal = new DateTime(n.Year, n.Month, n.Day, n.Hour, n.Minute, 1, n.Millisecond);
- Trigger trig1 = new SimpleTrigger("T1", null, cal);
+ IOperableTrigger trig1 = new SimpleTriggerImpl("T1", null, cal);
trig1.Priority = 5;
- Trigger trig2 = new SimpleTrigger("T2", null, cal);
+ IOperableTrigger trig2 = new SimpleTriggerImpl("T2", null, cal);
trig2.Priority = 10;
JobDetailImpl jobDetail = new JobDetailImpl("JD", null, typeof (TestJob));
sched.ScheduleJob(jobDetail, trig1);
- trig2.JobName = jobDetail.Name;
+ trig2.JobKey = new JobKey(jobDetail.Key.Name);
sched.ScheduleJob(trig2);
sched.Start();
@@ -113,9 +115,9 @@ public void TestDifferentPriority()
class TestJob : IStatefulJob
{
- public void Execute(JobExecutionContext context)
+ public void Execute(IJobExecutionContext context)
{
- result.Append(context.Trigger.Name);
+ result.Append(context.Trigger.Key.Name);
}
}
}
diff --git a/src/Quartz.Tests.Unit/Quartz.Tests.Unit.2010.csproj b/src/Quartz.Tests.Unit/Quartz.Tests.Unit.2010.csproj
index e86539406..f69fc370c 100644
--- a/src/Quartz.Tests.Unit/Quartz.Tests.Unit.2010.csproj
+++ b/src/Quartz.Tests.Unit/Quartz.Tests.Unit.2010.csproj
@@ -113,7 +113,6 @@
-
diff --git a/src/Quartz.Tests.Unit/Simpl/RAMJobStoreTest.cs b/src/Quartz.Tests.Unit/Simpl/RAMJobStoreTest.cs
index dd2a8f624..23654f1a2 100644
--- a/src/Quartz.Tests.Unit/Simpl/RAMJobStoreTest.cs
+++ b/src/Quartz.Tests.Unit/Simpl/RAMJobStoreTest.cs
@@ -21,7 +21,10 @@
using System;
using NUnit.Framework;
+
+using Quartz.Impl;
using Quartz.Impl.Calendar;
+using Quartz.Impl.Triggers;
using Quartz.Job;
using Quartz.Simpl;
using Quartz.Spi;
@@ -55,16 +58,16 @@ public void SetUp()
public void TestAcquireNextTrigger()
{
DateTimeOffset d = DateTimeOffset.UtcNow;
- Trigger trigger1 =
- new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name,
+ IOperableTrigger trigger1 =
+ new SimpleTriggerImpl("trigger1", "triggerGroup1", fJobDetail.Name,
fJobDetail.Group, d.AddSeconds(200),
d.AddSeconds(200), 2, TimeSpan.FromSeconds(2));
- Trigger trigger2 =
- new SimpleTrigger("trigger2", "triggerGroup1", fJobDetail.Name,
+ IOperableTrigger trigger2 =
+ new SimpleTriggerImpl("trigger2", "triggerGroup1", fJobDetail.Name,
fJobDetail.Group, d.AddSeconds(-100),
d.AddSeconds(20), 2, TimeSpan.FromSeconds(2));
- Trigger trigger3 =
- new SimpleTrigger("trigger1", "triggerGroup2", fJobDetail.Name,
+ IOperableTrigger trigger3 =
+ new SimpleTriggerImpl("trigger1", "triggerGroup2", fJobDetail.Name,
fJobDetail.Group, d.AddSeconds(100),
d.AddSeconds(200), 2, TimeSpan.FromSeconds(2));
@@ -106,25 +109,25 @@ public void TestAcquireNextTrigger()
[Test]
public void TestAcquireNextTriggerBatch()
{
- Trigger trigger1 =
- new SimpleTrigger("trigger1", "triggerGroup1", this.fJobDetail.Name,
+ IOperableTrigger trigger1 =
+ new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.Name,
this.fJobDetail.Group, DateTimeOffset.UtcNow.AddSeconds(200),
DateTimeOffset.UtcNow.AddSeconds(200), 2, TimeSpan.FromSeconds(2));
- Trigger trigger2 =
- new SimpleTrigger("trigger2", "triggerGroup1", this.fJobDetail.Name,
+ IOperableTrigger trigger2 =
+ new SimpleTriggerImpl("trigger2", "triggerGroup1", this.fJobDetail.Name,
this.fJobDetail.Group, DateTimeOffset.UtcNow.AddMilliseconds(200100),
DateTimeOffset.UtcNow.AddMilliseconds(200100), 2, TimeSpan.FromSeconds(2));
- Trigger trigger3 =
- new SimpleTrigger("trigger3", "triggerGroup1", this.fJobDetail.Name,
+ IOperableTrigger trigger3 =
+ new SimpleTriggerImpl("trigger3", "triggerGroup1", this.fJobDetail.Name,
this.fJobDetail.Group, DateTimeOffset.UtcNow.AddMilliseconds(200200),
DateTimeOffset.UtcNow.AddMilliseconds(200200), 2, TimeSpan.FromSeconds(2));
- Trigger trigger4 =
- new SimpleTrigger("trigger4", "triggerGroup1", this.fJobDetail.Name,
+ IOperableTrigger trigger4 =
+ new SimpleTriggerImpl("trigger4", "triggerGroup1", this.fJobDetail.Name,
this.fJobDetail.Group, DateTimeOffset.UtcNow.AddMilliseconds(200300),
DateTimeOffset.UtcNow.AddMilliseconds(200300), 2, TimeSpan.FromSeconds(2));
- Trigger trigger10 =
- new SimpleTrigger("trigger10", "triggerGroup2", this.fJobDetail.Name,
+ IOperableTrigger trigger10 =
+ new SimpleTriggerImpl("trigger10", "triggerGroup2", this.fJobDetail.Name,
this.fJobDetail.Group, DateTimeOffset.UtcNow.AddSeconds(500),
DateTimeOffset.UtcNow.AddSeconds(700), 2, TimeSpan.FromSeconds(2));
@@ -177,19 +180,19 @@ public void TestAcquireNextTriggerBatch()
[Test]
public void TestTriggerStates()
{
- Trigger trigger =
- new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
+ IOperableTrigger trigger =
+ new SimpleTriggerImpl("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
DateTimeOffset.Now.AddSeconds(100), DateTimeOffset.Now.AddSeconds(200), 2, TimeSpan.FromSeconds(2));
trigger.ComputeFirstFireTimeUtc(null);
- Assert.AreEqual(TriggerState.None, fJobStore.GetTriggerState(trigger.Name, trigger.Group));
+ Assert.AreEqual(TriggerState.None, fJobStore.GetTriggerState(trigger.Key));
fJobStore.StoreTrigger(trigger, false);
- Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(trigger.Name, trigger.Group));
+ Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(trigger.Key));
- fJobStore.PauseTrigger(trigger.Name, trigger.Group);
- Assert.AreEqual(TriggerState.Paused, fJobStore.GetTriggerState(trigger.Name, trigger.Group));
+ fJobStore.PauseTrigger(trigger.Key);
+ Assert.AreEqual(TriggerState.Paused, fJobStore.GetTriggerState(trigger.Key));
- fJobStore.ResumeTrigger(trigger.Name, trigger.Group);
- Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(trigger.Name, trigger.Group));
+ fJobStore.ResumeTrigger(trigger.Key);
+ Assert.AreEqual(TriggerState.Normal, fJobStore.GetTriggerState(trigger.Key));
trigger = fJobStore.AcquireNextTriggers(trigger.GetNextFireTimeUtc().Value.AddSeconds(10), 1,
TimeSpan.FromMilliseconds(1))[0];
@@ -207,7 +210,7 @@ public void TestRemoveCalendarWhenTriggersPresent()
{
// QRTZNET-29
- Trigger trigger = new SimpleTrigger("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
+ IOperableTrigger trigger = new SimpleTriggerImpl("trigger1", "triggerGroup1", fJobDetail.Name, fJobDetail.Group,
DateTimeOffset.Now.AddSeconds(100), DateTimeOffset.Now.AddSeconds(200), 2,
TimeSpan.FromSeconds(2));
trigger.ComputeFirstFireTimeUtc(null);
@@ -228,18 +231,17 @@ public void TestStoreTriggerReplacesTrigger()
string trName = "StoreTriggerReplacesTrigger";
string trGroup = "StoreTriggerReplacesTriggerGroup";
- Trigger tr = new SimpleTrigger(trName, trGroup, DateTimeOffset.Now);
- tr.JobGroup = jobGroup;
- tr.JobName = jobName;
+ IOperableTrigger tr = new SimpleTriggerImpl(trName, trGroup, DateTimeOffset.Now);
+ tr.JobKey = new JobKey(jobName, jobGroup);
tr.CalendarName = null;
fJobStore.StoreTrigger(tr, false);
- Assert.AreEqual(tr, fJobStore.RetrieveTrigger(trName, trGroup));
+ Assert.AreEqual(tr, fJobStore.RetrieveTrigger(new TriggerKey(trName, trGroup)));
tr.CalendarName = "NonExistingCalendar";
fJobStore.StoreTrigger(tr, true);
- Assert.AreEqual(tr, fJobStore.RetrieveTrigger(trName, trGroup));
- Assert.AreEqual(tr.CalendarName, fJobStore.RetrieveTrigger(trName, trGroup).CalendarName,
+ Assert.AreEqual(tr, fJobStore.RetrieveTrigger(new TriggerKey(trName, trGroup)));
+ Assert.AreEqual(tr.CalendarName, fJobStore.RetrieveTrigger(new TriggerKey(trName, trGroup)).CalendarName,
"StoreJob doesn't replace triggers");
bool exeptionRaised = false;
@@ -271,18 +273,17 @@ public void PauseJobGroupPausesNewJob()
string trName = "PauseJobGroupPausesNewJobTrigger";
string trGroup = "PauseJobGroupPausesNewJobTriggerGroup";
- Trigger tr = new SimpleTrigger(trName, trGroup, DateTimeOffset.UtcNow);
- tr.JobGroup = jobGroup;
- tr.JobName = jobName2;
+ IOperableTrigger tr = new SimpleTriggerImpl(trName, trGroup, DateTimeOffset.UtcNow);
+ tr.JobKey = new JobKey(jobName2, jobGroup);
fJobStore.StoreTrigger(tr, false);
- Assert.AreEqual(TriggerState.Paused, fJobStore.GetTriggerState(tr.Name, tr.Group));
+ Assert.AreEqual(TriggerState.Paused, fJobStore.GetTriggerState(tr.Key));
}
[Test]
public void TestRetrieveJob_NoJobFound()
{
RAMJobStore store = new RAMJobStore();
- JobDetailImpl job = store.RetrieveJob("not", "existing");
+ IJobDetail job = store.RetrieveJob(new JobKey("not", "existing"));
Assert.IsNull(job);
}
@@ -290,7 +291,7 @@ public void TestRetrieveJob_NoJobFound()
public void TestRetrieveTrigger_NoTriggerFound()
{
RAMJobStore store = new RAMJobStore();
- Trigger trigger = store.RetrieveTrigger("not", "existing");
+ IOperableTrigger trigger = store.RetrieveTrigger(new TriggerKey("not", "existing"));
Assert.IsNull(trigger);
}
@@ -298,18 +299,22 @@ public class SampleSignaler : ISchedulerSignaler
{
internal int fMisfireCount = 0;
- public void NotifyTriggerListenersMisfired(Trigger trigger)
+ public void NotifyTriggerListenersMisfired(ITrigger trigger)
{
fMisfireCount++;
}
- public void NotifySchedulerListenersFinalized(Trigger trigger)
+ public void NotifySchedulerListenersFinalized(ITrigger trigger)
{
}
public void SignalSchedulingChange(DateTimeOffset? candidateNewNextFireTimeUtc)
{
}
+
+ public void NotifySchedulerListenersJobDeleted(JobKey jobKey)
+ {
+ }
}
}
}
\ No newline at end of file
diff --git a/src/Quartz.Tests.Unit/SimpleTriggerTest.cs b/src/Quartz.Tests.Unit/SimpleTriggerTest.cs
index c5325839d..556260aa8 100644
--- a/src/Quartz.Tests.Unit/SimpleTriggerTest.cs
+++ b/src/Quartz.Tests.Unit/SimpleTriggerTest.cs
@@ -21,6 +21,8 @@
using NUnit.Framework;
using Quartz.Impl.Calendar;
+using Quartz.Impl.Triggers;
+using Quartz.Spi;
namespace Quartz.Tests.Unit
@@ -30,7 +32,7 @@ namespace Quartz.Tests.Unit
///
public class SimpleTriggerTest : SerializationTestSupport
{
- private static readonly string[] Versions = new string[] {"0.6"};
+ private static readonly string[] Versions = new string[] {"2.0"};
//private static TimeZone EST_TIME_ZONE = TimeZone.CurrentTimeZone;
private static readonly DateTimeOffset StartTime;
@@ -55,14 +57,13 @@ protected override object GetTargetObject()
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.Put("A", "B");
- SimpleTrigger t = new SimpleTrigger("SimpleTrigger", "SimpleGroup",
+ SimpleTriggerImpl t = new SimpleTriggerImpl("SimpleTrigger", "SimpleGroup",
"JobName", "JobGroup", StartTime,
EndTime, 5, TimeSpan.FromSeconds(1));
t.CalendarName = "MyCalendar";
t.Description = "SimpleTriggerDesc";
t.JobDataMap = jobDataMap;
t.MisfireInstruction = (MisfireInstruction.SimpleTrigger.RescheduleNextWithRemainingCount);
- t.Volatile = true;
return t;
}
@@ -86,8 +87,8 @@ protected override String[] GetVersions()
///
protected override void VerifyMatch(Object target, Object deserialized)
{
- SimpleTrigger targetSimpleTrigger = (SimpleTrigger) target;
- SimpleTrigger deserializedSimpleTrigger = (SimpleTrigger) deserialized;
+ SimpleTriggerImpl targetSimpleTrigger = (SimpleTriggerImpl) target;
+ SimpleTriggerImpl deserializedSimpleTrigger = (SimpleTriggerImpl) deserialized;
Assert.IsNotNull(deserializedSimpleTrigger);
Assert.AreEqual(targetSimpleTrigger.Name, deserializedSimpleTrigger.Name);
@@ -102,7 +103,6 @@ protected override void VerifyMatch(Object target, Object deserialized)
Assert.AreEqual(targetSimpleTrigger.Description, deserializedSimpleTrigger.Description);
Assert.AreEqual(targetSimpleTrigger.JobDataMap, deserializedSimpleTrigger.JobDataMap);
Assert.AreEqual(targetSimpleTrigger.MisfireInstruction, deserializedSimpleTrigger.MisfireInstruction);
- Assert.IsTrue(targetSimpleTrigger.Volatile);
}
[Test]
@@ -112,7 +112,7 @@ public void TestUpdateAfterMisfire()
DateTimeOffset endTime = new DateTimeOffset(2005, 7, 5, 10, 0, 0, TimeSpan.Zero);
- SimpleTrigger simpleTrigger = new SimpleTrigger();
+ SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
simpleTrigger.MisfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount;
simpleTrigger.RepeatCount = 5;
simpleTrigger.StartTimeUtc = startTime;
@@ -127,7 +127,7 @@ public void TestUpdateAfterMisfire()
[Test]
public void TestGetFireTimeAfter()
{
- SimpleTrigger simpleTrigger = new SimpleTrigger();
+ SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
DateTimeOffset startTime = TriggerUtils.GetEvenSecondDate(DateTime.UtcNow);
@@ -143,16 +143,16 @@ public void TestGetFireTimeAfter()
[Test]
public void TestClone()
{
- SimpleTrigger simpleTrigger = new SimpleTrigger();
+ SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
// Make sure empty sub-objects are cloned okay
- Trigger clone = (Trigger) simpleTrigger.Clone();
+ ITrigger clone = (ITrigger) simpleTrigger.Clone();
Assert.AreEqual(0, clone.JobDataMap.Count);
// Make sure non-empty sub-objects are cloned okay
simpleTrigger.JobDataMap.Put("K1", "V1");
simpleTrigger.JobDataMap.Put("K2", "V2");
- clone = (Trigger) simpleTrigger.Clone();
+ clone = (ITrigger) simpleTrigger.Clone();
Assert.AreEqual(2, clone.JobDataMap.Count);
Assert.AreEqual("V1", clone.JobDataMap.Get("K1"));
Assert.AreEqual("V2", clone.JobDataMap.Get("K2"));
@@ -172,10 +172,10 @@ public void TestClone()
public void TestGetFireTimeAfter_WithCalendar()
{
DailyCalendar dailyCalendar = new DailyCalendar("1:20", "14:50");
- SimpleTrigger simpleTrigger = new SimpleTrigger();
+ SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
simpleTrigger.RepeatInterval = TimeSpan.FromMilliseconds(10);
simpleTrigger.RepeatCount = 1;
- DateTimeOffset neverFireTime = TriggerUtils.GetEvenMinuteDateBefore(dailyCalendar.GetTimeRangeStartingTimeUtc(DateTime.Now));
+ DateTimeOffset neverFireTime = DateBuilder.EvenMinuteDateBefore(dailyCalendar.GetTimeRangeStartingTimeUtc(DateTime.Now));
simpleTrigger.StartTimeUtc = neverFireTime;
simpleTrigger.ComputeFirstFireTimeUtc(dailyCalendar);
@@ -187,7 +187,7 @@ public void TestGetFireTimeAfter_WithCalendar()
[Test]
public void TestPrecision()
{
- Trigger trigger = new SimpleTrigger();
+ IOperableTrigger trigger = new SimpleTriggerImpl();
trigger.StartTimeUtc = new DateTimeOffset(1982, 6, 28, 13, 5, 5, 233, TimeSpan.Zero);
Assert.IsTrue(trigger.HasMillisecondPrecision);
Assert.AreEqual(233, trigger.StartTimeUtc.Millisecond);
diff --git a/src/Quartz/CalendarIntervalScheduleBuilder.cs b/src/Quartz/CalendarIntervalScheduleBuilder.cs
index 1e6b065de..21735e0cd 100644
--- a/src/Quartz/CalendarIntervalScheduleBuilder.cs
+++ b/src/Quartz/CalendarIntervalScheduleBuilder.cs
@@ -41,7 +41,7 @@ namespace Quartz
* @see TriggerBuilder
*/
- public class CalendarIntervalScheduleBuilder : ScheduleBuilder
+ public class CalendarIntervalScheduleBuilder : ScheduleBuilder
{
private int interval = 1;
private IntervalUnit intervalUnit = IntervalUnit.Day;
diff --git a/src/Quartz/Core/QuartzSchedulerThread.cs b/src/Quartz/Core/QuartzSchedulerThread.cs
index a5bc368c6..4a2be1df3 100644
--- a/src/Quartz/Core/QuartzSchedulerThread.cs
+++ b/src/Quartz/Core/QuartzSchedulerThread.cs
@@ -417,7 +417,7 @@ public override void Run()
JobRunShell shell = null;
try
{
- shell = qsRsrcs.JobRunShellFactory.CreateJobRunShell();
+ shell = qsRsrcs.JobRunShellFactory.CreateJobRunShell(bndle);
shell.Initialize(qs);
}
catch (SchedulerException)
diff --git a/src/Quartz/CronScheduleBuilder.cs b/src/Quartz/CronScheduleBuilder.cs
index 4888f898e..7dd126f7a 100644
--- a/src/Quartz/CronScheduleBuilder.cs
+++ b/src/Quartz/CronScheduleBuilder.cs
@@ -62,9 +62,9 @@ namespace Quartz
* @see TriggerBuilder
*/
- public class CronScheduleBuilder : ScheduleBuilder
+ public class CronScheduleBuilder : ScheduleBuilder
{
- private string cronExpression;
+ private readonly string cronExpression;
private TimeZoneInfo tz;
private int misfireInstruction = MisfireInstruction.SmartPolicy;
@@ -93,7 +93,7 @@ public override IMutableTrigger Build()
{
// all methods of construction ensure the expression is valid by this point...
throw new Exception("CronExpression '" + cronExpression +
- "' is invalid, which should not be possible, please report bug to Quartz developers.");
+ "' is invalid, which should not be possible, please report bug to Quartz developers.");
}
ct.TimeZone = tz;
ct.MisfireInstruction = misfireInstruction;
@@ -110,7 +110,7 @@ public override IMutableTrigger Build()
* @see CronExpression
*/
- public static CronScheduleBuilder cronSchedule(string cronExpression)
+ public static CronScheduleBuilder CronSchedule(string cronExpression)
{
CronExpression.ValidateExpression(cronExpression);
return new CronScheduleBuilder(cronExpression);
@@ -127,7 +127,7 @@ public static CronScheduleBuilder cronSchedule(string cronExpression)
* @see CronExpression
*/
- public static CronScheduleBuilder cronScheduleDaily(int hour, int minute)
+ public static CronScheduleBuilder DailyAtHourAndMinute(int hour, int minute)
{
DateBuilder.validateHour(hour);
DateBuilder.validateMinute(minute);
@@ -157,7 +157,7 @@ public static CronScheduleBuilder cronScheduleDaily(int hour, int minute)
* @see DateBuilder#SUNDAY
*/
- public static CronScheduleBuilder cronScheduleDailyWeekly(int dayOfWeek, int hour, int minute)
+ public static CronScheduleBuilder WeeklyOnDayAndHourAndMinute(int dayOfWeek, int hour, int minute)
{
DateBuilder.validateDayOfWeek(dayOfWeek);
DateBuilder.validateHour(hour);
@@ -181,7 +181,7 @@ public static CronScheduleBuilder cronScheduleDailyWeekly(int dayOfWeek, int hou
* @see CronExpression
*/
- public static CronScheduleBuilder cronScheduleDailyMonthly(int dayOfMonth, int hour, int minute)
+ public static CronScheduleBuilder MonthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
{
DateBuilder.validateDayOfMonth(dayOfMonth);
DateBuilder.validateHour(hour);
@@ -200,7 +200,7 @@ public static CronScheduleBuilder cronScheduleDailyMonthly(int dayOfMonth, int h
* @see CronExpression#getTimeZone()
*/
- public CronScheduleBuilder inTimeZone(TimeZoneInfo tz)
+ public CronScheduleBuilder InTimeZone(TimeZoneInfo tz)
{
this.tz = tz;
return this;
@@ -214,7 +214,8 @@ public CronScheduleBuilder inTimeZone(TimeZoneInfo tz)
* @return the updated CronScheduleBuilder
* @see Trigger#MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
*/
- public CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
+
+ public CronScheduleBuilder WithMisfireHandlingInstructionIgnoreMisfires()
{
misfireInstruction = MisfireInstruction.IgnoreMisfirePolicy;
return this;
@@ -228,7 +229,7 @@ public CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
* @see CronTrigger#MISFIRE_INSTRUCTION_DO_NOTHING
*/
- public CronScheduleBuilder withMisfireHandlingInstructionDoNothing()
+ public CronScheduleBuilder WithMisfireHandlingInstructionDoNothing()
{
misfireInstruction = MisfireInstruction.CronTrigger.DoNothing;
return this;
@@ -242,13 +243,13 @@ public CronScheduleBuilder withMisfireHandlingInstructionDoNothing()
* @see CronTrigger#MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
*/
- public CronScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
+ public CronScheduleBuilder WithMisfireHandlingInstructionFireAndProceed()
{
misfireInstruction = MisfireInstruction.CronTrigger.FireOnceNow;
return this;
}
- internal CronScheduleBuilder withMisfireHandlingInstruction(int readMisfireInstructionFromString)
+ internal CronScheduleBuilder WithMisfireHandlingInstruction(int readMisfireInstructionFromString)
{
misfireInstruction = readMisfireInstructionFromString;
return this;
diff --git a/src/Quartz/ICalendarIntervalTrigger.cs b/src/Quartz/ICalendarIntervalTrigger.cs
index 65cd10328..bdac882c9 100644
--- a/src/Quartz/ICalendarIntervalTrigger.cs
+++ b/src/Quartz/ICalendarIntervalTrigger.cs
@@ -1,6 +1,6 @@
namespace Quartz
{
- public interface ICalendarIntervalTrigger
+ public interface ICalendarIntervalTrigger : ITrigger
{
///
/// Get or set the interval unit - the time unit on with the interval applies.
@@ -18,6 +18,8 @@ public interface ICalendarIntervalTrigger
/// Get the number of times the DateIntervalTrigger
has already fired.
///
int TimesTriggered { get; set; }
+
+ TriggerBuilder GetTriggerBuilder();
}
public enum IntervalUnit
diff --git a/src/Quartz/ICronTrigger.cs b/src/Quartz/ICronTrigger.cs
index eb39c7f69..1981138cb 100644
--- a/src/Quartz/ICronTrigger.cs
+++ b/src/Quartz/ICronTrigger.cs
@@ -152,7 +152,7 @@ namespace Quartz
/// James House
/// Contributions from Mads Henderson
/// Marko Lahma (.NET)
- public interface ICronTrigger
+ public interface ICronTrigger : ITrigger
{
///
/// Gets or sets the cron expression string.
@@ -179,5 +179,7 @@ public interface ICronTrigger
///
///
string GetExpressionSummary();
+
+ TriggerBuilder GetTriggerBuilder();
}
}
\ No newline at end of file
diff --git a/src/Quartz/IScheduleBuilder.cs b/src/Quartz/IScheduleBuilder.cs
new file mode 100644
index 000000000..674cbc527
--- /dev/null
+++ b/src/Quartz/IScheduleBuilder.cs
@@ -0,0 +1,9 @@
+using Quartz.Spi;
+
+namespace Quartz
+{
+ public interface IScheduleBuilder
+ {
+ IMutableTrigger Build();
+ }
+}
\ No newline at end of file
diff --git a/src/Quartz/ISimpleTrigger.cs b/src/Quartz/ISimpleTrigger.cs
index d71b2145f..7ab5084ef 100644
--- a/src/Quartz/ISimpleTrigger.cs
+++ b/src/Quartz/ISimpleTrigger.cs
@@ -11,7 +11,7 @@ namespace Quartz
/// James House
/// Contributions by Lieven Govaerts of Ebitec Nv, Belgium.
/// Marko Lahma (.NET)
- public interface ISimpleTrigger
+ public interface ISimpleTrigger : ITrigger
{
///
/// Get or set thhe number of times the should
@@ -30,5 +30,7 @@ public interface ISimpleTrigger
/// fired.
///
int TimesTriggered { get; set; }
+
+ TriggerBuilder GetTriggerBuilder();
}
}
\ No newline at end of file
diff --git a/src/Quartz/ITrigger.cs b/src/Quartz/ITrigger.cs
index 90ed7a2a1..a3500131b 100644
--- a/src/Quartz/ITrigger.cs
+++ b/src/Quartz/ITrigger.cs
@@ -66,14 +66,14 @@ public interface ITrigger : ICloneable, IComparable
/// Trigger
identical to this one.
///
///
- TriggerBuilder GetTriggerBuilder();
+ TriggerBuilder GetTriggerBuilder() where T : ITrigger;
///
/// Get a that is configured to produce a
/// schedule identical to this trigger's schedule.
///
///
- ScheduleBuilder GetScheduleBuilder();
+ ScheduleBuilder GetScheduleBuilder() where T : ITrigger;
///
/// Get or set the description given to the instance by
@@ -193,5 +193,8 @@ public interface ITrigger : ICloneable, IComparable
/// will be returned.
///
DateTimeOffset? GetFireTimeAfter(DateTimeOffset? afterTime);
+
+ bool HasMillisecondPrecision { get; }
+
}
}
\ No newline at end of file
diff --git a/src/Quartz/Impl/AdoJobStore/CalendarIntervalTriggerPersistenceDelegate.cs b/src/Quartz/Impl/AdoJobStore/CalendarIntervalTriggerPersistenceDelegate.cs
index 335e5e45e..598951cac 100644
--- a/src/Quartz/Impl/AdoJobStore/CalendarIntervalTriggerPersistenceDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/CalendarIntervalTriggerPersistenceDelegate.cs
@@ -42,16 +42,16 @@ protected override SimplePropertiesTriggerProperties GetTriggerProperties(IOpera
SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();
- props.setInt1(calTrig.RepeatInterval);
- props.setString1(calTrig.RepeatIntervalUnit.ToString());
- props.setInt2(calTrig.TimesTriggered);
+ props.Int1 = (calTrig.RepeatInterval);
+ props.String1 = (calTrig.RepeatIntervalUnit.ToString());
+ props.Int2 = (calTrig.TimesTriggered);
return props;
}
protected override TriggerPropertyBundle GetTriggerPropertyBundle(SimplePropertiesTriggerProperties props)
{
- ScheduleBuilder sb = CalendarIntervalScheduleBuilder.CalendarIntervalSchedule()
+ CalendarIntervalScheduleBuilder sb = CalendarIntervalScheduleBuilder.CalendarIntervalSchedule()
.withInterval(
props.Int1,
(IntervalUnit) Enum.Parse(typeof(IntervalUnit), props.String1, true));
diff --git a/src/Quartz/Impl/AdoJobStore/CronTriggerPersistenceDelegate.cs b/src/Quartz/Impl/AdoJobStore/CronTriggerPersistenceDelegate.cs
index d9eb29cf7..f9657daeb 100644
--- a/src/Quartz/Impl/AdoJobStore/CronTriggerPersistenceDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/CronTriggerPersistenceDelegate.cs
@@ -92,7 +92,7 @@ public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransact
CronScheduleBuilder cb = null;
try
{
- cb = CronScheduleBuilder.cronSchedule(cronExpr);
+ cb = CronScheduleBuilder.CronSchedule(cronExpr);
}
catch (FormatException)
{
@@ -101,7 +101,7 @@ public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransact
if (timeZoneId != null)
{
- cb.inTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId));
+ cb.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId));
}
return new TriggerPropertyBundle(cb, null, null);
diff --git a/src/Quartz/Impl/AdoJobStore/DBSemaphore.cs b/src/Quartz/Impl/AdoJobStore/DBSemaphore.cs
index 7a807359b..d76b8ef52 100644
--- a/src/Quartz/Impl/AdoJobStore/DBSemaphore.cs
+++ b/src/Quartz/Impl/AdoJobStore/DBSemaphore.cs
@@ -229,8 +229,8 @@ private void SetExpandedSql()
{
if (TablePrefix != null && SchedName != null && sql != null && insertSql != null)
{
- expandedSQL = Util.rtp(this.sql, TablePrefix, SchedulerNameLiteral);
- expandedInsertSQL = Util.rtp(this.insertSql, TablePrefix, SchedulerNameLiteral);
+ expandedSQL = AdoJobStoreUtil.ReplaceTablePrefix(this.sql, TablePrefix, SchedulerNameLiteral);
+ expandedInsertSQL = AdoJobStoreUtil.ReplaceTablePrefix(this.insertSql, TablePrefix, SchedulerNameLiteral);
}
}
diff --git a/src/Quartz/Impl/AdoJobStore/IDriverDelegate.cs b/src/Quartz/Impl/AdoJobStore/IDriverDelegate.cs
index 2b02ec98f..7a3e757d1 100644
--- a/src/Quartz/Impl/AdoJobStore/IDriverDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/IDriverDelegate.cs
@@ -44,6 +44,8 @@ namespace Quartz.Impl.AdoJobStore
/// Marko Lahma (.NET)
public interface IDriverDelegate
{
+ void Initialize(string initString);
+
///
/// Update all triggers having one of the two given states, to the given new
/// state.
@@ -120,21 +122,21 @@ public interface IDriverDelegate
// jobs
//---------------------------------------------------------------------------
- ///
- /// Insert the job detail record.
- ///
- /// The DB Connection
- /// The job to insert.
- /// Number of rows inserted.
- int InsertJobDetail(ConnectionAndTransactionHolder conn, JobDetailImpl job);
+ ///
+ /// Insert the job detail record.
+ ///
+ /// The DB Connection
+ /// The job to insert.
+ /// Number of rows inserted.
+ int InsertJobDetail(ConnectionAndTransactionHolder conn, IJobDetail job);
- ///
- /// Update the job detail record.
- ///
- /// The DB Connection.
- /// The job to update.
- /// Number of rows updated.
- int UpdateJobDetail(ConnectionAndTransactionHolder conn, JobDetailImpl job);
+ ///
+ /// Update the job detail record.
+ ///
+ /// The DB Connection.
+ /// The job to update.
+ /// Number of rows updated.
+ int UpdateJobDetail(ConnectionAndTransactionHolder conn, IJobDetail job);
///
/// Get the names of all of the triggers associated with the given job.
@@ -173,13 +175,13 @@ public interface IDriverDelegate
/// true if the job exists, false otherwise
bool JobExists(ConnectionAndTransactionHolder conn, JobKey jobKey);
- ///
- /// Update the job data map for the given job.
- ///
- /// The DB Connection
- /// The job.
- /// the number of rows updated
- int UpdateJobData(ConnectionAndTransactionHolder conn, JobDetailImpl job);
+ ///
+ /// Update the job data map for the given job.
+ ///
+ /// The DB Connection
+ /// The job.
+ /// the number of rows updated
+ int UpdateJobData(ConnectionAndTransactionHolder conn, IJobDetail job);
///
/// Select the JobDetail object for a given job name / group name.
@@ -225,7 +227,7 @@ public interface IDriverDelegate
/// The state that the trigger should be stored in.
/// The job detail.
/// The number of rows inserted
- int InsertTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, JobDetailImpl jobDetail);
+ int InsertTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail);
///
/// Insert the blob trigger data.
@@ -243,7 +245,7 @@ public interface IDriverDelegate
/// The state.
/// The job detail.
/// the number of rows updated
- int UpdateTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, JobDetailImpl jobDetail);
+ int UpdateTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail);
///
/// Update the blob trigger data.
@@ -756,5 +758,13 @@ int UpdateTriggerGroupStateFromOtherStates(ConnectionAndTransactionHolder conn,
bool HasMisfiredTriggersInState(ConnectionAndTransactionHolder conn, string state1, DateTimeOffset ts, int count, IList resultList);
int UpdateFiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail job);
+
+
+ ///
+ /// Clear (delete!) all scheduling data - all {@link Job}s, {@link Trigger}s
+ /// {@link Calendar}s.
+ ///
+ ///
+ void ClearData(ConnectionAndTransactionHolder conn);
}
}
\ No newline at end of file
diff --git a/src/Quartz/Impl/AdoJobStore/ITriggerPersistenceDelegate.cs b/src/Quartz/Impl/AdoJobStore/ITriggerPersistenceDelegate.cs
index d7a9c564d..d9c1c9617 100644
--- a/src/Quartz/Impl/AdoJobStore/ITriggerPersistenceDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/ITriggerPersistenceDelegate.cs
@@ -47,18 +47,18 @@ public interface ITriggerPersistenceDelegate
public class TriggerPropertyBundle
{
- private ScheduleBuilder sb;
+ private IScheduleBuilder sb;
private string[] statePropertyNames;
private object[] statePropertyValues;
- public TriggerPropertyBundle(ScheduleBuilder sb, string[] statePropertyNames, object[] statePropertyValues)
+ public TriggerPropertyBundle(IScheduleBuilder sb, string[] statePropertyNames, object[] statePropertyValues)
{
this.sb = sb;
this.statePropertyNames = statePropertyNames;
this.statePropertyValues = statePropertyValues;
}
- public ScheduleBuilder getScheduleBuilder()
+ public IScheduleBuilder getScheduleBuilder()
{
return sb;
}
diff --git a/src/Quartz/Impl/AdoJobStore/JobStoreCMT.cs b/src/Quartz/Impl/AdoJobStore/JobStoreCMT.cs
index 3686e4a39..4d193ed9b 100644
--- a/src/Quartz/Impl/AdoJobStore/JobStoreCMT.cs
+++ b/src/Quartz/Impl/AdoJobStore/JobStoreCMT.cs
@@ -130,7 +130,7 @@ protected override ConnectionAndTransactionHolder GetNonManagedTXConnection()
/// Callback to execute.
protected override object ExecuteInLock(
string lockName,
- ITransactionCallback txCallback)
+ Func txCallback)
{
bool transOwner = false;
ConnectionAndTransactionHolder conn = null;
@@ -153,7 +153,7 @@ protected override object ExecuteInLock(
conn = GetNonManagedTXConnection();
}
- return txCallback.Execute(conn);
+ return txCallback(conn);
}
finally
{
diff --git a/src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs b/src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs
index 17c1881c5..fa7d14868 100644
--- a/src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs
+++ b/src/Quartz/Impl/AdoJobStore/JobStoreSupport.cs
@@ -30,6 +30,7 @@
using Common.Logging;
using Quartz.Impl.AdoJobStore.Common;
+using Quartz.Impl.Triggers;
using Quartz.Spi;
using Quartz.Util;
@@ -55,6 +56,7 @@ public abstract class JobStoreSupport : AdoConstants, IJobStore
private string instanceId;
private string instanceName;
protected string delegateTypeName;
+ protected string delegateInitString;
protected Type delegateType;
protected Dictionary calendarCache = new Dictionary();
private IDriverDelegate driverDelegate;
@@ -294,6 +296,15 @@ public virtual string DriverDelegateType
set { delegateTypeName = value; }
}
+ ///
+ /// The driver delegate's initialization string.
+ ///
+ public string DriverDelegateInitString
+ {
+ set { this.delegateInitString = value; }
+ get { return this.delegateInitString; }
+ }
+
///
/// set the SQL statement to use to select and lock a row in the "locks"
/// table.
@@ -420,43 +431,51 @@ protected virtual IDriverDelegate Delegate
{
if (driverDelegate == null)
{
- try
+ lock (this)
{
- if (delegateTypeName != null)
+ try
{
- delegateType = TypeLoadHelper.LoadType(delegateTypeName);
- }
+ if (delegateTypeName != null)
+ {
+ delegateType = TypeLoadHelper.LoadType(delegateTypeName);
+ }
+
+ // TODO: the current method of instantiating and initializing delegates is really sucky
+ // probably all constructor args should be moved to the initialize method and/or use
+ // the TablePrefixAware interface to set some things (and rename that interface to
+ // something more apt), etc. etc.
+
+ ConstructorInfo ctor;
+ Object[] ctorParams;
+ IDbProvider dbProvider = DBConnectionManager.Instance.GetDbProvider(DataSource);
+ if (CanUseProperties)
+ {
+ Type[] ctorParamTypes =
+ new Type[]
+ {
+ typeof (ILog), typeof (String), typeof (String), typeof (String), typeof(ITypeLoadHelper), typeof (IDbProvider),
+ typeof (Boolean)
+ };
+ ctor = delegateType.GetConstructor(ctorParamTypes);
+ ctorParams = new Object[] {Log, tablePrefix, instanceName, instanceId, typeLoadHelper, dbProvider, CanUseProperties};
+ }
+ else
+ {
+ Type[] ctorParamTypes =
+ new Type[] { typeof(ILog), typeof(String), typeof(String), typeof(String), typeof(IDbProvider) };
+ ctor = delegateType.GetConstructor(ctorParamTypes);
+ ctorParams = new Object[] {Log, tablePrefix, instanceName, instanceId, typeLoadHelper, dbProvider};
+ }
- ConstructorInfo ctor;
- Object[] ctorParams;
- IDbProvider dbProvider = DBConnectionManager.Instance.GetDbProvider(DataSource);
- if (CanUseProperties)
- {
- Type[] ctorParamTypes =
- new Type[]
- {
- typeof (ILog), typeof (String), typeof (String), typeof (IDbProvider),
- typeof (Boolean)
- };
- ctor = delegateType.GetConstructor(ctorParamTypes);
- ctorParams = new Object[] {Log, tablePrefix, instanceId, dbProvider, CanUseProperties};
+ driverDelegate = (IDriverDelegate) ctor.Invoke(ctorParams);
+ driverDelegate.Initialize(DriverDelegateInitString);
}
- else
+ catch (Exception e)
{
- Type[] ctorParamTypes =
- new Type[] {typeof (ILog), typeof (String), typeof (String), typeof (IDbProvider)};
- ctor = delegateType.GetConstructor(ctorParamTypes);
- ctorParams = new Object[] {Log, tablePrefix, instanceId, dbProvider};
+ throw new NoSuchDelegateException("Couldn't instantiate delegate: " + e.Message, e);
}
-
- driverDelegate = (IDriverDelegate) ctor.Invoke(ctorParams);
- }
- catch (Exception e)
- {
- throw new NoSuchDelegateException("Couldn't instantiate delegate: " + e.Message, e);
}
}
-
return driverDelegate;
}
}
@@ -509,7 +528,7 @@ public virtual void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
if (UseDBLocks)
{
Log.Info("Using db table-based data access locking (synchronization).");
- LockHandler = new StdRowLockSemaphore(TablePrefix, SelectWithLockSQL, DbProvider);
+ LockHandler = new StdRowLockSemaphore(TablePrefix, InstanceName, SelectWithLockSQL, DbProvider);
}
else
{
@@ -596,26 +615,6 @@ protected virtual void ReleaseLock(ConnectionAndTransactionHolder cth, string lo
}
}
- ///
- /// Removes all volatile data.
- ///
- protected virtual void CleanVolatileTriggerAndJobs()
- {
- ExecuteInNonManagedTXLock(LockTriggerAccess, new CleanVolatileTriggerAndJobsCallback(this));
- }
-
- protected class CleanVolatileTriggerAndJobsCallback : CallbackSupport, IVoidTransactionCallback
- {
- public CleanVolatileTriggerAndJobsCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.CleanVolatileTriggerAndJobs(conn);
- }
- }
protected class CallbackSupport
{
@@ -629,58 +628,13 @@ public CallbackSupport(JobStoreSupport js)
}
- ///
- /// Removes all volatile data.
- ///
- protected virtual void CleanVolatileTriggerAndJobs(ConnectionAndTransactionHolder conn)
- {
- try
- {
- // find volatile jobs & triggers...
- IList volatileTriggers = Delegate.SelectVolatileTriggers(conn);
- IList volatileJobs = Delegate.SelectVolatileJobs(conn);
-
- foreach (Key trigger in volatileTriggers)
- {
- RemoveTrigger(conn, trigger.Name, trigger.Group);
- }
- Log.Info("Removed " + volatileTriggers.Count + " Volatile Trigger(s).");
-
- foreach (Key job in volatileJobs)
- {
- RemoveJob(conn, job.Name, job.Group, true);
- }
- Log.Info("Removed " + volatileJobs.Count + " Volatile Job(s).");
-
- // clean up any fired trigger entries
- Delegate.DeleteVolatileFiredTriggers(conn);
- }
- catch (Exception e)
- {
- throw new JobPersistenceException("Couldn't clean volatile data: " + e.Message, e);
- }
- }
-
///
/// Will recover any failed or misfired jobs and clean up the data store as
/// appropriate.
///
protected virtual void RecoverJobs()
{
- ExecuteInNonManagedTXLock(LockTriggerAccess, new RecoverJobsCallback(this));
- }
-
- protected class RecoverJobsCallback : CallbackSupport, IVoidTransactionCallback
- {
- public RecoverJobsCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.RecoverJobs(conn);
- }
+ ExecuteInNonManagedTXLock(LockTriggerAccess, conn => RecoverJobs(conn));
}
///
@@ -707,13 +661,13 @@ protected virtual void RecoverJobs(ConnectionAndTransactionHolder conn)
RecoverMisfiredJobs(conn, true);
// recover jobs marked for recovery that were not fully executed
- IList recoveringJobTriggers = Delegate.SelectTriggersForRecoveringJobs(conn);
+ IList recoveringJobTriggers = Delegate.SelectTriggersForRecoveringJobs(conn);
Log.Info("Recovering " + recoveringJobTriggers.Count +
" jobs that were in-progress at the time of the last shut-down.");
- foreach (Trigger trigger in recoveringJobTriggers)
+ foreach (IOperableTrigger trigger in recoveringJobTriggers)
{
- if (JobExists(conn, trigger.JobName, trigger.JobGroup))
+ if (JobExists(conn, trigger.JobKey ))
{
trigger.ComputeFirstFireTimeUtc(null);
StoreTrigger(conn, trigger, null, false, StateWaiting, false, true);
@@ -722,10 +676,10 @@ protected virtual void RecoverJobs(ConnectionAndTransactionHolder conn)
Log.Info("Recovery complete.");
// remove lingering 'complete' triggers...
- IList triggersInState = Delegate.SelectTriggersInState(conn, StateComplete);
+ IList triggersInState = Delegate.SelectTriggersInState(conn, StateComplete);
for (int i = 0; triggersInState != null && i < triggersInState.Count; i++)
{
- RemoveTrigger(conn, triggersInState[i].Name, triggersInState[i].Group);
+ RemoveTrigger(conn, triggersInState[i]);
}
if (triggersInState != null)
{
@@ -756,7 +710,7 @@ public virtual RecoverMisfiredJobsResult RecoverMisfiredJobs(ConnectionAndTransa
// triggers right away.
int maxMisfiresToHandleAtATime = (recovering) ? -1 : MaxMisfiresToHandleAtATime;
- IList misfiredTriggers = new List();
+ IList misfiredTriggers = new List();
DateTimeOffset earliestNewTime = DateTimeOffset.MaxValue;
// We must still look for the MISFIRED state in case triggers were left
@@ -785,9 +739,9 @@ public virtual RecoverMisfiredJobsResult RecoverMisfiredJobs(ConnectionAndTransa
return RecoverMisfiredJobsResult.NoOp;
}
- foreach (Key triggerKey in misfiredTriggers)
+ foreach (TriggerKey triggerKey in misfiredTriggers)
{
- Trigger trig = RetrieveTrigger(conn, triggerKey.Name, triggerKey.Group);
+ IOperableTrigger trig = RetrieveTrigger(conn, triggerKey);
if (trig == null)
{
@@ -808,13 +762,12 @@ public virtual RecoverMisfiredJobsResult RecoverMisfiredJobs(ConnectionAndTransa
protected virtual bool UpdateMisfiredTrigger(ConnectionAndTransactionHolder conn,
- string triggerName,
- string groupName, string newStateIfNotComplete,
+ TriggerKey triggerKey, string newStateIfNotComplete,
bool forceState)
{
try
{
- Trigger trig = RetrieveTrigger(conn, triggerName, groupName);
+ IOperableTrigger trig = RetrieveTrigger(conn, triggerKey);
DateTimeOffset misfireTime = SystemTime.UtcNow();
if (MisfireThreshold > TimeSpan.Zero)
@@ -836,12 +789,12 @@ protected virtual bool UpdateMisfiredTrigger(ConnectionAndTransactionHolder conn
catch (Exception e)
{
throw new JobPersistenceException(
- string.Format("Couldn't update misfired trigger '{0}.{1}': {2}", groupName, triggerName, e.Message), e);
+ string.Format("Couldn't update misfired trigger '{0}': {1}", triggerKey, e.Message), e);
}
}
- private void DoUpdateOfMisfiredTrigger(ConnectionAndTransactionHolder conn, Trigger trig,
+ private void DoUpdateOfMisfiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trig,
bool forceState, string newStateIfNotComplete, bool recovering)
{
ICalendar cal = null;
@@ -865,14 +818,18 @@ private void DoUpdateOfMisfiredTrigger(ConnectionAndTransactionHolder conn, Trig
}
///
- /// Store the given and .
+ /// Store the given and .
///
/// Job to be stored.
/// Trigger to be stored.
- public void StoreJobAndTrigger(JobDetailImpl newJob, Trigger newTrigger)
+ public void StoreJobAndTrigger(IJobDetail newJob, IOperableTrigger newTrigger)
{
- ExecuteInLock((LockOnInsert) ? LockTriggerAccess : null,
- new StoreJobAndTriggerCallback(this, newJob, newTrigger));
+ ExecuteInLock((LockOnInsert) ? LockTriggerAccess : null, conn =>
+ {
+ StoreJob(conn, newJob, false);
+ StoreTrigger(conn, newTrigger, newJob, false, StateWaiting, false, false);
+ return null;
+ });
}
///
@@ -897,32 +854,6 @@ public bool IsTriggerGroupPaused(string groupName)
throw new NotImplementedException();
}
- protected class StoreJobAndTriggerCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly JobDetailImpl newJob;
- private readonly Trigger newTrigger;
-
- public StoreJobAndTriggerCallback(JobStoreSupport js, JobDetailImpl newJob, Trigger newTrigger)
- : base(js)
- {
- this.newJob = newJob;
- this.newTrigger = newTrigger;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- if (newJob.Volatile && !newTrigger.Volatile)
- {
- JobPersistenceException jpe = new JobPersistenceException("Cannot associate non-volatile trigger with a volatile job!");
- throw jpe;
- }
-
- js.StoreJob(conn, newJob, false);
- js.StoreTrigger(conn, newTrigger, newJob, false, StateWaiting, false, false);
- }
- }
-
-
///
/// Stores the given .
///
@@ -931,29 +862,11 @@ public void Execute(ConnectionAndTransactionHolder conn)
/// If , any existing in the
/// with the same name & group should be over-written.
///
- public void StoreJob(JobDetailImpl newJob, bool replaceExisting)
+ public void StoreJob(IJobDetail newJob, bool replaceExisting)
{
ExecuteInLock(
(LockOnInsert || replaceExisting) ? LockTriggerAccess : null,
- new StoreJobCallback(this, newJob, replaceExisting));
- }
-
- protected class StoreJobCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly JobDetailImpl newJob;
- private readonly bool replaceExisting;
-
- public StoreJobCallback(JobStoreSupport js, JobDetailImpl newJob, bool replaceExisting)
- : base(js)
- {
- this.newJob = newJob;
- this.replaceExisting = replaceExisting;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.StoreJob(conn, newJob, replaceExisting);
- }
+ conn => StoreJob(conn, newJob, replaceExisting));
}
///
@@ -961,15 +874,10 @@ public void Execute(ConnectionAndTransactionHolder conn)
///
///
protected virtual void StoreJob(ConnectionAndTransactionHolder conn,
- JobDetailImpl newJob,
+ IJobDetail newJob,
bool replaceExisting)
{
- if (newJob.Volatile && Clustered)
- {
- Log.Info("note: volatile jobs are effectively non-volatile in a clustered environment.");
- }
-
- bool existingJob = JobExists(conn, newJob.Name, newJob.Group);
+ bool existingJob = JobExists(conn, newJob.Key);
try
{
if (existingJob)
@@ -998,16 +906,16 @@ protected virtual void StoreJob(ConnectionAndTransactionHolder conn,
///
/// Check existence of a given job.
///
- protected virtual bool JobExists(ConnectionAndTransactionHolder conn, string jobName, string groupName)
+ protected virtual bool JobExists(ConnectionAndTransactionHolder conn, JobKey jobKey)
{
try
{
- return Delegate.JobExists(conn, jobName, groupName);
+ return Delegate.JobExists(conn, jobKey);
}
catch (Exception e)
{
throw new JobPersistenceException(
- "Couldn't determine job existence (" + groupName + "." + jobName + "): " + e.Message, e);
+ "Couldn't determine job existence (" + jobKey + "): " + e.Message, e);
}
}
@@ -1025,46 +933,19 @@ protected virtual bool JobExists(ConnectionAndTransactionHolder conn, string job
/// if a with the same name/group already
/// exists, and replaceExisting is set to false.
///
- public void StoreTrigger(Trigger newTrigger, bool replaceExisting)
+ public void StoreTrigger(IOperableTrigger newTrigger, bool replaceExisting)
{
ExecuteInLock(
(LockOnInsert || replaceExisting) ? LockTriggerAccess : null,
- new StoreTriggerCallback(this, newTrigger, replaceExisting));
- }
-
- protected class StoreTriggerCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly Trigger newTrigger;
- private readonly bool replaceExisting;
-
- public StoreTriggerCallback(JobStoreSupport js, Trigger newTrigger,
- bool replaceExisting)
- : base(js)
- {
- this.newTrigger = newTrigger;
- this.replaceExisting = replaceExisting;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.StoreTrigger(conn, newTrigger, null, replaceExisting, StateWaiting, false, false);
- }
+ conn => StoreTrigger(conn, newTrigger, null, replaceExisting, StateWaiting, false, false));
}
///
/// Insert or update a trigger.
///
- protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn,
- Trigger newTrigger,
- JobDetailImpl job, bool replaceExisting, string state, bool forceState,
- bool recovering)
+ protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger newTrigger, IJobDetail job, bool replaceExisting, string state, bool forceState, bool recovering)
{
- if (newTrigger.Volatile && Clustered)
- {
- Log.Info("note: volatile triggers are effectively non-volatile in a clustered environment.");
- }
-
- bool existingTrigger = TriggerExists(conn, newTrigger.Name, newTrigger.Group);
+ bool existingTrigger = TriggerExists(conn, newTrigger.Key);
if ((existingTrigger) && (!replaceExisting))
@@ -1076,7 +957,7 @@ protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn,
{
if (!forceState)
{
- bool shouldBepaused = Delegate.IsTriggerGroupPaused(conn, newTrigger.Group);
+ bool shouldBepaused = Delegate.IsTriggerGroupPaused(conn, newTrigger.Key.Group);
if (!shouldBepaused)
{
@@ -1084,7 +965,7 @@ protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn,
if (shouldBepaused)
{
- Delegate.InsertPausedTriggerGroup(conn, newTrigger.Group);
+ Delegate.InsertPausedTriggerGroup(conn, newTrigger.Key.Group);
}
}
@@ -1097,59 +978,29 @@ protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn,
if (job == null)
{
- job = Delegate.SelectJobDetail(conn, newTrigger.JobName, newTrigger.JobGroup, TypeLoadHelper);
+ job = Delegate.SelectJobDetail(conn, newTrigger.JobKey, TypeLoadHelper);
}
if (job == null)
{
- throw new JobPersistenceException("The job (" + newTrigger.FullJobName +
+ throw new JobPersistenceException("The job (" + newTrigger.JobKey +
") referenced by the trigger does not exist.");
}
- if (job.Volatile && !newTrigger.Volatile)
- {
- throw new JobPersistenceException("It does not make sense to " +
- "associate a non-volatile Trigger with a volatile Job!");
- }
-
- if (job.Stateful && !recovering)
+ if (job.ConcurrentExectionDisallowed && !recovering)
{
- state = CheckBlockedState(conn, job.Name, job.Group, state);
+ state = CheckBlockedState(conn, job.Key, state);
}
if (existingTrigger)
{
- if (newTrigger is SimpleTrigger && !newTrigger.HasAdditionalProperties)
- {
- Delegate.UpdateSimpleTrigger(conn, (SimpleTrigger) newTrigger);
- }
- else if (newTrigger is CronTrigger && !newTrigger.HasAdditionalProperties)
- {
- Delegate.UpdateCronTrigger(conn, (CronTrigger) newTrigger);
- }
- else
- {
- Delegate.UpdateBlobTrigger(conn, newTrigger);
- }
Delegate.UpdateTrigger(conn, newTrigger, state, job);
}
else
{
Delegate.InsertTrigger(conn, newTrigger, state, job);
- if (newTrigger is SimpleTrigger && !newTrigger.HasAdditionalProperties)
- {
- Delegate.InsertSimpleTrigger(conn, (SimpleTrigger) newTrigger);
- }
- else if (newTrigger is CronTrigger && !newTrigger.HasAdditionalProperties)
- {
- Delegate.InsertCronTrigger(conn, (CronTrigger) newTrigger);
- }
- else
- {
- Delegate.InsertBlobTrigger(conn, newTrigger);
- }
}
}
catch (Exception e)
{
- string message = String.Format("Couldn't store trigger '{0}' for '{1}' job: {2}", newTrigger.Name, newTrigger.JobName, e.Message);
+ string message = String.Format("Couldn't store trigger '{0}' for '{1}' job: {2}", newTrigger.Key, newTrigger.JobKey, e.Message);
throw new JobPersistenceException(message, e);
}
}
@@ -1157,17 +1008,16 @@ protected virtual void StoreTrigger(ConnectionAndTransactionHolder conn,
///
/// Check existence of a given trigger.
///
- protected virtual bool TriggerExists(ConnectionAndTransactionHolder conn, string triggerName,
- string groupName)
+ protected virtual bool TriggerExists(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
try
{
- return Delegate.TriggerExists(conn, triggerName, groupName);
+ return Delegate.TriggerExists(conn, triggerKey);
}
catch (Exception e)
{
throw new JobPersistenceException(
- "Couldn't determine trigger existence (" + groupName + "." + triggerName + "): " + e.Message, e);
+ "Couldn't determine trigger existence (" + triggerKey + "): " + e.Message, e);
}
}
@@ -1182,50 +1032,29 @@ protected virtual bool TriggerExists(ConnectionAndTransactionHolder conn, string
/// group should be removed from the 's list of
/// known group names.
///
- /// The name of the to be removed.
- /// The group name of the to be removed.
///
/// if a with the given name &
/// group was found and removed from the store.
///
- public bool RemoveJob(string jobName, string groupName)
+ public bool RemoveJob(JobKey jobKey)
{
- return (bool) ExecuteInLock(LockTriggerAccess, new RemoveJobCallback(this, jobName, groupName));
+ return (bool)ExecuteInLock(LockTriggerAccess, conn => RemoveJob(conn, jobKey, true));
}
- protected class RemoveJobCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string jobName;
- private readonly string groupName;
-
-
- public RemoveJobCallback(JobStoreSupport js, string jobName, string groupName)
- : base(js)
- {
- this.jobName = jobName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RemoveJob(conn, jobName, groupName, true);
- }
- }
protected virtual bool RemoveJob(ConnectionAndTransactionHolder conn,
- string jobName,
- string groupName, bool activeDeleteSafe)
+ JobKey jobKey, bool activeDeleteSafe)
{
try
{
- IList jobTriggers = Delegate.SelectTriggerNamesForJob(conn, jobName, groupName);
+ IList jobTriggers = Delegate.SelectTriggerNamesForJob(conn, jobKey);
- foreach (Key trigger in jobTriggers)
+ foreach (TriggerKey jobTrigger in jobTriggers)
{
- DeleteTriggerAndChildren(conn, trigger.Name, trigger.Group);
+ DeleteTriggerAndChildren(conn, jobTrigger);
}
- return DeleteJobAndChildren(conn, jobName, groupName);
+ return DeleteJobAndChildren(conn, jobKey);
}
catch (Exception e)
{
@@ -1295,10 +1124,9 @@ public void StoreJobsAndTriggers(IDictionary> trigge
///
///
///
- private bool DeleteJobAndChildren(ConnectionAndTransactionHolder conn, string jobName,
- string groupName)
+ private bool DeleteJobAndChildren(ConnectionAndTransactionHolder conn, JobKey key)
{
- return (Delegate.DeleteJobDetail(conn, jobName, groupName) > 0);
+ return (Delegate.DeleteJobDetail(conn, key) > 0);
}
///
@@ -1307,19 +1135,10 @@ private bool DeleteJobAndChildren(ConnectionAndTransactionHolder conn, string jo
///
///
///
- private bool DeleteTriggerAndChildren(ConnectionAndTransactionHolder conn, string triggerName,
- string triggerGroupName)
+ private bool DeleteTriggerAndChildren(ConnectionAndTransactionHolder conn, TriggerKey key)
{
IDriverDelegate del = Delegate;
-
- // Once it succeeds in deleting one sub-table entry it will not try the others.
- if ((del.DeleteSimpleTrigger(conn, triggerName, triggerGroupName) == 0) &&
- (del.DeleteCronTrigger(conn, triggerName, triggerGroupName) == 0))
- {
- del.DeleteBlobTrigger(conn, triggerName, triggerGroupName);
- }
-
- return (del.DeleteTrigger(conn, triggerName, triggerGroupName) > 0);
+ return (del.DeleteTrigger(conn, key) > 0);
}
///
@@ -1329,38 +1148,17 @@ private bool DeleteTriggerAndChildren(ConnectionAndTransactionHolder conn, strin
/// The name of the to be retrieved.
/// The group name of the to be retrieved.
/// The desired , or null if there is no match.
- public JobDetailImpl RetrieveJob(string jobName, string groupName)
+ public IJobDetail RetrieveJob(JobKey jobKey)
{
// no locks necessary for read...
- return (JobDetailImpl) ExecuteWithoutLock(new RetrieveJobCallback(this, jobName, groupName));
- }
-
- protected class RetrieveJobCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string jobName;
- private readonly string groupName;
-
- public RetrieveJobCallback(JobStoreSupport js, string jobName, string groupName)
- : base(js)
- {
- this.jobName = jobName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RetrieveJob(conn, jobName, groupName);
- }
+ return (JobDetailImpl)ExecuteWithoutLock(conn => RetrieveJob(conn, jobKey));
}
-
- protected virtual JobDetailImpl RetrieveJob(ConnectionAndTransactionHolder conn,
- string jobName,
- string groupName)
+ protected virtual JobDetailImpl RetrieveJob(ConnectionAndTransactionHolder conn, JobKey jobKey)
{
try
{
- JobDetailImpl job = Delegate.SelectJobDetail(conn, jobName, groupName, TypeLoadHelper);
+ JobDetailImpl job = Delegate.SelectJobDetail(conn, jobKey, TypeLoadHelper);
return job;
}
@@ -1400,53 +1198,32 @@ protected virtual JobDetailImpl RetrieveJob(ConnectionAndTransactionHolder conn,
/// if a with the given
/// name & group was found and removed from the store.
///
- public bool RemoveTrigger(string triggerName, string groupName)
+ public bool RemoveTrigger(TriggerKey triggerKey)
{
return (bool) ExecuteInLock(
LockTriggerAccess,
- new RemoveTriggerCallback(this, triggerName, groupName));
- }
-
- protected class RemoveTriggerCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string triggerName;
- private readonly string groupName;
-
- public RemoveTriggerCallback(JobStoreSupport js, string triggerName,
- string groupName)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RemoveTrigger(conn, triggerName, groupName);
- }
+ conn => RemoveTrigger(conn, triggerKey));
}
- protected virtual bool RemoveTrigger(ConnectionAndTransactionHolder conn,
- string triggerName,
- string groupName)
+ protected virtual bool RemoveTrigger(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
bool removedTrigger;
try
{
// this must be called before we delete the trigger, obviously
// we use fault tolerant type loading as we only want to delete things
- JobDetailImpl job = Delegate.SelectJobForTrigger(conn, triggerName, groupName, new NoOpJobTypeLoader());
+ JobDetailImpl job = Delegate.SelectJobForTrigger(conn, triggerKey, new NoOpJobTypeLoader());
- removedTrigger = DeleteTriggerAndChildren(conn, triggerName, groupName);
+ removedTrigger = DeleteTriggerAndChildren(conn, triggerKey);
if (null != job && !job.Durable)
{
- int numTriggers = Delegate.SelectNumTriggersForJob(conn, job.Name, job.Group);
+ int numTriggers = Delegate.SelectNumTriggersForJob(conn, job.Key);
if (numTriggers == 0)
{
// Don't call RemoveJob() because we don't want to check for
// triggers again.
- DeleteJobAndChildren(conn, job.Name, job.Group);
+ DeleteJobAndChildren(conn, job.Key);
}
}
}
@@ -1481,55 +1258,32 @@ public Stream GetResourceAsStream(string name)
}
///
- public bool ReplaceTrigger(string triggerName, string groupName, Trigger newTrigger)
+ public bool ReplaceTrigger(TriggerKey triggerKey, IOperableTrigger newTrigger)
{
return
(bool)
- ExecuteInLock(LockTriggerAccess,
- new ReplaceTriggerCallback(this, triggerName, groupName, newTrigger));
- }
-
- protected class ReplaceTriggerCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string triggerName;
- private readonly string groupName;
- private readonly Trigger newTrigger;
-
- public ReplaceTriggerCallback(JobStoreSupport js, string triggerName,
- string groupName, Trigger newTrigger)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- this.newTrigger = newTrigger;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.ReplaceTrigger(conn, triggerName, groupName, newTrigger);
- }
+ ExecuteInLock(LockTriggerAccess, conn => ReplaceTrigger(conn, triggerKey, newTrigger));
}
protected virtual bool ReplaceTrigger(ConnectionAndTransactionHolder conn,
- string triggerName,
- string groupName, Trigger newTrigger)
+ TriggerKey triggerKey, IOperableTrigger newTrigger)
{
try
{
// this must be called before we delete the trigger, obviously
- JobDetailImpl job = Delegate.SelectJobForTrigger(conn, triggerName, groupName, TypeLoadHelper);
+ JobDetailImpl job = Delegate.SelectJobForTrigger(conn, triggerKey, TypeLoadHelper);
if (job == null)
{
return false;
}
- if (!newTrigger.JobName.Equals(job.Name) || !newTrigger.JobGroup.Equals(job.Group))
+ if (!newTrigger.JobKey.Equals(job.Key))
{
throw new JobPersistenceException("New trigger is not related to the same job as the old trigger.");
}
- bool removedTrigger = DeleteTriggerAndChildren(conn, triggerName, groupName);
+ bool removedTrigger = DeleteTriggerAndChildren(conn, triggerKey);
StoreTrigger(conn, newTrigger, job, false, StateWaiting, false, false);
@@ -1547,37 +1301,17 @@ protected virtual bool ReplaceTrigger(ConnectionAndTransactionHolder conn,
/// The name of the to be retrieved.
/// The group name of the to be retrieved.
/// The desired , or null if there is no match.
- public Trigger RetrieveTrigger(string triggerName, string groupName)
- {
- return (Trigger) ExecuteWithoutLock( // no locks necessary for read...
- new RetrieveTriggerCallback(this, triggerName, groupName));
- }
-
- protected class RetrieveTriggerCallback : CallbackSupport, ITransactionCallback
+ public IOperableTrigger RetrieveTrigger(TriggerKey triggerKey)
{
- private readonly string triggerName;
- private readonly string groupName;
-
- public RetrieveTriggerCallback(JobStoreSupport js, string triggerName,
- string groupName)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RetrieveTrigger(conn, triggerName, groupName);
- }
+ return (IOperableTrigger) ExecuteWithoutLock( // no locks necessary for read...
+ conn => RetrieveTrigger(conn, triggerKey));
}
- protected virtual Trigger RetrieveTrigger(ConnectionAndTransactionHolder conn, string triggerName,
- string groupName)
+ protected virtual IOperableTrigger RetrieveTrigger(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
try
{
- Trigger trigger = Delegate.SelectTrigger(conn, triggerName, groupName);
+ IOperableTrigger trigger = Delegate.SelectTrigger(conn, triggerKey);
return trigger;
}
catch (Exception e)
@@ -1595,32 +1329,12 @@ protected virtual Trigger RetrieveTrigger(ConnectionAndTransactionHolder conn, s
///
///
///
- public TriggerState GetTriggerState(string triggerName, string groupName)
+ public TriggerState GetTriggerState(TriggerKey triggerKey)
{
// no locks necessary for read...
- return (TriggerState) ExecuteWithoutLock(new GetTriggerStateCallback(this, triggerName, groupName));
- }
-
- protected class GetTriggerStateCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string triggerName;
- private readonly string groupName;
-
- public GetTriggerStateCallback(JobStoreSupport js, string triggerName,
- string groupName)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetTriggerState(conn, triggerName, groupName);
- }
+ return (TriggerState) ExecuteWithoutLock(conn => GetTriggerState(conn, triggerKey));
}
-
///
/// Gets the state of the trigger.
///
@@ -1628,12 +1342,11 @@ public object Execute(ConnectionAndTransactionHolder conn)
/// Name of the trigger.
/// Name of the group.
///
- public virtual TriggerState GetTriggerState(ConnectionAndTransactionHolder conn,
- string triggerName, string groupName)
+ public virtual TriggerState GetTriggerState(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
try
{
- string ts = Delegate.SelectTriggerState(conn, triggerName, groupName);
+ string ts = Delegate.SelectTriggerState(conn, triggerKey);
if (ts == null)
{
@@ -1675,7 +1388,7 @@ public virtual TriggerState GetTriggerState(ConnectionAndTransactionHolder conn,
catch (Exception e)
{
throw new JobPersistenceException(
- "Couldn't determine state of trigger (" + groupName + "." + triggerName + "): " + e.Message, e);
+ "Couldn't determine state of trigger (" + triggerKey + "): " + e.Message, e);
}
}
@@ -1698,30 +1411,7 @@ public void StoreCalendar(string calName, ICalendar calendar, bool replaceExisti
{
ExecuteInLock(
(LockOnInsert || updateTriggers) ? LockTriggerAccess : null,
- new StoreCalendarCallback(this, calName, calendar, replaceExisting, updateTriggers));
- }
-
- protected class StoreCalendarCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string calName;
- private readonly ICalendar calendar;
- private readonly bool replaceExisting;
- private readonly bool updateTriggers;
-
- public StoreCalendarCallback(JobStoreSupport js, string calName, ICalendar calendar,
- bool replaceExisting, bool updateTriggers)
- : base(js)
- {
- this.calName = calName;
- this.calendar = calendar;
- this.replaceExisting = replaceExisting;
- this.updateTriggers = updateTriggers;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.StoreCalendar(conn, calName, calendar, replaceExisting, updateTriggers);
- }
+ conn => StoreCalendar(conn, calName, calendar, replaceExisting, updateTriggers));
}
protected virtual void StoreCalendar(ConnectionAndTransactionHolder conn,
@@ -1745,9 +1435,9 @@ protected virtual void StoreCalendar(ConnectionAndTransactionHolder conn,
if (updateTriggers)
{
- IList triggers = Delegate.SelectTriggersForCalendar(conn, calName);
+ IList triggers = Delegate.SelectTriggersForCalendar(conn, calName);
- foreach (Trigger trigger in triggers)
+ foreach (IOperableTrigger trigger in triggers)
{
trigger.UpdateWithNewCalendar(calendar, MisfireThreshold);
StoreTrigger(conn, trigger, null, true, StateWaiting, false, false);
@@ -1808,24 +1498,7 @@ protected virtual bool CalendarExists(ConnectionAndTransactionHolder conn, strin
///
public bool RemoveCalendar(string calName)
{
- return (bool) ExecuteInLock(LockTriggerAccess, new RemoveCalendarCallback(this, calName));
- }
-
- protected class RemoveCalendarCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string calName;
-
-
- public RemoveCalendarCallback(JobStoreSupport js, string calName)
- : base(js)
- {
- this.calName = calName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RemoveCalendar(conn, calName);
- }
+ return (bool)ExecuteInLock(LockTriggerAccess, conn => RemoveCalendar(conn, calName));
}
protected virtual bool RemoveCalendar(ConnectionAndTransactionHolder conn,
@@ -1859,28 +1532,10 @@ protected virtual bool RemoveCalendar(ConnectionAndTransactionHolder conn,
public ICalendar RetrieveCalendar(string calName)
{
return (ICalendar) ExecuteWithoutLock( // no locks necessary for read...
- new RetrieveCalendarCallback(this, calName));
- }
-
- protected class RetrieveCalendarCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string calName;
-
-
- public RetrieveCalendarCallback(JobStoreSupport js, string calName)
- : base(js)
- {
- this.calName = calName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.RetrieveCalendar(conn, calName);
- }
+ conn => RetrieveCalendar(conn, calName));
}
- protected virtual ICalendar RetrieveCalendar(ConnectionAndTransactionHolder conn,
- string calName)
+ protected virtual ICalendar RetrieveCalendar(ConnectionAndTransactionHolder conn, string calName)
{
// all calendars are persistent, but we lazy-cache them during run
// time as long as we aren't running clustered.
@@ -1922,20 +1577,7 @@ protected virtual ICalendar RetrieveCalendar(ConnectionAndTransactionHolder conn
public int GetNumberOfJobs()
{
// no locks necessary for read...
- return (int) ExecuteWithoutLock(new GetNumberOfJobsCallback(this));
- }
-
- protected class GetNumberOfJobsCallback : CallbackSupport, ITransactionCallback
- {
- public GetNumberOfJobsCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetNumberOfJobs(conn);
- }
+ return (int) ExecuteWithoutLock(conn => GetNumberOfJobs(conn));
}
protected virtual int GetNumberOfJobs(ConnectionAndTransactionHolder conn)
@@ -1957,23 +1599,9 @@ protected virtual int GetNumberOfJobs(ConnectionAndTransactionHolder conn)
public int GetNumberOfTriggers()
{
return (int) ExecuteWithoutLock( // no locks necessary for read...
- new GetNumberOfTriggersCallback(this));
- }
-
- protected class GetNumberOfTriggersCallback : CallbackSupport, ITransactionCallback
- {
- public GetNumberOfTriggersCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetNumberOfTriggers(conn);
- }
+ conn => GetNumberOfTriggers(conn));
}
-
protected virtual int GetNumberOfTriggers(ConnectionAndTransactionHolder conn)
{
try
@@ -1993,20 +1621,7 @@ protected virtual int GetNumberOfTriggers(ConnectionAndTransactionHolder conn)
public int GetNumberOfCalendars()
{
// no locks necessary for read...
- return (int) ExecuteWithoutLock(new GetNumberOfCalendarsCallback(this));
- }
-
- protected class GetNumberOfCalendarsCallback : CallbackSupport, ITransactionCallback
- {
- public GetNumberOfCalendarsCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetNumberOfCalendars(conn);
- }
+ return (int) ExecuteWithoutLock(conn => GetNumberOfCalendars(conn));
}
protected virtual int GetNumberOfCalendars(ConnectionAndTransactionHolder conn)
@@ -2029,33 +1644,15 @@ protected virtual int GetNumberOfCalendars(ConnectionAndTransactionHolder conn)
/// If there are no jobs in the given group name, the result should be a
/// zero-length array (not ).
///
- public IList GetJobKeys(string groupName)
+ public IList GetJobKeys(string groupName)
{
// no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetJobNamesCallback(this, groupName));
- }
-
- protected class GetJobNamesCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string groupName;
-
-
- public GetJobNamesCallback(JobStoreSupport js, string groupName)
- : base(js)
- {
- this.groupName = groupName;
- }
-
- public Object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetJobNames(conn, groupName);
- }
+ return (IList)ExecuteWithoutLock(conn => GetJobNames(conn, groupName));
}
- protected virtual IList GetJobNames(ConnectionAndTransactionHolder conn,
- string groupName)
+ protected virtual IList GetJobNames(ConnectionAndTransactionHolder conn, string groupName)
{
- IList jobNames;
+ IList jobNames;
try
{
@@ -2069,85 +1666,133 @@ protected virtual IList GetJobNames(ConnectionAndTransactionHolder conn,
return jobNames;
}
+ /**
+ * Determine whether a {@link Job} with the given identifier already
+ * exists within the scheduler.
+ *
+ * @param jobKey the identifier to check for
+ * @return true if a Job exists with the given identifier
+ * @throws SchedulerException
+ */
- ///
- /// Get the names of all of the s
- /// that have the given group name.
- ///
- ///
- /// If there are no triggers in the given group name, the result should be a
- /// zero-length array (not ).
- ///
- public IList GetTriggerKeys(string groupName)
+ public bool CheckExists(JobKey jobKey)
{
- // no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetTriggerNamesCallback(this, groupName));
+ return (bool) ExecuteWithoutLock( // no locks necessary for read...
+ conn => CheckExists(conn, jobKey));
}
- protected class GetTriggerNamesCallback : CallbackSupport, ITransactionCallback
+ protected bool CheckExists(ConnectionAndTransactionHolder conn, JobKey jobKey)
{
- private readonly string groupName;
-
-
- public GetTriggerNamesCallback(JobStoreSupport js, string groupName)
- : base(js)
+ try
{
- this.groupName = groupName;
+ return Delegate.JobExists(conn, jobKey);
}
-
- public object Execute(ConnectionAndTransactionHolder conn)
+ catch (Exception e)
{
- return js.GetTriggerNames(conn, groupName);
+ throw new JobPersistenceException("Couldn't check for existence of job: " + e.Message, e);
}
}
- protected virtual IList GetTriggerNames(ConnectionAndTransactionHolder conn,
- string groupName)
+ /**
+ * Determine whether a {@link Trigger} with the given identifier already
+ * exists within the scheduler.
+ *
+ * @param triggerKey the identifier to check for
+ * @return true if a Trigger exists with the given identifier
+ * @throws SchedulerException
+ */
+
+ public bool CheckExists(TriggerKey triggerKey)
{
- IList triggerNames;
+ return (bool) ExecuteWithoutLock( // no locks necessary for read...
+ conn => CheckExists(conn, triggerKey));
+ }
+ protected bool CheckExists(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
+ {
try
{
- triggerNames = Delegate.SelectTriggersInGroup(conn, groupName);
+ return Delegate.TriggerExists(conn, triggerKey);
}
catch (Exception e)
{
- throw new JobPersistenceException("Couldn't obtain trigger names: " + e.Message, e);
+ throw new JobPersistenceException("Couldn't check for existence of job: " + e.Message, e);
}
+ }
- return triggerNames;
+ /**
+ * Clear (delete!) all scheduling data - all {@link Job}s, {@link Trigger}s
+ * {@link Calendar}s.
+ *
+ * @throws JobPersistenceException
+ */
+
+ public void ClearAllSchedulingData()
+ {
+ ExecuteInLock(
+ LockTriggerAccess,
+ conn => ClearAllSchedulingData(conn));
+ }
+
+ protected void ClearAllSchedulingData(ConnectionAndTransactionHolder conn)
+ {
+ try
+ {
+ Delegate.ClearData(conn);
+ }
+ catch (Exception e)
+ {
+ throw new JobPersistenceException("Error clearing scheduling data: " + e.Message, e);
+ }
}
///
- /// Get the names of all of the
- /// groups.
+ /// Get the names of all of the s
+ /// that have the given group name.
///
- ///
///
- /// If there are no known group names, the result should be a zero-length
- /// array (not ).
+ /// If there are no triggers in the given group name, the result should be a
+ /// zero-length array (not ).
///
- public IList GetJobGroupNames()
+ public IList GetTriggerKeys(string groupName)
{
// no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetJobGroupNamesCallback(this));
+ return (IList)ExecuteWithoutLock(conn => GetTriggerNames(conn, groupName));
}
- protected class GetJobGroupNamesCallback : CallbackSupport, ITransactionCallback
+ protected virtual IList GetTriggerNames(ConnectionAndTransactionHolder conn, string groupName)
{
- public GetJobGroupNamesCallback(JobStoreSupport js)
- : base(js)
+ IList triggerNames;
+
+ try
{
+ triggerNames = Delegate.SelectTriggersInGroup(conn, groupName);
}
-
- public Object Execute(ConnectionAndTransactionHolder conn)
+ catch (Exception e)
{
- return js.GetJobGroupNames(conn);
+ throw new JobPersistenceException("Couldn't obtain trigger names: " + e.Message, e);
}
+
+ return triggerNames;
}
+ ///
+ /// Get the names of all of the
+ /// groups.
+ ///
+ ///
+ ///
+ /// If there are no known group names, the result should be a zero-length
+ /// array (not ).
+ ///
+ public IList GetJobGroupNames()
+ {
+ // no locks necessary for read...
+ return (IList)ExecuteWithoutLock(conn => GetJobGroupNames(conn));
+ }
+
protected virtual IList GetJobGroupNames(ConnectionAndTransactionHolder conn)
{
IList groupNames;
@@ -2176,23 +1821,9 @@ protected virtual IList GetJobGroupNames(ConnectionAndTransactionHolder
public IList GetTriggerGroupNames()
{
// no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetTriggerGroupNamesCallback(this));
- }
-
- protected class GetTriggerGroupNamesCallback : CallbackSupport, ITransactionCallback
- {
- public GetTriggerGroupNamesCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetTriggerGroupNames(conn);
- }
+ return (IList)ExecuteWithoutLock(conn => GetTriggerGroupNames(conn));
}
-
protected virtual IList GetTriggerGroupNames(ConnectionAndTransactionHolder conn)
{
IList groupNames;
@@ -2221,20 +1852,7 @@ protected virtual IList GetTriggerGroupNames(ConnectionAndTransactionHol
public IList GetCalendarNames()
{
// no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetCalendarNamesCallback(this));
- }
-
- protected class GetCalendarNamesCallback : CallbackSupport, ITransactionCallback
- {
- public GetCalendarNamesCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetCalendarNames(conn);
- }
+ return (IList)ExecuteWithoutLock(conn => GetCalendarNames(conn));
}
protected virtual IList GetCalendarNames(ConnectionAndTransactionHolder conn)
@@ -2256,40 +1874,19 @@ protected virtual IList GetCalendarNames(ConnectionAndTransactionHolder
///
/// If there are no matches, a zero-length array should be returned.
///
- public IList GetTriggersForJob(string jobName, string groupName)
+ public IList GetTriggersForJob(JobKey jobKey)
{
// no locks necessary for read...
- return (IList) ExecuteWithoutLock(new GetTriggersForJobCallback(this, jobName, groupName));
- }
-
- protected class GetTriggersForJobCallback : CallbackSupport, ITransactionCallback
- {
- private readonly string jobName;
- private readonly string groupName;
-
-
- public GetTriggersForJobCallback(JobStoreSupport js, string jobName,
- string groupName)
- : base(js)
- {
- this.jobName = jobName;
- this.groupName = groupName;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetTriggersForJob(conn, jobName, groupName);
- }
+ return (IList)ExecuteWithoutLock(conn => GetTriggersForJob(conn, jobKey));
}
-
- protected virtual IList GetTriggersForJob(ConnectionAndTransactionHolder conn, string jobName, string groupName)
+ protected virtual IList GetTriggersForJob(ConnectionAndTransactionHolder conn, JobKey jobKey)
{
- IList array;
+ IList array;
try
{
- array = Delegate.SelectTriggersForJob(conn, jobName, groupName);
+ array = Delegate.SelectTriggersForJob(conn, jobKey);
}
catch (Exception e)
{
@@ -2302,53 +1899,33 @@ protected virtual IList GetTriggersForJob(ConnectionAndTransactionHolde
///
/// Pause the with the given name.
///
- public void PauseTrigger(string triggerName, string groupName)
- {
- ExecuteInLock(LockTriggerAccess, new PauseTriggerCallback(this, triggerName, groupName));
- }
-
- protected class PauseTriggerCallback : CallbackSupport, IVoidTransactionCallback
+ public void PauseTrigger(TriggerKey triggerKey)
{
- private readonly string triggerName;
- private readonly string groupName;
-
-
- public PauseTriggerCallback(JobStoreSupport js, string triggerName, string groupName)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.PauseTrigger(conn, triggerName, groupName);
- }
+ ExecuteInLock(LockTriggerAccess, conn => PauseTrigger(conn, triggerKey));
}
///
/// Pause the with the given name.
///
- public virtual void PauseTrigger(ConnectionAndTransactionHolder conn, string triggerName,
- string groupName)
+ public virtual void PauseTrigger(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
try
{
- string oldState = Delegate.SelectTriggerState(conn, triggerName, groupName);
+ string oldState = Delegate.SelectTriggerState(conn, triggerKey);
if (oldState.Equals(StateWaiting) || oldState.Equals(StateAcquired))
{
- Delegate.UpdateTriggerState(conn, triggerName, groupName, StatePaused);
+ Delegate.UpdateTriggerState(conn, triggerKey, StatePaused);
}
else if (oldState.Equals(StateBlocked))
{
- Delegate.UpdateTriggerState(conn, triggerName, groupName, StatePausedBlocked);
+ Delegate.UpdateTriggerState(conn, triggerKey, StatePausedBlocked);
}
}
catch (Exception e)
{
throw new JobPersistenceException(
- "Couldn't pause trigger '" + groupName + "." + triggerName + "': " + e.Message, e);
+ "Couldn't pause trigger '" + triggerKey + "': " + e.Message, e);
}
}
@@ -2358,31 +1935,17 @@ public virtual void PauseTrigger(ConnectionAndTransactionHolder conn, string tri
/// pausing all of its current s.
///
///
- public virtual void PauseJob(string jobName, string groupName)
+ public virtual void PauseJob(JobKey jobKey)
{
- ExecuteInLock(LockTriggerAccess, new PauseJobCallback(this, jobName, groupName));
- }
-
- protected class PauseJobCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string jobName;
- private readonly string groupName;
-
- public PauseJobCallback(JobStoreSupport js, string jobName, string groupName)
- : base(js)
- {
- this.jobName = jobName;
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- IList triggers = js.GetTriggersForJob(conn, jobName, groupName);
- foreach (Trigger trigger in triggers)
- {
- js.PauseTrigger(conn, trigger.Name, trigger.Group);
- }
- }
+ ExecuteInLock(LockTriggerAccess,
+ conn =>
+ {
+ IList triggers = GetTriggersForJob(conn, jobKey);
+ foreach (IOperableTrigger trigger in triggers)
+ {
+ PauseTrigger(conn, trigger.Key);
+ }
+ });
}
///
@@ -2392,32 +1955,19 @@ public void Execute(ConnectionAndTransactionHolder conn)
///
public virtual void PauseJobGroup(string groupName)
{
- ExecuteInLock(LockTriggerAccess, new PauseJobGroupCallback(this, groupName));
- }
+ ExecuteInLock(LockTriggerAccess, conn =>
+ {
+ IList jobNames = GetJobNames(conn, groupName);
- protected class PauseJobGroupCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string groupName;
-
- public PauseJobGroupCallback(JobStoreSupport js, string groupName)
- : base(js)
- {
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- IList jobNames = js.GetJobNames(conn, groupName);
-
- foreach (string jobName in jobNames)
- {
- IList triggers = js.GetTriggersForJob(conn, jobName, groupName);
- foreach (Trigger trigger in triggers)
- {
- js.PauseTrigger(conn, trigger.Name, trigger.Group);
- }
- }
- }
+ foreach (JobKey jobKey in jobNames)
+ {
+ IList triggers = GetTriggersForJob(conn, jobKey);
+ foreach (IOperableTrigger trigger in triggers)
+ {
+ PauseTrigger(conn, trigger.Key);
+ }
+ }
+ });
}
///
@@ -2426,9 +1976,7 @@ public void Execute(ConnectionAndTransactionHolder conn)
/// StatePaused/StateWaiting respectively.
///
/// StatePausedBlocked, StateBlocked, or the currentState.
- protected virtual string CheckBlockedState(
- ConnectionAndTransactionHolder conn, string jobName,
- string jobGroupName, string currentState)
+ protected virtual string CheckBlockedState(ConnectionAndTransactionHolder conn, JobKey jobKey, string currentState)
{
// State can only transition to BLOCKED from PAUSED or WAITING.
if ((currentState.Equals(StateWaiting) == false) &&
@@ -2439,17 +1987,13 @@ protected virtual string CheckBlockedState(
try
{
- IList lst = Delegate.SelectFiredTriggerRecordsByJob(conn,
- jobName, jobGroupName);
+ IList lst = Delegate.SelectFiredTriggerRecordsByJob(conn, jobKey.Name, jobKey.Group);
if (lst.Count > 0)
{
FiredTriggerRecord rec = lst[0];
- if (rec.JobIsStateful)
+ if (rec.JobDisallowsConcurrentExecution) // TODO: worry about failed/recovering/volatile job states?
{
- // TODO: worry about
- // failed/recovering/volatile job
- // states?
return (StatePaused.Equals(currentState)) ? StatePausedBlocked : StateBlocked;
}
}
@@ -2459,95 +2003,13 @@ protected virtual string CheckBlockedState(
catch (Exception e)
{
throw new JobPersistenceException(
- "Couldn't determine if trigger should be in a blocked state '"
- + jobGroupName + "."
- + jobName + "': "
- + e.Message, e);
- }
- }
-
-
- protected virtual string GetNewStatusForTrigger(ConnectionAndTransactionHolder conn,
- string jobName,
- string groupName)
- {
- try
- {
- string newState = StateWaiting;
-
- IList lst = Delegate.SelectFiredTriggerRecordsByJob(conn, jobName, groupName);
-
- if (lst.Count > 0)
- {
- FiredTriggerRecord rec = lst[0];
- if (rec.JobIsStateful)
- {
- // TODO: worry about
- // failed/recovering/volatile job
- // states?
- newState = StateBlocked;
- }
- }
-
- return newState;
- }
- catch (Exception e)
- {
- throw new JobPersistenceException("Couldn't determine state for new trigger: " + e.Message, e);
+ "Couldn't determine if trigger should be in a blocked state '" + jobKey + "': " + e.Message, e);
}
}
- /*
- * private List findTriggersToBeBlocked(Connection conn, SchedulingContext
- * ctxt, string groupName) throws JobPersistenceException {
- *
- * try { List blockList = new LinkedList();
- *
- * List affectingJobs =
- * getDelegate().SelectStatefulJobsOfTriggerGroup(conn, groupName);
- *
- * Iterator itr = affectingJobs.iterator(); while(itr.hasNext()) { Key
- * jobKey = (Key) itr.next();
- *
- * List lst = getDelegate().SelectFiredTriggerRecordsByJob(conn,
- * jobKey.getName(), jobKey.getGroup());
- *
- * This logic is BROKEN...
- *
- * if(lst.size() > 0) { FiredTriggerRecord rec =
- * (FiredTriggerRecord)lst.get(0); if(rec.isJobIsStateful()) // TODO: worry
- * about failed/recovering/volatile job states? blockList.add(
- * rec.getTriggerKey() ); } }
- *
- *
- * return blockList; } catch (SQLException e) { throw new
- * JobPersistenceException ("Couldn't determine states of resumed triggers
- * in group '" + groupName + "': " + e.getMessage(), e); } }
- */
-
-
- public virtual void ResumeTrigger(string triggerName, string groupName)
- {
- ExecuteInLock(LockTriggerAccess, new ResumeTriggerCallback(this, triggerName, groupName));
- }
-
- protected class ResumeTriggerCallback : CallbackSupport, IVoidTransactionCallback
+ public virtual void ResumeTrigger(TriggerKey triggerKey)
{
- private readonly string triggerName;
- private readonly string groupName;
-
- public ResumeTriggerCallback(JobStoreSupport js, string triggerName,
- string groupName)
- : base(js)
- {
- this.triggerName = triggerName;
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.ResumeTrigger(conn, triggerName, groupName);
- }
+ ExecuteInLock(LockTriggerAccess, conn => ResumeTrigger(conn, triggerKey));
}
///
@@ -2558,12 +2020,11 @@ public void Execute(ConnectionAndTransactionHolder conn)
/// If the missed one or more fire-times, then the
/// 's misfire instruction will be applied.
///
- public virtual void ResumeTrigger(ConnectionAndTransactionHolder conn,
- string triggerName, string groupName)
+ public virtual void ResumeTrigger(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
try
{
- TriggerStatus status = Delegate.SelectTriggerStatus(conn, triggerName, groupName);
+ TriggerStatus status = Delegate.SelectTriggerStatus(conn, triggerKey);
if (status == null || !status.NextFireTimeUtc.HasValue || status.NextFireTimeUtc == DateTimeOffset.MinValue)
{
@@ -2576,32 +2037,30 @@ public virtual void ResumeTrigger(ConnectionAndTransactionHolder conn,
blocked = true;
}
- string newState = CheckBlockedState(conn, status.JobKey.Name, status.JobKey.Group, StateWaiting);
+ string newState = CheckBlockedState(conn, status.JobKey, StateWaiting);
bool misfired = false;
if ((status.NextFireTimeUtc.Value < SystemTime.UtcNow()))
{
- misfired = UpdateMisfiredTrigger(conn, triggerName, groupName, newState, true);
+ misfired = UpdateMisfiredTrigger(conn, triggerKey, newState, true);
}
if (!misfired)
{
if (blocked)
{
- Delegate.UpdateTriggerStateFromOtherState(conn, triggerName, groupName, newState,
- StatePausedBlocked);
+ Delegate.UpdateTriggerStateFromOtherState(conn, triggerKey, newState, StatePausedBlocked);
}
else
{
- Delegate.UpdateTriggerStateFromOtherState(conn, triggerName, groupName, newState, StatePaused);
+ Delegate.UpdateTriggerStateFromOtherState(conn, triggerKey, newState, StatePaused);
}
}
}
catch (Exception e)
{
- throw new JobPersistenceException(
- "Couldn't resume trigger '" + groupName + "." + triggerName + "': " + e.Message, e);
+ throw new JobPersistenceException("Couldn't resume trigger '" + triggerKey + "': " + e.Message, e);
}
}
@@ -2616,31 +2075,16 @@ public virtual void ResumeTrigger(ConnectionAndTransactionHolder conn,
/// instruction will be applied.
///
///
- public virtual void ResumeJob(string jobName, string groupName)
+ public virtual void ResumeJob(JobKey jobKey)
{
- ExecuteInLock(LockTriggerAccess, new ResumeJobCallback(this, jobName, groupName));
- }
-
- protected class ResumeJobCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string jobName;
- private readonly string groupName;
-
- public ResumeJobCallback(JobStoreSupport js, string jobName, string groupName)
- : base(js)
- {
- this.jobName = jobName;
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- IList triggers = js.GetTriggersForJob(conn, jobName, groupName);
- foreach (Trigger trigger in triggers)
- {
- js.ResumeTrigger(conn, trigger.Name, trigger.Group);
- }
- }
+ ExecuteInLock(LockTriggerAccess, conn =>
+ {
+ IList triggers = GetTriggersForJob(conn, jobKey);
+ foreach (IOperableTrigger trigger in triggers)
+ {
+ ResumeTrigger(conn, trigger.Key);
+ }
+ });
}
///
@@ -2655,32 +2099,19 @@ public void Execute(ConnectionAndTransactionHolder conn)
///
public virtual void ResumeJobGroup(string groupName)
{
- ExecuteInLock(LockTriggerAccess, new ResumeJobGroupCallback(this, groupName));
- }
-
- protected class ResumeJobGroupCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string groupName;
+ ExecuteInLock(LockTriggerAccess, conn =>
+ {
+ IList jobNames = GetJobNames(conn, groupName);
- public ResumeJobGroupCallback(JobStoreSupport js, string groupName)
- : base(js)
- {
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- IList jobNames = js.GetJobNames(conn, groupName);
-
- foreach (string jobName in jobNames)
- {
- IList triggers = js.GetTriggersForJob(conn, jobName, groupName);
- foreach (Trigger trigger in triggers)
- {
- js.ResumeTrigger(conn, trigger.Name, trigger.Group);
- }
- }
- }
+ foreach (JobKey jobKey in jobNames)
+ {
+ IList triggers = GetTriggersForJob(conn, jobKey);
+ foreach (IOperableTrigger trigger in triggers)
+ {
+ ResumeTrigger(conn, trigger.Key);
+ }
+ }
+ });
}
///
@@ -2689,31 +2120,13 @@ public void Execute(ConnectionAndTransactionHolder conn)
///
public virtual void PauseTriggerGroup(string groupName)
{
- ExecuteInLock(LockTriggerAccess, new PauseTriggerGroupCallback(this, groupName));
- }
-
- protected class PauseTriggerGroupCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string groupName;
-
-
- public PauseTriggerGroupCallback(JobStoreSupport js, string groupName)
- : base(js)
- {
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.PauseTriggerGroup(conn, groupName);
- }
+ ExecuteInLock(LockTriggerAccess, conn => PauseTriggerGroup(conn, groupName));
}
///
/// Pause all of the s in the given group.
///
- public virtual void PauseTriggerGroup(ConnectionAndTransactionHolder conn,
- string groupName)
+ public virtual void PauseTriggerGroup(ConnectionAndTransactionHolder conn, string groupName)
{
try
{
@@ -2739,23 +2152,9 @@ public virtual void PauseTriggerGroup(ConnectionAndTransactionHolder conn,
public Collection.ISet GetPausedTriggerGroups()
{
// no locks necessary for read...
- return (Collection.ISet) ExecuteWithoutLock(new GetPausedTriggerGroupsCallback(this));
+ return (Collection.ISet)ExecuteWithoutLock(conn => GetPausedTriggerGroups(conn));
}
- protected class GetPausedTriggerGroupsCallback : CallbackSupport, ITransactionCallback
- {
- public GetPausedTriggerGroupsCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public Object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.GetPausedTriggerGroups(conn);
- }
- }
-
-
///
/// Pause all of the s in the
/// given group.
@@ -2775,27 +2174,9 @@ public virtual Collection.ISet GetPausedTriggerGroups(ConnectionAndTrans
public virtual void ResumeTriggerGroup(string groupName)
{
- ExecuteInLock(LockTriggerAccess, new ResumeTriggerGroupCallback(this, groupName));
+ ExecuteInLock(LockTriggerAccess, conn => ResumeTriggerGroup(conn, groupName));
}
- protected class ResumeTriggerGroupCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly string groupName;
-
-
- public ResumeTriggerGroupCallback(JobStoreSupport js, string groupName)
- : base(js)
- {
- this.groupName = groupName;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.ResumeTriggerGroup(conn, groupName);
- }
- }
-
-
///
/// Resume (un-pause) all of the s
/// in the given group.
@@ -2811,11 +2192,11 @@ public virtual void ResumeTriggerGroup(ConnectionAndTransactionHolder conn,
{
Delegate.DeletePausedTriggerGroup(conn, groupName);
- IList triggerNames = Delegate.SelectTriggersInGroup(conn, groupName);
+ IList triggerNames = Delegate.SelectTriggersInGroup(conn, groupName);
- foreach (string triggerName in triggerNames)
+ foreach (TriggerKey triggerKey in triggerNames)
{
- ResumeTrigger(conn, triggerName, groupName);
+ ResumeTrigger(conn, triggerKey);
}
// TODO: find an efficient way to resume triggers (better than the
@@ -2859,20 +2240,7 @@ public virtual void ResumeTriggerGroup(ConnectionAndTransactionHolder conn,
public virtual void PauseAll()
{
- ExecuteInLock(LockTriggerAccess, new PauseAllCallback(this));
- }
-
- protected class PauseAllCallback : CallbackSupport, IVoidTransactionCallback
- {
- public PauseAllCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.PauseAll(conn);
- }
+ ExecuteInLock(LockTriggerAccess, conn => PauseAll(conn));
}
///
@@ -2919,20 +2287,7 @@ public virtual void PauseAll(ConnectionAndTransactionHolder conn)
///
public virtual void ResumeAll()
{
- ExecuteInLock(LockTriggerAccess, new ResumeAllCallback(this));
- }
-
- protected class ResumeAllCallback : CallbackSupport, IVoidTransactionCallback
- {
- public ResumeAllCallback(JobStoreSupport js)
- : base(js)
- {
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.ResumeAll(conn);
- }
+ ExecuteInLock(LockTriggerAccess, conn => ResumeAll(conn));
}
///
@@ -2971,55 +2326,34 @@ public virtual void ResumeAll(ConnectionAndTransactionHolder conn)
/// by the calling scheduler.
///
///
- public virtual IList AcquireNextTriggers(DateTimeOffset noLaterThan, int maxCount, TimeSpan timeWindow)
+ public virtual IList AcquireNextTriggers(DateTimeOffset noLaterThan, int maxCount, TimeSpan timeWindow)
{
if (AcquireTriggersWithinLock)
{
return
- (IList) ExecuteInNonManagedTXLock(LockTriggerAccess, new AcquireNextTriggerCallback(this, noLaterThan, maxCount, timeWindow));
+ (IList)ExecuteInNonManagedTXLock(LockTriggerAccess, conn => AcquireNextTrigger(conn, noLaterThan, maxCount, timeWindow));
}
else
{
// default behavior since Quartz 1.0.1 release
- return (IList) ExecuteInNonManagedTXLock(
+ return (IList)ExecuteInNonManagedTXLock(
null, /* passing null as lock name causes no lock to be made */
- new AcquireNextTriggerCallback(this, noLaterThan, maxCount, timeWindow));
+ conn => AcquireNextTrigger(conn, noLaterThan, maxCount, timeWindow));
}
}
- protected class AcquireNextTriggerCallback : CallbackSupport, ITransactionCallback
- {
- private readonly DateTimeOffset noLaterThan;
- private int maxCount;
- private TimeSpan timeWindow;
-
- public AcquireNextTriggerCallback(JobStoreSupport js, DateTimeOffset noLaterThan, int maxCount, TimeSpan timeWindow)
- : base(js)
- {
- this.noLaterThan = noLaterThan;
- this.maxCount = maxCount;
- this.timeWindow = timeWindow;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- return js.AcquireNextTrigger(conn, noLaterThan, maxCount, timeWindow);
- }
- }
-
-
// TODO: this really ought to return something like a FiredTriggerBundle,
// so that the fireInstanceId doesn't have to be on the trigger...
- protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHolder conn, DateTimeOffset noLaterThan, int maxCount, TimeSpan timeWindow)
+ protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHolder conn, DateTimeOffset noLaterThan, int maxCount, TimeSpan timeWindow)
{
do
{
try
{
- Trigger nextTrigger = null;
+ IOperableTrigger nextTrigger = null;
- IList keys = Delegate.SelectTriggerToAcquire(conn, noLaterThan, MisfireTime);
+ IList keys = Delegate.SelectTriggerToAcquire(conn, noLaterThan, MisfireTime);
// No trigger is ready to fire yet.
if (keys == null || keys.Count == 0)
@@ -3027,11 +2361,11 @@ protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHold
return null;
}
- foreach (Key triggerKey in keys)
+ foreach (TriggerKey triggerKey in keys)
{
int rowsUpdated = Delegate.UpdateTriggerStateFromOtherState(
conn,
- triggerKey.Name, triggerKey.Group,
+ triggerKey,
StateAcquired, StateWaiting);
// If our trigger was no longer in the expected state, try a new one.
@@ -3040,7 +2374,7 @@ protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHold
continue;
}
- nextTrigger = RetrieveTrigger(conn, triggerKey.Name, triggerKey.Group);
+ nextTrigger = RetrieveTrigger(conn, triggerKey);
// If our trigger is no longer available, try a new one.
if (nextTrigger == null)
@@ -3060,12 +2394,14 @@ protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHold
nextTrigger.FireInstanceId = FiredTriggerRecordId;
Delegate.InsertFiredTrigger(conn, nextTrigger, StateAcquired, null);
- return new List(new[] {nextTrigger});
+ List acquiredList = new List();
+ acquiredList.Add(nextTrigger);
+
+ return acquiredList;
}
catch (Exception e)
{
- throw new JobPersistenceException(
- "Couldn't acquire next trigger: " + e.Message, e);
+ throw new JobPersistenceException("Couldn't acquire next trigger: " + e.Message, e);
}
} while (true);
}
@@ -3076,34 +2412,16 @@ protected virtual IList AcquireNextTrigger(ConnectionAndTransactionHold
/// fire the given , that it had previously acquired
/// (reserved).
///
- public void ReleaseAcquiredTrigger(Trigger trigger)
+ public void ReleaseAcquiredTrigger(IOperableTrigger trigger)
{
- ExecuteInNonManagedTXLock(LockTriggerAccess, new ReleaseAcquiredTriggerCallback(this, trigger));
+ ExecuteInNonManagedTXLock(LockTriggerAccess, conn => ReleaseAcquiredTrigger(conn, trigger));
}
- protected class ReleaseAcquiredTriggerCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly Trigger trigger;
-
- public ReleaseAcquiredTriggerCallback(JobStoreSupport js, Trigger trigger)
- : base(js)
- {
- this.trigger = trigger;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.ReleaseAcquiredTrigger(conn, trigger);
- }
- }
-
- protected virtual void ReleaseAcquiredTrigger(ConnectionAndTransactionHolder conn,
- Trigger trigger)
+ protected virtual void ReleaseAcquiredTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger)
{
try
{
- Delegate.UpdateTriggerStateFromOtherState(conn, trigger.Name, trigger.Group, StateWaiting,
- StateAcquired);
+ Delegate.UpdateTriggerStateFromOtherState(conn, trigger.Key, StateWaiting, StateAcquired);
Delegate.DeleteFiredTrigger(conn, trigger.FireInstanceId);
}
catch (Exception e)
@@ -3113,52 +2431,37 @@ protected virtual void ReleaseAcquiredTrigger(ConnectionAndTransactionHolder con
}
- public virtual IList TriggersFired(IList triggers)
+ public virtual IList TriggersFired(IList triggers)
{
return
- (IList) ExecuteInNonManagedTXLock(LockTriggerAccess, new TriggerFiredCallback(this, triggers));
- }
-
- protected class TriggerFiredCallback : CallbackSupport, ITransactionCallback
- {
- private readonly IList triggers;
-
- public TriggerFiredCallback(JobStoreSupport js, IList triggers)
- : base(js)
- {
- this.triggers = triggers;
- }
-
- public object Execute(ConnectionAndTransactionHolder conn)
- {
- List results = new List();
-
- TriggerFiredResult result;
- foreach (Trigger trigger in triggers)
- {
- try
- {
- TriggerFiredBundle bundle = js.TriggerFired(conn, trigger);
- result = new TriggerFiredResult(bundle);
- }
- catch (JobPersistenceException jpe)
- {
- result = new TriggerFiredResult(jpe);
- }
- catch (Exception re)
- {
- result = new TriggerFiredResult(re);
- }
- results.Add(result);
- }
-
- return results;
- }
- }
-
-
- protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder conn,
- Trigger trigger)
+ (IList) ExecuteInNonManagedTXLock(LockTriggerAccess, conn =>
+ {
+ List results = new List();
+
+ TriggerFiredResult result;
+ foreach (IOperableTrigger trigger in triggers)
+ {
+ try
+ {
+ TriggerFiredBundle bundle = TriggerFired(conn, trigger);
+ result = new TriggerFiredResult(bundle);
+ }
+ catch (JobPersistenceException jpe)
+ {
+ result = new TriggerFiredResult(jpe);
+ }
+ catch (Exception re)
+ {
+ result = new TriggerFiredResult(re);
+ }
+ results.Add(result);
+ }
+
+ return results;
+ });
+ }
+
+ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder conn, IOperableTrigger trigger)
{
JobDetailImpl job;
ICalendar cal = null;
@@ -3167,7 +2470,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
try
{
// if trigger was deleted, state will be StateDeleted
- string state = Delegate.SelectTriggerState(conn, trigger.Name, trigger.Group);
+ string state = Delegate.SelectTriggerState(conn, trigger.Key);
if (!state.Equals(StateAcquired))
{
return null;
@@ -3180,7 +2483,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
try
{
- job = RetrieveJob(conn, trigger.JobName, trigger.JobGroup);
+ job = RetrieveJob(conn, trigger.JobKey);
if (job == null)
{
return null;
@@ -3191,7 +2494,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
try
{
Log.Error("Error retrieving job, setting trigger state to ERROR.", jpe);
- Delegate.UpdateTriggerState(conn, trigger.Name, trigger.Group, StateError);
+ Delegate.UpdateTriggerState(conn, trigger.Key, StateError);
}
catch (Exception sqle)
{
@@ -3211,8 +2514,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
try
{
- Delegate.DeleteFiredTrigger(conn, trigger.FireInstanceId); // TODO: Improve me by collapsing these two statements into one update (of the existing row)
- Delegate.InsertFiredTrigger(conn, trigger, StateExecuting, job);
+ Delegate.UpdateFiredTrigger(conn, trigger, StateExecuting, job);
}
catch (Exception e)
{
@@ -3227,18 +2529,15 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
string state2 = StateWaiting;
bool force = true;
- if (job.Stateful)
+ if (job.ConcurrentExectionDisallowed)
{
state2 = StateBlocked;
force = false;
try
{
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Name, job.Group, StateBlocked,
- StateWaiting);
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Name, job.Group, StateBlocked,
- StateAcquired);
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Name, job.Group, StatePausedBlocked,
- StatePaused);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StateBlocked, StateWaiting);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StateBlocked, StateAcquired);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, job.Key, StatePausedBlocked, StatePaused);
}
catch (Exception e)
{
@@ -3260,7 +2559,7 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
job,
trigger,
cal,
- trigger.Group.Equals(SchedulerConstants.DefaultRecoveryGroup),
+ trigger.Key.Group.Equals(SchedulerConstants.DefaultRecoveryGroup),
SystemTime.UtcNow(),
trigger.GetPreviousFireTimeUtc(),
prevFireTime,
@@ -3275,38 +2574,15 @@ protected virtual TriggerFiredBundle TriggerFired(ConnectionAndTransactionHolder
/// in the given should be updated if the
/// is stateful.
///
- public virtual void TriggeredJobComplete(Trigger trigger, JobDetailImpl jobDetail,
+ public virtual void TriggeredJobComplete(IOperableTrigger trigger, IJobDetail jobDetail,
SchedulerInstruction triggerInstCode)
{
- ExecuteInNonManagedTXLock(LockTriggerAccess,
- new TriggeredJobCompleteCallback(this, trigger, triggerInstCode, jobDetail));
+ ExecuteInNonManagedTXLock(LockTriggerAccess, conn => TriggeredJobComplete(conn, trigger, jobDetail, triggerInstCode));
}
- protected class TriggeredJobCompleteCallback : CallbackSupport, IVoidTransactionCallback
- {
- private readonly Trigger trigger;
- private readonly SchedulerInstruction triggerInstCode;
- private readonly JobDetailImpl jobDetail;
-
- public TriggeredJobCompleteCallback(JobStoreSupport js, Trigger trigger,
- SchedulerInstruction triggerInstCode, JobDetailImpl jobDetail)
- : base(js)
- {
- this.trigger = trigger;
- this.triggerInstCode = triggerInstCode;
- this.jobDetail = jobDetail;
- }
-
- public void Execute(ConnectionAndTransactionHolder conn)
- {
- js.TriggeredJobComplete(conn, trigger, jobDetail, triggerInstCode);
- }
- }
-
-
protected virtual void TriggeredJobComplete(ConnectionAndTransactionHolder conn,
- Trigger trigger,
- JobDetailImpl jobDetail, SchedulerInstruction triggerInstCode)
+ IOperableTrigger trigger,
+ IJobDetail jobDetail, SchedulerInstruction triggerInstCode)
{
try
{
@@ -3316,49 +2592,45 @@ protected virtual void TriggeredJobComplete(ConnectionAndTransactionHolder conn,
{
// double check for possible reschedule within job
// execution, which would cancel the need to delete...
- TriggerStatus stat = Delegate.SelectTriggerStatus(conn, trigger.Name, trigger.Group);
+ TriggerStatus stat = Delegate.SelectTriggerStatus(conn, trigger.Key);
if (stat != null && !stat.NextFireTimeUtc.HasValue)
{
- RemoveTrigger(conn, trigger.Name, trigger.Group);
+ RemoveTrigger(conn, trigger.Key);
}
}
else
{
- RemoveTrigger(conn, trigger.Name, trigger.Group);
+ RemoveTrigger(conn, trigger.Key);
SignalSchedulingChangeOnTxCompletion(null);
}
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerComplete)
{
- Delegate.UpdateTriggerState(conn, trigger.Name, trigger.Group, StateComplete);
+ Delegate.UpdateTriggerState(conn, trigger.Key, StateComplete);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerError)
{
- Log.Info("Trigger " + trigger.FullName + " set to ERROR state.");
- Delegate.UpdateTriggerState(conn, trigger.Name, trigger.Group, StateError);
+ Log.Info("Trigger " + trigger.Key + " set to ERROR state.");
+ Delegate.UpdateTriggerState(conn, trigger.Key, StateError);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersComplete)
{
- Delegate.UpdateTriggerStatesForJob(conn, trigger.JobName, trigger.JobGroup, StateComplete);
+ Delegate.UpdateTriggerStatesForJob(conn, trigger.JobKey, StateComplete);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersError)
{
- Log.Info("All triggers of Job " + trigger.FullJobName + " set to ERROR state.");
- Delegate.UpdateTriggerStatesForJob(conn, trigger.JobName, trigger.JobGroup, StateError);
+ Log.Info("All triggers of Job " + trigger.JobKey + " set to ERROR state.");
+ Delegate.UpdateTriggerStatesForJob(conn, trigger.JobKey, StateError);
SignalSchedulingChangeOnTxCompletion(null);
}
- if (jobDetail.Stateful)
+ if (jobDetail.PersistJobDataAfterExecution)
{
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Name, jobDetail.Group,
- StateWaiting, StateBlocked);
-
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Name, jobDetail.Group,
- StatePaused,
- StatePausedBlocked);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Key, StateWaiting, StateBlocked);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Key, StatePaused, StatePausedBlocked);
SignalSchedulingChangeOnTxCompletion(null);
try
@@ -3605,7 +2877,7 @@ protected virtual IList FindFailedInstances(ConnectionAndT
// Someone must have done recovery for us.
if ((foundThisScheduler == false) && (firstCheckIn == false))
{
- // TODO: revisit when handle self-failed-out implied (see TODO in clusterCheckIn() below)
+ // TODO: revisit when handle self-failed-out impl'ed (see TODO in clusterCheckIn() below)
Log.Warn(
"This scheduler instance (" + InstanceId + ") is still " +
"active but was recovered by another instance in the cluster. " +
@@ -3707,7 +2979,7 @@ protected virtual void ClusterRecover(ConnectionAndTransactionHolder conn, IList
int recoveredCount = 0;
int otherCount = 0;
- var triggerKeys = new Collection.HashSet();
+ Collection.HashSet triggerKeys = new Collection.HashSet();
foreach (FiredTriggerRecord ftRec in firedTriggerRecs)
{
@@ -3719,13 +2991,13 @@ protected virtual void ClusterRecover(ConnectionAndTransactionHolder conn, IList
// release blocked triggers..
if (ftRec.FireInstanceState.Equals(StateBlocked))
{
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey.Name, jKey.Group,
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey,
StateWaiting,
StateBlocked);
}
else if (ftRec.FireInstanceState.Equals(StatePausedBlocked))
{
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey.Name, jKey.Group,
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey,
StatePaused,
StatePausedBlocked);
}
@@ -3733,27 +3005,26 @@ protected virtual void ClusterRecover(ConnectionAndTransactionHolder conn, IList
// release acquired triggers..
if (ftRec.FireInstanceState.Equals(StateAcquired))
{
- Delegate.UpdateTriggerStateFromOtherState(conn, tKey.Name, tKey.Group, StateWaiting,
- StateAcquired);
+ Delegate.UpdateTriggerStateFromOtherState(conn, tKey, StateWaiting, StateAcquired);
acquiredCount++;
}
else if (ftRec.JobRequestsRecovery)
{
// handle jobs marked for recovery that were not fully
// executed..
- if (JobExists(conn, jKey.Name, jKey.Group))
+ if (JobExists(conn, jKey))
{
DateTimeOffset tempAux = new DateTimeOffset(ftRec.FireTimestamp, TimeSpan.Zero);
- SimpleTrigger rcvryTrig =
- new SimpleTrigger(
+ SimpleTriggerImpl rcvryTrig =
+ new SimpleTriggerImpl(
"recover_" + rec.SchedulerInstanceId + "_" + Convert.ToString(recoverIds++, CultureInfo.InvariantCulture),
SchedulerConstants.DefaultRecoveryGroup, tempAux);
- rcvryTrig.Volatile = ftRec.TriggerIsVolatile;
+
rcvryTrig.JobName = jKey.Name;
rcvryTrig.JobGroup = jKey.Group;
rcvryTrig.MisfireInstruction = MisfireInstruction.SimpleTrigger.FireNow;
rcvryTrig.Priority = ftRec.Priority;
- JobDataMap jd = Delegate.SelectTriggerJobDataMap(conn, tKey.Name, tKey.Group);
+ JobDataMap jd = Delegate.SelectTriggerJobDataMap(conn, tKey);
jd.Put(SchedulerConstants.FailedJobOriginalTriggerName, tKey.Name);
jd.Put(SchedulerConstants.FailedJobOriginalTriggerGroup, tKey.Group);
jd.Put(SchedulerConstants.FailedJobOriginalTriggerFiretimeInMillisecoonds, Convert.ToString(ftRec.FireTimestamp, CultureInfo.InvariantCulture));
@@ -3776,14 +3047,10 @@ protected virtual void ClusterRecover(ConnectionAndTransactionHolder conn, IList
}
// free up stateful job's triggers
- if (ftRec.JobIsStateful)
+ if (ftRec.JobDisallowsConcurrentExecution)
{
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey.Name, jKey.Group,
- StateWaiting,
- StateBlocked);
- Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey.Name, jKey.Group,
- StatePaused,
- StatePausedBlocked);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey, StateWaiting, StateBlocked);
+ Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jKey, StatePaused, StatePausedBlocked);
}
}
@@ -3793,17 +3060,15 @@ protected virtual void ClusterRecover(ConnectionAndTransactionHolder conn, IList
// Check if any of the fired triggers we just deleted were the last fired trigger
// records of a COMPLETE trigger.
int completeCount = 0;
- foreach (Key triggerKey in triggerKeys)
+ foreach (TriggerKey triggerKey in triggerKeys)
{
if (
- Delegate.SelectTriggerState(conn, triggerKey.Name, triggerKey.Group).Equals(
- StateComplete))
+ Delegate.SelectTriggerState(conn, triggerKey).Equals(StateComplete))
{
- IList firedTriggers =
- Delegate.SelectFiredTriggerRecords(conn, triggerKey.Name, triggerKey.Group);
+ IList firedTriggers = Delegate.SelectFiredTriggerRecords(conn, triggerKey.Name, triggerKey.Group);
if (firedTriggers.Count == 0)
{
- if (RemoveTrigger(conn, triggerKey.Name, triggerKey.Group))
+ if (RemoveTrigger(conn, triggerKey))
{
completeCount++;
}
diff --git a/src/Quartz/Impl/AdoJobStore/JobStoreTX.cs b/src/Quartz/Impl/AdoJobStore/JobStoreTX.cs
index 564dec08c..a7996a957 100644
--- a/src/Quartz/Impl/AdoJobStore/JobStoreTX.cs
+++ b/src/Quartz/Impl/AdoJobStore/JobStoreTX.cs
@@ -17,6 +17,8 @@
*/
#endregion
+using System;
+
using Quartz.Spi;
namespace Quartz.Impl.AdoJobStore
@@ -69,7 +71,7 @@ protected override ConnectionAndTransactionHolder GetNonManagedTXConnection()
///
///
///
- protected override object ExecuteInLock(string lockName, ITransactionCallback txCallback)
+ protected override object ExecuteInLock(string lockName, Func txCallback)
{
return ExecuteInNonManagedTXLock(lockName, txCallback);
}
diff --git a/src/Quartz/Impl/AdoJobStore/MySQLDelegate.cs b/src/Quartz/Impl/AdoJobStore/MySQLDelegate.cs
index 0ecc77387..370d252a2 100644
--- a/src/Quartz/Impl/AdoJobStore/MySQLDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/MySQLDelegate.cs
@@ -19,6 +19,8 @@
using Common.Logging;
+using Quartz.Spi;
+
namespace Quartz.Impl.AdoJobStore
{
///
@@ -34,7 +36,8 @@ public class MySQLDelegate : StdAdoDelegate
/// the prefix of all table names
/// The instance id.
/// The db provider.
- public MySQLDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider) : base(logger, tablePrefix, instanceId, dbProvider)
+ public MySQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
{
}
@@ -46,7 +49,8 @@ public MySQLDelegate(ILog logger, string tablePrefix, string instanceId, IDbProv
/// The instance id.
/// The db provider.
/// if set to true [use properties].
- public MySQLDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider, bool useProperties) : base(logger, tablePrefix, instanceId, dbProvider, useProperties)
+ public MySQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
+ : base(logger, tablePrefix,schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
{
}
diff --git a/src/Quartz/Impl/AdoJobStore/OracleDelegate.cs b/src/Quartz/Impl/AdoJobStore/OracleDelegate.cs
index c9edc75ca..f6daa43af 100644
--- a/src/Quartz/Impl/AdoJobStore/OracleDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/OracleDelegate.cs
@@ -19,6 +19,8 @@
using Common.Logging;
+using Quartz.Spi;
+
namespace Quartz.Impl.AdoJobStore
{
///
@@ -36,7 +38,8 @@ public class OracleDelegate : StdAdoDelegate
/// the prefix of all table names
/// The instance id.
/// The db provider.
- public OracleDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider) : base(logger, tablePrefix, instanceId, dbProvider)
+ public OracleDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
{
CreateSqlForSelectNextTriggerToAcquire();
}
@@ -49,7 +52,8 @@ public OracleDelegate(ILog logger, string tablePrefix, string instanceId, IDbPro
/// The instance id.
/// The db provider.
/// if set to true [use properties].
- public OracleDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider, bool useProperties) : base(logger, tablePrefix, instanceId, dbProvider, useProperties)
+ public OracleDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
{
CreateSqlForSelectNextTriggerToAcquire();
}
diff --git a/src/Quartz/Impl/AdoJobStore/PostgreSQLDelegate.cs b/src/Quartz/Impl/AdoJobStore/PostgreSQLDelegate.cs
index 709d54635..dc7745437 100644
--- a/src/Quartz/Impl/AdoJobStore/PostgreSQLDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/PostgreSQLDelegate.cs
@@ -21,6 +21,8 @@
using Common.Logging;
+using Quartz.Spi;
+
namespace Quartz.Impl.AdoJobStore
{
///
@@ -37,8 +39,8 @@ public class PostgreSQLDelegate : StdAdoDelegate
/// The table prefix.
/// The instance id.
/// The db provider.
- public PostgreSQLDelegate(ILog log, string tablePrefix, string instanceId, IDbProvider dbProvider)
- : base(log, tablePrefix, instanceId, dbProvider)
+ public PostgreSQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
{
}
@@ -50,8 +52,8 @@ public PostgreSQLDelegate(ILog log, string tablePrefix, string instanceId, IDbPr
/// The instance id.
/// The db provider.
/// if set to true [use properties].
- public PostgreSQLDelegate(ILog log, string tablePrefix, string instanceId, IDbProvider dbProvider, bool useProperties)
- : base(log, tablePrefix, instanceId, dbProvider, useProperties)
+ public PostgreSQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
{
}
diff --git a/src/Quartz/Impl/AdoJobStore/SimplePropertiesTriggerPersistenceDelegateSupport.cs b/src/Quartz/Impl/AdoJobStore/SimplePropertiesTriggerPersistenceDelegateSupport.cs
index a2a7a9e05..2e99fd638 100644
--- a/src/Quartz/Impl/AdoJobStore/SimplePropertiesTriggerPersistenceDelegateSupport.cs
+++ b/src/Quartz/Impl/AdoJobStore/SimplePropertiesTriggerPersistenceDelegateSupport.cs
@@ -57,35 +57,35 @@ public abstract class SimplePropertiesTriggerPersistenceDelegateSupport : ITrigg
protected static readonly string SELECT_SIMPLE_PROPS_TRIGGER = "SELECT *" + " FROM "
+ StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " WHERE "
- + StdAdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
- + " AND " + COL_TRIGGER_NAME + " = ? AND " + COL_TRIGGER_GROUP + " = ?";
+ + AdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
+ + " AND " + AdoConstants.ColumnTriggerName + " = ? AND " + AdoConstants.ColumnTriggerGroup + " = ?";
protected static readonly string DELETE_SIMPLE_PROPS_TRIGGER = "DELETE FROM "
- + StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " WHERE "
- + StdAdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
- + " AND " + COL_TRIGGER_NAME + " = ? AND " + COL_TRIGGER_GROUP + " = ?";
+ + StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " WHERE "
+ + AdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
+ + " AND " + AdoConstants.ColumnTriggerName + " = ? AND " + AdoConstants.ColumnTriggerGroup + " = ?";
protected static readonly string INSERT_SIMPLE_PROPS_TRIGGER = "INSERT INTO "
- + StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " ("
- + StdAdoConstants.ColumnSchedulerName + ", "
- + COL_TRIGGER_NAME + ", " + COL_TRIGGER_GROUP + ", "
- + COL_STR_PROP_1 + ", " + COL_STR_PROP_2 + ", " + COL_STR_PROP_3 + ", "
- + COL_INT_PROP_1 + ", " + COL_INT_PROP_2 + ", "
- + COL_LONG_PROP_1 + ", " + COL_LONG_PROP_2 + ", "
- + COL_DEC_PROP_1 + ", " + COL_DEC_PROP_2 + ", "
- + COL_BOOL_PROP_1 + ", " + COL_BOOL_PROP_2
+ + StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " ("
+ + AdoConstants.ColumnSchedulerName + ", "
+ + AdoConstants.ColumnTriggerName + ", " + AdoConstants.ColumnTriggerGroup + ", "
+ + ColumnStrProp1 + ", " + ColumnStrProp2 + ", " + ColumnStrProp3 + ", "
+ + ColumnIntProp1 + ", " + ColumnIntProp2 + ", "
+ + ColumnLongProp1 + ", " + ColumnLongProp2 + ", "
+ + ColumnDecProp1 + ", " + ColumnDecProp2 + ", "
+ + ColumnBoolProp1 + ", " + ColumnBoolProp2
+ ") " + " VALUES(" + StdAdoConstants.SchedulerNameSubst + ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
protected static readonly string UPDATE_SIMPLE_PROPS_TRIGGER = "UPDATE "
+ StdAdoConstants.TablePrefixSubst + TABLE_SIMPLE_PROPERTIES_TRIGGERS + " SET "
- + COL_STR_PROP_1 + " = ?, " + COL_STR_PROP_2 + " = ?, " + COL_STR_PROP_3 + " = ?, "
- + COL_INT_PROP_1 + " = ?, " + COL_INT_PROP_2 + " = ?, "
- + COL_LONG_PROP_1 + " = ?, " + COL_LONG_PROP_2 + " = ?, "
- + COL_DEC_PROP_1 + " = ?, " + COL_DEC_PROP_2 + " = ?, "
- + COL_BOOL_PROP_1 + " = ?, " + COL_BOOL_PROP_2
- + " = ? WHERE " + StdAdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
- + " AND " + COL_TRIGGER_NAME
- + " = ? AND " + COL_TRIGGER_GROUP + " = ?";
+ + ColumnStrProp1 + " = ?, " + ColumnStrProp2 + " = ?, " + ColumnStrProp3 + " = ?, "
+ + ColumnIntProp1 + " = ?, " + ColumnIntProp2 + " = ?, "
+ + ColumnLongProp1 + " = ?, " + ColumnLongProp2 + " = ?, "
+ + ColumnDecProp1 + " = ?, " + ColumnDecProp2 + " = ?, "
+ + ColumnBoolProp1 + " = ?, " + ColumnBoolProp2
+ + " = ? WHERE " + AdoConstants.ColumnSchedulerName + " = " + StdAdoConstants.SchedulerNameSubst
+ + " AND " + AdoConstants.ColumnTriggerName
+ + " = ? AND " + AdoConstants.ColumnTriggerGroup + " = ?";
protected string tablePrefix;
protected string schedNameLiteral;
@@ -109,8 +109,8 @@ public int DeleteExtendedTriggerProperties(ConnectionAndTransactionHolder conn,
{
using (IDbCommand cmd = adoUtil.PrepareCommand(AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlDeleteSimplePropsTrigger, tablePrefix, schedNameLiteral)))
{
- adoUtil.AddCommandParameter(cmd, "@", triggerKey.Name);
- adoUtil.AddCommandParameter(cmd, "@", triggerKey.Group);
+ adoUtil.AddCommandParameter(cmd, "triggerName", triggerKey.Name);
+ adoUtil.AddCommandParameter(cmd, "triggerGroup", triggerKey.Group);
return cmd.ExecuteNonQuery();
}
@@ -122,19 +122,20 @@ public int InsertExtendedTriggerProperties(ConnectionAndTransactionHolder conn,
using (IDbCommand cmd = adoUtil.PrepareCommand(AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlInsertSimplePropsTrigger, tablePrefix, schedNameLiteral)))
{
- adoUtil.AddCommandParameter(cmd, "@", trigger.Key.Name);
- adoUtil.AddCommandParameter(cmd, "@", trigger.Key.Group);
- adoUtil.AddCommandParameter(cmd, "@", properties.String1);
- adoUtil.AddCommandParameter(cmd, "@", properties.String2);
- adoUtil.AddCommandParameter(cmd, "@", properties.String3);
- adoUtil.AddCommandParameter(cmd, "@", properties.Int1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Int2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Long1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Long2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Decimal1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Decimal2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Boolean1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Boolean2);
+ adoUtil.AddCommandParameter(cmd, "triggerName", trigger.Key.Name);
+ adoUtil.AddCommandParameter(cmd, "triggerGroup", trigger.Key.Group);
+
+ adoUtil.AddCommandParameter(cmd, "string1", properties.String1);
+ adoUtil.AddCommandParameter(cmd, "string1", properties.String2);
+ adoUtil.AddCommandParameter(cmd, "string3", properties.String3);
+ adoUtil.AddCommandParameter(cmd, "int1", properties.Int1);
+ adoUtil.AddCommandParameter(cmd, "int2", properties.Int2);
+ adoUtil.AddCommandParameter(cmd, "long1", properties.Long1);
+ adoUtil.AddCommandParameter(cmd, "long2", properties.Long2);
+ adoUtil.AddCommandParameter(cmd, "decimal1", properties.Decimal1);
+ adoUtil.AddCommandParameter(cmd, "decimal2", properties.Decimal2);
+ adoUtil.AddCommandParameter(cmd, "boolean1", properties.Boolean1);
+ adoUtil.AddCommandParameter(cmd, "boolean2", properties.Boolean2);
return cmd.ExecuteNonQuery();
}
@@ -168,7 +169,7 @@ public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransact
}
}
- throw new InvalidOperationException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_SIMPLE_TRIGGER, tablePrefix));
+ throw new InvalidOperationException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectSimpleTrigger, tablePrefix, schedNameLiteral));
}
public int UpdateExtendedTriggerProperties(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail)
@@ -177,19 +178,19 @@ public int UpdateExtendedTriggerProperties(ConnectionAndTransactionHolder conn,
using (IDbCommand cmd = adoUtil.PrepareCommand(AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqUpdateSimplePropsTrigger, tablePrefix, schedNameLiteral)))
{
- adoUtil.AddCommandParameter(cmd, "@", properties.String1);
- adoUtil.AddCommandParameter(cmd, "@", properties.String2);
- adoUtil.AddCommandParameter(cmd, "@", properties.String3);
- adoUtil.AddCommandParameter(cmd, "@", properties.Int1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Int2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Long1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Long2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Decimal1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Decimal2);
- adoUtil.AddCommandParameter(cmd, "@", properties.Boolean1);
- adoUtil.AddCommandParameter(cmd, "@", properties.Boolean2);
- adoUtil.AddCommandParameter(cmd, "@", trigger.Key.Name);
- adoUtil.AddCommandParameter(cmd, "@", trigger.Key.Group);
+ adoUtil.AddCommandParameter(cmd, "string1", properties.String1);
+ adoUtil.AddCommandParameter(cmd, "string1", properties.String2);
+ adoUtil.AddCommandParameter(cmd, "string3", properties.String3);
+ adoUtil.AddCommandParameter(cmd, "int1", properties.Int1);
+ adoUtil.AddCommandParameter(cmd, "int2", properties.Int2);
+ adoUtil.AddCommandParameter(cmd, "long1", properties.Long1);
+ adoUtil.AddCommandParameter(cmd, "long2", properties.Long2);
+ adoUtil.AddCommandParameter(cmd, "decimal1", properties.Decimal1);
+ adoUtil.AddCommandParameter(cmd, "decimal2", properties.Decimal2);
+ adoUtil.AddCommandParameter(cmd, "boolean1", properties.Boolean1);
+ adoUtil.AddCommandParameter(cmd, "boolean2", properties.Boolean2);
+ adoUtil.AddCommandParameter(cmd, "triggerName", trigger.Key.Name);
+ adoUtil.AddCommandParameter(cmd, "triggerGroup", trigger.Key.Group);
return cmd.ExecuteNonQuery();
}
diff --git a/src/Quartz/Impl/AdoJobStore/SimpleTriggerPersistenceDelegate.cs b/src/Quartz/Impl/AdoJobStore/SimpleTriggerPersistenceDelegate.cs
index bb572453e..6650d612c 100644
--- a/src/Quartz/Impl/AdoJobStore/SimpleTriggerPersistenceDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/SimpleTriggerPersistenceDelegate.cs
@@ -91,9 +91,9 @@ public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransact
long repeatInterval = rs.GetInt64(AdoConstants.ColumnRepeatInterval);
int timesTriggered = rs.GetInt32(AdoConstants.ColumnTimesTriggered);
- SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule()
- .withRepeatCount(repeatCount)
- .withIntervalInMilliseconds(repeatInterval);
+ SimpleScheduleBuilder sb = SimpleScheduleBuilder.SimpleSchedule()
+ .WithRepeatCount(repeatCount)
+ .WithInterval(TimeSpan.FromMilliseconds(repeatInterval));
string[] statePropertyNames = {"timesTriggered"};
object[] statePropertyValues = {timesTriggered};
diff --git a/src/Quartz/Impl/AdoJobStore/SqlServerDelegate.cs b/src/Quartz/Impl/AdoJobStore/SqlServerDelegate.cs
index 3d1cfd7f0..5ab8c0443 100644
--- a/src/Quartz/Impl/AdoJobStore/SqlServerDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/SqlServerDelegate.cs
@@ -19,6 +19,8 @@
using Common.Logging;
+using Quartz.Spi;
+
namespace Quartz.Impl.AdoJobStore
{
///
@@ -36,7 +38,8 @@ public class SqlServerDelegate : StdAdoDelegate
/// the prefix of all table names
/// The instance id.
/// The db provider.
- public SqlServerDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider) : base(logger, tablePrefix, instanceId, dbProvider)
+ public SqlServerDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
{
CreateSqlForSelectNextTriggerToAcquire();
}
@@ -49,7 +52,8 @@ public SqlServerDelegate(ILog logger, string tablePrefix, string instanceId, IDb
/// The instance id.
/// The db provider.
/// if set to true [use properties].
- public SqlServerDelegate(ILog logger, string tablePrefix, string instanceId, IDbProvider dbProvider, bool useProperties) : base(logger, tablePrefix, instanceId, dbProvider, useProperties)
+ public SqlServerDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
+ : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
{
CreateSqlForSelectNextTriggerToAcquire();
}
diff --git a/src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs b/src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
index cfe6e36c6..eda77fc8a 100644
--- a/src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
+++ b/src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
@@ -235,8 +235,8 @@ public virtual IList SelectMisfiredTriggers(ConnectionAndTransaction
List list = new List();
while (rs.Read())
{
- string triggerName = GetString(rs[ColumnTriggerName]);
- string groupName = GetString(rs[ColumnTriggerGroup]);
+ string triggerName = rs.GetString(ColumnTriggerName);
+ string groupName = rs.GetString(ColumnTriggerGroup);
list.Add(new TriggerKey(triggerName, groupName));
}
return list;
@@ -260,7 +260,7 @@ public virtual IList SelectTriggersInState(ConnectionAndTransactionH
List list = new List();
while (rs.Read())
{
- list.Add(new TriggerKey(GetString(rs[0]), GetString(rs[1])));
+ list.Add(new TriggerKey(rs.GetString(0), rs.GetString(1)));
}
return list;
@@ -289,8 +289,8 @@ public virtual IList HasMisfiredTriggersInState(ConnectionAndTransac
List list = new List();
while (rs.Read())
{
- string triggerName = GetString(rs[ColumnTriggerName]);
- string groupName = GetString(rs[ColumnTriggerGroup]);
+ string triggerName = rs.GetString(ColumnTriggerName);
+ string groupName = rs.GetString(ColumnTriggerGroup);
list.Add(new TriggerKey(triggerName, groupName));
}
return list;
@@ -330,8 +330,8 @@ public virtual bool HasMisfiredTriggersInState(ConnectionAndTransactionHolder co
}
else
{
- string triggerName = GetString(rs[ColumnTriggerName]);
- string groupName = GetString(rs[ColumnTriggerGroup]);
+ string triggerName = rs.GetString(ColumnTriggerName);
+ string groupName = rs.GetString(ColumnTriggerGroup);
resultList.Add(new TriggerKey(triggerName, groupName));
}
}
@@ -389,7 +389,7 @@ public virtual IList SelectMisfiredTriggersInGroupInState(Connection
List list = new List();
while (rs.Read())
{
- string triggerName = GetString(rs[ColumnTriggerName]);
+ string triggerName = rs.GetString(ColumnTriggerName);
list.Add(new TriggerKey(triggerName, groupName));
}
return list;
@@ -427,10 +427,10 @@ public virtual IList SelectTriggersForRecoveringJobs(Connectio
while (rs.Read())
{
- string jobName = GetString(rs[ColumnJobName]);
- string jobGroup = GetString(rs[ColumnJobGroup]);
- // string trigName = GetString(rs[ColumnTriggerName]);
- // string trigGroup = GetString(rs[ColumnTriggerGroup]);
+ string jobName = rs.GetString(ColumnJobName);
+ string jobGroup = rs.GetString(ColumnJobGroup);
+ // string trigName = rs.GetString(ColumnTriggerName);
+ // string trigGroup = rs.GetString(ColumnTriggerGroup);
long firedTimeInTicks = Convert.ToInt64(rs[ColumnFiredTime], CultureInfo.InvariantCulture);
int priority = Convert.ToInt32(rs[ColumnPriority], CultureInfo.InvariantCulture);
DateTimeOffset firedTime = new DateTimeOffset(firedTimeInTicks, TimeSpan.Zero);
@@ -529,7 +529,7 @@ public void ClearData(ConnectionAndTransactionHolder conn)
/// The DB Connection.
/// The job to insert.
/// Number of rows inserted.
- public virtual int InsertJobDetail(ConnectionAndTransactionHolder conn, JobDetailImpl job)
+ public virtual int InsertJobDetail(ConnectionAndTransactionHolder conn, IJobDetail job)
{
byte[] baos = SerializeJobData(job.JobDataMap);
@@ -537,8 +537,8 @@ public virtual int InsertJobDetail(ConnectionAndTransactionHolder conn, JobDetai
using (IDbCommand cmd = PrepareCommand(conn, ReplaceTablePrefix(SqlInsertJobDetail)))
{
- AddCommandParameter(cmd, "jobName", job.Name);
- AddCommandParameter(cmd, "jobGroup", job.Group);
+ AddCommandParameter(cmd, "jobName", job.Key.Name);
+ AddCommandParameter(cmd, "jobGroup", job.Key.Group);
AddCommandParameter(cmd, "jobDescription", job.Description);
AddCommandParameter(cmd, "jobType", GetStorableJobTypeName(job.JobType));
AddCommandParameter(cmd, "jobDurable", GetDbBooleanValue(job.Durable));
@@ -582,7 +582,7 @@ protected virtual string GetStorableJobTypeName(Type jobType)
/// The DB Connection.
/// The job to update.
/// Number of rows updated.
- public virtual int UpdateJobDetail(ConnectionAndTransactionHolder conn, JobDetailImpl job)
+ public virtual int UpdateJobDetail(ConnectionAndTransactionHolder conn, IJobDetail job)
{
byte[] baos = SerializeJobData(job.JobDataMap);
@@ -595,8 +595,8 @@ public virtual int UpdateJobDetail(ConnectionAndTransactionHolder conn, JobDetai
AddCommandParameter(cmd, "jobStateful", GetDbBooleanValue(job.PersistJobDataAfterExecution));
AddCommandParameter(cmd, "jobRequestsRecovery", GetDbBooleanValue(job.RequestsRecovery));
AddCommandParameter(cmd, "jobDataMap", baos, dbProvider.Metadata.DbBinaryType);
- AddCommandParameter(cmd, "jobName", job.Name);
- AddCommandParameter(cmd, "jobGroup", job.Group);
+ AddCommandParameter(cmd, "jobName", job.Key.Name);
+ AddCommandParameter(cmd, "jobGroup", job.Key.Group);
int insertResult = cmd.ExecuteNonQuery();
@@ -622,8 +622,8 @@ public virtual IList SelectTriggerNamesForJob(ConnectionAndTransacti
List list = new List(10);
while (rs.Read())
{
- string trigName = GetString(rs[ColumnTriggerName]);
- string trigGroup = GetString(rs[ColumnTriggerGroup]);
+ string trigName = rs.GetString(ColumnTriggerName);
+ string trigGroup = rs.GetString(ColumnTriggerGroup);
list.Add(new TriggerKey(trigName, trigGroup));
}
return list;
@@ -709,15 +709,15 @@ public virtual bool JobExists(ConnectionAndTransactionHolder conn, JobKey jobKey
/// The conn.
/// the job to update
/// the number of rows updated
- public virtual int UpdateJobData(ConnectionAndTransactionHolder conn, JobDetailImpl job)
+ public virtual int UpdateJobData(ConnectionAndTransactionHolder conn, IJobDetail job)
{
byte[] baos = SerializeJobData(job.JobDataMap);
using (IDbCommand cmd = PrepareCommand(conn, ReplaceTablePrefix(SqlUpdateJobData)))
{
AddCommandParameter(cmd, "jobDataMap", baos, dbProvider.Metadata.DbBinaryType);
- AddCommandParameter(cmd, "jobName", job.Name);
- AddCommandParameter(cmd, "jobGroup", job.Group);
+ AddCommandParameter(cmd, "jobName", job.Key.Name);
+ AddCommandParameter(cmd, "jobGroup", job.Key.Group);
return cmd.ExecuteNonQuery();
}
@@ -746,12 +746,12 @@ public virtual JobDetailImpl SelectJobDetail(ConnectionAndTransactionHolder conn
{
job = new JobDetailImpl();
- job.Name = GetString(rs[ColumnJobName]);
- job.Group = GetString(rs[ColumnJobGroup]);
- job.Description = GetString(rs[ColumnDescription]);
- job.JobType = loadHelper.LoadType(GetString(rs[ColumnJobClass]));
- job.Durable = GetBoolean(rs[ColumnIsDurable]);
- job.RequestsRecovery = GetBoolean(rs[ColumnRequestsRecovery]);
+ job.Name = rs.GetString(ColumnJobName);
+ job.Group = rs.GetString(ColumnJobGroup);
+ job.Description = rs.GetString(ColumnDescription);
+ job.JobType = loadHelper.LoadType(rs.GetString(ColumnJobClass));
+ job.Durable = rs.GetBoolean(ColumnIsDurable);
+ job.RequestsRecovery = rs.GetBoolean(ColumnRequestsRecovery);
IDictionary map;
if (CanUseProperties)
@@ -814,7 +814,7 @@ public virtual IList SelectJobGroups(ConnectionAndTransactionHolder conn
List list = new List();
while (rs.Read())
{
- list.Add((string) rs[0]);
+ list.Add(rs.GetString(0));
}
return list.ToArray();
@@ -839,7 +839,7 @@ public virtual IList SelectJobsInGroup(ConnectionAndTransactionHolder co
List list = new List();
while (rs.Read())
{
- list.Add(new JobKey(GetString(rs[0]), groupName));
+ list.Add(new JobKey(rs.GetString(0), groupName));
}
return list;
@@ -859,8 +859,7 @@ public virtual IList SelectJobsInGroup(ConnectionAndTransactionHolder co
/// the state that the trigger should be stored in
/// The job detail.
/// the number of rows inserted
- public virtual int InsertTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state,
- JobDetailImpl jobDetail)
+ public virtual int InsertTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail)
{
byte[] baos = null;
if (trigger.JobDataMap.Count > 0)
@@ -967,8 +966,7 @@ public virtual int InsertBlobTrigger(ConnectionAndTransactionHolder conn, IOpera
/// The state that the trigger should be stored in.
/// The job detail.
/// The number of rows updated.
- public virtual int UpdateTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state,
- JobDetailImpl jobDetail)
+ public virtual int UpdateTrigger(ConnectionAndTransactionHolder conn, IOperableTrigger trigger, string state, IJobDetail jobDetail)
{
// save some clock cycles by unnecessarily writing job data blob ...
bool updateJobData = trigger.JobDataMap.Dirty;
@@ -1378,11 +1376,11 @@ public virtual JobDetailImpl SelectJobForTrigger(ConnectionAndTransactionHolder
if (rs.Read())
{
JobDetailImpl job = new JobDetailImpl();
- job.Name = GetString(rs[0]);
- job.Group = GetString(rs[1]);
- job.Durable = GetBoolean(rs[2]);
- job.JobType = loadHelper.LoadType(GetString(rs[3]));
- job.RequestsRecovery = GetBoolean(rs[4]);
+ job.Name = rs.GetString(0);
+ job.Group = rs.GetString(1);
+ job.Durable = rs.GetBoolean(2);
+ job.JobType = loadHelper.LoadType(rs.GetString(3));
+ job.RequestsRecovery = rs.GetBoolean(4);
return job;
}
@@ -1453,7 +1451,7 @@ public virtual IList SelectTriggersForCalendar(ConnectionAndTr
{
while (rs.Read())
{
- trigList.Add(SelectTrigger(conn, new TriggerKey(GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup]))));
+ trigList.Add(SelectTrigger(conn, new TriggerKey(rs.GetString(ColumnTriggerName), rs.GetString(ColumnTriggerGroup))));
}
}
}
@@ -1492,15 +1490,15 @@ public virtual IOperableTrigger SelectTrigger(ConnectionAndTransactionHolder con
{
if (rs.Read())
{
- jobName = GetString(rs[ColumnJobName]);
- jobGroup = GetString(rs[ColumnJobGroup]);
- description = GetString(rs[ColumnDescription]);
+ jobName = rs.GetString(ColumnJobName);
+ jobGroup = rs.GetString(ColumnJobGroup);
+ description = rs.GetString(ColumnDescription);
long nextFireTime = Convert.ToInt64(rs[ColumnNextFireTime], CultureInfo.InvariantCulture);
long prevFireTime = Convert.ToInt64(rs[ColumnPreviousFireTime], CultureInfo.InvariantCulture);
- triggerType = GetString(rs[ColumnTriggerType]);
+ triggerType = rs.GetString(ColumnTriggerType);
long startTime = Convert.ToInt64(rs[ColumnStartTime], CultureInfo.InvariantCulture);
long endTime = Convert.ToInt64(rs[ColumnEndTime], CultureInfo.InvariantCulture);
- calendarName = GetString(rs[ColumnCalendarName]);
+ calendarName = rs.GetString(ColumnCalendarName);
misFireInstr = Convert.ToInt32(rs[ColumnMifireInstruction], CultureInfo.InvariantCulture);
priority = Convert.ToInt32(rs[ColumnPriority], CultureInfo.InvariantCulture);
@@ -1659,7 +1657,7 @@ public virtual string SelectTriggerState(ConnectionAndTransactionHolder conn, Tr
{
if (rs.Read())
{
- state = GetString(rs[ColumnTriggerState]);
+ state = rs.GetString(ColumnTriggerState);
}
else
{
@@ -1691,10 +1689,10 @@ public virtual TriggerStatus SelectTriggerStatus(ConnectionAndTransactionHolder
{
if (rs.Read())
{
- string state = GetString(rs[ColumnTriggerState]);
+ string state = rs.GetString(ColumnTriggerState);
long nextFireTime = Convert.ToInt64(rs[ColumnNextFireTime], CultureInfo.InvariantCulture);
- string jobName = GetString(rs[ColumnJobName]);
- string jobGroup = GetString(rs[ColumnJobGroup]);
+ string jobName = rs.GetString(ColumnJobName);
+ string jobGroup = rs.GetString(ColumnJobGroup);
DateTimeOffset? nft = null;
@@ -2092,7 +2090,7 @@ public virtual TriggerKey SelectTriggerForFireTime(ConnectionAndTransactionHolde
{
if (rs.Read())
{
- return new TriggerKey(GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup]));
+ return new TriggerKey(rs.GetString(ColumnTriggerName), rs.GetString(ColumnTriggerGroup));
}
return null;
@@ -2263,17 +2261,17 @@ public virtual IList SelectFiredTriggerRecords(ConnectionAnd
{
FiredTriggerRecord rec = new FiredTriggerRecord();
- rec.FireInstanceId = GetString(rs[ColumnEntryId]);
- rec.FireInstanceState = GetString(rs[ColumnEntryState]);
+ rec.FireInstanceId = rs.GetString(ColumnEntryId);
+ rec.FireInstanceState = rs.GetString(ColumnEntryState);
rec.FireTimestamp = Convert.ToInt64(rs[ColumnFiredTime], CultureInfo.InvariantCulture);
rec.Priority = Convert.ToInt32(rs[ColumnPriority], CultureInfo.InvariantCulture);
- rec.SchedulerInstanceId = GetString(rs[ColumnInstanceName]);
- rec.TriggerKey = new TriggerKey(GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup]));
+ rec.SchedulerInstanceId = rs.GetString(ColumnInstanceName);
+ rec.TriggerKey = new TriggerKey(rs.GetString(ColumnTriggerName), rs.GetString(ColumnTriggerGroup));
if (!rec.FireInstanceState.Equals(StateAcquired))
{
- rec.JobDisallowsConcurrentExecution = GetBoolean(rs[ColumnIsNonConcurrent]);
- rec.JobRequestsRecovery = GetBoolean(rs[ColumnRequestsRecovery]);
- rec.JobKey = new JobKey(GetString(rs[ColumnJobName]), GetString(rs[ColumnJobGroup]));
+ rec.JobDisallowsConcurrentExecution = rs.GetBoolean(ColumnIsNonConcurrent);
+ rec.JobRequestsRecovery = rs.GetBoolean(ColumnRequestsRecovery);
+ rec.JobKey = new JobKey(rs.GetString(ColumnJobName), rs.GetString(ColumnJobGroup));
}
lst.Add(rec);
}
@@ -2313,17 +2311,17 @@ public virtual IList SelectFiredTriggerRecordsByJob(Connecti
{
FiredTriggerRecord rec = new FiredTriggerRecord();
- rec.FireInstanceId = GetString(rs[ColumnEntryId]);
- rec.FireInstanceState = GetString(rs[ColumnEntryState]);
+ rec.FireInstanceId = rs.GetString(ColumnEntryId);
+ rec.FireInstanceState = rs.GetString(ColumnEntryState);
rec.FireTimestamp = Convert.ToInt64(rs[ColumnFiredTime], CultureInfo.InvariantCulture);
rec.Priority = Convert.ToInt32(rs[ColumnPriority], CultureInfo.InvariantCulture);
- rec.SchedulerInstanceId = GetString(rs[ColumnInstanceName]);
- rec.TriggerKey = new TriggerKey(GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup]));
+ rec.SchedulerInstanceId = rs.GetString(ColumnInstanceName);
+ rec.TriggerKey = new TriggerKey(rs.GetString(ColumnTriggerName), rs.GetString(ColumnTriggerGroup));
if (!rec.FireInstanceState.Equals(StateAcquired))
{
- rec.JobDisallowsConcurrentExecution = GetBoolean(rs[ColumnIsNonConcurrent]);
- rec.JobRequestsRecovery = GetBoolean(rs[ColumnRequestsRecovery]);
- rec.JobKey = new JobKey(GetString(rs[ColumnJobName]), GetString(rs[ColumnJobGroup]));
+ rec.JobDisallowsConcurrentExecution = rs.GetBoolean(ColumnIsNonConcurrent);
+ rec.JobRequestsRecovery = rs.GetBoolean(ColumnRequestsRecovery);
+ rec.JobKey = new JobKey(rs.GetString(ColumnJobName), rs.GetString(ColumnJobGroup));
}
lst.Add(rec);
}
@@ -2352,16 +2350,16 @@ public virtual IList SelectInstancesFiredTriggerRecords(Conn
{
FiredTriggerRecord rec = new FiredTriggerRecord();
- rec.FireInstanceId = GetString(rs[ColumnEntryId]);
- rec.FireInstanceState = GetString(rs[ColumnEntryState]);
+ rec.FireInstanceId = rs.GetString(ColumnEntryId);
+ rec.FireInstanceState = rs.GetString(ColumnEntryState);
rec.FireTimestamp = Convert.ToInt64(rs[ColumnFiredTime], CultureInfo.InvariantCulture);
- rec.SchedulerInstanceId = GetString(rs[ColumnInstanceName]);
- rec.TriggerKey = new TriggerKey(GetString(rs[ColumnTriggerName]), GetString(rs[ColumnTriggerGroup]));
+ rec.SchedulerInstanceId = rs.GetString(ColumnInstanceName);
+ rec.TriggerKey = new TriggerKey(rs.GetString(ColumnTriggerName), rs.GetString(ColumnTriggerGroup));
if (!rec.FireInstanceState.Equals(StateAcquired))
{
- rec.JobDisallowsConcurrentExecution = GetBoolean(rs[ColumnIsNonConcurrent]);
- rec.JobRequestsRecovery = GetBoolean(rs[ColumnRequestsRecovery]);
- rec.JobKey = new JobKey(GetString(rs[ColumnJobName]), GetString(rs[ColumnJobGroup]));
+ rec.JobDisallowsConcurrentExecution = rs.GetBoolean(ColumnIsNonConcurrent);
+ rec.JobRequestsRecovery = rs.GetBoolean(ColumnRequestsRecovery);
+ rec.JobKey = new JobKey(rs.GetString(ColumnJobName), rs.GetString(ColumnJobGroup));
}
lst.Add(rec);
}
@@ -2392,7 +2390,7 @@ public Collection.ISet SelectFiredTriggerInstanceNames(ConnectionAndTran
{
while (rs.Read())
{
- instanceNames.Add((string) rs[ColumnInstanceName]);
+ instanceNames.Add(rs.GetString(ColumnInstanceName));
}
return instanceNames;
@@ -2529,7 +2527,7 @@ public virtual IList SelectSchedulerStateRecords(Connectio
while (rs.Read())
{
SchedulerStateRecord rec = new SchedulerStateRecord();
- rec.SchedulerInstanceId = GetString(rs[ColumnInstanceName]);
+ rec.SchedulerInstanceId = rs.GetString(ColumnInstanceName);
rec.CheckinTimestamp = new DateTimeOffset(Convert.ToInt64(rs[ColumnLastCheckinTime], CultureInfo.InvariantCulture), TimeSpan.Zero);
rec.CheckinInterval = TimeSpan.FromMilliseconds(Convert.ToInt64(rs[ColumnCheckinInterval], CultureInfo.InvariantCulture));
list.Add(rec);
diff --git a/src/Quartz/Impl/AdoJobStore/StdRowLockSemaphore.cs b/src/Quartz/Impl/AdoJobStore/StdRowLockSemaphore.cs
index 800daedb8..25f36b4eb 100644
--- a/src/Quartz/Impl/AdoJobStore/StdRowLockSemaphore.cs
+++ b/src/Quartz/Impl/AdoJobStore/StdRowLockSemaphore.cs
@@ -87,7 +87,7 @@ protected override void ExecuteSQL(ConnectionAndTransactionHolder conn, string l
if (res != 1)
{
- throw new Exception(Util.rtp(
+ throw new Exception(AdoJobStoreUtil.ReplaceTablePrefix(
"No row exists, and one could not be inserted in table " + TablePrefixSubst + TableLocks +
" for lock named: " + lockName, TablePrefix, SchedulerNameLiteral));
}
diff --git a/src/Quartz/Impl/AdoJobStore/TriggerStatus.cs b/src/Quartz/Impl/AdoJobStore/TriggerStatus.cs
index 32c006dae..d008d8f90 100644
--- a/src/Quartz/Impl/AdoJobStore/TriggerStatus.cs
+++ b/src/Quartz/Impl/AdoJobStore/TriggerStatus.cs
@@ -37,14 +37,14 @@ public class TriggerStatus
private readonly string status;
- private readonly DateTimeOffset nextFireTime;
+ private readonly DateTimeOffset? nextFireTime;
///
/// Construct a new TriggerStatus with the status name and nextFireTime.
///
/// The trigger's status
/// The next time trigger will fire
- public TriggerStatus(string status, DateTimeOffset nextFireTime)
+ public TriggerStatus(string status, DateTimeOffset? nextFireTime)
{
this.status = status;
this.nextFireTime = nextFireTime;
@@ -67,7 +67,7 @@ public string Status
get { return status; }
}
- public DateTimeOffset NextFireTimeUtc
+ public DateTimeOffset? NextFireTimeUtc
{
get { return nextFireTime; }
}
diff --git a/src/Quartz/Impl/JobDetailImpl.cs b/src/Quartz/Impl/JobDetailImpl.cs
index 7b8896aa4..47a65e994 100644
--- a/src/Quartz/Impl/JobDetailImpl.cs
+++ b/src/Quartz/Impl/JobDetailImpl.cs
@@ -20,6 +20,8 @@
using System;
using System.Globalization;
+using Quartz.Util;
+
namespace Quartz.Impl
{
///
@@ -293,7 +295,7 @@ public virtual bool Durable
///
public bool PersistJobDataAfterExecution
{
- get { return ClassUtils.isAnnotationPresent(jobType, typeof (PersistJobDataAfterExecution)); }
+ get { return ObjectUtils.IsAttributePresent(jobType, typeof(PersistJobDataAfterExecutionAttribute)); }
}
///
@@ -301,7 +303,7 @@ public bool PersistJobDataAfterExecution
///
public bool ConcurrentExectionDisallowed
{
- get { return ClassUtils.isAnnotationPresent(jobType, typeof (DisallowConcurrentExecution)); }
+ get { return ObjectUtils.IsAttributePresent(jobType, typeof (DisallowConcurrentExecutionAttribute)); }
}
///
@@ -334,8 +336,8 @@ public override string ToString()
return
string.Format(
CultureInfo.InvariantCulture,
- "JobDetail '{0}': jobType: '{1} isStateful: {2} isVolatile: {3} isDurable: {4} requestsRecovers: {5}",
- FullName, ((JobType == null) ? null : JobType.FullName), Stateful, Volatile, Durable, RequestsRecovery);
+ "JobDetail '{0}': jobType: '{1} persistJobDataAfterExecution: {2} concurrentExectionDisallowed: {3} isDurable: {4} requestsRecovers: {5}",
+ FullName, ((JobType == null) ? null : JobType.FullName), PersistJobDataAfterExecution, ConcurrentExectionDisallowed, Durable, RequestsRecovery);
}
///
diff --git a/src/Quartz/Impl/JobExecutionContextImpl.cs b/src/Quartz/Impl/JobExecutionContextImpl.cs
index 5b1a34e65..7c20df19a 100644
--- a/src/Quartz/Impl/JobExecutionContextImpl.cs
+++ b/src/Quartz/Impl/JobExecutionContextImpl.cs
@@ -303,7 +303,7 @@ public override string ToString()
{
return
string.Format(CultureInfo.InvariantCulture, "JobExecutionContext: trigger: '{0}' job: '{1}' fireTimeUtc: '{2:r}' scheduledFireTimeUtc: '{3:r}' previousFireTimeUtc: '{4:r}' nextFireTimeUtc: '{5:r}' recovering: {6} refireCount: {7}",
- Trigger.FullName,
+ Trigger.Key,
JobDetail.Key,
FireTimeUtc,
ScheduledFireTimeUtc,
diff --git a/src/Quartz/Impl/Triggers/AbstractTrigger.cs b/src/Quartz/Impl/Triggers/AbstractTrigger.cs
index 4a372cca9..1911adcdd 100644
--- a/src/Quartz/Impl/Triggers/AbstractTrigger.cs
+++ b/src/Quartz/Impl/Triggers/AbstractTrigger.cs
@@ -44,8 +44,8 @@ namespace Quartz.Impl.Triggers
/// into the on the .
///
///
- ///
- ///
+ ///
+ ///
///
///
///
@@ -54,13 +54,8 @@ namespace Quartz.Impl.Triggers
/// Sharada Jambula
/// Marko Lahma (.NET)
[Serializable]
- public abstract class AbstractTrigger : IOperableTrigger
+ public abstract class AbstractTrigger : IOperableTrigger where T : ITrigger
{
- ///
- /// The default value for priority.
- ///
- public const int DefaultPriority = 5;
-
private string name;
private string group = SchedulerConstants.DefaultGroup;
private string jobName;
@@ -232,7 +227,7 @@ public virtual string FullJobName
get { return jobGroup + "." + jobName; }
}
- public abstract ScheduleBuilder GetScheduleBuilder();
+ public abstract IScheduleBuilder GetScheduleBuilder();
///
/// Get or set the description given to the instance by
@@ -327,8 +322,8 @@ public virtual string FireInstanceId
set { fireInstanceId = value; }
}
- public abstract void SetNextFireTimeUtc(DateTimeOffset nextFireTime);
- public abstract void SetPreviousFireTimeUtc(DateTimeOffset previousFireTime);
+ public abstract DateTimeOffset? NextFireTimeUtc { set; }
+ public abstract DateTimeOffset? PreviousFireTimeUtc { set; }
///
/// Gets and sets the date/time on which the trigger must stop firing. This
@@ -741,10 +736,10 @@ public virtual int CompareTo(ITrigger other)
///
public override bool Equals(object obj)
{
- return Equals(obj as AbstractTrigger);
+ return Equals(obj as AbstractTrigger);
}
- public virtual bool Equals(AbstractTrigger trigger)
+ public virtual bool Equals(AbstractTrigger trigger)
{
if (trigger == null)
{
@@ -773,10 +768,10 @@ public override int GetHashCode()
///
public virtual object Clone()
{
- AbstractTrigger copy;
+ AbstractTrigger copy;
try
{
- copy = (AbstractTrigger) MemberwiseClone();
+ copy = (AbstractTrigger)MemberwiseClone();
// Shallow copy the jobDataMap. Note that this means that if a user
// modifies a value object in this map from the cloned Trigger
@@ -794,9 +789,9 @@ public virtual object Clone()
}
- public TriggerBuilder GetTriggerBuilder()
+ public ITriggerBuilder GetTriggerBuilder()
{
- TriggerBuilder b = TriggerBuilder.NewTrigger()
+ TriggerBuilder b = TriggerBuilder.NewTrigger()
.ForJob(JobKey)
.ModifiedByCalendar(CalendarName)
.UsingJobData(JobDataMap)
@@ -809,7 +804,6 @@ public TriggerBuilder GetTriggerBuilder()
return b;
}
}
-
}
diff --git a/src/Quartz/Impl/Triggers/CalendarIntervalTriggerImpl.cs b/src/Quartz/Impl/Triggers/CalendarIntervalTriggerImpl.cs
index be6043479..105e937c1 100644
--- a/src/Quartz/Impl/Triggers/CalendarIntervalTriggerImpl.cs
+++ b/src/Quartz/Impl/Triggers/CalendarIntervalTriggerImpl.cs
@@ -29,7 +29,7 @@ namespace Quartz.Impl.Triggers
/// The trigger will fire every N (see ) units of calendar time
/// (see ) as specified in the trigger's definition.
/// This trigger can achieve schedules that are not possible with (e.g
- /// because months are not a fixed number of seconds) or (e.g. because
+ /// because months are not a fixed number of seconds) or (e.g. because
/// "every 5 months" is not an even divisor of 12).
///
/// If you use an interval unit of then care should be taken when setting
@@ -39,18 +39,18 @@ namespace Quartz.Impl.Triggers
/// and the next time after that will be March 28th - and essentially each subsequent firing will
/// occur on the 28th of the month, even if a 31st day exists. If you want a trigger that always
/// fires on the last day of the month - regardless of the number of days in the month,
- /// you should use .
+ /// you should use .
///
///
///
- ///
+ ///
///
///
///
/// 1.2
/// James House
/// Marko Lahma (.NET)
- public class CalendarIntervalTriggerImpl : AbstractTrigger, ICalendarIntervalTrigger
+ public class CalendarIntervalTriggerImpl : AbstractTrigger, ICalendarIntervalTrigger
{
private const int YearToGiveupSchedulingAt = 2299;
@@ -522,7 +522,7 @@ public override SchedulerInstruction ExecutionComplete(IJobExecutionContext cont
*
*/
- public DateTimeOffset? NextFireTimeUtc
+ public override DateTimeOffset? NextFireTimeUtc
{
set { this.nextFireTime = value; }
}
@@ -537,7 +537,7 @@ public DateTimeOffset? NextFireTimeUtc
*
*/
- public DateTimeOffset PreviousFireTimeUtc
+ public override DateTimeOffset? PreviousFireTimeUtc
{
set { this.previousFireTime = value; }
}
@@ -816,7 +816,7 @@ public override void Validate()
*
* @see #getTriggerBuilder()
*/
- public ScheduleBuilder GetScheduleBuilder()
+ public override ScheduleBuilder GetScheduleBuilder()
{
CalendarIntervalScheduleBuilder cb = CalendarIntervalScheduleBuilder.CalendarIntervalSchedule()
@@ -824,10 +824,10 @@ public ScheduleBuilder GetScheduleBuilder()
switch (MisfireInstruction)
{
- case MISFIRE_INSTRUCTION_DO_NOTHING:
+ case Quartz.MisfireInstruction.CalendarIntervalTrigger.DoNothing:
cb.withMisfireHandlingInstructionDoNothing();
break;
- case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW:
+ case Quartz.MisfireInstruction.CalendarIntervalTrigger.FireOnceNow:
cb.withMisfireHandlingInstructionFireAndProceed();
break;
}
diff --git a/src/Quartz/Impl/Triggers/CronTriggerImpl.cs b/src/Quartz/Impl/Triggers/CronTriggerImpl.cs
index 55b3a99ad..37a7d4373 100644
--- a/src/Quartz/Impl/Triggers/CronTriggerImpl.cs
+++ b/src/Quartz/Impl/Triggers/CronTriggerImpl.cs
@@ -173,7 +173,7 @@ namespace Quartz.Impl.Triggers
/// Contributions from Mads Henderson
/// Marko Lahma (.NET)
[Serializable]
- public class CronTriggerImpl : AbstractTrigger, ICronTrigger
+ public class CronTriggerImpl : AbstractTrigger, ICronTrigger
{
protected internal const int YearToGiveupSchedulingAt = 2299;
private CronExpression cronEx;
diff --git a/src/Quartz/Impl/Triggers/SimpleTriggerImpl.cs b/src/Quartz/Impl/Triggers/SimpleTriggerImpl.cs
index 8bb14b9d6..f574c5dba 100644
--- a/src/Quartz/Impl/Triggers/SimpleTriggerImpl.cs
+++ b/src/Quartz/Impl/Triggers/SimpleTriggerImpl.cs
@@ -33,7 +33,7 @@ namespace Quartz.Impl.Triggers
/// Contributions by Lieven Govaerts of Ebitec Nv, Belgium.
/// Marko Lahma (.NET)
[Serializable]
- public class SimpleTriggerImpl : AbstractTrigger, ISimpleTrigger
+ public class SimpleTriggerImpl : AbstractTrigger, ISimpleTrigger
{
///
/// Used to indicate the 'repeat count' of the trigger is indefinite. Or in
diff --git a/src/Quartz/JobBuilder.cs b/src/Quartz/JobBuilder.cs
index 91d3a93e9..d26df4632 100644
--- a/src/Quartz/JobBuilder.cs
+++ b/src/Quartz/JobBuilder.cs
@@ -195,7 +195,18 @@ public JobBuilder WithDescription(string description)
///
public JobBuilder OfType()
{
- jobType = typeof(T);
+ return OfType(typeof(T));
+ }
+
+ ///
+ /// Set the class which will be instantiated and executed when a
+ /// Trigger fires that is associated with this JobDetail.
+ ///
+ /// the updated JobBuilder
+ ///
+ public JobBuilder OfType(Type type)
+ {
+ jobType = type;
return this;
}
diff --git a/src/Quartz/Plugin/Xml/JobInitializationPlugin.cs b/src/Quartz/Plugin/Xml/JobInitializationPlugin.cs
deleted file mode 100644
index 93412d92b..000000000
--- a/src/Quartz/Plugin/Xml/JobInitializationPlugin.cs
+++ /dev/null
@@ -1,469 +0,0 @@
-#region License
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Net;
-using System.Web;
-
-using Common.Logging;
-
-using Quartz.Job;
-using Quartz.Simpl;
-using Quartz.Spi;
-using Quartz.Util;
-using Quartz.Xml;
-
-namespace Quartz.Plugin.Xml
-{
- ///
- /// This plugin loads XML file(s) to add jobs and schedule them with triggers
- /// as the scheduler is initialized, and can optionally periodically scan the
- /// file for changes.
- ///
- ///
- /// The periodically scanning of files for changes is not currently supported in a
- /// clustered environment.
- ///
- /// James House
- /// Pierre Awaragi
- public class JobInitializationPlugin : ISchedulerPlugin, IFileScanListener
- {
- private readonly ILog log;
- private const int MaxJobTriggerNameLength = 80;
- private const string JobInitializationPluginName = "JobInitializationPlugin";
- private const char FileNameDelimiter = ',';
-
- private bool overwriteExistingJobs;
- private bool failOnFileNotFound = true;
- private string fileNames = JobSchedulingDataProcessor.QuartzXmlFileName;
-
- // Populated by initialization
- private readonly List> jobFiles = new List>();
-
- private bool validating;
- private bool validatingSchema = true;
- private TimeSpan scanInterval = TimeSpan.Zero;
-
- private bool started;
-
- private ITypeLoadHelper typeLoadHelper;
-
- private readonly Collection.HashSet jobTriggerNameSet = new Collection.HashSet();
- private IScheduler scheduler;
- private string name;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public JobInitializationPlugin()
- {
- log = LogManager.GetLogger(typeof (JobInitializationPlugin));
- fileNames = JobSchedulingDataProcessor.QuartzXmlFileName;
- }
-
-
- ///
- /// Gets the log.
- ///
- /// The log.
- protected ILog Log
- {
- get { return log; }
- }
-
-
- public string Name
- {
- get { return name; }
- }
-
- public IScheduler Scheduler
- {
- get { return scheduler; }
- }
-
- protected ITypeLoadHelper TypeLoadHelper
- {
- get { return typeLoadHelper; }
- }
-
- ///
- /// Comma separated list of file names (with paths) to the XML files that should be read.
- ///
- public virtual string FileNames
- {
- get { return fileNames; }
- set { fileNames = value; }
- }
-
- ///
- /// Whether or not jobs defined in the XML file should be overwrite existing
- /// jobs with the same name.
- ///
- public virtual bool OverwriteExistingJobs
- {
- get { return overwriteExistingJobs; }
- set { overwriteExistingJobs = value; }
- }
-
- ///
- /// The interval at which to scan for changes to the file.
- /// If the file has been changed, it is re-loaded and parsed. The default
- /// value for the interval is 0, which disables scanning.
- ///
- [TimeSpanParseRule(TimeSpanParseRule.Seconds)]
- public virtual TimeSpan ScanInterval
- {
- get { return scanInterval; }
- set { scanInterval = value; }
- }
-
- ///
- /// Whether or not initialization of the plugin should fail (throw an
- /// exception) if the file cannot be found. Default is .
- ///
- public virtual bool FailOnFileNotFound
- {
- get { return failOnFileNotFound; }
- set { failOnFileNotFound = value; }
- }
-
- ///
- /// Whether or not the XML should be validated. Default is .
- ///
- public virtual bool Validating
- {
- get { return validating; }
- set { validating = value; }
- }
-
- ///
- /// Whether or not the XML schema should be validated. Default is .
- ///
- public virtual bool ValidatingSchema
- {
- get { return validatingSchema; }
- set { validatingSchema = value; }
- }
-
- ///
- ///
- ///
- ///
- public virtual void FileUpdated(string fName)
- {
- if (started)
- {
- ProcessFile(fName);
- }
- }
-
- ///
- /// Called during creation of the in order to give
- /// the a chance to initialize.
- ///
- /// The name.
- /// The scheduler.
- /// SchedulerConfigException
- public virtual void Initialize(string pluginName, IScheduler sched)
- {
- name = pluginName;
- scheduler = sched;
- typeLoadHelper = new SimpleTypeLoadHelper();
- typeLoadHelper.Initialize();
-
- Log.Info("Registering Quartz Job Initialization Plug-in.");
-
- // Create JobFile objects
- string[] tokens = fileNames.Split(FileNameDelimiter);
-
- foreach (string token in tokens)
- {
- JobFile jobFile = new JobFile(this, token);
- jobFiles.Add(new KeyValuePair(jobFile.FilePath, jobFile));
- }
- }
-
- ///
- /// Called when the associated is started, in order
- /// to let the plug-in know it can now make calls into the scheduler if it
- /// needs to.
- ///
- public virtual void Start()
- {
- try
- {
- if (jobFiles.Count > 0)
- {
- if (scanInterval > TimeSpan.Zero)
- {
- scheduler.Context.Put(JobInitializationPluginName + '_' + Name, this);
- }
-
- foreach (KeyValuePair pair in jobFiles)
- {
- JobFile jobFile = pair.Value;
-
- if (scanInterval > TimeSpan.Zero)
- {
- string jobTriggerName = BuildJobTriggerName(jobFile.FileBasename);
-
- SimpleTrigger trig = new SimpleTrigger(
- jobTriggerName,
- JobInitializationPluginName,
- SystemTime.UtcNow(), null,
- SimpleTrigger.RepeatIndefinitely, scanInterval);
- trig.Volatile = true;
-
- JobDetailImpl job = new JobDetailImpl(
- jobTriggerName,
- JobInitializationPluginName,
- typeof(FileScanJob));
-
- job.Volatile = true;
- job.JobDataMap.Put(FileScanJob.FileName, jobFile.FilePath);
- job.JobDataMap.Put(FileScanJob.FileScanListenerName, JobInitializationPluginName + '_' + Name);
-
- scheduler.ScheduleJob(job, trig);
- }
-
- ProcessFile(jobFile);
- }
- }
- }
- catch (SchedulerException se)
- {
- Log.Error("Error starting background-task for watching jobs file.", se);
- }
- finally
- {
- started = true;
- }
- }
-
- ///
- /// Helper method for generating unique job/trigger name for the
- /// file scanning jobs (one per FileJob). The unique names are saved
- /// in jobTriggerNameSet.
- ///
- ///
- ///
- private string BuildJobTriggerName(string fileBasename)
- {
- // Name w/o collisions will be prefix + _ + filename (with '.' of filename replaced with '_')
- // For example: JobInitializationPlugin_jobInitializer_myjobs_xml
- string jobTriggerName = JobInitializationPluginName + '_' + Name + '_' + fileBasename.Replace('.', '_');
-
- // If name is too long (DB column is 80 chars), then truncate to max length
- if (jobTriggerName.Length > MaxJobTriggerNameLength)
- {
- jobTriggerName = jobTriggerName.Substring(0, MaxJobTriggerNameLength);
- }
-
- // Make sure this name is unique in case the same file name under different
- // directories is being checked, or had a naming collision due to length truncation.
- // If there is a conflict, keep incrementing a _# suffix on the name (being sure
- // not to get too long), until we find a unique name.
- int currentIndex = 1;
- while (jobTriggerNameSet.Add(jobTriggerName) == false)
- {
- // If not our first time through, then strip off old numeric suffix
- if (currentIndex > 1)
- {
- jobTriggerName = jobTriggerName.Substring(0, jobTriggerName.LastIndexOf('_'));
- }
-
- string numericSuffix = "_" + currentIndex++;
-
- // If the numeric suffix would make the name too long, then make room for it.
- if (jobTriggerName.Length > (MaxJobTriggerNameLength - numericSuffix.Length))
- {
- jobTriggerName = jobTriggerName.Substring(0, (MaxJobTriggerNameLength - numericSuffix.Length));
- }
-
- jobTriggerName += numericSuffix;
- }
-
- return jobTriggerName;
- }
-
- ///
- /// Called in order to inform the that it
- /// should free up all of it's resources because the scheduler is shutting
- /// down.
- ///
- public virtual void Shutdown()
- {
- // nothing to do
- }
-
- private void ProcessFile(JobFile jobFile)
- {
- if ((jobFile == null) || (jobFile.FileFound == false))
- {
- return;
- }
-
- JobSchedulingDataProcessor processor = new JobSchedulingDataProcessor(Validating, ValidatingSchema);
-
- try
- {
- processor.ProcessFileAndScheduleJobs(
- jobFile.FilePath,
- jobFile.FilePath, // systemId
- scheduler,
- OverwriteExistingJobs);
- }
- catch (Exception e)
- {
- Log.Error("Error scheduling jobs: " + e.Message, e);
- }
- }
-
- public void ProcessFile(string filePath)
- {
- JobFile file = null;
- int idx = jobFiles.FindIndex(pair => pair.Key == filePath);
- if (idx >= 0)
- {
- file = jobFiles[idx].Value;
- }
- ProcessFile(file);
- }
-
- internal class JobFile
- {
- private readonly string fileName;
-
- // These are set by initialize()
- private string filePath;
- private string fileBasename;
- private bool fileFound;
- private readonly JobInitializationPlugin plugin;
-
- public JobFile(JobInitializationPlugin plugin, string fileName)
- {
- this.plugin = plugin;
- this.fileName = fileName;
- Initialize();
- }
-
- public string FileName
- {
- get { return fileName; }
- }
-
- public bool FileFound
- {
- get { return fileFound; }
- }
-
- public string FilePath
- {
- get { return filePath; }
- }
-
- public string FileBasename
- {
- get { return fileBasename; }
- }
-
- public void Initialize()
- {
- Stream f = null;
- try
- {
- string furl = null;
-
- string fName = FileName;
-
- // check for special lookup
- fName = FileUtil.ResolveFile(fName);
-
- FileInfo file = new FileInfo(fName); // files in filesystem
- if (!file.Exists)
- {
- Uri url = plugin.typeLoadHelper.GetResource(FileName);
- if (url != null)
- {
- furl = HttpUtility.UrlDecode(url.AbsolutePath);
- file = new FileInfo(furl);
- try
- {
- f = WebRequest.Create(url).GetResponse().GetResponseStream();
- }
- catch (IOException)
- {
- // Swallow the exception
- }
- }
- }
- else
- {
- try
- {
- f = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
- }
- catch (FileNotFoundException)
- {
- // ignore
- }
- }
-
- if (f == null)
- {
- if (plugin.FailOnFileNotFound)
- {
- throw new SchedulerException(
- "File named '" + FileName + "' does not exist.");
- }
- else
- {
- plugin.Log.Warn(string.Format(CultureInfo.InvariantCulture, "File named '{0}' does not exist.", FileName));
- }
- }
- else
- {
- fileFound = true;
- filePath = furl ?? file.FullName;
- fileBasename = file.Name;
- }
- }
- finally
- {
- try
- {
- if (f != null)
- {
- f.Close();
- }
- }
- catch (IOException ioe)
- {
- plugin.Log.Warn("Error closing jobs file " + FileName, ioe);
- }
- }
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/Quartz/Plugin/Xml/XMLSchedulingDataProcessorPlugin.cs b/src/Quartz/Plugin/Xml/XMLSchedulingDataProcessorPlugin.cs
index 18f18b1d9..f5652d1c9 100644
--- a/src/Quartz/Plugin/Xml/XMLSchedulingDataProcessorPlugin.cs
+++ b/src/Quartz/Plugin/Xml/XMLSchedulingDataProcessorPlugin.cs
@@ -76,10 +76,8 @@ public class XMLSchedulingDataProcessorPlugin : ISchedulerPlugin, IFileScanListe
public XMLSchedulingDataProcessorPlugin()
{
log = LogManager.GetLogger(typeof (JobInitializationPlugin));
- fileNames = JobSchedulingDataProcessor.QuartzXmlFileName;
}
-
///
/// Gets the log.
///
@@ -198,7 +196,7 @@ public virtual void Start()
{
string jobTriggerName = BuildJobTriggerName(jobFile.FileBasename);
- TriggerKey tKey = new TriggerKey(jobTriggerName, JOB_INITIALIZATION_PLUGIN_NAME);
+ TriggerKey tKey = new TriggerKey(jobTriggerName, JobInitializationPluginName);
// remove pre-existing job/trigger, if any
Scheduler.UnscheduleJob(tKey);
@@ -206,12 +204,12 @@ public virtual void Start()
// TODO: convert to use builder
SimpleTriggerImpl trig = (SimpleTriggerImpl) Scheduler.GetTrigger(tKey);
trig = new SimpleTriggerImpl();
- trig.setName(jobTriggerName);
- trig.setGroup(JOB_INITIALIZATION_PLUGIN_NAME);
- trig.setStartTime(new Date());
- trig.setEndTime(null);
- trig.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
- trig.setRepeatInterval(scanInterval);
+ trig.Name = (jobTriggerName);
+ trig.Group = (JobInitializationPluginName);
+ trig.StartTimeUtc = (DateTimeOffset.UtcNow);
+ trig.EndTimeUtc = (null);
+ trig.RepeatCount = (SimpleTriggerImpl.RepeatIndefinitely);
+ trig.RepeatInterval = (scanInterval);
// TODO: convert to use builder
JobDetailImpl job = new JobDetailImpl(
diff --git a/src/Quartz/Quartz.2010.csproj b/src/Quartz/Quartz.2010.csproj
index 3148cf67e..b209f2ec0 100644
--- a/src/Quartz/Quartz.2010.csproj
+++ b/src/Quartz/Quartz.2010.csproj
@@ -134,6 +134,7 @@
+
@@ -361,6 +362,7 @@
Code
+
Code
@@ -427,7 +429,6 @@
-
@@ -439,12 +440,6 @@
-
-
-
-
- job_scheduling_data_1_0.xsd
-
job_scheduling_data_2_0.xsd
@@ -457,9 +452,6 @@
-
- Designer
-
Designer
diff --git a/src/Quartz/ScheduleBuilder.cs b/src/Quartz/ScheduleBuilder.cs
index 79c0ed408..1eb5a8578 100644
--- a/src/Quartz/ScheduleBuilder.cs
+++ b/src/Quartz/ScheduleBuilder.cs
@@ -21,7 +21,7 @@
namespace Quartz
{
- public abstract class ScheduleBuilder
+ public abstract class ScheduleBuilder : IScheduleBuilder where T : ITrigger
{
public abstract IMutableTrigger Build();
}
diff --git a/src/Quartz/SimpleScheduleBuilder.cs b/src/Quartz/SimpleScheduleBuilder.cs
index 293f5b7ef..dd3db0d52 100644
--- a/src/Quartz/SimpleScheduleBuilder.cs
+++ b/src/Quartz/SimpleScheduleBuilder.cs
@@ -62,9 +62,9 @@ namespace Quartz
* @see TriggerBuilder
*/
- public class SimpleScheduleBuilder : ScheduleBuilder
+ public class SimpleScheduleBuilder : ScheduleBuilder
{
- private long interval = 0;
+ private TimeSpan interval = TimeSpan.Zero;
private int repeatCount = 0;
private int misfireInstruction = MisfireInstruction.SmartPolicy;
@@ -79,88 +79,271 @@ private SimpleScheduleBuilder()
* @return the new SimpleScheduleBuilder
*/
- public static SimpleScheduleBuilder simpleSchedule()
+ public static SimpleScheduleBuilder SimpleSchedule()
{
return new SimpleScheduleBuilder();
}
/**
- * Build the actual Trigger -- NOT intended to be invoked by end users,
- * but will rather be invoked by a TriggerBuilder which this
- * ScheduleBuilder is given to.
+ * Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.
*
- * @see TriggerBuilder#withSchedule(ScheduleBuilder)
+ * @return the new SimpleScheduleBuilder
*/
- public override IMutableTrigger Build()
+ public static SimpleScheduleBuilder RepeatMinutelyForever()
{
- SimpleTriggerImpl st = new SimpleTriggerImpl();
- st.setRepeatInterval(interval);
- st.setRepeatCount(repeatCount);
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromMinutes(1))
+ .RepeatForever();
- return st;
+ return sb;
}
/**
- * Specify a repeat interval in milliseconds.
- *
- * @param intervalInMillis the number of seconds at which the trigger should repeat.
- * @return the updated SimpleScheduleBuilder
- * @see SimpleTrigger#getRepeatInterval()
- * @see #withRepeatCount(int)
- */
+ * Create a SimpleScheduleBuilder set to repeat forever with an interval
+ * of the given number of minutes.
+ *
+ * @return the new SimpleScheduleBuilder
+ */
- public SimpleScheduleBuilder withIntervalInMilliseconds(long intervalInMillis)
+ public static SimpleScheduleBuilder RepeatMinutelyForever(int minutes)
{
- this.interval = intervalInMillis;
- return this;
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromMinutes(minutes))
+ .RepeatForever();
+
+ return sb;
}
/**
- * Specify a repeat interval in seconds - which will then be multiplied
- * by 1000 to produce milliseconds.
- *
- * @param intervalInSeconds the number of seconds at which the trigger should repeat.
- * @return the updated SimpleScheduleBuilder
- * @see SimpleTrigger#getRepeatInterval()
- * @see #withRepeatCount(int)
- */
+ * Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.
+ *
+ * @return the new SimpleScheduleBuilder
+ */
- public SimpleScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
+ public static SimpleScheduleBuilder RepeatSecondlyForever()
{
- this.interval = intervalInSeconds*1000L;
- return this;
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromSeconds(1))
+ .RepeatForever();
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat forever with an interval
+ * of the given number of seconds.
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatSecondlyForever(int seconds)
+ {
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromSeconds(seconds))
+ .RepeatForever();
+
+ return sb;
}
/**
- * Specify a repeat interval in minutes - which will then be multiplied
- * by 60 * 1000 to produce milliseconds.
+ * Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatHourlyForever()
+ {
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromHours(1))
+ .RepeatForever();
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat forever with an interval
+ * of the given number of hours.
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatHourlyForever(int hours)
+ {
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromHours(hours))
+ .RepeatForever();
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with a 1 minute interval.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromMinutes(1))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with an interval of the given number of minutes.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count, int minutes)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromMinutes(minutes))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with a 1 second interval.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromSeconds(1))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with an interval of the given number of seconds.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count, int seconds)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromSeconds(seconds))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with a 1 hour interval.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromHours(1))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Create a SimpleScheduleBuilder set to repeat the given number
+ * of times - 1 with an interval of the given number of hours.
+ *
+ * Note: Total count = 1 (at start time) + repeat count
+ *
+ * @return the new SimpleScheduleBuilder
+ */
+
+ public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count, int hours)
+ {
+ if (count < 1)
+ {
+ throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
+ }
+
+ SimpleScheduleBuilder sb = SimpleSchedule()
+ .WithInterval(TimeSpan.FromHours(hours))
+ .WithRepeatCount(count - 1);
+
+ return sb;
+ }
+
+ /**
+ * Build the actual Trigger -- NOT intended to be invoked by end users,
+ * but will rather be invoked by a TriggerBuilder which this
+ * ScheduleBuilder is given to.
*
- * @param intervalInMinutes the number of seconds at which the trigger should repeat.
- * @return the updated SimpleScheduleBuilder
- * @see SimpleTrigger#getRepeatInterval()
- * @see #withRepeatCount(int)
+ * @see TriggerBuilder#withSchedule(ScheduleBuilder)
*/
- public SimpleScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
+ public override IMutableTrigger Build()
{
- this.interval = intervalInMinutes*DateBuilder.MILLISECONDS_IN_MINUTE;
- return this;
+ SimpleTriggerImpl st = new SimpleTriggerImpl();
+ st.RepeatInterval = (interval);
+ st.RepeatCount = (repeatCount);
+
+ return st;
}
/**
- * Specify a repeat interval in minutes - which will then be multiplied
- * by 60 * 60 * 1000 to produce milliseconds.
+ * Specify a repeat interval in milliseconds.
*
- * @param intervalInHours the number of seconds at which the trigger should repeat.
+ * @param intervalInMillis the number of seconds at which the trigger should repeat.
* @return the updated SimpleScheduleBuilder
* @see SimpleTrigger#getRepeatInterval()
* @see #withRepeatCount(int)
*/
- public SimpleScheduleBuilder withIntervalInHours(int intervalInHours)
+ public SimpleScheduleBuilder WithInterval(TimeSpan timeSpan)
{
- this.interval = intervalInHours*DateBuilder.MILLISECONDS_IN_HOUR;
+ this.interval = timeSpan;
return this;
}
@@ -171,13 +354,10 @@ public SimpleScheduleBuilder withIntervalInHours(int intervalInHours)
* @param repeatCount the number of seconds at which the trigger should repeat.
* @return the updated SimpleScheduleBuilder
* @see SimpleTrigger#getRepeatCount()
- * @see #withIntervalInMilliseconds(long)
- * @see #withIntervalInSeconds(int)
- * @see #withIntervalInMinutes(int)
- * @see #withIntervalInHours(int)
+ * @see #repeatForever(int)
*/
- public SimpleScheduleBuilder withRepeatCount(int repeatCount)
+ public SimpleScheduleBuilder WithRepeatCount(int repeatCount)
{
this.repeatCount = repeatCount;
return this;
@@ -195,7 +375,7 @@ public SimpleScheduleBuilder withRepeatCount(int repeatCount)
* @see #withIntervalInHours(int)
*/
- public SimpleScheduleBuilder repeatForever()
+ public SimpleScheduleBuilder RepeatForever()
{
this.repeatCount = SimpleTriggerImpl.RepeatIndefinitely;
return this;
@@ -209,7 +389,8 @@ public SimpleScheduleBuilder repeatForever()
* @return the updated CronScheduleBuilder
* @see Trigger#MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
+
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionIgnoreMisfires()
{
misfireInstruction = MisfireInstruction.IgnoreMisfirePolicy;
return this;
@@ -223,7 +404,7 @@ public SimpleScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
* @see SimpleTrigger#MISFIRE_INSTRUCTION_FIRE_NOW
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionFireNow()
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionFireNow()
{
misfireInstruction = MisfireInstruction.SimpleTrigger.FireNow;
return this;
@@ -237,7 +418,7 @@ public SimpleScheduleBuilder withMisfireHandlingInstructionFireNow()
* @see SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithExistingCount()
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionNextWithExistingCount()
{
misfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNextWithExistingCount;
return this;
@@ -251,7 +432,7 @@ public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithExistingCount
* @see SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithRemainingCount()
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionNextWithRemainingCount()
{
misfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNextWithRemainingCount;
return this;
@@ -265,7 +446,7 @@ public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithRemainingCoun
* @see SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionNowWithExistingCount()
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionNowWithExistingCount()
{
misfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNowWithExistingRepeatCount;
return this;
@@ -279,13 +460,13 @@ public SimpleScheduleBuilder withMisfireHandlingInstructionNowWithExistingCount(
* @see SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
*/
- public SimpleScheduleBuilder withMisfireHandlingInstructionNowWithRemainingCount()
+ public SimpleScheduleBuilder WithMisfireHandlingInstructionNowWithRemainingCount()
{
misfireInstruction = MisfireInstruction.SimpleTrigger.RescheduleNowWithRemainingRepeatCount;
return this;
}
- internal SimpleScheduleBuilder withMisfireHandlingInstruction(int readMisfireInstructionFromString)
+ internal SimpleScheduleBuilder WithMisfireHandlingInstruction(int readMisfireInstructionFromString)
{
misfireInstruction = readMisfireInstructionFromString;
return this;
diff --git a/src/Quartz/TriggerBuilder.cs b/src/Quartz/TriggerBuilder.cs
index b3c26b36c..b15c49e38 100644
--- a/src/Quartz/TriggerBuilder.cs
+++ b/src/Quartz/TriggerBuilder.cs
@@ -58,18 +58,44 @@ namespace Quartz
* @see Trigger
*/
- public class TriggerBuilder
+ public interface ITriggerBuilder
+ {
+ T Build();
+ TriggerBuilder WithIdentity(string name);
+ TriggerBuilder WithIdentity(string name, string group);
+ TriggerBuilder WithIdentity(TriggerKey key);
+ TriggerBuilder WithDescription(string description);
+ TriggerBuilder WithPriority(int priority);
+ TriggerBuilder ModifiedByCalendar(string calendarName);
+ TriggerBuilder StartAt(DateTimeOffset startTimeUtc);
+ TriggerBuilder StartNow();
+ TriggerBuilder EndAt(DateTimeOffset? endTimeUtc);
+ TriggerBuilder WithSchedule(IScheduleBuilder scheduleBuilder);
+ TriggerBuilder ForJob(JobKey jobKey);
+ TriggerBuilder ForJob(string jobName);
+ TriggerBuilder ForJob(string jobName, string jobGroup);
+ TriggerBuilder ForJob(IJobDetail jobDetail);
+ TriggerBuilder UsingJobData(string key, string value);
+ TriggerBuilder UsingJobData(string key, int value);
+ TriggerBuilder UsingJobData(string key, long value);
+ TriggerBuilder UsingJobData(string key, float value);
+ TriggerBuilder UsingJobData(string key, Double value);
+ TriggerBuilder UsingJobData(string key, Boolean value);
+ TriggerBuilder UsingJobData(JobDataMap newJobDataMap);
+ }
+
+ public class TriggerBuilder : ITriggerBuilder where T : ITrigger
{
private TriggerKey key;
private string description;
private DateTimeOffset startTime = DateTimeOffset.UtcNow;
private DateTimeOffset? endTime;
- private int priority = AbstractTrigger.DefaultPriority;
+ private int priority = TriggerConstants.DefaultPriority;
private string calendarName;
private JobKey jobKey;
private JobDataMap jobDataMap = new JobDataMap();
- private ScheduleBuilder scheduleBuilder;
+ private IScheduleBuilder scheduleBuilder;
private TriggerBuilder()
{
@@ -82,9 +108,9 @@ private TriggerBuilder()
* @return the new TriggerBuilder
*/
- public static TriggerBuilder NewTrigger()
+ public static TriggerBuilder NewTrigger()
{
- return new TriggerBuilder();
+ return new TriggerBuilder();
}
/**
@@ -93,11 +119,11 @@ public static TriggerBuilder NewTrigger()
* @return a Trigger that meets the specifications of the builder.
*/
- public ITrigger Build()
+ public T Build()
{
if (scheduleBuilder == null)
{
- scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
+ scheduleBuilder = SimpleScheduleBuilder.SimpleSchedule();
}
IMutableTrigger trig = scheduleBuilder.Build();
@@ -121,7 +147,7 @@ public ITrigger Build()
trig.JobDataMap = jobDataMap;
}
- return trig;
+ return (T) trig;
}
/**
@@ -137,7 +163,7 @@ public ITrigger Build()
* @see Trigger#getKey()
*/
- public TriggerBuilder WithIdentity(string name)
+ public TriggerBuilder WithIdentity(string name)
{
key = new TriggerKey(name, null);
return this;
@@ -157,7 +183,7 @@ public TriggerBuilder WithIdentity(string name)
* @see Trigger#getKey()
*/
- public TriggerBuilder WithIdentity(string name, string group)
+ public TriggerBuilder WithIdentity(string name, string group)
{
key = new TriggerKey(name, group);
return this;
@@ -175,7 +201,7 @@ public TriggerBuilder WithIdentity(string name, string group)
* @see Trigger#getKey()
*/
- public TriggerBuilder WithIdentity(TriggerKey key)
+ public TriggerBuilder WithIdentity(TriggerKey key)
{
this.key = key;
return this;
@@ -189,7 +215,7 @@ public TriggerBuilder WithIdentity(TriggerKey key)
* @see Trigger#getDescription()
*/
- public TriggerBuilder WithDescription(string description)
+ public TriggerBuilder WithDescription(string description)
{
this.description = description;
return this;
@@ -206,7 +232,7 @@ public TriggerBuilder WithDescription(string description)
* @see Trigger#getPriority()
*/
- public TriggerBuilder WithPriority(int priority)
+ public TriggerBuilder WithPriority(int priority)
{
this.priority = priority;
return this;
@@ -222,7 +248,7 @@ public TriggerBuilder WithPriority(int priority)
* @see Trigger#getCalendarName()
*/
- public TriggerBuilder ModifiedByCalendar(string calendarName)
+ public TriggerBuilder ModifiedByCalendar(string calendarName)
{
this.calendarName = calendarName;
return this;
@@ -240,7 +266,7 @@ public TriggerBuilder ModifiedByCalendar(string calendarName)
* @see DateBuilder
*/
- public TriggerBuilder StartAt(DateTimeOffset startTimeUtc)
+ public TriggerBuilder StartAt(DateTimeOffset startTimeUtc)
{
this.startTime = startTimeUtc;
return this;
@@ -255,7 +281,7 @@ public TriggerBuilder StartAt(DateTimeOffset startTimeUtc)
* @see Trigger#getStartTime()
*/
- public TriggerBuilder StartNow()
+ public TriggerBuilder StartNow()
{
this.startTime = DateTimeOffset.UtcNow;
return this;
@@ -271,7 +297,7 @@ public TriggerBuilder StartNow()
* @see DateBuilder
*/
- public TriggerBuilder EndAt(DateTimeOffset? endTimeUtc)
+ public TriggerBuilder EndAt(DateTimeOffset? endTimeUtc)
{
this.endTime = endTimeUtc;
return this;
@@ -292,7 +318,7 @@ public TriggerBuilder EndAt(DateTimeOffset? endTimeUtc)
* @see CalendarIntervalScheduleBuilder
*/
- public TriggerBuilder WithSchedule(ScheduleBuilder scheduleBuilder)
+ public TriggerBuilder WithSchedule(IScheduleBuilder scheduleBuilder)
{
this.scheduleBuilder = scheduleBuilder;
return this;
@@ -307,7 +333,7 @@ public TriggerBuilder WithSchedule(ScheduleBuilder scheduleBuilder)
* @see Trigger#getJobKey()
*/
- public TriggerBuilder ForJob(JobKey jobKey)
+ public TriggerBuilder ForJob(JobKey jobKey)
{
this.jobKey = jobKey;
return this;
@@ -323,7 +349,7 @@ public TriggerBuilder ForJob(JobKey jobKey)
* @see Trigger#getJobKey()
*/
- public TriggerBuilder ForJob(string jobName)
+ public TriggerBuilder ForJob(string jobName)
{
this.jobKey = new JobKey(jobName, null);
return this;
@@ -340,7 +366,7 @@ public TriggerBuilder ForJob(string jobName)
* @see Trigger#getJobKey()
*/
- public TriggerBuilder ForJob(string jobName, string jobGroup)
+ public TriggerBuilder ForJob(string jobName, string jobGroup)
{
this.jobKey = new JobKey(jobName, jobGroup);
return this;
@@ -355,7 +381,7 @@ public TriggerBuilder ForJob(string jobName, string jobGroup)
* @see Trigger#getJobKey()
*/
- public TriggerBuilder ForJob(IJobDetail jobDetail)
+ public TriggerBuilder ForJob(IJobDetail jobDetail)
{
JobKey k = jobDetail.Key;
if (k.Name == null)
@@ -373,7 +399,7 @@ public TriggerBuilder ForJob(IJobDetail jobDetail)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, string value)
+ public TriggerBuilder UsingJobData(string key, string value)
{
jobDataMap.Put(key, value);
return this;
@@ -386,7 +412,7 @@ public TriggerBuilder UsingJobData(string key, string value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, int value)
+ public TriggerBuilder UsingJobData(string key, int value)
{
jobDataMap.Put(key, value);
return this;
@@ -399,7 +425,7 @@ public TriggerBuilder UsingJobData(string key, int value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, long value)
+ public TriggerBuilder UsingJobData(string key, long value)
{
jobDataMap.Put(key, value);
return this;
@@ -412,7 +438,7 @@ public TriggerBuilder UsingJobData(string key, long value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, float value)
+ public TriggerBuilder UsingJobData(string key, float value)
{
jobDataMap.Put(key, value);
return this;
@@ -425,7 +451,7 @@ public TriggerBuilder UsingJobData(string key, float value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, Double value)
+ public TriggerBuilder UsingJobData(string key, Double value)
{
jobDataMap.Put(key, value);
return this;
@@ -438,7 +464,7 @@ public TriggerBuilder UsingJobData(string key, Double value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(string key, Boolean value)
+ public TriggerBuilder UsingJobData(string key, Boolean value)
{
jobDataMap.Put(key, value);
return this;
@@ -453,7 +479,7 @@ public TriggerBuilder UsingJobData(string key, Boolean value)
* @see Trigger#getJobDataMap()
*/
- public TriggerBuilder UsingJobData(JobDataMap newJobDataMap)
+ public TriggerBuilder UsingJobData(JobDataMap newJobDataMap)
{
// add any existing data to this new map
foreach (string key in jobDataMap.Keys)
diff --git a/src/Quartz/TriggerConstants.cs b/src/Quartz/TriggerConstants.cs
new file mode 100644
index 000000000..e25ace4ad
--- /dev/null
+++ b/src/Quartz/TriggerConstants.cs
@@ -0,0 +1,10 @@
+namespace Quartz
+{
+ public static class TriggerConstants
+ {
+ ///
+ /// The default value for priority.
+ ///
+ public const int DefaultPriority = 5;
+ }
+}
\ No newline at end of file
diff --git a/src/Quartz/TriggerUtils.cs b/src/Quartz/TriggerUtils.cs
index bf34ad603..6a5e67715 100644
--- a/src/Quartz/TriggerUtils.cs
+++ b/src/Quartz/TriggerUtils.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Globalization;
+using Quartz.Impl.Triggers;
+
namespace Quartz
{
///
@@ -242,7 +244,7 @@ public static ITrigger MakeMonthlyTrigger(string trigName, int dayOfMonth, int h
/// the newly created trigger
public static ITrigger MakeImmediateTrigger(int repeatCount, TimeSpan repeatInterval)
{
- SimpleTrigger trig = new SimpleTrigger();
+ SimpleTriggerImpl trig = new SimpleTriggerImpl();
trig.StartTimeUtc = SystemTime.UtcNow();
trig.RepeatCount = repeatCount;
trig.RepeatInterval = repeatInterval;
@@ -276,7 +278,7 @@ public static ITrigger MakeImmediateTrigger(string trigName, int repeatCount, Ti
/// the new trigger
public static ITrigger MakeSecondlyTrigger()
{
- return MakeSecondlyTrigger(1, SimpleTrigger.RepeatIndefinitely);
+ return MakeSecondlyTrigger(1, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -290,7 +292,7 @@ public static ITrigger MakeSecondlyTrigger()
/// the new trigger
public static ITrigger MakeSecondlyTrigger(string trigName)
{
- return MakeSecondlyTrigger(trigName, 1, SimpleTrigger.RepeatIndefinitely);
+ return MakeSecondlyTrigger(trigName, 1, SimpleTriggerImpl.RepeatIndefinitely);
}
@@ -305,7 +307,7 @@ public static ITrigger MakeSecondlyTrigger(string trigName)
/// the new trigger
public static ITrigger MakeSecondlyTrigger(int intervalInSeconds)
{
- return MakeSecondlyTrigger(intervalInSeconds, SimpleTrigger.RepeatIndefinitely);
+ return MakeSecondlyTrigger(intervalInSeconds, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -321,7 +323,7 @@ public static ITrigger MakeSecondlyTrigger(int intervalInSeconds)
/// the new trigger
public static ITrigger MakeSecondlyTrigger(int intervalInSeconds, int repeatCount)
{
- SimpleTrigger trig = new SimpleTrigger();
+ SimpleTriggerImpl trig = new SimpleTriggerImpl();
trig.RepeatInterval = TimeSpan.FromSeconds(intervalInSeconds);
trig.RepeatCount = repeatCount;
@@ -359,7 +361,7 @@ public static ITrigger MakeSecondlyTrigger(string trigName, int intervalInSecond
/// the new trigger
public static ITrigger MakeMinutelyTrigger()
{
- return MakeMinutelyTrigger(1, SimpleTrigger.RepeatIndefinitely);
+ return MakeMinutelyTrigger(1, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -373,7 +375,7 @@ public static ITrigger MakeMinutelyTrigger()
/// the new trigger
public static ITrigger MakeMinutelyTrigger(string trigName)
{
- return MakeMinutelyTrigger(trigName, 1, SimpleTrigger.RepeatIndefinitely);
+ return MakeMinutelyTrigger(trigName, 1, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -387,7 +389,7 @@ public static ITrigger MakeMinutelyTrigger(string trigName)
/// the new trigger
public static ITrigger MakeMinutelyTrigger(int intervalInMinutes)
{
- return MakeMinutelyTrigger(intervalInMinutes, SimpleTrigger.RepeatIndefinitely);
+ return MakeMinutelyTrigger(intervalInMinutes, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -403,7 +405,7 @@ public static ITrigger MakeMinutelyTrigger(int intervalInMinutes)
/// the new trigger
public static ITrigger MakeMinutelyTrigger(int intervalInMinutes, int repeatCount)
{
- SimpleTrigger trig = new SimpleTrigger();
+ SimpleTriggerImpl trig = new SimpleTriggerImpl();
trig.RepeatInterval = TimeSpan.FromMinutes(intervalInMinutes);
trig.RepeatCount = repeatCount;
trig.StartTimeUtc = SystemTime.UtcNow();
@@ -440,7 +442,7 @@ public static ITrigger MakeMinutelyTrigger(string trigName, int intervalInMinute
/// the new trigger
public static ITrigger MakeHourlyTrigger()
{
- return MakeHourlyTrigger(1, SimpleTrigger.RepeatIndefinitely);
+ return MakeHourlyTrigger(1, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -454,7 +456,7 @@ public static ITrigger MakeHourlyTrigger()
/// the new trigger
public static ITrigger MakeHourlyTrigger(string trigName)
{
- return MakeHourlyTrigger(trigName, 1, SimpleTrigger.RepeatIndefinitely);
+ return MakeHourlyTrigger(trigName, 1, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -468,7 +470,7 @@ public static ITrigger MakeHourlyTrigger(string trigName)
/// the new trigger
public static ITrigger MakeHourlyTrigger(int intervalInHours)
{
- return MakeHourlyTrigger(intervalInHours, SimpleTrigger.RepeatIndefinitely);
+ return MakeHourlyTrigger(intervalInHours, SimpleTriggerImpl.RepeatIndefinitely);
}
///
@@ -484,7 +486,7 @@ public static ITrigger MakeHourlyTrigger(int intervalInHours)
/// the new trigger
public static ITrigger MakeHourlyTrigger(int intervalInHours, int repeatCount)
{
- SimpleTrigger trig = new SimpleTrigger();
+ SimpleTriggerImpl trig = new SimpleTriggerImpl();
trig.RepeatInterval = TimeSpan.FromHours(intervalInHours);
trig.RepeatCount = repeatCount;
diff --git a/src/Quartz/Util/ObjectUtils.cs b/src/Quartz/Util/ObjectUtils.cs
index 08866348a..1cce5462b 100644
--- a/src/Quartz/Util/ObjectUtils.cs
+++ b/src/Quartz/Util/ObjectUtils.cs
@@ -196,6 +196,11 @@ public static TimeSpan GetTimeSpanValueForProperty(PropertyInfo pi, object value
throw new ArgumentOutOfRangeException();
}
}
+
+ public static bool IsAttributePresent(Type typeToExamine, Type attributeType)
+ {
+ return typeToExamine.GetCustomAttributes(attributeType, true).Length > 0;
+ }
}
}
diff --git a/src/Quartz/Xml/CalendarBundle.cs b/src/Quartz/Xml/CalendarBundle.cs
deleted file mode 100644
index 80e0a8f52..000000000
--- a/src/Quartz/Xml/CalendarBundle.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-#region License
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- */
-#endregion
-
-using System;
-using Quartz.Util;
-
-namespace Quartz.Xml
-{
- ///
- /// Wraps a .
- ///
- /// Chris Bonham
- /// Marko Lahma (.NET)
- [Serializable]
- public class CalendarBundle : ICalendar
- {
- private string calendarName;
- private string typeName;
- private ICalendar calendar;
- private bool replace;
-
- ///
- /// Gets or sets the name of the calendar.
- ///
- /// The name of the calendar.
- public virtual string CalendarName
- {
- get { return calendarName; }
- set { calendarName = value; }
- }
-
- ///
- /// Gets or sets the name of the class.
- ///
- /// The name of the class.
- public virtual string TypeName
- {
- get { return typeName; }
- set
- {
- typeName = value;
- CreateCalendar();
- }
- }
-
- ///
- /// Gets or sets the calendar.
- ///
- /// The calendar.
- public virtual ICalendar Calendar
- {
- get { return calendar; }
- set { calendar = value; }
- }
-
- public virtual bool Replace
- {
- get { return replace; }
- set { replace = value; }
- }
-
- ///
- /// Gets or sets a description for the instance - may be
- /// useful for remembering/displaying the purpose of the calendar, though
- /// the description has no meaning to Quartz.
- ///
- ///
- public virtual string Description
- {
- get { return calendar.Description; }
- set { calendar.Description = value; }
- }
-
- ///
- /// Set a new base calendar or remove the existing one.
- ///
- ///
- public virtual ICalendar CalendarBase
- {
- get { return calendar.CalendarBase; }
- set
- {
- if (value is CalendarBundle)
- {
- value = ((CalendarBundle) value).Calendar;
- }
- calendar.CalendarBase = value;
- }
- }
-
- public virtual bool IsTimeIncluded(DateTimeOffset timeStamp)
- {
- return calendar.IsTimeIncluded(timeStamp);
- }
-
- public virtual DateTimeOffset GetNextIncludedTimeUtc(DateTimeOffset timeStamp)
- {
- return calendar.GetNextIncludedTimeUtc(timeStamp);
- }
-
- protected virtual void CreateCalendar()
- {
- Type type = Type.GetType(typeName);
- if (type == null)
- {
- throw new SchedulerConfigException("Unknown calendar type " + typeName);
- }
- Calendar = ObjectUtils.InstantiateType(type);
- }
-
- public object Clone()
- {
- try
- {
- CalendarBundle clone = (CalendarBundle) MemberwiseClone();
- return clone;
- }
- catch (Exception)
- {
- throw new NotSupportedException("Not Cloneable.");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Quartz/Xml/JobSchedulingBundle.cs b/src/Quartz/Xml/JobSchedulingBundle.cs
deleted file mode 100644
index a6e4ef4a8..000000000
--- a/src/Quartz/Xml/JobSchedulingBundle.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-#region License
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-
-namespace Quartz.Xml
-{
- ///
- /// Wraps a and .
- ///
- /// Chris Bonham
- /// James House
- /// Marko Lahma (.NET)
- public class JobSchedulingBundle
- {
- private IJobDetail jobDetail;
- private IList triggers = new List();
-
- ///
- /// Gets or sets the job detail.
- ///
- /// The job detail.
- public virtual IJobDetail JobDetail
- {
- get { return jobDetail; }
- set { jobDetail = value; }
- }
-
- ///
- /// Gets or sets the triggers associated with this bundle.
- ///
- /// The triggers.
- public virtual IList Triggers
- {
- get { return triggers; }
- set { triggers = value; }
- }
-
- ///
- /// Gets the name of the bundle.
- ///
- /// The name.
- public virtual string Name
- {
- get
- {
- if (JobDetail != null)
- {
- return JobDetail.Name;
- }
- else
- {
- return null;
- }
- }
- }
-
- ///
- /// Gets the full name.
- ///
- /// The full name.
- public virtual string FullName
- {
- get
- {
- if (JobDetail != null)
- {
- return JobDetail.FullName;
- }
- else
- {
- return null;
- }
- }
- }
-
- ///
- /// Gets a value indicating whether this is valid.
- ///
- /// true if valid; otherwise, false.
- public virtual bool Valid
- {
- get { return ((JobDetail != null) && (Triggers != null)); }
- }
-
-
- ///
- /// Adds a trigger to this bundle.
- ///
- /// The trigger.
- public virtual void AddTrigger(ITrigger trigger)
- {
- if (trigger.StartTimeUtc == DateTimeOffset.MinValue)
- {
- trigger.StartTimeUtc = SystemTime.UtcNow();
- }
-
- if (trigger is CronTrigger)
- {
- CronTrigger ct = (CronTrigger) trigger;
- if (ct.TimeZone == null)
- {
- ct.TimeZone = TimeZoneInfo.Local;
- }
- }
-
- triggers.Add(trigger);
- }
-
- ///
- /// Removes the given trigger from this bundle.
- ///
- /// The trigger.
- public virtual void RemoveTrigger(ITrigger trigger)
- {
- triggers.Remove(trigger);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Quartz/Xml/JobSchedulingDataProcessor.cs b/src/Quartz/Xml/JobSchedulingDataProcessor.cs
deleted file mode 100644
index 21c2e664b..000000000
--- a/src/Quartz/Xml/JobSchedulingDataProcessor.cs
+++ /dev/null
@@ -1,756 +0,0 @@
-#region License
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- */
-#endregion
-
-using System;
-
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.IO;
-using System.Reflection;
-using System.Xml;
-using System.Xml.Schema;
-using System.Xml.Serialization;
-
-using Common.Logging;
-
-using Quartz.Xml.JobSchedulingData10;
-using Quartz.Util;
-
-namespace Quartz.Xml
-{
- ///
- /// Parses an XML file that declares Jobs and their schedules (Triggers).
- ///
- ///
- ///
- /// The xml document must conform to the format defined in
- /// "job_scheduling_data_1_0.xsd"
- ///
- ///
- ///
- /// After creating an instance of this class, you should call one of the
- /// functions, after which you may call the
- /// function to get a handle to the defined Jobs and Triggers, which can then be
- /// scheduled with the . Alternatively, you could call
- /// the function to do all of this
- /// in one step.
- ///
- ///
- ///
- /// The same instance can be used again and again, with the list of defined Jobs
- /// being cleared each time you call a method,
- /// however a single instance is not thread-safe.
- ///
- ///
- /// Chris Bonham
- /// James House
- /// Marko Lahma (.NET)
- public class JobSchedulingDataProcessor
- {
- private readonly ILog log;
- private readonly bool validateXml;
- private readonly bool validateSchema;
-
- public const string PropertyQuartzSystemIdDir = "quartz.system.id.dir";
- public const string QuartzXmlFileName = "quartz_jobs.xml";
- public const string QuartzSchema = "http://quartznet.sourceforge.net/xml/job_scheduling_data_1_0.xsd";
- public const string QuartzXsdResourceName = "Quartz.Xml.job_scheduling_data_1_0.xsd";
-
- protected const string ThreadLocalKeyScheduler = "quartz_scheduler";
-
- ///
- /// XML Schema dateTime datatype format.
- ///
- /// See
- /// http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#dateTime
- ///
- ///
- protected const string XsdDateFormat = "yyyy-MM-dd'T'hh:mm:ss";
-
- private readonly IDictionary scheduledJobs = new Dictionary();
- private readonly IList jobsToSchedule = new List();
- private readonly IList calsToSchedule = new List();
- private readonly IList listenersToSchedule = new List();
- private readonly IList triggerListenersToSchedule = new List();
-
- private readonly List validationExceptions = new List();
-
- private bool overwriteExistingJobs = true;
-
-
- ///
- /// Gets or sets whether to overwrite existing jobs.
- ///
- public virtual bool OverwriteExistingJobs
- {
- get { return overwriteExistingJobs; }
- set { overwriteExistingJobs = value; }
- }
-
-
- ///
- /// Gets the log.
- ///
- /// The log.
- protected internal ILog Log
- {
- get { return log; }
- }
-
- ///
- /// Returns a of scheduled jobs.
- ///
- /// The key is the job name and the value is a
- /// containing the and .
- ///
- ///
- /// a of scheduled jobs.
- ///
- public virtual IDictionary ScheduledJobs
- {
- get { return scheduledJobs; }
- }
-
-
- ///
- /// Constructor for JobSchedulingDataProcessor.
- ///
- public JobSchedulingDataProcessor() : this(true, true)
- {
- }
-
- ///
- /// Constructor for JobSchedulingDataProcessor.
- ///
- /// whether or not to validate XML.
- /// whether or not to validate XML schema.
- public JobSchedulingDataProcessor(bool validateXml, bool validateSchema)
- {
- this.validateXml = validateXml;
- this.validateSchema = validateSchema;
- log = LogManager.GetLogger(GetType());
- }
-
-
- ///
- /// Process the xml file in the default location (a file named
- /// "quartz_jobs.xml" in the current working directory).
- ///
- public virtual void ProcessFile()
- {
- ProcessFile(QuartzXmlFileName);
- }
-
- ///
- /// Process the xml file named .
- ///
- /// meta data file name.
- public virtual void ProcessFile(string fileName)
- {
- ProcessFile(fileName, fileName);
- }
-
- ///
- /// Process the xmlfile named with the given system
- /// ID.
- ///
- /// Name of the file.
- /// The system id.
- public virtual void ProcessFile(string fileName, string systemId)
- {
- Log.Info(string.Format(CultureInfo.InvariantCulture, "Parsing XML file: {0} with systemId: {1} validating: {2} validating schema: {3}", fileName, systemId, validateXml, validateSchema));
- using (StreamReader sr = new StreamReader(fileName))
- {
- ProcessInternal(sr.ReadToEnd());
- }
- }
-
- ///
- /// Process the xmlfile named with the given system
- /// ID.
- ///
- /// The stream.
- /// The system id.
- public virtual void ProcessStream(Stream stream, string systemId)
- {
- Log.Info(string.Format(CultureInfo.InvariantCulture, "Parsing XML from stream with systemId: {0} validating: {1} validating schema: {2}", systemId, validateXml, validateSchema));
- using (StreamReader sr = new StreamReader(stream))
- {
- ProcessInternal(sr.ReadToEnd());
- }
- }
-
- protected internal virtual void ProcessInternal(string xml)
- {
- ClearValidationExceptions();
-
- scheduledJobs.Clear();
- jobsToSchedule.Clear();
- calsToSchedule.Clear();
-
- ValidateXmlIfNeeded(xml);
-
- // deserialize as object model
- XmlSerializer xs = new XmlSerializer(typeof(QuartzXmlConfiguration10));
- QuartzXmlConfiguration10 data = (QuartzXmlConfiguration10) xs.Deserialize(new StringReader(xml));
-
- // process data
- overwriteExistingJobs = data.overwriteexistingjobs;
-
- // add calendars
- if (data.calendar != null)
- {
- foreach (calendarType ct in data.calendar)
- {
- CalendarBundle c = CreateCalendarFromXmlObject(ct);
- AddCalendarToSchedule(c);
- }
- }
-
- // add job scheduling bundles
- ProcessJobs(data);
-
- if (data.joblistener != null)
- {
- // go through listeners
- foreach (joblistenerType jt in data.joblistener)
- {
- Type listenerType = Type.GetType(jt.type);
- if (listenerType == null)
- {
- throw new SchedulerConfigException("Unknown job listener type " + jt.type);
- }
- IJobListener listener = ObjectUtils.InstantiateType(listenerType);
- // set name of trigger with reflection, this might throw errors
- NameValueCollection properties = new NameValueCollection();
- properties.Add("Name", jt.name);
-
- try
- {
- ObjectUtils.SetObjectProperties(listener, properties);
- }
- catch (Exception)
- {
- throw new SchedulerConfigException(string.Format("Could not set name for job listener of type '{0}', do you have public set method defined for property 'Name'?", jt.type));
- }
- AddListenerToSchedule(listener);
- }
- }
-
- ProcessTriggerListeners(data);
-
- MaybeThrowValidationException();
- }
-
- private void ProcessJobs(QuartzXmlConfiguration10 data)
- {
- if (data.job == null)
- {
- // no jobs to process, file is empty
- return;
- }
-
- foreach (jobType jt in data.job)
- {
- JobSchedulingBundle jsb = new JobSchedulingBundle();
- jobdetailType j = jt.jobdetail;
- Type jobType = Type.GetType(j.jobtype);
- if (jobType == null)
- {
- throw new SchedulerConfigException("Unknown job type " + j.jobtype);
- }
-
- JobDetailImpl jd = new JobDetailImpl(j.name, j.group, jobType, j.@volatile, j.durable, j.recover);
- jd.Description = j.description;
-
- jsb.JobDetail = jd;
-
- // read job data map
- if (j.jobdatamap != null && j.jobdatamap.entry != null)
- {
- foreach (entryType entry in j.jobdatamap.entry)
- {
- jd.JobDataMap.Put(entry.key, entry.value);
- }
- }
-
- triggerType[] tArr = jt.trigger ?? new triggerType[0];
- foreach (triggerType t in tArr)
- {
- Trigger trigger;
- if (t.Item is cronType)
- {
- cronType c = (cronType) t.Item;
-
- DateTimeOffset startTime = (c.starttime == DateTime.MinValue ? SystemTime.UtcNow() : c.starttime);
- DateTimeOffset? endTime = (c.endtime == DateTime.MinValue ? null : (DateTime?)c.endtime);
-
- string jobName = c.jobname != null ? c.jobname : j.name;
- string jobGroup = c.jobgroup != null ? c.jobgroup : j.group;
-
- CronTrigger ct = new CronTrigger(
- c.name,
- c.group,
- jobName,
- jobGroup,
- startTime,
- endTime,
- c.cronexpression);
-
- if (c.timezone != null && c.timezone.Trim().Length > 0)
- {
- ct.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(c.timezone);
- }
- trigger = ct;
- }
- else if (t.Item is simpleType)
- {
- simpleType s = (simpleType) t.Item;
-
- DateTimeOffset startTime = (s.starttime == DateTime.MinValue ? SystemTime.UtcNow() : s.starttime);
- DateTimeOffset? endTime = (s.endtime == DateTime.MinValue ? null : (DateTimeOffset?)s.endtime);
-
- string jobName = s.jobname != null ? s.jobname : j.name;
- string jobGroup = s.jobgroup != null ? s.jobgroup : j.group;
-
- SimpleTrigger st = new SimpleTrigger(
- s.name,
- s.group,
- jobName,
- jobGroup,
- startTime,
- endTime,
- ParseSimpleTriggerRepeatCount(s.repeatcount),
- TimeSpan.FromMilliseconds(Convert.ToInt64(s.repeatinterval, CultureInfo.InvariantCulture)));
-
- trigger = st;
- }
- else
- {
- throw new ArgumentException("Unknown trigger type in XML");
- }
-
- trigger.Description = t.Item.description;
- trigger.CalendarName = t.Item.calendarname;
-
- if (t.Item.misfireinstruction != null)
- {
- trigger.MisfireInstruction = ReadMisfireInstructionFromString(t.Item.misfireinstruction);
- }
- if (t.Item.jobdatamap != null && t.Item.jobdatamap.entry != null)
- {
- foreach (entryType entry in t.Item.jobdatamap.entry)
- {
- if (trigger.JobDataMap.ContainsKey(entry.key))
- {
- Log.Warn("Overriding key '" + entry.key + "' with another value in same trigger job data map");
- }
- trigger.JobDataMap[entry.key] = entry.value;
- }
- }
- jsb.Triggers.Add(trigger);
- }
-
- AddJobToSchedule(jsb);
- }
- }
-
- private void ProcessTriggerListeners(QuartzXmlConfiguration10 data)
- {
- if (data.triggerlistener != null)
- {
- // go through listeners
- foreach (triggerlistenerType lt in data.triggerlistener)
- {
- Type listenerType = Type.GetType(lt.type);
- if (listenerType == null)
- {
- throw new SchedulerConfigException("Unknown trigger listener type " + lt.type);
- }
- ITriggerListener listener = ObjectUtils.InstantiateType(listenerType);
- // set name of trigger with reflection, this might throw errors
- NameValueCollection properties = new NameValueCollection();
- properties.Add("Name", lt.name);
-
- try
- {
- ObjectUtils.SetObjectProperties(listener, properties);
- }
- catch (Exception)
- {
- throw new SchedulerConfigException(string.Format("Could not set name for job listener of type '{0}', do you have public set method defined for property 'Name'?", lt.type));
- }
- AddTriggerListenerToSchedule(listener);
- }
- }
- }
- private static int ParseSimpleTriggerRepeatCount(string repeatcount)
- {
- int value;
- if (repeatcount == "RepeatIndefinitely")
- {
- value = SimpleTrigger.RepeatIndefinitely;
- }
- else
- {
- value = Convert.ToInt32(repeatcount, CultureInfo.InvariantCulture);
- }
-
- return value;
- }
-
- private static int ReadMisfireInstructionFromString(string misfireinstruction)
- {
- Constants c = new Constants(typeof(MisfireInstruction), typeof(MisfireInstruction.CronTrigger), typeof(MisfireInstruction.SimpleTrigger));
- return c.AsNumber(misfireinstruction);
- }
-
- private static CalendarBundle CreateCalendarFromXmlObject(calendarType ct)
- {
- CalendarBundle c = new CalendarBundle();
-
- // set type name first as it creates the actual inner instance
- c.TypeName = ct.type;
- c.Description = ct.description;
- c.CalendarName = ct.name;
- c.Replace = ct.replace;
-
- if (ct.basecalendar != null)
- {
- c.CalendarBase = CreateCalendarFromXmlObject(ct.basecalendar);
- }
- return c;
- }
-
- private void ValidateXmlIfNeeded(string xml)
- {
- if (validateXml)
- {
- // stream to validate
- using (StringReader stringReader = new StringReader(xml))
- {
- XmlTextReader xmlr = new XmlTextReader(stringReader);
- XmlValidatingReader xmlvread = new XmlValidatingReader(xmlr);
-
- // Set the validation event handler
- xmlvread.ValidationEventHandler += new ValidationEventHandler(XmlValidationCallBack);
-
- // Read XML data
- while (xmlvread.Read()) { }
-
- //Close the reader.
- xmlvread.Close();
- }
- }
- }
-
- private void XmlValidationCallBack(object sender, ValidationEventArgs e)
- {
- validationExceptions.Add(e.Exception);
- }
-
-
- ///
- /// Process the xml file in the default location, and schedule all of the
- /// jobs defined within it.
- ///
- public virtual void ProcessFileAndScheduleJobs(IScheduler sched, bool overwriteExistingJobs)
- {
- ProcessFileAndScheduleJobs(QuartzXmlFileName, sched, overwriteExistingJobs);
- }
-
- ///
- /// Process the xml file in the given location, and schedule all of the
- /// jobs defined within it.
- ///
- /// meta data file name.
- /// The scheduler.
- /// if set to true overwrite existing jobs.
- public virtual void ProcessFileAndScheduleJobs(string fileName, IScheduler sched, bool overwriteExistingJobs)
- {
- ProcessFileAndScheduleJobs(fileName, fileName, sched, overwriteExistingJobs);
- }
-
- ///
- /// Process the xml file in the given location, and schedule all of the
- /// jobs defined within it.
- ///
- /// Name of the file.
- /// The system id.
- /// The sched.
- /// if set to true [over write existing jobs].
- public virtual void ProcessFileAndScheduleJobs(string fileName, string systemId, IScheduler sched,
- bool overwriteExistingJobs)
- {
- LogicalThreadContext.SetData(ThreadLocalKeyScheduler, sched);
- try
- {
- ProcessFile(fileName, systemId);
- ScheduleJobs(ScheduledJobs, sched, overwriteExistingJobs);
- }
- finally
- {
- LogicalThreadContext.FreeNamedDataSlot(ThreadLocalKeyScheduler);
- }
- }
-
- ///
- /// Add the Jobs and Triggers defined in the given map of
- /// s to the given scheduler.
- ///
- /// The job bundles.
- /// The sched.
- /// if set to true [over write existing jobs].
- public virtual void ScheduleJobs(IDictionary jobBundles, IScheduler sched, bool overwriteExistingJobs)
- {
- Log.Info(string.Format(CultureInfo.InvariantCulture, "Scheduling {0} parsed jobs.", jobsToSchedule.Count));
-
- foreach (CalendarBundle bndle in calsToSchedule)
- {
- AddCalendar(sched, bndle);
- }
-
- foreach (JobSchedulingBundle bndle in jobsToSchedule)
- {
- ScheduleJob(bndle, sched, overwriteExistingJobs);
- }
-
- Log.Info(string.Format(CultureInfo.InvariantCulture, "{0} scheduled jobs.", jobBundles.Count));
- }
-
- ///
- /// Returns a for the job name.
- ///
- /// The name.
- ///
- /// a for the job name.
- ///
- public virtual JobSchedulingBundle GetScheduledJob(string name)
- {
- JobSchedulingBundle bundle;
- ScheduledJobs.TryGetValue(name, out bundle);
- return bundle;
- }
-
- ///
- /// Returns an from the fileName as a resource.
- ///
- /// Name of the file.
- ///
- /// an from the fileName as a resource.
- ///
- protected virtual Stream GetInputStream(string fileName)
- {
- return new StreamReader(fileName).BaseStream;
- }
-
- ///
- /// Schedules a given job and trigger (both wrapped by a ).
- ///
- /// job wrapper.
- ///
- /// if the Job or Trigger cannot be added to the Scheduler, or
- /// there is an internal Scheduler error.
- ///
- public virtual void ScheduleJob(JobSchedulingBundle job)
- {
- ScheduleJob(job, LogicalThreadContext.GetData(ThreadLocalKeyScheduler), OverwriteExistingJobs);
- }
-
-
- public virtual void AddJobToSchedule(JobSchedulingBundle job)
- {
- jobsToSchedule.Add(job);
- }
-
- public virtual void AddCalendarToSchedule(CalendarBundle cal)
- {
- calsToSchedule.Add(cal);
- }
-
- public virtual void AddListenerToSchedule(IJobListener listener)
- {
- listenersToSchedule.Add(listener);
- }
-
- public virtual void AddTriggerListenerToSchedule(ITriggerListener listener)
- {
- triggerListenersToSchedule.Add(listener);
- }
-
- ///
- /// Schedules a given job and trigger (both wrapped by a ).
- ///
- /// The job.
- /// The sched.
- /// if set to true [local over write existing jobs].
- ///
- /// if the Job or Trigger cannot be added to the Scheduler, or
- /// there is an internal Scheduler error.
- ///
- public virtual void ScheduleJob(JobSchedulingBundle job, IScheduler sched, bool localOverWriteExistingJobs)
- {
- if ((job != null) && job.Valid)
- {
- JobDetailImpl detail = job.JobDetail;
-
- JobDetailImpl dupeJ = sched.GetJobDetail(detail.Name, detail.Group);
-
- if ((dupeJ != null) && !localOverWriteExistingJobs)
- {
- Log.Info("Not overwriting existing job: " + dupeJ.FullName);
- return;
- }
-
- if (dupeJ != null)
- {
- Log.Info(string.Format(CultureInfo.InvariantCulture, "Replacing job: {0}", detail.FullName));
- }
- else
- {
- Log.Info(string.Format(CultureInfo.InvariantCulture, "Adding job: {0}", detail.FullName));
- }
-
- if (job.Triggers.Count == 0 && !job.JobDetail.Durable)
- {
- throw new SchedulerException("A Job defined without any triggers must be durable");
- }
-
- sched.AddJob(detail, true);
-
-
- foreach(Trigger trigger in job.Triggers)
- {
- Trigger dupeT = sched.GetTrigger(trigger.Name, trigger.Group);
-
- trigger.JobName = detail.Name;
- trigger.JobGroup = detail.Group;
-
- if (trigger.StartTimeUtc == DateTimeOffset.MinValue)
- {
- trigger.StartTimeUtc = SystemTime.UtcNow();
- }
-
- if (dupeT != null)
- {
- Log.Debug(string.Format(CultureInfo.InvariantCulture, "Rescheduling job: {0} with updated trigger: {1}", detail.FullName, trigger.FullName));
- if (!dupeT.JobGroup.Equals(trigger.JobGroup) || !dupeT.JobName.Equals(trigger.JobName))
- {
- Log.Warn("Possibly duplicately named triggers in jobs xml file!");
- }
- sched.RescheduleJob(trigger.Name, trigger.Group, trigger);
- }
- else
- {
- Log.Debug(string.Format(CultureInfo.InvariantCulture, "Scheduling job: {0} with trigger: {1}", detail.FullName, trigger.FullName));
- sched.ScheduleJob(trigger);
- }
- }
-
- AddScheduledJob(job);
- }
- }
-
- ///
- /// Adds a scheduled job.
- ///
- /// The job.
- protected virtual void AddScheduledJob(JobSchedulingBundle job)
- {
- scheduledJobs[job.FullName] = job;
- }
-
- ///
- /// Adds a calendar.
- ///
- /// The sched.
- /// calendar bundle.
- /// SchedulerException if the Calendar cannot be added to the Scheduler, or
- public virtual void AddCalendar(IScheduler sched, CalendarBundle calendarBundle)
- {
- sched.AddCalendar(calendarBundle.CalendarName, calendarBundle.Calendar, calendarBundle.Replace, true);
- }
-
-
-
-
- ///
- /// Adds a detected validation exception.
- ///
- /// The exception.
- protected virtual void AddValidationException(XmlException e)
- {
- validationExceptions.Add(e);
- }
-
- ///
- /// Resets the the number of detected validation exceptions.
- ///
- protected virtual void ClearValidationExceptions()
- {
- validationExceptions.Clear();
- }
-
- ///
- /// Throws a ValidationException if the number of validationExceptions
- /// detected is greater than zero.
- ///
- ///
- /// DTD validation exception.
- ///
- protected virtual void MaybeThrowValidationException()
- {
- if (validationExceptions.Count > 0)
- {
- throw new ValidationException(validationExceptions);
- }
- }
-
-
- }
-
- ///
- /// Helper class to map constant names to their values.
- ///
- internal class Constants
- {
- private readonly Type[] types;
-
- public Constants(params Type[] reflectedTypes)
- {
- types = reflectedTypes;
- }
-
- public int AsNumber(string field)
- {
- foreach (Type type in types)
- {
- FieldInfo fi = type.GetField(field);
- if (fi != null)
- {
- return Convert.ToInt32(fi.GetValue(null), CultureInfo.InvariantCulture);
- }
- }
-
- // not found
- throw new Exception(string.Format(CultureInfo.InvariantCulture, "Unknown field '{0}'", field));
- }
- }
-}
diff --git a/src/Quartz/Xml/XMLSchedulingDataProcessor.cs b/src/Quartz/Xml/XMLSchedulingDataProcessor.cs
index b618cb527..8317d41fa 100644
--- a/src/Quartz/Xml/XMLSchedulingDataProcessor.cs
+++ b/src/Quartz/Xml/XMLSchedulingDataProcessor.cs
@@ -19,12 +19,14 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
+using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Common.Logging;
+using Quartz.Impl.Triggers;
using Quartz.Spi;
using Quartz.Util;
using Quartz.Xml.JobSchedulingData20;
@@ -339,15 +341,15 @@ protected virtual void ProcessInternal(string xml)
bool jobDurability = jobDetailType.durable;
bool jobRecoveryRequested = jobDetailType.recover;
- Type jobClass = typeLoadHelper.LoadType(jobTypeName);
+ Type jobType = typeLoadHelper.LoadType(jobTypeName);
- IJobDetail jobDetail = newJob(jobClass)
- .withIdentity(jobName, jobGroup)
- .withDescription(jobDescription)
- .storeDurably(jobDurability)
- .requestRecovery(jobRecoveryRequested)
- .build();
+ IJobDetail jobDetail = JobBuilder.NewJob(jobType)
+ .WithIdentity(jobName, jobGroup)
+ .WithDescription(jobDescription)
+ .StoreDurably(jobDurability)
+ .RequestRecovery(jobRecoveryRequested)
+ .Build();
if (jobDetailType.jobdatamap != null && jobDetailType.jobdatamap.entry != null)
{
@@ -389,6 +391,12 @@ protected virtual void ProcessInternal(string xml)
string triggerJobName = triggerNode.Item.jobname.TrimEmptyToNull();
string triggerJobGroup = triggerNode.Item.jobgroup.TrimEmptyToNull();
+ int triggerPriority = TriggerConstants.DefaultPriority;
+ if (!triggerNode.Item.priority.IsNullOrWhiteSpace())
+ {
+ triggerPriority = Convert.ToInt32(triggerNode.Item.priority);
+ }
+
DateTimeOffset triggerStartTime = SystemTime.UtcNow();
if (triggerNode.Item.Item != null)
{
@@ -405,7 +413,7 @@ protected virtual void ProcessInternal(string xml)
TriggerKey triggerKey = triggerKey(triggerName, triggerGroup);
- ScheduleBuilder sched = null;
+ IScheduleBuilder sched = null;
if (triggerNode.Item is simpleTriggerType)
{
@@ -417,13 +425,13 @@ protected virtual void ProcessInternal(string xml)
int repeatCount = ParseSimpleTriggerRepeatCount(repeatCountString);
TimeSpan repeatInterval = repeatIntervalString == null ? TimeSpan.Zero : TimeSpan.FromMilliseconds(Convert.ToInt64(repeatIntervalString));
- sched = simpleSchedule()
- .withIntervalInMilliseconds(repeatInterval)
- .withRepeatCount(repeatCount);
+ sched = SimpleScheduleBuilder.SimpleSchedule()
+ .WithInterval(repeatInterval)
+ .WithRepeatCount(repeatCount);
if (!String.IsNullOrWhiteSpace(simpleTrigger.misfireinstruction))
{
- ((SimpleScheduleBuilder) sched).withMisfireHandlingInstruction(ReadMisfireInstructionFromString(simpleTrigger.misfireinstruction));
+ ((SimpleScheduleBuilder) sched).WithMisfireHandlingInstruction(ReadMisfireInstructionFromString(simpleTrigger.misfireinstruction));
}
}
@@ -435,12 +443,12 @@ protected virtual void ProcessInternal(string xml)
string timezoneString = cronTrigger.timezone.TrimEmptyToNull();
TimeZoneInfo tz = timezoneString != null ? TimeZoneInfo.FindSystemTimeZoneById(timezoneString) : null;
- sched = cronSchedule(cronExpression)
- .inTimeZone(tz);
+ sched = CronScheduleBuilder.CronSchedule(cronExpression)
+ .InTimeZone(tz);
if (!String.IsNullOrWhiteSpace(cronTrigger.misfireinstruction))
{
- ((CronScheduleBuilder)sched).withMisfireHandlingInstruction(ReadMisfireInstructionFromString(cronTrigger.misfireinstruction));
+ ((CronScheduleBuilder)sched).WithMisfireHandlingInstruction(ReadMisfireInstructionFromString(cronTrigger.misfireinstruction));
}
}
else if (triggerNode.Item is calendarIntervalTriggerType)
@@ -452,7 +460,7 @@ protected virtual void ProcessInternal(string xml)
IntervalUnit intervalUnit = ParseDateIntervalTriggerIntervalUnit(calendarIntervalTrigger.repeatintervalunit.TrimEmptyToNull());
int repeatInterval = repeatIntervalString == null ? 0 : Convert.ToInt32(repeatIntervalString);
- sched = calendarIntervalSchedule()
+ sched = CalendarIntervalScheduleBuilder.CalendarIntervalSchedule()
.withInterval(repeatInterval, intervalUnit);
if (!String.IsNullOrWhiteSpace(calendarIntervalTrigger.misfireinstruction))
@@ -465,15 +473,16 @@ protected virtual void ProcessInternal(string xml)
throw new SchedulerConfigException("Unknown trigger type in XML configuration");
}
- IMutableTrigger trigger = newTrigger()
- .withIdentity(triggerName, triggerGroup)
- .withDescription(triggerDescription)
- .forJob(triggerJobName, triggerJobGroup)
- .startAt(triggerStartTime)
- .endAt(triggerEndTime)
- .modifiedByCalendar(triggerCalendarRef)
- .withSchedule(sched)
- .build();
+ IMutableTrigger trigger = TriggerBuilder.NewTrigger()
+ .WithIdentity(triggerName, triggerGroup)
+ .WithDescription(triggerDescription)
+ .ForJob(triggerJobName, triggerJobGroup)
+ .StartAt(triggerStartTime)
+ .EndAt(triggerEndTime)
+ .WithPriority(triggerPriority)
+ .ModifiedByCalendar(triggerCalendarRef)
+ .WithSchedule(sched)
+ .Build();
if (triggerNode.Item.jobdatamap != null && triggerNode.Item.jobdatamap.entry != null)
{
@@ -993,5 +1002,35 @@ public void AddTriggerGroupToNeverDelete(string triggerGroupName)
{
triggerGroupsToNeverDelete.Add(triggerGroupName);
}
+
+
+
+ ///
+ /// Helper class to map constant names to their values.
+ ///
+ internal class Constants
+ {
+ private readonly Type[] types;
+
+ public Constants(params Type[] reflectedTypes)
+ {
+ types = reflectedTypes;
+ }
+
+ public int AsNumber(string field)
+ {
+ foreach (Type type in types)
+ {
+ FieldInfo fi = type.GetField(field);
+ if (fi != null)
+ {
+ return Convert.ToInt32(fi.GetValue(null), CultureInfo.InvariantCulture);
+ }
+ }
+
+ // not found
+ throw new Exception(string.Format(CultureInfo.InvariantCulture, "Unknown field '{0}'", field));
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Quartz/Xml/job_scheduling_data_1_0.cs b/src/Quartz/Xml/job_scheduling_data_1_0.cs
deleted file mode 100644
index fe0a000ec..000000000
--- a/src/Quartz/Xml/job_scheduling_data_1_0.cs
+++ /dev/null
@@ -1,676 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-//
-// This source code was auto-generated by xsd, Version=2.0.50727.3038.
-//
-
-namespace Quartz.Xml.JobSchedulingData10
-{
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true,
- Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData",
- IsNullable = false, ElementName = "quartz")]
- public partial class QuartzXmlConfiguration10
- {
- private joblistenerType[] joblistenerField;
-
- private triggerlistenerType[] triggerlistenerField;
-
- private calendarType[] calendarField;
-
- private jobType[] jobField;
-
- private string versionField;
-
- private bool overwriteexistingjobsField;
-
- public QuartzXmlConfiguration10()
- {
- this.overwriteexistingjobsField = true;
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-listener")]
- public joblistenerType[] joblistener
- {
- get { return this.joblistenerField; }
- set { this.joblistenerField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("trigger-listener")]
- public triggerlistenerType[] triggerlistener
- {
- get { return this.triggerlistenerField; }
- set { this.triggerlistenerField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("calendar")]
- public calendarType[] calendar
- {
- get { return this.calendarField; }
- set { this.calendarField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job")]
- public jobType[] job
- {
- get { return this.jobField; }
- set { this.jobField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string version
- {
- get { return this.versionField; }
- set { this.versionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute("overwrite-existing-jobs")]
- [System.ComponentModel.DefaultValueAttribute(true)]
- public bool overwriteexistingjobs
- {
- get { return this.overwriteexistingjobsField; }
- set { this.overwriteexistingjobsField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "job-listenerType",
- Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class joblistenerType
- {
- private string typeField;
-
- private string nameField;
-
- public joblistenerType()
- {
- this.nameField = "required";
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string type
- {
- get { return this.typeField; }
- set { this.typeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- [System.ComponentModel.DefaultValueAttribute("required")]
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
- }
-
- ///
- [System.Xml.Serialization.XmlIncludeAttribute(typeof (cronType))]
- [System.Xml.Serialization.XmlIncludeAttribute(typeof (simpleType))]
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public abstract partial class abstractTriggerType
- {
- private string nameField;
-
- private string groupField;
-
- private string descriptionField;
-
- private string misfireinstructionField;
-
- private string calendarnameField;
-
- private bool volatileField;
-
- private bool volatileFieldSpecified;
-
- private string triggerlistenerrefField;
-
- private jobdatamapType jobdatamapField;
-
- public abstractTriggerType()
- {
- this.volatileField = false;
- }
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
- }
-
- ///
- public string description
- {
- get { return this.descriptionField; }
- set { this.descriptionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("misfire-instruction")]
- public string misfireinstruction
- {
- get { return this.misfireinstructionField; }
- set { this.misfireinstructionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("calendar-name")]
- public string calendarname
- {
- get { return this.calendarnameField; }
- set { this.calendarnameField = value; }
- }
-
- ///
- public bool @volatile
- {
- get { return this.volatileField; }
- set { this.volatileField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlIgnoreAttribute()]
- public bool volatileSpecified
- {
- get { return this.volatileFieldSpecified; }
- set { this.volatileFieldSpecified = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("trigger-listener-ref")]
- public string triggerlistenerref
- {
- get { return this.triggerlistenerrefField; }
- set { this.triggerlistenerrefField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-data-map")]
- public jobdatamapType jobdatamap
- {
- get { return this.jobdatamapField; }
- set { this.jobdatamapField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "job-data-mapType",
- Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobdatamapType
- {
- private entryType[] entryField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("entry")]
- public entryType[] entry
- {
- get { return this.entryField; }
- set { this.entryField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class entryType
- {
- private string keyField;
-
- private string valueField;
-
- ///
- public string key
- {
- get { return this.keyField; }
- set { this.keyField = value; }
- }
-
- ///
- public string value
- {
- get { return this.valueField; }
- set { this.valueField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class cronType : abstractTriggerType
- {
- private string jobnameField;
-
- private string jobgroupField;
-
- private System.DateTime starttimeField;
-
- private System.DateTime endtimeField;
-
- private string cronexpressionField;
-
- private string timezoneField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-name")]
- public string jobname
- {
- get { return this.jobnameField; }
- set { this.jobnameField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-group")]
- public string jobgroup
- {
- get { return this.jobgroupField; }
- set { this.jobgroupField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("start-time")]
- public System.DateTime starttime
- {
- get { return this.starttimeField; }
- set { this.starttimeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("end-time")]
- public System.DateTime endtime
- {
- get { return this.endtimeField; }
- set { this.endtimeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("cron-expression")]
- public string cronexpression
- {
- get { return this.cronexpressionField; }
- set { this.cronexpressionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("time-zone")]
- public string timezone
- {
- get { return this.timezoneField; }
- set { this.timezoneField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class simpleType : abstractTriggerType
- {
- private string jobnameField;
-
- private string jobgroupField;
-
- private System.DateTime starttimeField;
-
- private System.DateTime endtimeField;
-
- private bool endtimeFieldSpecified;
-
- private string repeatcountField;
-
- private string repeatintervalField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-name")]
- public string jobname
- {
- get { return this.jobnameField; }
- set { this.jobnameField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-group")]
- public string jobgroup
- {
- get { return this.jobgroupField; }
- set { this.jobgroupField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("start-time")]
- public System.DateTime starttime
- {
- get { return this.starttimeField; }
- set { this.starttimeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("end-time")]
- public System.DateTime endtime
- {
- get { return this.endtimeField; }
- set { this.endtimeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlIgnoreAttribute()]
- public bool endtimeSpecified
- {
- get { return this.endtimeFieldSpecified; }
- set { this.endtimeFieldSpecified = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("repeat-count", DataType = "integer")]
- public string repeatcount
- {
- get { return this.repeatcountField; }
- set { this.repeatcountField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("repeat-interval", DataType = "nonNegativeInteger")]
- public string repeatinterval
- {
- get { return this.repeatintervalField; }
- set { this.repeatintervalField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class triggerType
- {
- private abstractTriggerType itemField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("cron", typeof (cronType))]
- [System.Xml.Serialization.XmlElementAttribute("simple", typeof (simpleType))]
- public abstractTriggerType Item
- {
- get { return this.itemField; }
- set { this.itemField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "job-detailType",
- Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobdetailType
- {
- private string nameField;
-
- private string groupField;
-
- private string descriptionField;
-
- private string jobtypeField;
-
- private string joblistenerrefField;
-
- private bool volatileField;
-
- private bool durableField;
-
- private bool recoverField;
-
- private jobdatamapType jobdatamapField;
-
- public jobdetailType()
- {
- this.volatileField = false;
- this.durableField = false;
- this.recoverField = false;
- }
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
- }
-
- ///
- public string description
- {
- get { return this.descriptionField; }
- set { this.descriptionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-type")]
- public string jobtype
- {
- get { return this.jobtypeField; }
- set { this.jobtypeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-listener-ref")]
- public string joblistenerref
- {
- get { return this.joblistenerrefField; }
- set { this.joblistenerrefField = value; }
- }
-
- ///
- public bool @volatile
- {
- get { return this.volatileField; }
- set { this.volatileField = value; }
- }
-
- ///
- public bool durable
- {
- get { return this.durableField; }
- set { this.durableField = value; }
- }
-
- ///
- public bool recover
- {
- get { return this.recoverField; }
- set { this.recoverField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-data-map")]
- public jobdatamapType jobdatamap
- {
- get { return this.jobdatamapField; }
- set { this.jobdatamapField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobType
- {
- private jobdetailType jobdetailField;
-
- private triggerType[] triggerField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("job-detail")]
- public jobdetailType jobdetail
- {
- get { return this.jobdetailField; }
- set { this.jobdetailField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("trigger")]
- public triggerType[] trigger
- {
- get { return this.triggerField; }
- set { this.triggerField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class calendarType
- {
- private string nameField;
-
- private string descriptionField;
-
- private calendarType basecalendarField;
-
- private string typeField;
-
- private bool replaceField;
-
- public calendarType()
- {
- this.replaceField = false;
- }
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string description
- {
- get { return this.descriptionField; }
- set { this.descriptionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("base-calendar")]
- public calendarType basecalendar
- {
- get { return this.basecalendarField; }
- set { this.basecalendarField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string type
- {
- get { return this.typeField; }
- set { this.typeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- [System.ComponentModel.DefaultValueAttribute(false)]
- public bool replace
- {
- get { return this.replaceField; }
- set { this.replaceField = value; }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "trigger-listenerType",
- Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class triggerlistenerType
- {
- private string typeField;
-
- private string nameField;
-
- public triggerlistenerType()
- {
- this.nameField = "required";
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string type
- {
- get { return this.typeField; }
- set { this.typeField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- [System.ComponentModel.DefaultValueAttribute("required")]
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
- }
-}
diff --git a/src/Quartz/Xml/job_scheduling_data_1_0.xsd b/src/Quartz/Xml/job_scheduling_data_1_0.xsd
deleted file mode 100644
index 9ad727339..000000000
--- a/src/Quartz/Xml/job_scheduling_data_1_0.xsd
+++ /dev/null
@@ -1,418 +0,0 @@
-
-
-
-
- All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License"); you may not
- use this file except in compliance with the License. You may obtain a copy
- of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- License for the specific language governing permissions and limitations
- under the License.
-
-
-
-
-
-
- ...
-
-
- The instance documents may indicate the published version of
- the schema using the xsi:schemaLocation attribute for the Quartz
- namespace with the following location:
-
- http://quartznet.sourceforge.net/xml/job_scheduling_data.xsd
- ]]>
-
-
-
-
- Root level node
-
-
-
-
-
-
-
-
-
-
- Version of the XML Schema instance
-
-
-
-
- Whether the existing jobs will be overwritten.
-
-
-
-
-
-
- Define a Job Listener
-
-
-
- Job Listener type name
-
-
-
-
- logical name for listener
-
-
-
-
-
- Define a Trigger Listener
-
-
-
- Trigger Listener type name
-
-
-
-
- logical name for listener
-
-
-
-
-
- Define a Calendar
-
-
-
-
-
-
-
-
- Calendar type name
-
-
-
-
- Flag to replace existing calendar
-
-
-
-
-
- Define a Job
-
-
-
-
-
-
-
-
- Define a JobDetail
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the JobDetail or Trigger
-
-
-
-
- Group in which the JobDetail or Trigger resides
-
-
-
-
- Fully qualified name of the Job type
-
-
-
-
- logical name of the Job Listener
-
-
-
-
- logical name of the Triiger Listener
-
-
-
-
- Whether the Job is volatile
-
-
-
-
- Whether the Job is durable
-
-
-
-
- Whether the Job is recoverable
-
-
-
-
- Define a JobDataMap
-
-
-
-
-
-
-
- Define a JobDataMap entry
-
-
-
-
-
-
-
-
- Define a JobDataMap key
-
-
-
-
- Define a JobDataMap value
-
-
-
-
- Define a Trigger
-
-
-
-
-
-
-
-
- Common Trigger definitions
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Define a Trigger Misfire Instruction
-
-
-
-
-
-
-
-
-
-
-
-
-
- Define a Trigger Calendar name
-
-
-
-
- Define a SimpleTrigger
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the Job
-
-
-
-
- Group in which the Job resides
-
-
-
-
- Start time of the job
-
-
-
-
- End time of the job
-
-
-
-
- Number of times to repeat the Trigger (-1 for indefinite)
-
-
-
-
-
-
-
- Time interval (in milliseconds) at which the Trigger should repeat
-
-
-
-
- Define a CronTrigger
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Cron expression (see JavaDoc for examples)
-
- Special thanks to Chris Thatcher (thatcher@butterfly.net) for the regular expression!
-
- Regular expressions are not my strong point but I believe this is complete,
- with the caveat that order for expressions like 3-0 is not legal but will pass,
- and month and day names must be capitalized.
- If you want to examine the correctness look for the [\s] to denote the
- seperation of individual regular expressions. This is how I break them up visually
- to examine them:
-
- SECONDS:
- (
- ((([0-9] | [0-5][0-9]),)*([0-9]|[0-5][0-9]))
- | (([0-9]|[0-5][0-9])(/|-)([0-9]|[0-5][0-9]))
- | ([\?])
- | ([\*])
- ) [\s]
- MINUTES:
- (
- ((([0-9] | [0-5][0-9]),)*([0-9]|[0-5][0-9]))
- | (([0-9]|[0-5][0-9])(/|-)([0-9]|[0-5][0-9]))
- | ([\?])
- | ([\*])
- ) [\s]
- HOURS:
- (
- ((([0-9]|[0-1][0-9]|[2][0-3]),)*([0-9]|[0-1][0-9]|[2][0-3]))
- | (([0-9]|[0-1][0-9]|[2][0-3])(/|-)([0-9]|[0-1][0-9]|[2][0-3]))
- | ([\?])
- | ([\*])
- ) [\s]
- DAY OF MONTH:
- (
- ((([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1]),)*([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?)
- | (([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(/|-)([1-9]|[0][1-9]|[1-2][0-9]|[3][0-1])(C)?)
- | (L)
- | (LW)
- | ([1-9]W)
- | ([1-3][0-9]W)
- | ([\?])
- | ([\*])
- )[\s]
- MONTH:
- (
- ((([1-9]|0[1-9]|1[0-2]),)*([1-9]|0[1-9]|1[0-2]))
- | (([1-9]|0[1-9]|1[0-2])(/|-)([1-9]|0[1-9]|1[0-2]))
- | (((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC),)*(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))
- | ((JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(-|/)(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))
- | ([\?])
- | ([\*])
- )[\s]
- DAY OF WEEK:
- (
- (([1-7],)*([1-7]))
- | ([1-7](/|-)([1-7]))
- | (((MON|TUE|WED|THU|FRI|SAT|SUN),)*(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?)
- | ((MON|TUE|WED|THU|FRI|SAT|SUN)(-|/)(MON|TUE|WED|THU|FRI|SAT|SUN)(C)?)
- | (([1-7]|(MON|TUE|WED|THU|FRI|SAT|SUN))(L|LW)?)
- | ([1-7]#([1-7])?)
- | ((MON|TUE|WED|THU|FRI|SAT|SUN)#([1-7])?)
- | ([\?])
- | ([\*])
- )
- YEAR (OPTIONAL):
- ([\s]19[7-9][0-9]|20[0-9]{2})?
-
-
-
-
-
-
-
-
- Valid Timezone ID
-
-
-
diff --git a/src/Quartz/Xml/job_scheduling_data_2_0.cs b/src/Quartz/Xml/job_scheduling_data_2_0.cs
index c5dd2a227..5b60e1eb9 100644
--- a/src/Quartz/Xml/job_scheduling_data_2_0.cs
+++ b/src/Quartz/Xml/job_scheduling_data_2_0.cs
@@ -11,595 +11,745 @@
//
// This source code was auto-generated by xsd, Version=4.0.30319.1.
//
-namespace Quartz.Xml.JobSchedulingData20
-{
+namespace Quartz.Xml.JobSchedulingData20 {
using System.Xml.Serialization;
-
-
+
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- [System.Xml.Serialization.XmlRootAttribute("job-scheduling-data", Namespace = "http://quartznet.sourceforge.net/JobSchedulingData", IsNullable = false)]
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ [System.Xml.Serialization.XmlRootAttribute("job-scheduling-data", Namespace="http://quartznet.sourceforge.net/JobSchedulingData", IsNullable=false)]
public partial class QuartzXmlConfiguration20
{
+
private preprocessingcommandsType[] preprocessingcommandsField;
-
+
private processingdirectivesType[] processingdirectivesField;
-
+
private jobschedulingdataSchedule[] scheduleField;
-
+
private string versionField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("pre-processing-commands")]
- public preprocessingcommandsType[] preprocessingcommands
- {
- get { return this.preprocessingcommandsField; }
- set { this.preprocessingcommandsField = value; }
+ public preprocessingcommandsType[] preprocessingcommands {
+ get {
+ return this.preprocessingcommandsField;
+ }
+ set {
+ this.preprocessingcommandsField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("processing-directives")]
- public processingdirectivesType[] processingdirectives
- {
- get { return this.processingdirectivesField; }
- set { this.processingdirectivesField = value; }
+ public processingdirectivesType[] processingdirectives {
+ get {
+ return this.processingdirectivesField;
+ }
+ set {
+ this.processingdirectivesField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("schedule")]
- public jobschedulingdataSchedule[] schedule
- {
- get { return this.scheduleField; }
- set { this.scheduleField = value; }
+ public jobschedulingdataSchedule[] schedule {
+ get {
+ return this.scheduleField;
+ }
+ set {
+ this.scheduleField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlAttributeAttribute()]
- public string version
- {
- get { return this.versionField; }
- set { this.versionField = value; }
+ public string version {
+ get {
+ return this.versionField;
+ }
+ set {
+ this.versionField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "pre-processing-commandsType", Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class preprocessingcommandsType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(TypeName="pre-processing-commandsType", Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class preprocessingcommandsType {
+
private string[] deletejobsingroupField;
-
+
private string[] deletetriggersingroupField;
-
+
private preprocessingcommandsTypeDeletejob[] deletejobField;
-
+
private preprocessingcommandsTypeDeletetrigger[] deletetriggerField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("delete-jobs-in-group")]
- public string[] deletejobsingroup
- {
- get { return this.deletejobsingroupField; }
- set { this.deletejobsingroupField = value; }
+ public string[] deletejobsingroup {
+ get {
+ return this.deletejobsingroupField;
+ }
+ set {
+ this.deletejobsingroupField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("delete-triggers-in-group")]
- public string[] deletetriggersingroup
- {
- get { return this.deletetriggersingroupField; }
- set { this.deletetriggersingroupField = value; }
+ public string[] deletetriggersingroup {
+ get {
+ return this.deletetriggersingroupField;
+ }
+ set {
+ this.deletetriggersingroupField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("delete-job")]
- public preprocessingcommandsTypeDeletejob[] deletejob
- {
- get { return this.deletejobField; }
- set { this.deletejobField = value; }
+ public preprocessingcommandsTypeDeletejob[] deletejob {
+ get {
+ return this.deletejobField;
+ }
+ set {
+ this.deletejobField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("delete-trigger")]
- public preprocessingcommandsTypeDeletetrigger[] deletetrigger
- {
- get { return this.deletetriggerField; }
- set { this.deletetriggerField = value; }
+ public preprocessingcommandsTypeDeletetrigger[] deletetrigger {
+ get {
+ return this.deletetriggerField;
+ }
+ set {
+ this.deletetriggerField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class preprocessingcommandsTypeDeletejob
- {
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class preprocessingcommandsTypeDeletejob {
+
private string nameField;
-
+
private string groupField;
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
+
+ ///
+ public string name {
+ get {
+ return this.nameField;
+ }
+ set {
+ this.nameField = value;
+ }
+ }
+
+ ///
+ public string group {
+ get {
+ return this.groupField;
+ }
+ set {
+ this.groupField = value;
+ }
}
}
-
+
///
- [System.Xml.Serialization.XmlIncludeAttribute(typeof (calendarIntervalTriggerType))]
- [System.Xml.Serialization.XmlIncludeAttribute(typeof (cronTriggerType))]
- [System.Xml.Serialization.XmlIncludeAttribute(typeof (simpleTriggerType))]
+ [System.Xml.Serialization.XmlIncludeAttribute(typeof(calendarIntervalTriggerType))]
+ [System.Xml.Serialization.XmlIncludeAttribute(typeof(cronTriggerType))]
+ [System.Xml.Serialization.XmlIncludeAttribute(typeof(simpleTriggerType))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public abstract partial class abstractTriggerType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public abstract partial class abstractTriggerType {
+
private string nameField;
-
+
private string groupField;
-
+
private string descriptionField;
-
+
private string jobnameField;
-
+
private string jobgroupField;
-
+
+ private string priorityField;
+
private string calendarnameField;
-
+
private jobdatamapType jobdatamapField;
-
+
private object itemField;
-
+
private System.DateTime endtimeField;
-
+
private bool endtimeFieldSpecified;
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
- }
-
- ///
- public string description
- {
- get { return this.descriptionField; }
- set { this.descriptionField = value; }
- }
-
+
+ ///
+ public string name {
+ get {
+ return this.nameField;
+ }
+ set {
+ this.nameField = value;
+ }
+ }
+
+ ///
+ public string group {
+ get {
+ return this.groupField;
+ }
+ set {
+ this.groupField = value;
+ }
+ }
+
+ ///
+ public string description {
+ get {
+ return this.descriptionField;
+ }
+ set {
+ this.descriptionField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("job-name")]
- public string jobname
- {
- get { return this.jobnameField; }
- set { this.jobnameField = value; }
+ public string jobname {
+ get {
+ return this.jobnameField;
+ }
+ set {
+ this.jobnameField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("job-group")]
- public string jobgroup
- {
- get { return this.jobgroupField; }
- set { this.jobgroupField = value; }
- }
-
+ public string jobgroup {
+ get {
+ return this.jobgroupField;
+ }
+ set {
+ this.jobgroupField = value;
+ }
+ }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
+ public string priority {
+ get {
+ return this.priorityField;
+ }
+ set {
+ this.priorityField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("calendar-name")]
- public string calendarname
- {
- get { return this.calendarnameField; }
- set { this.calendarnameField = value; }
+ public string calendarname {
+ get {
+ return this.calendarnameField;
+ }
+ set {
+ this.calendarnameField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("job-data-map")]
- public jobdatamapType jobdatamap
- {
- get { return this.jobdatamapField; }
- set { this.jobdatamapField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("start-time", typeof (System.DateTime))]
- [System.Xml.Serialization.XmlElementAttribute("start-time-seconds-in-future", typeof (string), DataType = "nonNegativeInteger")]
- public object Item
- {
- get { return this.itemField; }
- set { this.itemField = value; }
- }
-
+ public jobdatamapType jobdatamap {
+ get {
+ return this.jobdatamapField;
+ }
+ set {
+ this.jobdatamapField = value;
+ }
+ }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute("start-time", typeof(System.DateTime))]
+ [System.Xml.Serialization.XmlElementAttribute("start-time-seconds-in-future", typeof(string), DataType="nonNegativeInteger")]
+ public object Item {
+ get {
+ return this.itemField;
+ }
+ set {
+ this.itemField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("end-time")]
- public System.DateTime endtime
- {
- get { return this.endtimeField; }
- set { this.endtimeField = value; }
+ public System.DateTime endtime {
+ get {
+ return this.endtimeField;
+ }
+ set {
+ this.endtimeField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlIgnoreAttribute()]
- public bool endtimeSpecified
- {
- get { return this.endtimeFieldSpecified; }
- set { this.endtimeFieldSpecified = value; }
+ public bool endtimeSpecified {
+ get {
+ return this.endtimeFieldSpecified;
+ }
+ set {
+ this.endtimeFieldSpecified = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "job-data-mapType", Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobdatamapType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(TypeName="job-data-mapType", Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class jobdatamapType {
+
private entryType[] entryField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("entry")]
- public entryType[] entry
- {
- get { return this.entryField; }
- set { this.entryField = value; }
+ public entryType[] entry {
+ get {
+ return this.entryField;
+ }
+ set {
+ this.entryField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class entryType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class entryType {
+
private string keyField;
-
+
private string valueField;
-
- ///
- public string key
- {
- get { return this.keyField; }
- set { this.keyField = value; }
- }
-
- ///
- public string value
- {
- get { return this.valueField; }
- set { this.valueField = value; }
+
+ ///
+ public string key {
+ get {
+ return this.keyField;
+ }
+ set {
+ this.keyField = value;
+ }
+ }
+
+ ///
+ public string value {
+ get {
+ return this.valueField;
+ }
+ set {
+ this.valueField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class calendarIntervalTriggerType : abstractTriggerType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class calendarIntervalTriggerType : abstractTriggerType {
+
private string misfireinstructionField;
-
+
private string repeatintervalField;
-
+
private string repeatintervalunitField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("misfire-instruction")]
- public string misfireinstruction
- {
- get { return this.misfireinstructionField; }
- set { this.misfireinstructionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("repeat-interval", DataType = "nonNegativeInteger")]
- public string repeatinterval
- {
- get { return this.repeatintervalField; }
- set { this.repeatintervalField = value; }
- }
-
+ public string misfireinstruction {
+ get {
+ return this.misfireinstructionField;
+ }
+ set {
+ this.misfireinstructionField = value;
+ }
+ }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute("repeat-interval", DataType="nonNegativeInteger")]
+ public string repeatinterval {
+ get {
+ return this.repeatintervalField;
+ }
+ set {
+ this.repeatintervalField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("repeat-interval-unit")]
- public string repeatintervalunit
- {
- get { return this.repeatintervalunitField; }
- set { this.repeatintervalunitField = value; }
+ public string repeatintervalunit {
+ get {
+ return this.repeatintervalunitField;
+ }
+ set {
+ this.repeatintervalunitField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class cronTriggerType : abstractTriggerType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class cronTriggerType : abstractTriggerType {
+
private string misfireinstructionField;
-
+
private string cronexpressionField;
-
+
private string timezoneField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("misfire-instruction")]
- public string misfireinstruction
- {
- get { return this.misfireinstructionField; }
- set { this.misfireinstructionField = value; }
+ public string misfireinstruction {
+ get {
+ return this.misfireinstructionField;
+ }
+ set {
+ this.misfireinstructionField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("cron-expression")]
- public string cronexpression
- {
- get { return this.cronexpressionField; }
- set { this.cronexpressionField = value; }
+ public string cronexpression {
+ get {
+ return this.cronexpressionField;
+ }
+ set {
+ this.cronexpressionField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("time-zone")]
- public string timezone
- {
- get { return this.timezoneField; }
- set { this.timezoneField = value; }
+ public string timezone {
+ get {
+ return this.timezoneField;
+ }
+ set {
+ this.timezoneField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class simpleTriggerType : abstractTriggerType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class simpleTriggerType : abstractTriggerType {
+
private string misfireinstructionField;
-
+
private string repeatcountField;
-
+
private string repeatintervalField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("misfire-instruction")]
- public string misfireinstruction
- {
- get { return this.misfireinstructionField; }
- set { this.misfireinstructionField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("repeat-count", DataType = "integer")]
- public string repeatcount
- {
- get { return this.repeatcountField; }
- set { this.repeatcountField = value; }
- }
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("repeat-interval", DataType = "nonNegativeInteger")]
- public string repeatinterval
- {
- get { return this.repeatintervalField; }
- set { this.repeatintervalField = value; }
+ public string misfireinstruction {
+ get {
+ return this.misfireinstructionField;
+ }
+ set {
+ this.misfireinstructionField = value;
+ }
+ }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute("repeat-count", DataType="integer")]
+ public string repeatcount {
+ get {
+ return this.repeatcountField;
+ }
+ set {
+ this.repeatcountField = value;
+ }
+ }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute("repeat-interval", DataType="nonNegativeInteger")]
+ public string repeatinterval {
+ get {
+ return this.repeatintervalField;
+ }
+ set {
+ this.repeatintervalField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class triggerType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class triggerType {
+
private abstractTriggerType itemField;
-
- ///
- [System.Xml.Serialization.XmlElementAttribute("calendar-interval", typeof (calendarIntervalTriggerType))]
- [System.Xml.Serialization.XmlElementAttribute("cron", typeof (cronTriggerType))]
- [System.Xml.Serialization.XmlElementAttribute("simple", typeof (simpleTriggerType))]
- public abstractTriggerType Item
- {
- get { return this.itemField; }
- set { this.itemField = value; }
+
+ ///
+ [System.Xml.Serialization.XmlElementAttribute("calendar-interval", typeof(calendarIntervalTriggerType))]
+ [System.Xml.Serialization.XmlElementAttribute("cron", typeof(cronTriggerType))]
+ [System.Xml.Serialization.XmlElementAttribute("simple", typeof(simpleTriggerType))]
+ public abstractTriggerType Item {
+ get {
+ return this.itemField;
+ }
+ set {
+ this.itemField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "job-detailType", Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobdetailType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(TypeName="job-detailType", Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class jobdetailType {
+
private string nameField;
-
+
private string groupField;
-
+
private string descriptionField;
-
+
private string jobtypeField;
-
+
private bool durableField;
-
+
private bool recoverField;
-
+
private jobdatamapType jobdatamapField;
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
- }
-
- ///
- public string description
- {
- get { return this.descriptionField; }
- set { this.descriptionField = value; }
- }
-
+
+ ///
+ public string name {
+ get {
+ return this.nameField;
+ }
+ set {
+ this.nameField = value;
+ }
+ }
+
+ ///
+ public string group {
+ get {
+ return this.groupField;
+ }
+ set {
+ this.groupField = value;
+ }
+ }
+
+ ///
+ public string description {
+ get {
+ return this.descriptionField;
+ }
+ set {
+ this.descriptionField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("job-type")]
- public string jobtype
- {
- get { return this.jobtypeField; }
- set { this.jobtypeField = value; }
- }
-
- ///
- public bool durable
- {
- get { return this.durableField; }
- set { this.durableField = value; }
- }
-
- ///
- public bool recover
- {
- get { return this.recoverField; }
- set { this.recoverField = value; }
- }
-
+ public string jobtype {
+ get {
+ return this.jobtypeField;
+ }
+ set {
+ this.jobtypeField = value;
+ }
+ }
+
+ ///
+ public bool durable {
+ get {
+ return this.durableField;
+ }
+ set {
+ this.durableField = value;
+ }
+ }
+
+ ///
+ public bool recover {
+ get {
+ return this.recoverField;
+ }
+ set {
+ this.recoverField = value;
+ }
+ }
+
///
[System.Xml.Serialization.XmlElementAttribute("job-data-map")]
- public jobdatamapType jobdatamap
- {
- get { return this.jobdatamapField; }
- set { this.jobdatamapField = value; }
+ public jobdatamapType jobdatamap {
+ get {
+ return this.jobdatamapField;
+ }
+ set {
+ this.jobdatamapField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(TypeName = "processing-directivesType", Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class processingdirectivesType
- {
+ [System.Xml.Serialization.XmlTypeAttribute(TypeName="processing-directivesType", Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class processingdirectivesType {
+
private bool overwriteexistingdataField;
-
+
private bool ignoreduplicatesField;
-
- public processingdirectivesType()
- {
+
+ public processingdirectivesType() {
this.overwriteexistingdataField = true;
this.ignoreduplicatesField = false;
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("overwrite-existing-data")]
[System.ComponentModel.DefaultValueAttribute(true)]
- public bool overwriteexistingdata
- {
- get { return this.overwriteexistingdataField; }
- set { this.overwriteexistingdataField = value; }
+ public bool overwriteexistingdata {
+ get {
+ return this.overwriteexistingdataField;
+ }
+ set {
+ this.overwriteexistingdataField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("ignore-duplicates")]
[System.ComponentModel.DefaultValueAttribute(false)]
- public bool ignoreduplicates
- {
- get { return this.ignoreduplicatesField; }
- set { this.ignoreduplicatesField = value; }
+ public bool ignoreduplicates {
+ get {
+ return this.ignoreduplicatesField;
+ }
+ set {
+ this.ignoreduplicatesField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class preprocessingcommandsTypeDeletetrigger
- {
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class preprocessingcommandsTypeDeletetrigger {
+
private string nameField;
-
+
private string groupField;
-
- ///
- public string name
- {
- get { return this.nameField; }
- set { this.nameField = value; }
- }
-
- ///
- public string group
- {
- get { return this.groupField; }
- set { this.groupField = value; }
+
+ ///
+ public string name {
+ get {
+ return this.nameField;
+ }
+ set {
+ this.nameField = value;
+ }
+ }
+
+ ///
+ public string group {
+ get {
+ return this.groupField;
+ }
+ set {
+ this.groupField = value;
+ }
}
}
-
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://quartznet.sourceforge.net/JobSchedulingData")]
- public partial class jobschedulingdataSchedule
- {
+ [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://quartznet.sourceforge.net/JobSchedulingData")]
+ public partial class jobschedulingdataSchedule {
+
private jobdetailType[] jobField;
-
+
private triggerType[] triggerField;
-
+
///
[System.Xml.Serialization.XmlElementAttribute("job")]
- public jobdetailType[] job
- {
- get { return this.jobField; }
- set { this.jobField = value; }
+ public jobdetailType[] job {
+ get {
+ return this.jobField;
+ }
+ set {
+ this.jobField = value;
+ }
}
-
+
///
[System.Xml.Serialization.XmlElementAttribute("trigger")]
- public triggerType[] trigger
- {
- get { return this.triggerField; }
- set { this.triggerField = value; }
+ public triggerType[] trigger {
+ get {
+ return this.triggerField;
+ }
+ set {
+ this.triggerField = value;
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Quartz/Xml/job_scheduling_data_2_0.xsd b/src/Quartz/Xml/job_scheduling_data_2_0.xsd
index f160f2701..a6884c6da 100644
--- a/src/Quartz/Xml/job_scheduling_data_2_0.xsd
+++ b/src/Quartz/Xml/job_scheduling_data_2_0.xsd
@@ -147,6 +147,7 @@
+