Thursday, November 8, 2007

JBoss Seam

What is JBoss Seam

JBoss definition of JBoss Seam is “It’s a lightweight framework of Java EE 5.0

After reading this definition normally following question starts popping up:-

  • Isn’t Java EE (Enterprise Edition) 5.0 itself a collection of

“frameworks”?

  • Why do you need another one that is outside the official specification

Then what is actually JBoss Seam? JBoss seam can be viewed as “missing framework “, that should have been included in Java EE 5.0.

Key Features

  1. It sits on top of Java EE 5.0 framework to provide a consistent and easy to understand programming model for all components in an enterprise web application
  2. It also makes stateful applications and business process-driven applications a breeze to develop.

So, JBoss Seam is an agile framework. That is, Seam is all about developer productivity and application scalability.

The “glue” to Java Framework

The core framework in Java EE 5.0 is composed of:-

  • EJB (Enterprise Java Bean) 3.0. EJB3 is a POJO (Plain Old Java Objects) based lightweight framework for business services and data persistence
  • JSF (Java Server Faces) 1.2. JSF is a MVC (Model View Controller) component framework for web application

To make EJB3 and JSF work together, there is requirement for an artificial facade object (which is normally called backing bean) to tie business components to web pages, and boilerplate code to make method calls across framework boundaries. Gluing these technologies is the part of JBoss Seam.

Seam collapses the artificial layer between EJB3 and JSF. It provides a consistent, annotation based approach to integrate EJB3 and JSF. With a few simple annotations, the EJB3 business components in Seam can now be used directly to back JSF web forms or handle web UI events. Seam allows developers to use the “same kind of stuff”, annotated POJOs, for all application components. In another word, Seam brings out the synergy between EJB3 and JSF.

Designed for Stateful application

Seam is designed for stateful applications. Web applications are inherently multi – user applications and e-commerce based applications are inherently stateful and transactional.

In Seam, all the basic application components are inherently stateful. They are much easier to use than the HTTP session since their states are declaratively managed by Seam. There is no need to write distracting state management code in a Seam application -- just annotate the component with its scope, lifecycle methods, and other stateful properties -- and Seam takes over the rest. Seam stateful components also provide much finer control over user states than the plain HTTP session does. For instance, you can have multiple “conversations”, each consisting of a sequence of web requests and business method calls, in a HTTP session.

Furthermore, database caches and transactions can be automatically tied with the application state in Seam. Seam automatically holds database updates in memory and only commits to the database at the end of a conversation. The in-memory cache greatly reduces database load in complex stateful applications.

Seam takes state management in web applications a big step further by supporting integration with the Open Source JBoss jBPM business process engine.

POJO Services via Dependency Injection

Seam is a “lightweight framework” because it promotes the use of POJO (plain old Java objects) as service components. There are no framework interfaces or abstract classes to “hook” components into the application.

Seam wires POJO components together using a popular design pattern known as “dependency injection” (DI). Under this pattern, the Seam framework manages the lifecycle of all the components. When a component needs to use another, it declares this dependency to Seam using annotations. Seam determines where to get this dependent component based on the application’s current state and “injects” it into the asking component.

Expanding on the dependency injection concept, a Seam component A can also create another component B and “outjects” the created component B back to Seam for other components, such as C, to use later.

Avoid XML Abuse

Annotation based approach coupled with configuration by exception approach of JBoss Seam has made possible to remove hassles of xml configurations

Designed for testing

Seam is designed from ground up for easy testing. Since all Seam components are just annotated POJOs, they are very easy to unit test

No comments: