|
SYS-CON Magazines
|
Top Linux Links You Must Click On
Feature Seam: The Next Step in the Evolution of Web Applications
A powerful new application framework for managing contextual components
By: Norman Richards
Feb. 19, 2006 12:45 PM
The @BeginTask annotation takes the task associated with the taskId parameter and makes the corresponding process state available to the component. That allows the orderId to be injected and the corresponding order shipped. Since we've greatly simplified the flow here, this method uses the @EndTask annotation to signal the completion of the task. If the operation succeeds, the process will advance. In this simple example, the process completes, but if the process were more complex, other tasks, possibly for other users, might be created. Those new tasks would see any changes to the process state. We won't add any more tasks here. Instead let's make one tiny change to the process to illustrate how business process can further simplify the flow of the application. Let's imagine that we wanted to send an e-mail after shipping the order. We could do that in the ship() action, but then we'd be mixing the concerns of components. The ship component should only be concerned with the single action of shipping the order. There are many ways to add actions to a process in jBPM. We'll associate the e-mail action with the transition out of the state.
<transition name="shipped" to="complete"> This expression invokes the send action on the shippingEmail component. It's easy to see how a Seam component could inject state from the process, pull out the information to put in the e-mail, and use JavaMail to notify the user that the order has shipped. Using a process lets us separate out process concerns like sending a notification from application concerns like marking an order as shipped in the database. Seam lets us integrate with the business process without coupling the code to business process APIs or complicating the components with complex state management. Seam simplifies the application by letting components focus only on the exact task they're meant for and delegating all glue code to Seam.
One More Thing... The conversation model in Seam is much richer than what is shown here. Seam can carry on conversations with multiple components on a single page and switch between conversations. It has additional contexts beyond the ones mentioned so far. One example is the page context that stores state from one requrest for a subsequent request. Seam provides for model-based entity validation. Most Web application require user input to be validated. Sometimes this is done on the client side and sometimes it's done on the server side, but it's almost always a function of the UI. Seam provides an additional layer of model validation. Instead of only being about to say that an input field has to contain a valid e-mail address, an entity could use the Hibernate validation annotations to express that the e-mail address of the person entity should be a valid e-mail address. Seam can apply these validations any time an entity is used in a form. Seam supports the use of jBPM definition to describe the flow of pages in a conversation. jBPM pageflow is simpler and cleaner than JSF navigation, and allows for a separation of flows in an application. Pageflow definitions can be created and maintained using the visual process editor in jBPM. Seam applications and application components can be automatically generated, so a Seam-based application can get up and running quickly. This includes the now-popular generation of CRUD applications from a database schema. Testing is central to JBoss Seam. Seam supports testing user interactions with components in unit tests. These tests can be run, either in the IDE or from your build script, without involving an application server. Finally, JBoss Seam supports non-EJB development. This article show EJB3 integration, but Seam also supports Hibernate persistence directly. Application logic can be written using plain JavaBeans instead of EJB3 session beans. Seam applications can run inside any application server or even in a bare Web container like Tomcat.
Conclusion Resource
Reader Feedback: Page 1 of 1
Subscribe to our RSS feeds now and receive the next article instantly!
Subscribe to the World's Most Powerful Newsletters
|
||||||||||||||