SACenter/SA.Quartz/IOCJobFactory.cs

34 lines
910 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Quartz;
using Quartz.Spi;
using System;
namespace SA.Quartz
{
using IOCContainer = IServiceProvider;
/// <summary>
/// IOCJobFactory 实现在Timer触发的时候注入生成对应的Job组件
/// </summary>
public class IOCJobFactory : IJobFactory
{
protected readonly IOCContainer Container;
public IOCJobFactory(IOCContainer container)
{
Container = container;
}
//Called by the scheduler at the time of the trigger firing, in order to produce
//a Quartz.IJob instance on which to call Execute.
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
{
return Container.GetService(bundle.JobDetail.JobType) as IJob;
}
// Allows the job factory to destroy/cleanup the job if needed.
public void ReturnJob(IJob job)
{
}
}
}