For my final TheServerSide Java Symposium breakout session for the day, I am attending “Lightweight Application Development with Java EE 6” presented by Adam Bien. Adam’s talk is in part an attempt to bring former J2EE developers (myself included) back to the table who may have been driven off by previous, heavy-weight J2EE implementations, such as J2EE 1.4.
Adam spends most of his presentation actually building a simple Java EE 6 application on the fly, using Casino/Police/Mafia metaphor (since this conference is in Las Vegas). I’ll try to capture the highlights in this blog, but the code itself says volumes about how simple to use Java EE 6 has become. He develops in NetBeans IDe 6.9.1 with Glassfish as a web server, deploying everything as a WAR.
1. Simplifying Code with Annotations
Java EE 6, like Java EE 5 before it, solves a lot of complexity and deployment issues through Java 1.5’s creation of annotations. Adam shows a code example of a Stateless session bean is essentially just a POJO with the @Stateless annotation. The only required import is “javax.ejb.Stateless” for the annotation to reference.
2. Interceptors
Java EE 6 supports @Interceptors that redirect business methods for a better separation of POJOs and business logic. Serves as a filter for business methods.
3. Dependency Injection
The @Inject tag allows you create instances of related objects that live as long as the parent module. Easy to create events and inject them into classes.
4. Qualifiers
Adapted from Spring, helps control event ordering as far as which observer gets the message. The annotation @Qualifier is used on the class level with a @Retention and @Target parameters. The listener can then be updated to only listen to events of particular types or values. Furthermore, they can be use for filtering on events which is useful for batch processing.
5. Messaging
Java EE 6 supports @Asynchronous annotation for creating messaging handlers.
6. Interfaces
Similar to previous versions of J2EE, you can define an interface for a session bean and use references to the interface instead of the concrete class. Compiler throws an error if you try to inject an interface with no concrete implementation.
7. J2EE and Spring
Adam recommends not mixing the two, and building entirely in Spring xor J2EE 5 or 6. The features are very similar between the two and mixing them can be complicated. One of the major new features of Java EE 6 is REST integration.
Conclusion
Adam did not present any slides, but built a quite impressive Java EE 6 application on the fly with very little code. Everything he built deployed instanteously on his MacBook, and was accessible from the web browser right away. Adam pointed out not all computers or operating systems build as quickly.
I asked Adam if he would be posting his code online since it was quite educational. He said he will once he is back in Germany.
Thanks for attending my session && enjoy Java EE!
–adam
Adam usually posts his code to http://kenai.com/projects/javaee-patterns/sources/hg/show (See the “IronManManagementSystem” sample from his javaOne session)