InfoQ Homepage News Integrate Flex with Spring Framework

# Integrate Flex with Spring Framework

As rich-Internet application (RIA) technologies mature, it is becoming increasingly important to integrate RIA, such as Adobe Flex applications, with robust server-side services. One of Java developers' favorite server-side frameworks, Spring, could play an important role in this process.

Marco Casario of RIAvolutionize the Web explains why he recommends BlazeDS to Spring integrate the Flex enterprise system, saying, “Spring is an open-source framework that helps make the developer's life easier. Using standard JEE approach, you'll tend to write a lot of code that is not useful or redundant or spend time implementing J2EE design patterns that are workarounds for technology limitations rather than real solutions. By cutting out these processes, Spring can save you a lot of time.”

Christophe Coenraets provides the rationale for integrating Flex with Spring:

The whole idea behind Spring Inversion of Control (IoC) is to let the container instantiate components (and inject their dependencies). By default, however, components accessed remotely by a Flex client are instantiated by Flex destinations at the server-side. The key to the Flex/Spring integration is, therefore, to configure the Flex destinations to let the Spring container take care of instantiating Spring beans. The Flex data services support the concept of factory to enable this type of custom component instantiation. The role of a factory is simply to provide ready-to-use instances of components to a Flex destination, instead of letting the Flex destination instantiate these components itself.

With respect to the integration of Flex, Spring, IBATIS and Cairngorm, Chris Giametta remarks:

I believe in creating a consistent, modular, and repeatable architecture. The architecture must be sufficient to support small applications as well as extremely robust enterprise applications. A key to project success is creating an architecture that new developers can rapidly integrate themselves into and begin to be productive on day one. I feel that Flex combined with Spring, iBATIS, and Cairngorm help me to quickly produce a patterned- based, repeatable architecture.

Sébastien Arbogast went to the effort of creating a blog series to demonstrate how to build a full stack of Flex, BlazeDS and Spring integration.

Arbogast's stack, from the bottom up, includes JBoss as the application server, MySQL as the data storage, Hibernate to help data access, Spring to build the business layer, BlazeDS as the remoting service and Flexe-genial for building rich client. The system was built using Maven with flex-compiler-mojo plug-in.

Arbogast says, “This project setup certainly requires a bit of work, but—setting aside a small issue with configuration file duplication that should be fixed soon—it's pretty clean, and flex-compiler-mojo works really great.”

Style

## Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

• ##### Just a small precision

by Sébastien Arbogast /

• ##### Flex and Spring integration with Cinnamon remoting

by Jens Halm /

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Sébastien Arbogast /

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Jens Halm /

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Sébastien Arbogast /

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Sébastien Deleuze /

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Jens Halm /

• ##### Igenko

by Sébastien Deleuze /

• ##### Flex - Grails plugin

by Rodrigo Reyes /

• ##### Another IOC container for Flex is Prana

by Ryan Gardner /

• ##### Just a small precision

Your message is awaiting moderation. Thank you for participating in the discussion.

The small issue mentioned in the quote has been fixed since the original publication of my articles and they have all been updated accordingly.

• ##### Flex and Spring integration with Cinnamon remoting

by Jens Halm /

Your message is awaiting moderation. Thank you for participating in the discussion.

Since this is explicitly about combining Flex and Spring I'd like to mention the Cinnamon framework (www.spicefactory.org/cinnamon/). In addition to the features available in BlazeDS or other remoting frameworks which enable you to use Spring beans as remoting destinations, Cinnamon also let's you (optionally) use Spring to configure Cinnamon with a custom configuration namespace. In the most simple use case, adding remoting support for Flex clients to an existing Spring-based web application involves only two simple steps: Add the Cinnamon Servlet to web.xml and then add one tag to your existing bean definition:

<bean id="someService" class="example.SomeClass">    <cinnamon:export-service service-interface="example.SomeInterface"/></bean>

Furthermore Cinnamon adds a few features not available elsewhere:

• Support for pure AS3 clients (no Flex SDK required)

• Support for Java clients (if you need remoting from Flex *and* Java rich clients you can use the same protocol: AMF3)

• Ant Task for generating type-safe AS3 remoting stubs

