Amazon Ads

Wednesday, April 14, 2010

JSF, JBoss Seam and EJB3

I just happened to explore this combination of technologies recently as it was required for a project. The first impression is that it is a providing a very impressive standards-based alternative to other frameworks which have become the de-facto standard in the Java World – Hibernate and spring.

The learnings of the community from various previous not-so-successful frameworks and some good frameworks which have been adopted by many have all been put together.

Also, there has been some out-of-the-box thinking w.r.t the way the layering has been handled. Standard JEE applications have been used to writing a lot of “glue” code for communication across the layers – presentation, business & data apart from others like integration etc. Some of the JEE patterns have been subtly built-in while some of them become redundant in this context – like a DAO or DTO or Business Delegate.

To put it crisply, here are the advantages of this combination of technologies and frameworks:

1. Provides a unified component model centered around EJB3

2. No tedious glue code to copy data back and forth between the layers

3. Supports dependency bijection – this is one of the main points that help us do away with glue code

4. Annotation driven data binding

5. Seam support JSF in such a seamless way that we do not have to have an extra layer of backing beans / managed beans – session beans itself can play the same role

6. Seam integrates hibernate validators even if we do not use Hibernate at the persistence layer. This allows for annotation-based integrated validation of data across the layers. Infact, this can do the front-end validation directly by annotating at the entity bean

7. Supports JPA lazy loading in JSF (open session in view) by default

8. Supports the use of JSF EL within EJB-QL. This makes it very clean and convenient

9. Seam support a lot many scopes as against the standard session scope. To name a few, it has – event, page, conversation, session, application, business process. This expands the horizon of how to manage state within an application and yet not have too many memory issues

10. Using Facelets as the View technology instead of JSP is the best thing that has happened. There have been many problems using JSP with JSF. Please read this article on Improving JSF by dumping JSP

11. Facelets provide templating, re-use and ease of development which have been some concerns with JSF.