Permalink
Browse files

Revert "adds basic listener support"

This reverts commit 1240943.
  • Loading branch information...
teabaggs committed Jun 25, 2014
1 parent b8a60e2 commit 9bf1d62821b0d77c6ebb161fdca61203c00eabc0
Showing with 237 additions and 455 deletions.
  1. +1 −6 .gitignore
  2. +3 −5 Samples/Sample.Topshelf.Ninject/Sample.Topshelf.Ninject.csproj
  3. +1 −1 Samples/Sample.Topshelf.Ninject/packages.config
  4. +25 −194 Samples/Sample.Topshelf.Quartz.BackgroundJobs/Program.cs
  5. +3 −5 Samples/Sample.Topshelf.Quartz.BackgroundJobs/Sample.Topshelf.Quartz.BackgroundJobs.csproj
  6. +1 −1 Samples/Sample.Topshelf.Quartz.BackgroundJobs/packages.config
  7. +3 −5 Samples/Sample.Topshelf.Quartz.JobAsService/Sample.Topshelf.Quartz.JobAsService.csproj
  8. +1 −1 Samples/Sample.Topshelf.Quartz.JobAsService/packages.config
  9. +3 −5 Samples/Sample.Topshelf.WebApi/Sample.Topshelf.WebApi.csproj
  10. +1 −1 Samples/Sample.Topshelf.WebApi/packages.config
  11. +23 −3 Source/Topshelf.Ninject/Topshelf.Ninject.csproj
  12. +1 −1 Source/Topshelf.Ninject/packages.config
  13. +14 −6 Source/Topshelf.Quartz.Ninject/Topshelf.Quartz.Ninject.csproj
  14. +1 −1 Source/Topshelf.Quartz.Ninject/packages.config
  15. +29 −75 Source/Topshelf.Quartz/QuartzConfigurator.cs
  16. +1 −1 Source/Topshelf.Quartz/ScheduleJobHostConfiguratorExtensions.cs
  17. +91 −134 Source/Topshelf.Quartz/SchedulejobServiceConfiguratorExtensions.cs
  18. +18 −2 Source/Topshelf.Quartz/Topshelf.Quartz.csproj
  19. +1 −1 Source/Topshelf.Quartz/packages.config
  20. +10 −4 Source/Topshelf.WebApi.Ninject/Topshelf.WebApi.Ninject.csproj
  21. +1 −1 Source/Topshelf.WebApi.Ninject/packages.config
  22. +4 −1 Source/Topshelf.WebApi/Topshelf.WebApi.csproj
  23. +1 −1 Source/Topshelf.WebApi/packages.config
