Created
January 22, 2014 15:39
-
-
Save dlidstrom/8560930 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class JobStartable : IStartable | |
{ | |
private static readonly ILog Log = LogManager.GetLogger(typeof(JobStartable)); | |
private readonly IScheduler scheduler; | |
protected JobStartable(IScheduler scheduler) | |
{ | |
this.scheduler = scheduler; | |
} | |
public void Start() | |
{ | |
Log.Info("Starting job"); | |
var trigger = CreateTrigger(); | |
var job = JobBuilder.Create(GetJobType()).Build(); | |
scheduler.ScheduleJob(job, trigger); | |
} | |
public void Stop() | |
{ | |
} | |
protected abstract ITrigger CreateTrigger(); | |
protected abstract Type GetJobType(); | |
} | |
public class JobStartableInstaller : IWindsorInstaller | |
{ | |
public void Install(IWindsorContainer container, IConfigurationStore store) | |
{ | |
container.Register( | |
Classes.FromThisAssembly() | |
.BasedOn<JobStartable>() | |
.WithServiceBase() | |
.LifestyleSingleton()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment