February 27, 2021
Hot Topics:

Introducing JBoss(r) Seam

  • By Jim Farley
  • Send Email »
  • More Articles »

Seam Extends Java EE

The previous section gave you a sense for the ways that JBoss Seam simplifies Java EE development, especially when it comes to applications using JSF and EJB components. This section quickly surveys the various extended capabilities that Seam provides in its framework. These capabilities are pretty compelling in their own right, even if the programming simplifications described earlier don't interest you.

Seam Component Services

I mentioned the Seam component model in the previous section because it serves as the basis for the JSF/EJB simplifications provided by Seam. The Seam component model also provides a number of powerful extended services on top of the Java EE framework.

Seam Component Contexts

As with most Java EE component models, Seam components support various runtime contexts or scopes. Seam components support the typical contexts found in web components (request, page, session, and application scopes). But the model adds several additional contexts that can be useful in enterprise applications.

Seam components support an explicit representation of a stateless context, for example. This context isn't usually represented explicitly, because components with stateless context really don't have any context (context refers to the scope of the component state, and stateless components by definition have no state).

In addition, Seam components also have contexts for conversation scope and busi­ness process scope. The conversation context is a critical piece of Seam's overall web application model, so I discuss it next in its own section.

The business process context represents state for a (possibly long-running) business process. Since business processes can run much longer than the lifetime of a request, a session, or even the application server itself, the business process context uses persistence services for its state data. Business processes also involve multiple users, potentially, so the context supports concurrent access as well.

Seam Conversations

Seam conversations are a very interesting and potentially powerful concept provided by the framework. One way to describe Seam's conversation concept is that it is a truly user-oriented transaction. Persistence transactions (like those managed in a JTA context) are typically defined around data consistency concerns, and business process transactions typically are defined around task dependencies and process structural consistency. Seam conversations provide another dimension of transactions, defined by what a user needs/wants to do within an application.

Another, less formal but more palatable, way to describe conversations is that they provide another layer between request scope and session scope in web applications. A conversation can group together data across multiple web requests, and it can track multiple groupings like this within a single user session.

Seam Events

JSF provides an event model in its component model, but Seam introduces two new types of events that can be utilized within Seam applications: page actions and component-driven events.

Seam page actions are events that you can have triggered after a user makes a web request, but before the requested web component or page is rendered. You can specify page actions that are to be invoked on request to specific views, or use wildcards to cover groups of views. Page actions are implemented by component operations (JSF managed bean methods and/or Seam component methods).

Seam component-driven events provide a general event notification scheme for Seam components. A set of named events can be defined, and component methods can be registered as "callbacks" on these events. Any component can trigger an event any-where in its business code, and any component operations on the notification list will be invoked.

Integrated Pageflow with jPDL

First, it's used to implement a rich pageflow capability. The jBPM Process Definition Language (jPDL) supports more complex and robust pageflows than JSF navigation rules can provide. jPDL pageflows are stateful, in the sense that the flow is defined as transitions between explicit, named states. jPDL pageflows are much more structured than JSF navigation rules—they define starting states, transitions, intermediate state nodes, and end states. And jPDL pageflows can be more explicit and externalized than JSF pageflows—transitions are defined around component actions and their outcomes, state transitions can themselves trigger state changes by invoking component methods, and so on.

Integrated Business Processes with jBPM and JBoss Rulesh4

jBPM is also used in Seam to provide support for business process management in Seam applications. Business processes merge pageflow, transactions, task definitions, and rules to provide a way to define structured task flows. A business process defines what needs to be done and in what order, who needs to perform specific tasks or task types, and the rules under which all this happens.

In addition to jBPM, Seam also integrates the JBoss Rules framework into its business process services. These two capabilities work hand-in-hand to allow you to define and implement business processes in your Seam application.

Rich Internet Applications (aka Web 2.0)

Seam provides some powerful facilities for integrating rich Internet UIs into your Seam component model, providing interesting ways to plug your business logic directly into your client-side UI. Seam supports rich Internet applications built using Asynchronous JavaScript and XML (AJAX) in two fundamental ways. First, it supplies a remoting capability for Seam components (mentioned earlier in this article) that allows JavaScript code to invoke your components directly from the client side of the web UI. Second, Seam supplies a set of JavaScript "shim" code that makes it easy for you to make use of this component remoting capability in AJAX contexts.


In this article, you've had a brief (but hopefully motivating) introduction to the capabilities JBoss Seam brings to the table when building Java EE applications. You saw how Seam simplifies Java EE by bridging its EJB and JSF component models, and how Seam extends Java EE with a number of additional capabilities, like structured pageflow, business process management, and rich web application support. You were also introduced to the Gadget Catalog application.

About the Author

Jim Farley of JimFarley.org is an enterprise Java luminary, author, and expert. He currently works for Infosys as principal architect and is a lecturer at Harvard. His authoring credits include Java Enterprise in a Nutshell.

Source of This Material

Practical JBoss® Seam Projects
By Jim Farley

Published: July 2007, Paperback: 229 pages
Published by Apress
ISBN: 1-59059-863-6
Price: $39.99
eBook Price: $20.00
This material is Chapter 1 of the book.
Reprinted with the publisher's permission.

Page 6 of 6

This article was originally published on December 7, 2007

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date