From 50198bf8b80570cd96a814c286971f1b8fcc2627 Mon Sep 17 00:00:00 2001
From: Marko Lahma
Date: Sun, 13 May 2012 11:13:45 +0300
Subject: [PATCH] Cleaning Quartz.NET integration, removing #ifs as now only
Quartz.NET 2.0 supported
---
.../solutions/Spring.Net.Quartz.2008.sln | 39 ---
.../Scheduling/Quartz/AdaptableJobFactory.cs | 33 +-
.../Scheduling/Quartz/CronTriggerObject.cs | 9 +-
.../Scheduling/Quartz/DelegatingJob.cs | 10 +-
.../Quartz/IJobDetailAwareTrigger.cs | 8 +-
.../Scheduling/Quartz/MethodInvokingJob.cs | 8 +-
.../Scheduling/Quartz/QuartzJobObject.cs | 12 +-
.../Quartz/SchedulerFactoryObject.cs | 10 -
.../Scheduling/Quartz/SimpleTriggerObject.cs | 11 +-
.../Quartz/SpringDbProviderAdapter.cs | 1 -
.../Spring.Scheduling.Quartz20.2008.csproj | 4 +-
.../Spring.Scheduling.Quartz20.2010.csproj | 2 +-
...ing.Quartz20.Integration.Tests.2008.csproj | 12 +-
.../Quartz/AdaptableJobFactoryTest.cs | 11 +-
.../Quartz/CronTriggerObjectTest.cs | 11 +-
...ethodInvokingJobDetailFactoryObjectTest.cs | 28 +-
.../Quartz/MethodInvokingJobTest.cs | 20 +-
.../Scheduling/Quartz/QuartzSupportTests.cs | 292 ++++--------------
.../Quartz/SchedulerFactoryObjectTest.cs | 57 +---
.../Quartz/SimpleTriggerObjectTest.cs | 16 +-
.../Quartz/SpringObjectJobFactoryTest.cs | 31 +-
.../Scheduling/Quartz/TestUtil.cs | 10 +-
.../Scheduling/Quartz/TriggerObjectTest.cs | 59 +---
...ring.Scheduling.Quartz20.Tests.2008.csproj | 4 +-
...ring.Scheduling.Quartz20.Tests.2010.csproj | 2 +-
25 files changed, 118 insertions(+), 582 deletions(-)
diff --git a/build-support/solutions/Spring.Net.Quartz.2008.sln b/build-support/solutions/Spring.Net.Quartz.2008.sln
index 709b7e5e..5243da89 100644
--- a/build-support/solutions/Spring.Net.Quartz.2008.sln
+++ b/build-support/solutions/Spring.Net.Quartz.2008.sln
@@ -15,12 +15,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Aop.2008", "..\..\sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.2008", "..\..\src\Spring\Spring.Data\Spring.Data.2008.csproj", "{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Scheduling.Quartz.2008", "..\..\src\Spring\Spring.Scheduling.Quartz\Spring.Scheduling.Quartz.2008.csproj", "{E823D54C-CE82-4868-929F-5F95A999F61E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Scheduling.Quartz.Tests.2008", "..\..\test\Spring\Spring.Scheduling.Quartz.Tests\Spring.Scheduling.Quartz.Tests.2008.csproj", "{9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Scheduling.Quartz.Integration.Tests.2008", "..\..\test\Spring\Spring.Scheduling.Quartz.Integration.Tests\Spring.Scheduling.Quartz.Integration.Tests.2008.csproj", "{E4328F68-C3FC-43E2-9D63-30CEC55215B0}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Tests.2008", "..\..\test\Spring\Spring.Core.Tests\Spring.Core.Tests.2008.csproj", "{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Scheduling.Quartz20.Integration.Tests.2008", "..\..\test\Spring\Spring.Scheduling.Quartz20.Integration.Tests\Spring.Scheduling.Quartz20.Integration.Tests.2008.csproj", "{8CF0F34A-CC93-4D87-AE14-A2DEEF072F26}"
@@ -75,36 +69,6 @@ Global
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Debug|.NET.ActiveCfg = Debug|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Release|.NET.ActiveCfg = Release|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Release|Any CPU.Build.0 = Release|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {E823D54C-CE82-4868-929F-5F95A999F61E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Debug|.NET.ActiveCfg = Debug|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Release|.NET.ActiveCfg = Release|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Release|Any CPU.Build.0 = Release|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Debug|.NET.ActiveCfg = Debug|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Release|.NET.ActiveCfg = Release|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Release|Any CPU.Build.0 = Release|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|.NET.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.Build.0 = Debug|Any CPU
@@ -153,10 +117,7 @@ Global
{710961A3-0DF4-49E4-A26E-F5B9C044AC84} = {438FE108-6F55-4C8A-8BF4-C85D0906D134}
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C} = {438FE108-6F55-4C8A-8BF4-C85D0906D134}
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40} = {438FE108-6F55-4C8A-8BF4-C85D0906D134}
- {E823D54C-CE82-4868-929F-5F95A999F61E} = {438FE108-6F55-4C8A-8BF4-C85D0906D134}
{764C3A6A-8690-49DD-B9AF-99E7C09AE4F0} = {438FE108-6F55-4C8A-8BF4-C85D0906D134}
- {9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5} = {5ECE7B2B-6975-4800-982E-618794909499}
- {E4328F68-C3FC-43E2-9D63-30CEC55215B0} = {5ECE7B2B-6975-4800-982E-618794909499}
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904} = {5ECE7B2B-6975-4800-982E-618794909499}
{8CF0F34A-CC93-4D87-AE14-A2DEEF072F26} = {5ECE7B2B-6975-4800-982E-618794909499}
{47E7DF97-2515-4F2F-BBFD-0A4C205800DE} = {5ECE7B2B-6975-4800-982E-618794909499}
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/AdaptableJobFactory.cs b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/AdaptableJobFactory.cs
index 983efa40..2435e16a 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/AdaptableJobFactory.cs
+++ b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/AdaptableJobFactory.cs
@@ -20,12 +20,6 @@ using Quartz;
using Quartz.Spi;
using Quartz.Util;
-#if QUARTZ_2_0
-using JobDetail = Quartz.IJobDetail;
-#else
-using JobDetail = Quartz.JobDetail;
-#endif
-
namespace Spring.Scheduling.Quartz
{
///
@@ -38,7 +32,6 @@ namespace Spring.Scheduling.Quartz
///
public class AdaptableJobFactory : IJobFactory
{
-#if QUARTZ_2_0
///
/// Called by the scheduler at the time of the trigger firing, in order to
/// produce a instance on which to call Execute.
@@ -52,32 +45,12 @@ namespace Spring.Scheduling.Quartz
/// intervention (e.g. an application restart after fixing whatever
/// configuration problem led to the issue wih instantiating the Job.
///
- /// The TriggerFiredBundle from which the
+ /// The TriggerFiredBundle from which the
/// and other info relating to the trigger firing can be obtained.
/// The scheduler instance.
/// the newly instantiated Job
/// SchedulerException if there is a problem instantiating the Job.
public virtual IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
-#else
- ///
- /// Called by the scheduler at the time of the trigger firing, in order to
- /// produce a instance on which to call Execute.
- ///
- ///
- /// It should be extremely rare for this method to throw an exception -
- /// basically only the the case where there is no way at all to instantiate
- /// and prepare the Job for execution. When the exception is thrown, the
- /// Scheduler will move all triggers associated with the Job into the
- /// state, which will require human
- /// intervention (e.g. an application restart after fixing whatever
- /// configuration problem led to the issue wih instantiating the Job.
- ///
- /// The TriggerFiredBundle from which the
- /// and other info relating to the trigger firing can be obtained.
- /// the newly instantiated Job
- /// SchedulerException if there is a problem instantiating the Job.
- public virtual IJob NewJob(TriggerFiredBundle bundle)
-#endif
{
try
{
@@ -103,11 +76,7 @@ namespace Spring.Scheduling.Quartz
/// The job instance.
protected virtual object CreateJobInstance(TriggerFiredBundle bundle)
{
-#if QUARTZ_2_0
return ObjectUtils.InstantiateType
///
/// Juergen Hoeller
- ///
+ ///
///
///
///
@@ -62,7 +56,7 @@ namespace Spring.Scheduling.Quartz
/// values, and delegates to ExecuteInternal afterwards.
///
///
- public void Execute(JobExecutionContext context)
+ public void Execute(IJobExecutionContext context)
{
try
{
@@ -85,6 +79,6 @@ namespace Spring.Scheduling.Quartz
/// exactly the same as for the standard Quartz execute method.
///
///
- protected abstract void ExecuteInternal(JobExecutionContext context);
+ protected abstract void ExecuteInternal(IJobExecutionContext context);
}
}
\ No newline at end of file
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SchedulerFactoryObject.cs b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SchedulerFactoryObject.cs
index 96742dbe..8f3b2d9f 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SchedulerFactoryObject.cs
+++ b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SchedulerFactoryObject.cs
@@ -18,9 +18,7 @@ using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
-#if QUARTZ_2_0
using System.Linq;
-#endif
using Quartz;
using Quartz.Impl;
@@ -569,11 +567,7 @@ namespace Spring.Scheduling.Quartz
public virtual void AfterPropertiesSet()
{
// Create SchedulerFactory instance.
-#if QUARTZ_2_0
ISchedulerFactory schedulerFactory = ObjectUtils.InstantiateType(schedulerFactoryType);
-#else
- ISchedulerFactory schedulerFactory = (ISchedulerFactory) ObjectUtils.InstantiateType(schedulerFactoryType);
-#endif
InitSchedulerFactory(schedulerFactory);
@@ -762,12 +756,8 @@ namespace Spring.Scheduling.Quartz
// Put specified objects into Scheduler context.
if (schedulerContextMap != null)
{
-#if QUARTZ_2_0
var dictionary = schedulerContextMap.Cast().ToDictionary(entry => entry.Key.ToString(), entry => entry.Value);
scheduler.Context.PutAll(dictionary);
-#else
- scheduler.Context.PutAll(schedulerContextMap);
-#endif
}
// Register IApplicationContext in Scheduler context.
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SimpleTriggerObject.cs b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SimpleTriggerObject.cs
index cf171961..9c78fcab 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SimpleTriggerObject.cs
+++ b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SimpleTriggerObject.cs
@@ -15,8 +15,10 @@
*/
using System;
using System.Collections;
+
using Quartz;
using Quartz.Impl.Triggers;
+
using Spring.Objects.Factory;
using Spring.Util;
@@ -115,7 +117,7 @@ namespace Spring.Scheduling.Quartz
{
set
{
- AssertUtils.State(value > TimeSpan.Zero, "Start delay cannot be negative.");
+ AssertUtils.State(value >= TimeSpan.Zero, "Start delay cannot be negative.");
startDelay = value;
}
get { return startDelay; }
@@ -181,17 +183,10 @@ namespace Spring.Scheduling.Quartz
///
public virtual void AfterPropertiesSet()
{
-#if QUARTZ_2_0
if (StartTimeUtc == DateTimeOffset.MinValue)
{
StartTimeUtc = DateTimeOffset.UtcNow;
}
-#else
- if (StartTimeUtc == DateTime.MinValue)
- {
- StartTimeUtc = DateTime.UtcNow;
- }
-#endif
if (StartDelay > TimeSpan.Zero)
{
StartTimeUtc = DateTime.UtcNow.Add(startDelay);
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SpringDbProviderAdapter.cs b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SpringDbProviderAdapter.cs
index e83a3887..9b00be13 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SpringDbProviderAdapter.cs
+++ b/src/Spring/Spring.Scheduling.Quartz20/Scheduling/Quartz/SpringDbProviderAdapter.cs
@@ -18,7 +18,6 @@ using System;
using System.Data;
using System.Reflection;
-using Quartz.Impl.AdoJobStore;
using Quartz.Impl.AdoJobStore.Common;
using IDbMetadata=Spring.Data.Common.IDbMetadata;
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2008.csproj b/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2008.csproj
index 789484aa..2acc8a5e 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2008.csproj
+++ b/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2008.csproj
@@ -16,7 +16,7 @@
fullfalse..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz20\Debug\
- TRACE;DEBUG;NET_2_0,NET_3_0,NET_3_5,QUARTZ_2_0
+ TRACE;DEBUGprompt4..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz\Debug\Spring.Scheduling.Quartz20.XML
@@ -26,7 +26,7 @@
pdbonlytrue..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz20\Release\
- TRACE;NET_2_0,QUARTZ_2_0
+ TRACEprompt4
diff --git a/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2010.csproj b/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2010.csproj
index d0595f83..00191e50 100644
--- a/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2010.csproj
+++ b/src/Spring/Spring.Scheduling.Quartz20/Spring.Scheduling.Quartz20.2010.csproj
@@ -22,7 +22,7 @@
fullfalse..\..\..\build\VS.NET.2010\Spring.Scheduling.Quartz20\Debug\
- TRACE;DEBUG;NET_4_0,QUARTZ_2_0
+ TRACE;DEBUG;NET_4_0prompt4..\..\..\build\VS.NET.2010\Spring.Scheduling.Quartz20\Debug\Spring.Scheduling.Quartz20.XML
diff --git a/test/Spring/Spring.Scheduling.Quartz20.Integration.Tests/Spring.Scheduling.Quartz20.Integration.Tests.2008.csproj b/test/Spring/Spring.Scheduling.Quartz20.Integration.Tests/Spring.Scheduling.Quartz20.Integration.Tests.2008.csproj
index 51a816f6..76854fa3 100644
--- a/test/Spring/Spring.Scheduling.Quartz20.Integration.Tests/Spring.Scheduling.Quartz20.Integration.Tests.2008.csproj
+++ b/test/Spring/Spring.Scheduling.Quartz20.Integration.Tests/Spring.Scheduling.Quartz20.Integration.Tests.2008.csproj
@@ -16,7 +16,7 @@
fullfalse..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz20.Integration.Tests\Debug\
- TRACE;DEBUG;NET_2_0;NET_3_5
+ TRACE;DEBUGprompt4
@@ -24,7 +24,7 @@
pdbonlytrue..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz20.Integration.Tests\Release\
- TRACE;NET_2_0;NET_3_5
+ TRACEprompt4
@@ -69,6 +69,14 @@
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}Spring.Core.2008
+
+ {AE00E5AB-C39A-436F-86D2-33BFE33E2E40}
+ Spring.Data.2008
+
+
+ {764C3A6A-8690-49DD-B9AF-99E7C09AE4F0}
+ Spring.Scheduling.Quartz20.2008
+