Announcement Announcement Module
No announcement yet.
Changing handler mapping at runtime? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing handler mapping at runtime?

    I am working on an application developed using Spring Servlet MVC. I have run into a situation where I need the ability to swap modules in the middle of my application workflow. Suppose that my application has the following workflow:

    A --> B --> C1 --> D --> E

    A, B, C, and D are steps implemented as views and controllers.

    I need the ability to swap out, say, C1 and replace it with another module C2 so that the new workflow becomes:

    A --> B --> C2 --> D --> E

    I need this arrangement because C1 and C2 make use of two different, external service providers that have very different ways of doing things. Furthermore, I want the ability to develop maybe more modules, C3 and C4, wrap them into WAR files, drop them into the application as plug-ins in the future, and eliminate the need to modify myApp-servlet.xml.

    If my reasoning is correct, the solution boils down to the ability to change handler mapping at runtime. After reading the Spring reference and javadoc, it appears that my application is using the default instance of BeanNameUrlHandlerMapping to do the registration of controllers. Is there anyway to get the reference to this default instance of BeanNameUrlHandlerMapping at runtime? A more experienced Spring user from the #spring channel on Freenode has suggested that I look at ApplicationContext. Now, I have done more research and have an idea of how to secure a reference to the application context at runtime, but the ApplicationContext still does not seem to expose the BeanNameUrlHandlerMapping, directly or indirectly (or did I just miss the explanation in the Spring reference and javadoc)?

    How should I go about to solving this problem?