Changing startup delay properties to be time spans instead of plain integers

This commit is contained in:
lahma
2008-08-04 18:43:39 +00:00
parent f58951caa0
commit 651ab8ef8c
8 changed files with 144 additions and 30 deletions

View File

@@ -0,0 +1,115 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F04753EF-7A1B-4837-AB63-8C0821E8155D}"
ProjectSection(SolutionItems) = preProject
Spring.build = Spring.build
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{438FE108-6F55-4C8A-8BF4-C85D0906D134}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5ECE7B2B-6975-4800-982E-618794909499}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.2008", "..\..\src\Spring\Spring.Core\Spring.Core.2008.csproj", "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Aop.2008", "..\..\src\Spring\Spring.Aop\Spring.Aop.2008.csproj", "{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}"
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Release|.NET = Release|.NET
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|.NET.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|.NET.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|.NET.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|.NET.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Any CPU.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|.NET.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|.NET.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|.NET.ActiveCfg = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|.NET.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{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}
{9FE720ED-2BD9-4FB9-89C8-FFFA4A491CB5} = {5ECE7B2B-6975-4800-982E-618794909499}
{E4328F68-C3FC-43E2-9D63-30CEC55215B0} = {5ECE7B2B-6975-4800-982E-618794909499}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
NAntAddinLastFileName = Spring.build
EndGlobalSection
EndGlobal

View File

@@ -151,7 +151,7 @@ namespace Spring.Scheduling.Quartz
private Type schedulerFactoryType;
private ISchedulerListener[] schedulerListeners;
private string schedulerName;
private int startupDelay;
private TimeSpan startupDelay = TimeSpan.Zero;
private ITaskExecutor taskExecutor;
private ITriggerListener[] triggerListeners;
private ArrayList triggers;
@@ -480,7 +480,7 @@ namespace Spring.Scheduling.Quartz
}
/// <summary>
/// Set the number of seconds to wait after initialization before
/// Set the time span to wait after initialization before
/// starting the scheduler asynchronously. Default is 0, meaning
/// immediate synchronous startup on initialization of this object.
/// </summary>
@@ -488,7 +488,7 @@ namespace Spring.Scheduling.Quartz
/// Setting this to 10 or 20 seconds makes sense if no jobs
/// should be run before the entire application has started up.
/// </remarks>
public virtual int StartupDelay
public virtual TimeSpan StartupDelay
{
set { startupDelay = value; }
}
@@ -1101,11 +1101,11 @@ namespace Spring.Scheduling.Quartz
/// Start the Quartz Scheduler, respecting the "startDelay" setting.
/// </summary>
/// <param name="sched">the Scheduler to start</param>
/// <param name="startDelay">the number of seconds to wait before starting
/// <param name="startDelay">the time span to wait before starting
/// the Scheduler asynchronously</param>
protected virtual void StartScheduler(IScheduler sched, int startDelay)
protected virtual void StartScheduler(IScheduler sched, TimeSpan startDelay)
{
if (startDelay <= 0)
if (startDelay.TotalSeconds <= 0)
{
logger.Info("Starting Quartz Scheduler now");
sched.Start();
@@ -1118,7 +1118,7 @@ namespace Spring.Scheduling.Quartz
string.Format("Will start Quartz Scheduler [{0}] in {1} seconds", sched.SchedulerName,
startDelay));
}
sched.StartDelayed(startDelay);
sched.StartDelayed((int) startDelay.TotalSeconds);
}
}

View File

