Setting up spring-mvc in an application that already use it as a dependency of dependency

93 Views Asked by At

I did not know how to turn the title, hope this is understandable. I am working on a web-app that have existed for years and is currently in production. This web-app uses spring-flex to display some views and one of the dependency of spring-flex is spring-mvc. I think a relevant link would be there.

So I have all the dependencies already configured in my pom, and a DispatcherServlet already configured in my web.xml with the exact configuration from the manual (I am not the one who did the integration, I am trying to figuring out how it was done).

<servlet>
    <servlet-name>flex_servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>flex_servlet</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

From the link I have provided, we can see that by default when a flex message-broker is configured, the configuration looks like this (although it is nowhere to be seen in the project)

<!-- Maps request paths at /* to the BlazeDS MessageBroker -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <value>
            /*=_messageBroker
        </value>
    </property>
</bean>

<!-- Dispatches requests mapped to a MessageBroker -->
<bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>    

Now that I want to use spring-mvc for other tasks, what should I do?

  • Declare another DispatcherServlet or use the same one?
  • And If I use the same one, can I just copy-past the above block and complete it to override the default configuration?
  • And if I don't use the same one, how will each DispatcherServlet know which HandlerMapping to use since they are supposed to discover it themselves?

thanks for your help

EDIT: for future reference, here are relevant documentations:

1

There are 1 best solutions below

6
On BEST ANSWER

With BlazeDS you define a named service, the DispatcherServlet will use this name to send requests to the proper service. So to answer your questions:

  • Declare another DispatcherServlet or use the same one? Use the same one
  • And If I use the same one, can I just copy-past the above block and complete it to override the default configuration? No change needed
  • And if I don't use the same one, how will each DispatcherServlet know which HandlerMapping to use since they are supposed to discover it themselves? Irrelevant, you use the same one

Based on our conversation below, the answer from this question might help you aswell: Spring MVC: RESTful web services + BlazeDS integration possible in the same web application?