Enterprise Flex RIA

January 23, 2008

In this installment of the series Anatomy of an Enterprise Flex RIA we’re doing a little grunt work and installing some tools we’ll be using later. Download them and read up a bit on what they do. These tools are some common “enterprise software” development tools that we’ll need to get the example software up and running.

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.