• Integration with Parsley (www.spicefactory.org/parsley/), an AS3 IOC framework (if you are using Spring you might also want to use an IOC container in the Flash/Flex client).

• Scheduled for later this summer is integration with Pimento, a data management framework that adds JPA/Hibernate integration to Cinnamon remoting.

• ##### Re: Flex and Spring integration with Cinnamon remoting

Your message is awaiting moderation. Thank you for participating in the discussion.

It seems interesting but the first question that comes to mind is "why yet another AMF implementation?". GraniteDS existed as an open source alternative to LiveCycle Data Service before BlazeDS was open sourced. But what is the rationale behind cinnamon? Do you really think it's worth the migration?

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Jens Halm /

Your message is awaiting moderation. Thank you for participating in the discussion.

"Why yet another AMF implementation?". Well, why don't you ask the Adobe guys, of these three products BlazeDS was the last one to be released. ;-)

Seriously, I'm not sure if I understand the question. In my previous comment I listed several Cinnamon features that are not available in other products like support for pure AS3 clients and deep integration with Spring. And since these were/are often requirements for our own projects we pretty much did not have another choice than to roll our own. GraniteDS was already available when we started last summer but it didn't seem easy to add these features to their existing architecture.

I think BlazeDS, GraniteDS and Cinnamon all have a slightly different focus so I'd say they all have their "right to exist". We know developers who used to work with GraniteDS and then changed to Cinnamon and are much happier now. I guess this might be the other way around for other devs. Why are there hundreds of Java web frameworks? ;-)

• ##### Igenko

Your message is awaiting moderation. Thank you for participating in the discussion.

You can see an example of a real project based on Flex and Spring at code.google.com/p/igenko/

• ##### Re: Flex and Spring integration with Cinnamon remoting

Your message is awaiting moderation. Thank you for participating in the discussion.

The fact that there are hundreds of web frameworks available is not necessarily a good reference since many developers are not exactly happy with that situation either. But I got your point.

• ##### Re: Flex and Spring integration with Cinnamon remoting

Your message is awaiting moderation. Thank you for participating in the discussion.

I am also surprised by Cinnamon, since from my experience GraniteDS is a robust and cleanly designed AMF3 framework, with a community opened to external contributions. Have you discussed with Frank (GraniteDS project leader) to see if it was possible to integrate these functionnalities to GraniteDS ?

Spring integration is natively supported by GraniteDS, we use it from the beginning on Igenko, and it works very well. It also already supports Hibernate lazy loading.

• ##### Re: Flex and Spring integration with Cinnamon remoting

by Jens Halm /

Your message is awaiting moderation. Thank you for participating in the discussion.

To be honest I'm really puzzled by this mindset that just because there is a working solution each alternative is redundant. Tomcat works quite well, so whats the point of developing Jetty? Is CXF redundant because we have Axis2?

Yes, I briefly discussed with Franck about joining forces but we came to the conclusion that currently it's better to continue separately. It's not just about adding features, some of them might require architectural changes. With Spring integration it's not just about invoking Spring beans from Flex/Flash, we also support using Spring to configure Cinnamon, so the steps needed to expose an existing service for Flex/Flash clients are minimal for Spring users. Furthermore Cinnamon is not only a standalone product but also integrated with other Spicefactory Open Source projects like Parsley (which combines an AS3 IOC container with an MVC framework) and Pimento, the upcoming data management framework which will support a lot more for JPA/Hibernate than just lazy loading.

I mean, if you are happy with GraniteDS you should obviously stick with it but others might be happy to have choices.

• ##### Flex - Grails plugin

Your message is awaiting moderation. Thank you for participating in the discussion.

Have you seen this?

grails.org/Flex+Plugin

Seems to me it connects Flex and Spring (Grails = Groovy (Java) + Spring + Hibernate) in a couple of simple steps.

All it needs right now is a good scaffolding Flex generation.

Rodrigo

• ##### Another IOC container for Flex is Prana

by Ryan Gardner /

Your message is awaiting moderation. Thank you for participating in the discussion.

Prana is another IoC container for Flex - one which is fast and is a very close port of the spring core to Flex.

One more thing - be sure to secure your endpoints.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.