Jul 23rd, 2012, 09:18 AM
Spring MVC 3.1 load controllers dynamically
I am using Spring MVC 3.1 for my web project and I have a particular use case. I have to allow users to drop a jar file which has @Controller for RequestMapping that needs to be loaded dynamically. In other words, I do not have an option to restart the Tomcat or the Context (War). How can I do this.
Jul 23rd, 2012, 12:20 PM
Some OSGI stuff could help. Maybe with dm Server?
Jul 23rd, 2012, 12:27 PM
We are using Tomcat and other servers is not an option.
Jul 23rd, 2012, 12:30 PM
You could try to reload just some smaller spring applicationContexts bu I bet this will not work with @Controller since this is bound to the servlet context.
Why no servlet context restart?
Maybe an own handler for MVC-annotations will help.
Jul 23rd, 2012, 12:39 PM
Servlet Context restart is not possible because there could be users actively working in the system. Its just that new functionality
can be added on the fly. This is requirement in stone. Do you have any examples of "own handler for MVC-annotations" or how to approach this.
Jul 23rd, 2012, 12:49 PM
DefaultAnnotationHandlerMapping maybe a good start.
But, I think you will have no luck... all that stuff is not designed in a way to reload parts of a webapp. It may work somehow some day, but you will get new problems (mem leaks, stale dependencies etc pp).
Just reload the app, make the reload FAST and persist sessions.
Tags for this Thread