Integrating with the Java Spring Framework

The Java Spring framework is a popular server-side container that has its own mechanism of instantiating Java classes—it implements a design pattern called Inversion of Control. To put it simply, if an object Employee has a property of type Bonus, instead of explicit creation of the bonus instance in the class employee, the framework would create this instance and inject it into the variable bonus.

BlazeDS (and LCDS) knows how to instantiate Java classes configured in remoting-config.xml, but this is not what’s required by the Spring framework.

In the past, a solution based on the Class Factory design pattern was your only option. Both BlazeDS and LCDS allow you to specify not the name of the class to create, but the name of the class factory that will be creating instances of this class. An implementation of such a solution was available in the Flex-Spring library making Spring framework responsible for creating instances of such Java classes (a.k.a. Spring beans).

Today, there is a cleaner solution developed jointly by Adobe and SpringSource. It allows you to configure Spring beans in Extensible Markup Language (XML) files, which can be used by the BlazeDS component on the Java EE server of your choice.

James Ward and Jon Rose have published a reference card with code samples on Flex/Spring integration at http://tinyurl.com/cj3v7b.

Note

At the time of this writing, the project on the integration of BlazeDS and the Spring framework is a work in progress, and we suggest you to follow the blog of Adobe’s Christophe Coenraets, who publishes up-to-date information about this project.

Get Agile Enterprise Application Development with Flex now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.