Upgrading to Spring BlazeDS Integration M2

Jettro Coenradie
I have written some posts about using flex and the project Spring BlazeDS Integration. If you haven’t read that post I suggest you start there first : Flex remoting without configuring the client. That said, what is this post about? As the title already says, we are going to upgrade the example from the previous blog post to use the new features of the M2 release of spring Blazeds integration.


Maven

I do not think the spring blazeds artifacts are available in maven yet. Therefor you have to download them and install them in your local maven repo, or deploy them in your Artifactory if you use it.

mvn install:install-file -DgroupId=org.springframework.flex -DartifactId=org.springframework.flex -Dversion=1.0.0.M2 -Dpackaging=jar -Dfile=/path/to/jar

Change the used version of the jar in the books-web projects pom.xml. If you haven’t downloaded the sources yet, you can find them here.
Doing a mvn clean install and everything should be fine. If you are having problems with out of memory exceptions, give maven a bit of extra memory

export MAVEN_OPTS=-Xmx256m

Namespace support in spring configuration

Message broker

Next up is changing the spring configuration to use the new namespace support. Before you can use the new namespace, you have to specify it in the xml header. The next code block shows you the configuration as I use it. The suggestion comes from the reference manual.

...

The first element configures the message broker, the handler mapping and a message broker handler adapter. If you read my previous post, remember that we add our own handler adapter as well for the config files. By default spring looks up a handler adapter. If one is already available and you need a second, you have to configure one yourself. In our case we add the simple controller handler adapter.
The new namespace configuration also adds a SimpleUrlHandlermapping. We need to add our mapping for the config.properties file. Therefore we cannot use the default mapping. The default mapping routes all requests to the MessageBroker. Check the following code for the additional configuration as I would have liked it. To bad this is not possible. On the other hand, Jeremy Grelle gives a good explanation why this cannot be done this way in this forum thread.
 
 
 
 
This code block shows how it really must be. Which is good as well.
 
 
 
 
 
 
 
 /config.properties=configPropertyController
 
 
 

Remote services

Methods of beans can be exposed at remote services. There is namespace support for this as well. Again the namespace provides a lot of default behavior. One of the things is the name of the service that comes from the references bean. I need to change this since the used name is already used. This can easily be done using the service-id property. There is another feature that I like. You can explicitly configure the methods to expose or the methods to prevent from being exposed. You can use the exclude-methods and the include-methods. I use this to prevent the internal use method from being exposed. The following code block shows the configuration.
 

Remote services configuration

If your application is only using spring managed remote services you can remove the remoting configuration completely. Default channels are provided by the spring integration. We do have a problem with our current security implementation. This makes use of a non spring managed remote service for authentication. If we want to remove this we need to use the new spring security integration. That is the next step.

Integrating spring security

The new M2 milestone comes with spring security integration. To be honest, there is not much use for me here. I did add it because there must be some exception handling and mapping being done. I still have some questions on this area that I will try to get answered the coming weeks. So stay tuned for an improved security version as well.

Summary

The following two code blocks show the old config file and the new style. I just love these more clean configuration files that make use of namespaces. To bad I have to provide my own SimpleUrlMappingHandler, but as mentioned it is probably better to make the separation.
old

 
 
 
 
 
 
 /config.properties=configPropertyController
 /*=mySpringManagedMessageBroker
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 

new

 
 
 
 
 
 
 
 
 
 
 
 /config.properties=configPropertyController
 
 
 
 
 
 
 
 
 
 
 
 

Upgrading to Spring BlazeDS Integration M2

Comments