@@ -51,7 +51,7 @@ namespace Spring.Scheduling.Quartz
/// <seealso cref="CronTriggerObject" />
public class SimpleTriggerObject : SimpleTrigger, IJobDetailAwareTrigger, IObjectNameAware, IInitializingObject
{
private long startDelay;
private TimeSpan startDelay = TimeSpan.Zero;
private JobDetail jobDetail;
private string objectName;
private readonly Constants constants = new Constants(typeof(MisfireInstruction.SimpleTrigger), typeof(MisfireInstruction));
@@ -95,8 +95,8 @@ namespace Spring.Scheduling.Quartz
/// <summary>
/// Set the delay before starting the job for the first time.
/// The given number of milliseconds will be added to the current
/// time to calculate the start time. Default is 0.
/// The given time span will be added to the current
/// time to calculate the start time. Default is <see cref="TimeSpan.Zero" />.
/// </summary>
/// <remarks>
/// This delay will just be applied if no custom start time was
@@ -105,7 +105,7 @@ namespace Spring.Scheduling.Quartz
/// Specifying a relative delay is appropriate in that case.
/// </remarks>
/// <seealso cref="Trigger.StartTimeUtc" />
public virtual long StartDelay
public virtual TimeSpan StartDelay
{
set { startDelay = value; }
}
@@ -180,7 +180,7 @@ namespace Spring.Scheduling.Quartz
}
if (StartTimeUtc == DateTime.MinValue)
{
StartTimeUtc = DateTime.UtcNow.AddMilliseconds(startDelay);
StartTimeUtc = DateTime.UtcNow.Add(startDelay);
}
if (jobDetail != null)
{

View File

@@ -23,7 +23,7 @@
<object id="quartzSchedulerFactory" type="Spring.Scheduling.Quartz.SchedulerFactoryObject, Spring.Scheduling.Quartz">
<property name="AutoStartup" value="true" />
<property name="StartupDelay" value="5" />
<property name="StartupDelay" value="5s" />
<property name="QuartzProperties">
<dictionary>
<entry key="quartz.threadPool.threadCount" value="10"/>
@@ -54,7 +54,7 @@
<!-- see the example of method invoking job above -->
<property name="jobDetail" ref="testJob" />
<!-- 2 seconds -->
<property name="startDelay" value="2" />
<property name="startDelay" value="2s" />
<!-- repeat every 3 seconds -->
<property name="repeatInterval" value="3000" />
</object>

View File

@@ -2,33 +2,29 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E4328F68-C3FC-43E2-9D63-30CEC55215B0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Spring</RootNamespace>
<AssemblyName>Spring.Scheduling.Quartz.Integration.Tests</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\build\VS.NET.2005\Spring.Scheduling.Quartz.Integration.Tests\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
<OutputPath>..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz.Integration.Tests\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_2_0;NET_3_5</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\build\VS.NET.2005\Spring.Scheduling.Quartz.Integration.Tests\Release\</OutputPath>
<DefineConstants>TRACE;NET_2_0</DefineConstants>
<OutputPath>..\..\..\build\VS.NET.2008\Spring.Scheduling.Quartz.Integration.Tests\Release\</OutputPath>
<DefineConstants>TRACE;NET_2_0;NET_3_5</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@@ -46,15 +42,18 @@
<HintPath>..\..\..\lib\Net\2.0\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2005.csproj">
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2008.csproj">
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2005</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Scheduling.Quartz\Spring.Scheduling.Quartz.2005.csproj">
<ProjectReference Include="..\..\..\src\Spring\Spring.Scheduling.Quartz\Spring.Scheduling.Quartz.2008.csproj">
<Project>{E823D54C-CE82-4868-929F-5F95A999F61E}</Project>
<Name>Spring.Scheduling.Quartz.2005</Name>
</ProjectReference>

View File

@@ -85,7 +85,7 @@ namespace Spring.Scheduling.Quartz
methodInvokingJob.Execute(CreateMinimalJobExecutionContext());
Assert.Fail("Successful invoke when method threw exception");
}
catch (JobExecutionException)
catch (JobMethodInvocationFailedException)
{
// ok
}

View File

@@ -203,7 +203,7 @@ namespace Spring.Scheduling.Quartz
factory.SchedulerFactoryType = typeof(TestSchedulerFactory);
factory.AutoStartup = true;
factory.StartupDelay = 2;
factory.StartupDelay = TimeSpan.FromSeconds(2);
factory.AfterPropertiesSet();
}

View File

@@ -65,7 +65,7 @@ namespace Spring.Scheduling.Quartz
[Test]
public override void TestAfterPropertiesSet_ValuesGiven()
{
simpleTrigger.StartDelay = 100;
simpleTrigger.StartDelay = TimeSpan.FromMilliseconds(100);
simpleTrigger.AfterPropertiesSet();
base.TestAfterPropertiesSet_ValuesGiven();
}
@@ -74,7 +74,7 @@ namespace Spring.Scheduling.Quartz
public void TestAfterPropertiesSet_StartDelayGiven()
{
const int START_DELAY = 100000;
simpleTrigger.StartDelay = START_DELAY;
simpleTrigger.StartDelay = TimeSpan.FromMilliseconds(START_DELAY);
DateTime startTime = DateTime.UtcNow;
simpleTrigger.AfterPropertiesSet();
AssertDateTimesEqualityWithAllowedDelta(startTime.AddMilliseconds(START_DELAY), simpleTrigger.StartTimeUtc, 1000);