Home >
Anatomy of an Enterprise Flex RIA Part 1: The Tools You’ll Want
Inside src is a directory for the main source of the project, called main. At the same level is a folder for test code, called test. The code goes in the main and test directories and is organized by the type of language—in this case, a java directory holds the Java code in the data project directory, and a java and flex directory in the web project.
In this series, we’ll look at a small application that integrates the technologies of LCDS and EJB 3.0, and we’ll cover some timesaving tools as well as discuss how to use them to achieve a lightweight development environment for integrating an RIA with an enterprise environment. Ready to get started?
Tools
In this section, I’ll list the tools we’ll be using. Follow along and install them (or the listed alternatives) if you don’t have them already.
MySQL
MySQL is an open source, cross-platform, enterprise-quality, database server. I suggest that you use MySQL as your database server for these examples, although you can use another one if you prefer.
To install MySQL, go to http://dev.mysql.com/downloads/mysql/, download, and follow the instructions there. A few additional tools you may want are available at http://dev.mysql.com/downloads/gui-tools/.
Java
Java is a language and platform tailored to writing business applications. It was the first popular object-oriented language to gain almost ubiquitous support in the business community because of its powerful platform features, its virtual machine approach to platform independence, and its relatively easy-to-learn C-like syntax. Java is a prerequisite of most of these other tools.
To install Java go to http://www.java.com/en/download/, download, and follow the instructions there for your platform. Make sure Java is in your path by typing `java -version` at a command line.
Ant
Ant is a Java-based build and automation tool. With Ant, it’s easy to quickly describe a set of tasks that perform such jobs as compilation, system execution, or simply copying or moving of files on the system.
To install Ant go to http://ant.apache.org/, download, and follow the site’s instructions for your platform. Make sure you follow the instructions to put Ant in your path. Test by calling `ant -version`.
Maven
Maven is like Ant in some ways, but with a lot of other features and some philosophy thrown in. Maven’s creators felt that projects have many aspects which make them the same from a build process perspective; therefore, why should you have to write common tasks or processes every time you start a new project? Maven is a build process management tool, not just a tool for automating a build. Maven is also a code project management tool, and it has some good ideas about how our project should be structured.
Maven also has a good dependency management system for Java. That means all you have to do is list which JARs your project depends on, and Maven will find those JARs online, as well as any dependencies those JARs have. All of those will be available at compile time and, if needed, will be packaged with any artifacts your project produces.
Maven does a lot of what we need, but for some specific tasks, we’ll use Ant to quickly script parts of the process as well. Luckily, it’s easy to extend Maven with Ant.
To install Maven go to http://maven.apache.org/download.html, download, and follow the site’s instructions for your platform. Make sure Maven is in your path, and test by calling `mvn -v` from a command line.
DDLUtils and DBUnit
We will use DDLUtils and DBUnit to help us manage the structure of our database, as well as the data it contains. DDLUtils is a project that will let us define our database schema in a database-agnostic form, and automate the updates to the schema across our team as part of the build process.
DBUnit is a test framework for data. It will allow us to define data sets in XML, load them during testing, and make sure the data ends up in our process where we think it should be.
DBUnit will be fetched by Maven.
The DDLUtils libraries are included with the Maven library package.
TestNG
TestNG is a Java test framework. It will allow us to write unit tests for the Java code we’re going to write.
Maven will also fetch TestNG for us. Why, thanks, Maven!
EJB 3.0
EJB 3.0 is one of the stars of our project. It’s going to let us persist Java objects to the database quickly and easily with a minimum of configuration.
The EJB 3.0 libraries are included with the Maven library package.
JBoss and Embedded JBoss
JBoss is an open source J2EE application server that supports the EJB 3.0 spec. We’ll also use a JBoss project, called Embedded JBoss, to run the persistence tests without having to run them in the server along with the extra hassle that causes.
To install JBoss go to http://labs.jboss.com/jbossas/downloads, download, and follow the site’s instructions for your platform.
The Embedded JBoss libraries are under the source code installation instructions.
Eclipse and Flex Builder
Eclipse is an industry-standard IDE platform that offers powerful Java development features. Adobe’s Flex Builder is a plug-in for the platform, and it is the easiest way to develop with Flex. It’s not required, though, because the Flex SDK has command-line tools for compiling Flex. We’ll discuss developing with both, using Ant and Maven to automate the compilation of Flex resources.
To install Eclipse go to http://www.eclipse.org/downloads/ and get the latest Eclipse SDK, not a bundle. Download and follow the site’s instructions for your platform.
To install Flex Builder (a 30-day trial), go to http://www.adobe.com/products/flex/flexbuilder/ and follow the instructions to download, then follow the instructions to install the Flex Builder plug-in, not the standalone version. This will allow you to work with Flex alongside Java.
Flex
The other star of our project, Flex is a declarative language for Flash interface design. In my opinion, it is the language and platform that offer the best balance between power, ease of use, and platform independence for developing RIAs.
You don’t need the SDK if you have Flex Builder installed. If you don’t have Flex Builder, go to http://www.adobe.com/products/flex/sdk/, follow the download and installation instructions, and test by calling `mxmlc --version` from a command line.
LiveCycle Data Services
LCDS is a Java and Flex library that works with a J2EE application to provide Flex with a powerful and easy way to connect to and communicate with an enterprise system. It provides services such as data management, which allows Flex to automatically send changes to data on the frontend to the backend for possible persistence; conflict management, to govern and help synchronize changes from occasionally connected clients; and support for connecting to document services provided by LCDS.
The LCDS libraries are available in the Maven library package.
Cairngorm
Cairngorm is the hard-to-pronounce but easy-to-use micro-framework for Flex. Cairngorm provides a number of patterns to help architect your Flex application in a manner that promotes modularity and a standard application design. When a developer is familiar with Cairngorm, it’s easy for him to come up to speed on any other Cairngorm project. The modularity also makes it easy for a team to work on Flex projects together.
Cairngorm is included with the source code for the sample application.
Cairngen
Cairngorm has been accused of being verbose by some. Each command requires an event class, a command class, and a modification of the controller class. I think Cairngorm is hardly verbose compared to, say, EJB 2.1, but it is tedious to build all those classes by hand, especially if you’re doing a lot of commands at once, as you will in the beginning of a project. A code generator such as Eric Feminella’s Cairngen (http://www.ericfeminella.com/blog/cairngen/) is an easy way to cut down on the tedium.
Cairngen is included with the sample application.
FlexUnit and FlexUnit Ant Tasks
FlexUnit is a test framework for Flex, available at http://code.google.com/p/as3flexunitlib/. Peter Martin of Adobe Consulting has some Ant tasks that make it possible to run FlexUnit tests with Ant, provided there’s a way to run a .swf file from the command line, such as with a browser. We’ll use the Ant tasks to run FlexUnit tests during the test phase of the sample project’s Maven build.
FlexUnit is included with the source code, and the Ant tasks library is available with the Maven library package.
In the next installment we'll have a look at the sample code we'll be covering throughout this series. You can always find the entire series here.






Facebook Application Development
waiting for next installment to come, thanks for posting this...
Great start!
Looking forward to it
A couple of tools I'd not heard of here. Thanks!
David
Very Cool. Eager to continue...
Thank you, guys. The nature of serialization means that the content will be spread out over the next few weeks, but I'm glad there's already some enthusiasm.
I'll try to provide some running commentary in the comments to any questions you may have. See you here next time!
Nice One!
I often hear of some of these tools, but have not exactly seen it put to work in a practical environment, where there suitability and the efficiency they add to the development process are clearly amplified.
Im chilling eagerly...
Thanks
Dude,
Seems like this will be a great article, I'm pretty much starting out on the RIA journey so much of what your talking about will go over my head. I appreciate the fact that you're spending the time to put the post together. I'll be tuned in! Thanks
Very nice start, seems like you prepared something pretty serious for the developers. I'm tuned in, subscribed, thinking about translation this series into Russian — would you mind?
After looking through the enterprise-flex-code.zip, I have to admit that this is truly an impressive undertaking, given the "lightweight development environment" of using EJB and Cairngorm.
I suppose the author(s) are used to writing EJB's, but, let's get realistic here. The Java world is NOT writing EJB's anymore unless they have to. Everyone's moving back to manageable architectures, even POJO is now more popular and supportable.
I can only think one is trying to "flex" their Java muscle (excuse the pun) needlessly here. Developers don't want to learn how to fit an EJB solution with Flex...they want to learn the best integration methods for Flex and their associated data services, which, most likely, will not be EJB.
I like the thoroughness, but, implementing a complex EJB layer in an "best practices" example certainly does NOT promote learning "Enterprise" RIA.
Hi David,
You make some interesting comments there and I would be inclined to agree.
I would even go so far as to question why someone would implement a green field project using an RDBMS when there are technologies such as db4o around.
I used to allocate about 30% of my development estimates to having to deal with the database layer, and that certainly didn't change with EJB3.0. EJB 2 was messy, but I had code generators (e.g. WSAD) so I'm not saving much, if anything, with the new "streamlined" version of EJB.
For my current project I am using an OODBMS (db4o) for data storage and as a result my "database" estimate has been so low it hasn't even been worth putting it in to our plan.
With regards to Flex, when the developer is used to working with objects anyway it seems to me as though building RDBMS schema and implementing a complicated data services layer is a massive overhead in terms of learning curve and development effort.
Cheers,
Chris
The Cairngen Project has been moved to Google Code:
http://code.google.com/p/cairngen/
Thanks,
Eric
Busycode Inc. helps you to build Adobe Flex applications with very low hourlyrate.
Want to outsource a project?
Please visit http://www.busycode.com.
My email is: cogoing@gmail.com
Hello;
I originally had all of the tools already installed on this project but had problems building the boogie-ui portion of the project. I installed the latest versions of all the tools and tried again, but keep having the same problem.
Here is my problem when trying to build the project like the instructions say: mvn package
mvn -Dmaven.test.skip=true package I turned testing off because test fail. I am not concerned about them right now just want to launch the application.
This then builds the bookie-data, which is fine then the bookie-ui, which is where I am having my problem. Here is my error
[INFO] Error executing ant tasks
Embedded error: The following error occurred while executing this line:
C:\Temp\FlexExample\code\bookie-ui\build.xml:33: Execute failed: java.io.IOException: CreateProcess: C:\tools\flex3\bin\mxmlc -context-root /bookie -load-config C:\Temp\FlexExample\code\bookie-ui\src\main\bookie.war\WEB-INF\flex\flex-config.xml -services C:\Temp\FlexExample\code\bookie-ui\src\main\bookie.war\WEB-INF\flex\services-config.xml index.mxml error=193
It is the ant build.xml script line 33 where it tries to build the flex files. I tried performing this on the command line with the mxmlc compiler using the same switches as defined in the build.xml, but I still get the same error.
If anyone has seen this problem or could point me in the right direction that would be awesome. I am trying to get my company to move towards the RIA/Java technology and this example is what our architecture will look like.
Much help would be appreciate;
Thanks
Peter
For any one that is interested. I found a very good tutorial on this same topic that in my mind is much easier to follow and I was actually able to follow the instructions and build it.
http://sebastien-arbogast.com/2008/04/15/flex-spring-and-blazeds-the-full-stack-part-4/
Peter
Great start to the series!! Will be reading through all of them !!