Some time a go I had a chat with Alef Arendsen. We talked about flex and the integration with springframework. As a lot of you know, I wrote a few posts about that topic. We talked about what the springframework could do to make life easier for spring developers when using flex and BlazeDS. At that time I did not expect that springsource would jump into this the way they do now. I see already two projects

This sounds almost to good to be true. Combining my springframework knowledge with flex and ActionScript. Maybe I should create a flex front-end talking using BlazeDS to a Hippo Back-end. Of course the application is running on OSGi šŸ™‚

Oke, that is something I am not going to talk about in this post. I am going to talk about the new spring flex projects and my first impression. This post is about the BlazeDS integration.

I am going to use the books-overview sample to try out the integration. You can find the sources of books-overview at google code. I base the changes I do on the blog post from Jeremy Grelle about the release of M1. The books-overview project is build with maven. I was using a separate module for the flex remoting config files. Since these files now become very easy and do not need maintenance, I am placing them at the projects at hand. Therefore the config project is to be removed. And the files have been moved into the ria and the web project.


The hardest part with maven is to find the dependencies, I added two repositories and manually installed the blazeds spring integration.


There are two important modules, the books-web and the books-ria. Books-web contains the BlazeDS stuff, books-ria the flex stuff. Check the poms if you need the dependencies. I do want to show the flex compilation using the plugin from velo.




We start of with the spring replacement of the blazeds servlet. Instead of the flex.messaging.MessageBrokerServlet we now use the standard dispatcher servlet of spring.

        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>

        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>

Spring config

I am not going to spend to much time on explaining this stuff since Jeremy already does a good job in his blog. The following code block gives the spring config I have created with some comments in there as well. In short, we create a wrapper around the Message broker, a url handler that connects the incoming requests to this message broker. Finally you need the services. This is one of the nice things of the spring integration. You can export your remote services from the spring config file. I expose the book manager as the remoteBookManager. Now check the source

<beans xmlns=""

    <!-- Bootstraps and exposes the BlazeDS MessageBroker -->
    <bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean"/>

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

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

    <!-- remote proxies -->
    <bean id="remoteBookManager" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
        <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
        <property name="service" ref="bookManager"/>

That is it for the server side. We continue with the client

Client configuration

The client does not need to be changed a lot. We can now remove the special factory configuration for the connection of spring and flex. There is one thing that is still to be changed, the configuration of the destinations. For now I have an empty destination in my remoting-config.xml. I hope this is because I am doing something wrong. If that is the case I’ll correct this is the future. The next code block

<service id="remoting-service" class="">
        <adapter-definition id="java-object" class="" default="true"/>

        <channel ref="my-amf"/>

    <destination id="remoteBookManager"/>

    <destination id="authenticationHelper">


For now I do not see a lot of improvement in clarity, it does not get worse eaither. I can imagine if we make the configuration at the client side more easy it will get better. Of course the road map is interesting. Think about security. Now I have created some custom mechanisms for the security integration. It would be very nice if that is supported out of the box. So should you use it? Yes I think you should if you are into the spring framework. It looks like a clean way to integrate flex and spring and I do believe it will get better in the future.

In short, thanks SpringSource for this project, let’s hope this will give a push in the right direction.

Side note

By creating your own channels in code, you can accomplish losing the client configuration of destinations. I have made it work in an ugly way and will post more on this when I have made it nice. Go and habve a look at the post from kyle hayes if you want to learn more.

I personally like the approach of the other spring flex project. That is the direction I am going into:

Wow, springframework enters the ActionScript and flex domain
Tagged on: