Building First Cup. Pt 1

Summary: I will walk you through making the application, FirstCup, using Spring, Maven, Flare, and BlazeDS.

Introductory Fluff:

For my Information Visualization class, we were tasked with finding a large data set and creating a system for visualizing it. My group and I chose the corpus of entries at JavaBlogs.com for our dataset. Most of our data was plain text with annotations for post date, author, and site. Over all we had over 300,000 posts and around 800 MiB of data (posts + metadata + indexes).

Before I continue further, I would like to introduce my teammates. They were extremely helpful and patient during this project. I am happy with our results. Andrew Miller [www.andrewmiller.net] is a Human Centered Computing PhD student at Georgia Tech and did the graphical design of the site. My other partner was Steven Choi [http://www.prism.gatech.edu/~schoi67/ ] who is a MS Human Computer Interaction Student at Georgia Tech. He was responsible for much of the Flex work.

The video of this project can be viewed on YouTube.

Actual Content:

Enough with pleasantries, let’s get to business. I modeled most of my Maven structure after Sébastien Arbogast’s article. While this is slightly out of date, it is still a good read and step by step guide to get most of this project going. This article is updated however, and includes the latest Flex Mojos.

First, let’s make the maven project.
[sourcecode]
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=net.saga.projects \
-DartifactId=FirstCup
[/sourcecode]
Navigate into the FirstCup directory and open the pom. Make the packaging value pom instead of jar. Save the pom and continue.
Now let’s make the backend web module.

[sourcecode]
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes \
-DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=net.saga.projects -DartifactId=FirstCup-web
[/sourcecode]

The configuration module. This will provide an assembly which will serve as the repository for the BlazeDS configuration.

[sourcecode]
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=net.saga.projects \
-DartifactId=FirstCup-config
[/sourcecode]

And the two Flex views. These will use the flex-mojos archetype.

[sourcecode]
mvn archetype:create -DarchetypeGroupId=org.sonatype.flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DgroupId=net.saga.projects \
-DartifactId=FirstCup-Graph
[/sourcecode]

[sourcecode]
mvn archetype:create -DarchetypeGroupId=org.sonatype.flexmojos \
-DarchetypeArtifactId=flexmojos-archetypes-application \
-DgroupId=net.saga.projects \
-DartifactId=FirstCup-Timeline
[/sourcecode]

Now that we have our project set up, we must configure the build environments further. First, let’s set up out FirstCup-config project. As was mentioned, this will be a maven assembly project.
Add the assembly plugin and configuration:

[sourcecode] pom org.apache.maven.plugins
maven-assembly-plugin


make shared resources

single
package

src/main/assembly/resources.xml




[/sourcecode]

Notice we define a file called resources.xml This will be where we declare what files to add to the assembly.

[sourcecode]

resources
zip false


src/main/resources




[/sourcecode]

You should also create the “src/main/resources” structure.
Configure Flex Projects
The next steps will be done to BOTH Flex projects.
Let’s add the configuration files into our build.

[sourcecode] org.apache.maven.plugins
maven-dependency-plugin


unpack-config

unpack-dependencies
generate-resources
${project.build.directory}/generated-resources
FirstCup-config
${project.groupId}
true


[/sourcecode]

We also need to add a resources section to the build node.

[sourcecode]


${basedir}/src/main/resources


${basedir}/target/generated-resources
true


[/sourcecode]

Now time for adding the config project to our dependencies.

[sourcecode]

${project.groupId}
FirstCup-config
1.0-SNAPSHOT
resources
zip
provided

[/sourcecode]

Remember, this has to be done to the poms of BOTH Flex projects.

Configure the Web Application

Let’s add to the pom dependencies on both Flex projects as well as the config project.

[sourcecode] maven-dependency-plugin


unpack-config

unpack-dependencies
generate-resources
${project.build.directory}/${project.build.finalName}/WEB-INF/flex
FirstCup-config
${project.groupId}
resources
true
jar,swf



copy-swf process-classes
copy-dependencies


${project.build.directory}/${project.build.finalName}
swf


[/sourcecode]

And now our library dependencies.

[sourcecode]


${project.groupId}
FirstCup-Timeline
${project.version}
swf


${project.groupId}
FirstCup-Graph
${project.version}
swf


org.springframework
spring
2.5.2


com.adobe.blazeds
blazeds-common
3.0.0.544


com.adobe.blazeds
blazeds-core
3.0.0.544


com.adobe.blazeds
blazeds-remoting
3.0.0.544


backport-util-concurrent
backport-util-concurrent
3.1


javax.servlet
servlet-api
2.5
provided


${project.groupId}
FirstCup-config
1.0-SNAPSHOT
resources
zip
provided


org.springframework
spring-jdbc
2.5
compile


commons-dbcp
commons-dbcp
1.2.2
compile


mysql
mysql-connector-java
5.1.6
compile


[/sourcecode]

Conclusion

From here you should be able to build your project with mvn install. The project is ready for coding now. In the next part I will introduce actual logic.

Troubleshooting

If you have problems while running the tests, make sure that Flash is in your PATH.