Created
January 26, 2012 12:14
-
-
Save gabrielfuller/1682520 to your computer and use it in GitHub Desktop.
Quartz.net Integration with Windsor Castle and Asp.net MVC 3
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
protected virtual void InitializeServiceLocator() | |
{ | |
var container = new WindsorContainer(new XmlInterpreter()); | |
container.AddFacility("quartznet", new QuartzFacility()); | |
//Get All Controller Instances in Assembly and Add to IWindsorContainer | |
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); | |
var controllerTypes = (from t in Assembly.GetAssembly(typeof (BaseController)).GetExportedTypes() | |
where typeof (IController).IsAssignableFrom(t) | |
select t).ToArray(); | |
container.RegisterControllers(controllerTypes); | |
// Register HttpContext(Base) and HttpRequest(Base) so it automagically can be injected using IoC | |
container.AddFacility<FactorySupportFacility>(); | |
container.Register(Component.For<HttpRequestBase>().LifeStyle.PerWebRequest | |
.UsingFactoryMethod(() => new HttpRequestWrapper(HttpContext.Current.Request))); | |
container.Register(Component.For<HttpContextBase>().LifeStyle.PerWebRequest | |
.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current))); | |
var facility = new QuartzFacility(); | |
ComponentRegistrar.AddComponentsTo(container); | |
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container)); | |
} |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
version="1.0" | |
overwrite-existing-jobs="true"> | |
<job> | |
<job-detail> | |
<name>hello-world</name> | |
<job-type>SampleApp.SampleJob, SampleApp</job-type> | |
<durable>true</durable> | |
</job-detail> | |
</job> | |
</quartz> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment