3 character abbreviation

Why give software real names? Abbreviations are crystal clear.

  • Articles Solutions for problems we faced
  • About More about the authors and articles
  • Glossary Frequently used concepts

January 12, 2010
Posted by Tim

Using SpringMVC next to BlazeDS

We recently decided to extend an existing SpringMVC project with a Flex application. The main reason to update and not restart the project was the possibility to reuse the Hibernate model and the integration with other applications. To communicate with the backend, BlazeDS was our way to go, definitely with the Spring BlazeDS integration project available.

Two resources helped me very well in setting up the BlazeDS integration:

  1. Firstly I used Jeremy Grelle’s ‘Spring BlazeDS Integration’ reference as base.
  2. Furthermore, I used the testdrive project of Christophe Coenraets.

Some sidenotes about the integration

1. To run SpringMVC next to BlazeDS, you can share the same Spring DispatcherServlet in your web.xml. In this example, I made however two different mappings for the servlet.

<!--Spring MVC Dispatcher Servlet-->
<servlet>
	<servlet-name>controller</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>controller</servlet-name>
	<url-pattern>*.do</url-pattern>
</servlet-mapping>
 
<!--Mapping voor BlazeDS-->
<servlet-mapping>
	<servlet-name>controller</servlet-name>
	<url-pattern>/blaze/amf</url-pattern>
</servlet-mapping>

I mapped my BlazeDS servlet on a specific URL: e.g. /blaze/amf. According to the documentation, you can use a wildcard (*) here, but I couldn’t get that running.

For every dispatcherservlet, you need a [servlet-name]-servlet.xml file in your WEB-INF directory (Spring convention). So in this case I created a controller-servlet.xml The flex part is based on the documentation:

<!--===SpringMVC===-->
<context:component-scan base-package="be.3ca.app.frontend.controllers" />
 
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
	<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
	<property name="prefix" value="/WEB-INF/jsp/"/>
	<property name="suffix" value=".jspx"/>        
</bean>
 
 
<!--===BlazeDS==-->
<!-- Maps request paths at /blaze/amf to the BlazeDS MessageBroker -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
	<property name="mappings">
		<props><prop key="/blaze/amf">_messageBroker</prop></props>
	</property>
</bean>
 
<!-- Dispatches requests mapped to a MessageBroker -->
<bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>

2. The flex messagebroker overrules the default annotation handler and adapter of the Spring Framework. You have to define these two beans explicitly as shown in the code example. Check also this Spring resource around this matter.

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

3. Don’t forget to adapt your Apache httpd.conf file, so request to the blaze message broker will be forwared to the container:

Oc4jMount /app/blaze/amf OC4J_APP

No Comments

Posted Under BlazeDS Spring

No Comments Yet

You can be the first to comment!

Leave a comment

* = Required

  • Posts

     

    Script tag mini...

    Uncategorized

     

    Selected dates ...

    Flex

     

    Dynamic sizing ...

    Flex

  • Categories

    • BackEnd
      • BlazeDS
      • J2EE
      • Spring
    • FrontEnd
      • Flex
    • Maven
    • Uncategorized
  • Ads

3ca is a project of Roel Buyzen and Tim Van Laer.
This site is using Wordpress with the Handgloves theme.

Subscribe via RSS