InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Integrate Flex with Spring Framework

Posted by Moxie Zhang on May 22, 2008

Sections
Development
Topics
Java ,
Rich Internet Apps
Tags
Spring ,
Flex

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.”

 

10 comments

Watch Thread Reply

Just a small precision by Sébastien Arbogast Posted
Flex and Spring integration with Cinnamon remoting by Jens Halm Posted
Re: Flex and Spring integration with Cinnamon remoting by Sébastien Arbogast Posted
Re: Flex and Spring integration with Cinnamon remoting by Jens Halm Posted
Re: Flex and Spring integration with Cinnamon remoting by Sébastien Arbogast Posted
Re: Flex and Spring integration with Cinnamon remoting by Sébastien Deleuze Posted
Re: Flex and Spring integration with Cinnamon remoting by Jens Halm Posted
Igenko by Sébastien Deleuze Posted
Flex - Grails plugin by Rodrigo Reyes Posted
Another IOC container for Flex is Prana by Ryan Gardner Posted
  1. Back to top

    Just a small precision

    by Sébastien Arbogast

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

  2. Back to top

    Flex and Spring integration with Cinnamon remoting

    by Jens Halm

    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.

  3. Back to top

    Re: Flex and Spring integration with Cinnamon remoting

    by Sébastien Arbogast

    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?

  4. Back to top

    Re: Flex and Spring integration with Cinnamon remoting

    by Jens Halm

    "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? ;-)

  5. Back to top

    Igenko

    by Sébastien Deleuze

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

  6. Back to top

    Re: Flex and Spring integration with Cinnamon remoting

    by Sébastien Arbogast

    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.

  7. Back to top

    Re: Flex and Spring integration with Cinnamon remoting

    by Sébastien Deleuze

    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.

  8. Back to top

    Re: Flex and Spring integration with Cinnamon remoting

    by Jens Halm

    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.

  9. Back to top

    Flex - Grails plugin

    by Rodrigo Reyes

    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

  10. Back to top

    Another IOC container for Flex is Prana

    by Ryan Gardner

    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.

Educational Content

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?