How to make a legacy webapp spring aware at the container level for bean autowire into Servlets?

You can use Configurable in combination with a context:load-time-weaver and use Autowired in your servlets. This allows for classes that are not instantiated by spring to use be handled by spring.

You can use @Configurable in combination with a , and use @Autowired in your servlets. This allows for classes that are not instantiated by spring to use be handled by spring. You may use another approach as well - in the init(..) method of your servlet: ApplicationContext ctx = WebApplicationContextUtils.

GetWebApplicationContext(servletContext); if (ctx! = null) { ctx. GetAutowireCapableBeanFactory().

AutowireBean(this); } This will set all spring dependencies (where @Autowired/@Resource are used). It will work in case the service classes are defined in spring, which I assume is the case. From testability point of view - if there isn't a web application context, nothing will happen, and you can manually set your dependencies.

You can also mock the application context, if needed, depending on how are you testing your servlets.

Thanks, we'll look into those. I'll accept the answer if no other ideas come in and implement successfully – Pete Mar 23 '10 at 21:00.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions