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

How to instantiate Spring managed beans at runtime?

Looks like I found a solution. As I am using java based configuration it is even simpler than you can imagine. Alternative way in xml would be lookup-method, however only from spring version 4.1.X as it supports passing arguments to the method. Here is a complete working example: public class Container { private List<RuntimeBean> runtimeBeans … Read more

Inject a dependency into a custom model binder and using InRequestScope using Ninject

The ModelBinders are reused by MVC for multiple requests. This means they have a longer lifecycle than request scope and therefore aren’t allowed to depend on objects with the shorter request scope life cycle. Use a Factory instead to create the IPostRepository for every execution of BindModel