Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
Created January 22, 2014 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlidstrom/8560930 to your computer and use it in GitHub Desktop.
Save dlidstrom/8560930 to your computer and use it in GitHub Desktop.
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