Flex 4 & Spring 3 Integration (page 2)
Join the DZone community and get the full member experience.Join For Free
INTEGRATING FLEX AND SPRING
Adobe Flex has strong ties to Java, which include an Eclipse-based IDE and BlazeDS, its open source server-based Java remoting and web messaging technology. In late 2008, the Spring community began working on the Spring BlazeDS Integration project to add support for Flex development with Java and Spring.
By default BlazeDS creates instances of server-side Java objects and uses them to fulfill remote object requests. This approach doesn’t work with Spring, as the framework is built around injecting the service beans through the Spring container. The Spring integration with BlazeDS allows you to configure Spring beans as BlazeDS destinations for use as remote objects in Flex.
This tutorial assumes that you are already familiar with Spring and Flex. If you need an introduction or refresher to either, check out the Very First Steps in Flex and Spring Configuration DZone Refcardz.
BlazeDS provides simple two-way communication with Java back ends. Flash Player supports a serialization protocol called AMF that alleviates the bottlenecks of text-based protocols and provides a simpler way to communicate with servers. AMF is a binary protocol for exchanging data that can be used over HTTP in place of text-based protocols that transmit XML. Applications using AMF can eliminate an unnecessary data abstraction layer and communicate more efficiently with servers. To see a demonstration of the performance advantages of AMF, see the Census RIA Benchmark at: http://www.jamesward.org/census
To follow along with this tutorial you will initially need:
- An Eclipse 3.5 Distribution. You may choose either the standard distribution: Eclipse 3.5 (Galileo) for Java EE Developers (On Mac use the Eclipse Carbon version): http://www.eclipse.org/downloads/ Or, for enhanced Spring support you might consider using the SpringSource Tool Suite:
- Flash Builder 4 (60 day Trial) installed as a plug-in for the
Java EE Eclipse distribution:
- Tomcat 6:
- BlazeDS 4 (Binary Distribution):
- Spring Framework 3.0.2 (vanilla release):
- Spring BlazeDS Integration 1.0.3 (vanilla release):
- AOP Alliance 1.0:
- backport-util-concurrent 3.1 for the Java version you’re using:
- cglib 2.2
- asm 3.2
Manually downloading the dependencies is one way to get everything you need. Alternatively, you can use Maven or the SpringSource Tool Suite to automatically handle dependencies for you.
First install your chosen Eclipse distribution and then install Flash Builder 4 as a plug-in to the Eclipse distribution you just installed. Also extract the ZIP files for the other dependencies specified above. When you’ve completed these steps, run Eclipse. In Eclipse create a server that will run the application:
- Choose File > New > Other
- Select Server > Server
- Click Next
- Select Apache > Tomcat v6.0 Server
- Click Next
- Specify the location where Tomcat is installed and select the JRE(version 5 or higher) to use
- Click Finish
Opinions expressed by DZone contributors are their own.