Java EE 6 Twitter Demo @ JavaOne 2010 Technical General Session Keynote
By arungupta on Sep 21, 2010
This blog explains a typical 3-tier Java EE 6 application that lets the user monitor twitter trends for pre-defined hashtags. The following diagram explains the application's architecture.
Java EE 6 is a complete stack that provides support for all three tiers. This application uses a Java Server Faces front-end and uses PrimeFaces widget library to generate the monitoring charts. The widget library provides 100+ rich set of components and uses JSF 2.0 APIs and Servlet 3.0 features like self-registration. The "backing bean" for the JSF front-end is an EJB packaged in the WAR - yet another ease-of-use feature in Java EE 6. This EJB uses JPA for persistence query the stored tweets in a database. There is another EJB in the middle tier that triggers a method every 3 minutes, specified using the simplified cron-like @Schedule syntax, and uses Jersey Client API to get data from Twitter. And this EJB also uses JPA to store the queried tweets in the database.
A live version of this demo is available at glassfish.org/twitter-demo. An earlier snapshot of the trends is shown below:
The source code for this application can be downloaded as a Maven project here. This code comes with a "readme.txt" that explains how to create schema for a pre-defined JDBC resource in GlassFish, deploy, and run the application.
This application demonstrates the following features of Java EE 6:
- Facelets as templating language using JSF 2.0
- Composite components using JSF 2.0 - enables abstraction and reusable code
- Third-party open source widget library based upon JSF 2.0
- Simplified EJB packaging in a WAR file
- CDI bean as the "backing bean" for JSF 2.0 and other dependency injection
- Simplified cron-like timer syntax in EJB 3.1 using @Schedule
- Jersey Client API to invoke RESTful endpoints
- Simplified usage of JPA for persistence
Currently this application uses a pre-defined set of hashtags. A future version will allow the users to specify their own set of hashtags and then monitor them.
How about using this application for a tweet-a-thon for your next conference ?