| By Norman Richards | Article Rating: |
|
| February 19, 2006 12:45 PM EST | Reads: |
53,537 |
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">
<action expression="#{shippingEmail.send}" />
</transition>
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...
There's a lot more to say about Seam. This article has focused entirely on the management of contextual components to provide for simpler Web application development. However, Seam goes well beyond that. Let's look at some of the other things that make Seam interesting.
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
Seam is a powerful new application framework for managing contextual components. Seam represents the next logical step in the evolution of applications, letting Web application components take advantage of a much richer set of contexts without polluting the components with code unrelated to the core function of the component. Seam is fast and easy and represents the state-of-the-art of modern Web development.
Resource
Published February 19, 2006 Reads 53,537
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Norman Richards
Norman Richards is a JBoss developer living in Austin, Tx. He is co-author of JBoss: A Developer's Notebook and XDoclet in Action.
![]() |
SYS-CON Belgium News Desk 02/19/06 01:41:18 PM EST | |||
Web sites were originally static. Later dynamic content came about through CGI scripts paving the way for the first true Web applications. Since HTTP was entirely stateless, it became necessary to invent ways for requests to be linked together in a sequence. At first state was added to the URLs, but later the cookie concept came into being. By giving each user a special token, the server could maintain a context for each user, the HTTP session where the application can store state. As simple as it is, the HTTP session defines the entire concept of what a Web application is today. |
||||
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- Confessions of a Ulitzer Addict
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- It's the Java vs. C++ Shootout Revisited!
- Cloud Computing Can Revitalize Your Career as Software Developer
- IBM Could "Reinvent" Java: Mills
- Oracle & Cloud Computing: Exclusive Q&A with SVP Richard Sarwal
- A Brief History of Cloud Computing
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Why IBM’s Server Chief Got Busted
- Is Cloud Computing Like Teenage Sex?
- Industry Experts Discuss the State of Cloud Computing
- Performance Tuning Essentials for Java
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- i-Technology Predictions for 2007: Where's It All Headed?









