@@ -73,9 +73,4 @@ _ReSharper.*
# My specific Visual Studio
*.vsp
*.psess
*.DotSettings
#VS local history
.localhistory
.localhistory/*
*.psess
@@ -34,8 +34,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Ninject">
<HintPath>..\..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
</Reference>
<Reference Include="System" />
@@ -45,9 +44,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf, Version=3.1.107.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Topshelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
<Reference Include="Topshelf">
<HintPath>..\..\packages\TopShelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Topshelf" version="3.1.1" targetFramework="net45" />
<package id="TopShelf" version="3.1.1" targetFramework="net45" />
</packages>
@@ -1,215 +1,46 @@
using System;
using Ninject.Modules;
using Quartz;
using Quartz.Impl.Matchers;
using Topshelf;
using Topshelf.Ninject;
using Topshelf.Quartz;
using Topshelf.Quartz.Ninject;
namespace Sample.Topshelf.Quartz.BackgroundJobs
{
internal class Program
class Program
{
private static void Main()
static void Main()
{
HostFactory.Run(c =>
{
c.UseNinject(new SampleModule());
c.Service<SampleService>(s =>
{
// Topshelf.Quartz (Optional) - Construct service using Ninject
s.ConstructUsingNinject();
s.WhenStarted((service, control) => service.Start());
s.WhenStopped((service, control) => service.Stop());
{
c.UseNinject(new SampleModule());
// Topshelf.Quartz.Ninject (Optional) - Construct IJob instance with Ninject
s.UseQuartzNinject();
// Schedule a job to run in the background every 5 seconds.
// The full Quartz Builder framework is available here.
s.ScheduleQuartzJob(q =>
q.WithJob(() =>
JobBuilder.Create<SampleJob>()
.WithIdentity("sample")
.Build())
.AddTrigger(() =>
TriggerBuilder.Create()
.WithIdentity("sample")
.WithSimpleSchedule(
builder =>
builder.WithIntervalInSeconds(5)
.RepeatForever()).Build())
.WithJobListener(() =>
{
return new QuartzJobListenerConfig(
new SimpleJobListener(),
KeyMatcher<JobKey>.KeyEquals(new JobKey("sample")));
})
.WithTriggerListener(() =>
{
return new QuartzTriggerListenerConfig(
new SimpleTriggerListener(),
KeyMatcher<TriggerKey>.KeyEquals(new TriggerKey("sample")));
})
.WithScheduleListener(() => new SimpleScheduleListener())
);
});
c.Service<SampleService>(s =>
{
// Topshelf.Quartz (Optional) - Construct service using Ninject
s.ConstructUsingNinject();
s.WhenStarted((service, control) => service.Start());
s.WhenStopped((service, control) => service.Stop());
// Topshelf.Quartz.Ninject (Optional) - Construct IJob instance with Ninject
s.UseQuartzNinject();
// Schedule a job to run in the background every 5 seconds.
// The full Quartz Builder framework is available here.
s.ScheduleQuartzJob(q =>
q.WithJob(() =>
JobBuilder.Create<SampleJob>().Build())
.AddTrigger(() =>
TriggerBuilder.Create()
.WithSimpleSchedule(builder => builder.WithIntervalInSeconds(5).RepeatForever()).Build())
);
});
});
}
}
public class SimpleScheduleListener : ISchedulerListener
{
public void JobScheduled(ITrigger trigger)
{
Console.WriteLine("SAMPLE: Job Scheduled from trigger: " + trigger.Key.Name);
}
public void JobUnscheduled(TriggerKey triggerKey)
{
Console.WriteLine("SAMPLE: Job Unscheduled from trigger: " + triggerKey.Name);
}
public void TriggerFinalized(ITrigger trigger)
{
Console.WriteLine("SAMPLE: Trigger Finalized from trigger: " + trigger.Key.Name);
}
public void TriggerPaused(TriggerKey triggerKey)
{
Console.WriteLine("SAMPLE: Trigger Paused from trigger: " + triggerKey.Name);
}
public void TriggersPaused(string triggerGroup)
{
Console.WriteLine("SAMPLE: Trigger Paused for group: " + triggerGroup);
}
public void TriggerResumed(TriggerKey triggerKey)
{
Console.WriteLine("SAMPLE: Trigger Paused from trigger: " + triggerKey.Name);
}
public void TriggersResumed(string triggerGroup)
{
Console.WriteLine("SAMPLE: Trigger Resumed for group: " + triggerGroup);
}
public void JobAdded(IJobDetail jobDetail)
{
Console.WriteLine("SAMPLE: Job Added: " + jobDetail.Key.Name);
}
public void JobDeleted(JobKey jobKey)
{
Console.WriteLine("SAMPLE: Job Deleted: " + jobKey.Name);
}
public void JobPaused(JobKey jobKey)
{
Console.WriteLine("SAMPLE: Job Paused: " + jobKey.Name);
}
public void JobsPaused(string jobGroup)
{
Console.WriteLine("SAMPLE: Jobs Paused for group: " + jobGroup);
}
public void JobResumed(JobKey jobKey)
{
Console.WriteLine("SAMPLE: Job Resumed: " + jobKey.Name);
}
public void JobsResumed(string jobGroup)
{
Console.WriteLine("SAMPLE: Jobs Resumed for group: " + jobGroup);
}
public void SchedulerError(string msg, SchedulerException cause)
{
Console.WriteLine("SAMPLE: Scheduler error: " + msg + " with exception: " + cause.Message);
}
public void SchedulerInStandbyMode()
{
Console.WriteLine("SAMPLE: Scheduler is in standby");
}
public void SchedulerStarted()
{
Console.WriteLine("SAMPLE: Scheduler started");
}
public void SchedulerStarting()
{
Console.WriteLine("SAMPLE: Scheduler starting...");
}
public void SchedulerShutdown()
{
Console.WriteLine("SAMPLE: Scheduler shutdown");
}
public void SchedulerShuttingdown()
{
Console.WriteLine("SAMPLE: Scheduler shutting down...");
}
public void SchedulingDataCleared()
{
Console.WriteLine("SAMPLE: Scheduling data cleard");
}
}
public class SimpleJobListener : IJobListener
{
public void JobToBeExecuted(IJobExecutionContext context)
{
Console.WriteLine("SAMPLE: Job is about to execute: " + context.JobDetail.Key.Name);
}
public void JobExecutionVetoed(IJobExecutionContext context)
{
Console.WriteLine("SAMPLE: Job execution vetoed: " + context.JobDetail.Key.Name);
}
public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
{
Console.WriteLine("SAMPLE: Job was executed: " + context.JobDetail.Key.Name);
}
public string Name { get { return "SAMPLE JOB LISTENER"; } }
}
public class SimpleTriggerListener : ITriggerListener
{
public void TriggerFired(ITrigger trigger, IJobExecutionContext context)
{
Console.WriteLine("SAMPLE: Trigger {0} fired for job {1}", trigger.Key.Name, context.JobDetail.Key.Name);
}
public bool VetoJobExecution(ITrigger trigger, IJobExecutionContext context)
{
Console.WriteLine("SAMPLE: Trigger {0} vetoed for job {1}", trigger.Key.Name, context.JobDetail.Key.Name);
return false;
}
public void TriggerMisfired(ITrigger trigger)
{
Console.WriteLine("SAMPLE: Trigger {0} misfired", trigger.Key.Name);
}
public void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
Console.WriteLine("SAMPLE: Trigger {0} completed for job {1} with code {2}", trigger.Key.Name, context.JobDetail.Key.Name, triggerInstructionCode);
}
public string Name { get { return "SAMPLE TRIGGER LISTENER"; } }
}
public class SampleJob : IJob
{
public void Execute(IJobExecutionContext context)
@@ -37,8 +37,7 @@
<Reference Include="Common.Logging">
<HintPath>..\..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Ninject">
<HintPath>..\..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
</Reference>
<Reference Include="Ninject.Extensions.Quartz, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -55,9 +54,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf, Version=3.1.107.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Topshelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
<Reference Include="Topshelf">
<HintPath>..\..\packages\TopShelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -4,5 +4,5 @@
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Ninject.Extensions.Quartz" version="0.2.0.0" targetFramework="net45" />
<package id="Quartz" version="2.1.2" targetFramework="net45" />
<package id="Topshelf" version="3.1.1" targetFramework="net45" />
<package id="TopShelf" version="3.1.1" targetFramework="net45" />
</packages>
@@ -37,8 +37,7 @@
<Reference Include="Common.Logging">
<HintPath>..\..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Ninject">
<HintPath>..\..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
</Reference>
<Reference Include="Ninject.Extensions.Quartz, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -55,9 +54,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf, Version=3.1.107.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Topshelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
<Reference Include="Topshelf">
<HintPath>..\..\packages\TopShelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -4,5 +4,5 @@
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Ninject.Extensions.Quartz" version="0.2.0.0" targetFramework="net45" />
<package id="Quartz" version="2.1.2" targetFramework="net45" />
<package id="Topshelf" version="3.1.1" targetFramework="net45" />
<package id="TopShelf" version="3.1.1" targetFramework="net45" />
</packages>
@@ -37,8 +37,7 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Reference Include="Ninject">
<HintPath>..\..\packages\Ninject.3.0.1.10\lib\net45-full\Ninject.dll</HintPath>
</Reference>
<Reference Include="System" />
@@ -59,9 +58,8 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Topshelf, Version=3.1.107.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Topshelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
<Reference Include="Topshelf">
<HintPath>..\..\packages\TopShelf.3.1.1\lib\net40-full\Topshelf.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -6,5 +6,5 @@
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
<package id="Topshelf" version="3.1.1" targetFramework="net45" />
<package id="TopShelf" version="3.1.1" targetFramework="net45" />
</packages>
Oops, something went wrong.

0 comments on commit 9bf1d62

Please sign in to comment.