.net Core Quartz Dependency Injection

You can use the Quartz.Spi.IJobFactory interface and implement it. The Quartz documentations states: When a trigger fires, the Job it is associated to is instantiated via the JobFactory configured on the Scheduler. The default JobFactory simply activates a new instance of the job class. You may want to create your own implementation of JobFactory to … Read more

Dependency injection and ASP.Net Membership Providers

If you are configuring the custom membership providers via the <membership> element in the Web.config file, then I can see the issues you will have with dependency injection. The providers are constructed and managed by the framework, and there is no opportunity for you to intercept that construction to provide additional dependency injection for the … Read more

Autowiring in servlet

I followed the solution in the following link, and it works fine: Access Spring beans from a servlet in JBoss public class MyServlet extends HttpServlet { @Autowired private MyService myService; public void init(ServletConfig config) { super.init(config); SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext()); } }

Constructor injection with Quartz.NET and Simple Injector

According to this blog post, you would need to implement a custom IJobFactory, like this: public class SimpleInjectorJobFactory : IJobFactory { private readonly Container container; private readonly Dictionary<Type, InstanceProducer> jobProducers; public SimpleInjectorJobFactory( Container container, params Assembly[] assemblies) { this.container = container; // By creating producers, jobs can be decorated. var transient = Lifestyle.Transient; this.jobProducers = … Read more

.NET Core dependency injection -> Get all implementations of an interface

It’s just a matter of registering all IRule implementations one by one; the Microsoft.Extensions.DependencyInjection (MS.DI) library can resolve it as an IEnumerable<T>. For instance: services.AddTransient<IRule, Rule1>(); services.AddTransient<IRule, Rule2>(); services.AddTransient<IRule, Rule3>(); services.AddTransient<IRule, Rule4>(); Consumer: public sealed class Consumer { private readonly IEnumerable<IRule> rules; public Consumer(IEnumerable<IRule> rules) { this.rules = rules; } } NOTE: The only collection … Read more

Spring annotation-based DI vs xml configuration?

After reading some related posts here and having further discussion in the team we come to the following conclusions. I hope the would be useful to others here. About XML configuration (which we are using up to now), we decided to keep it for dependencies defined by libraries (regardless if being developed by us, or … Read more

Dagger @Reusable scope vs @Singleton

Use @Singleton if you rely on singleton behavior and guarantees. Use @Reusable if an object would only be a @Singleton for performance reasons. @Reusable bindings have much more in common with unscoped bindings than @Singleton bindings: You’re telling Dagger that you’d be fine creating a brand-new object, but if there’s a convenient object already created … Read more