JBoss Seam

JBoss Seam

In the following example for the DVD store application, we add business process to the validation of any order. Let's add a business process that automatically accepts every order under 100 dollars and delegates validation to an administrator for all other orders. Once the validation is made, a process step is needed to add the shipping number information. To do such a process, we decided to write the following JPDL:

<process-definition name="OrderManagement">

    <start-state>

        <transition to="decide"/>

    </start-state>

    

    <decision name="decide" 

expression="#{orderApproval.howLargeIsOrder}">

        <transition name="large order" 

                       to="approval"/>

        <transition name="small order" 

                       to="process"/>

    </decision>



    <task-node name="approval">

        <task name="approve">

           <assignment 

             pooled-actors="reviewers" />

        </task>

        <transition name="approve" 

                       to="process"/>

        <transition name="reject"  

                       to="complete"/>

    </task-node>

    

    <task-node name="process">

        <task name="ship">

           <assignment pooled-actors=

           "#{shipperAssignment.pooledActors}"/>

        </task>

        <transition name="shipped" 

                       to="complete">

            <action expression=

                   "#{afterShipping.log}"/>

        </transition>

    </task-node>

    

    <end-state name="complete"/>

</process-definition>

In this simple but yet powerful example, we see how the integration of jBPM and Seam let you directly enter JSF expressions directly into the jPDL. The #{orderApproval.howLargeIsOrder} calls the howLargeIsOrder method on the "orderApproval" Seam component, which is exactly how it works in the JSF page. Here is the source code for that Seam component:

package com.jboss.dvd.seam;



import org.jboss.seam.annotations.In;

import org.jboss.seam.annotations.Name;



@Name("orderApproval")

public class OrderApprovalDecision {

   @In float amount;

   public String getHowLargeIsOrder()

   {

      return amount > 100 ? 

        "large order" : "small order";

   }

}

Nothing fancy here; we just injected the amount from the stateful contexts and a string returns indicating which decision to take. We can also notice in the pageflow definition that the transition from "process" to "complete" triggers a call to the "log" method of the "afterShipping" Seam component.

Portable and Lightweight

Seam relies exclusively on JDK 5.0 annotation metadata for the declaration of components and how they are associated in a particular context--no XML hell. Seam can be used with any JSF implementation and runs on any JEE 5.0 container. With the Microcontainer, Seam can even be used in Tomcat or in unit tests. For developers who are not ready yet for EJB 3.0, Seam also supports POJOs and Hibernate persistent classes as components.

The DVD store example can work in Tomcat by adding few configuration files; there is such an example in the Seam distribution.

Resources

  • To learn more about JBoss Seam, visit the project website.
  • In the Seam distribution you will find the DVD store we talked about in this article in our examples.
  • Check out our Seam Hotel Booking demo application.
  • JBoss EJB3
  • JBoss jBPM
  • The JBoss Eclipse IDE bundles a jBPM pageflow and workflow visual designer.

Thomas Heute is the project leader of JBoss Seam


Return to ONJava.com.

Prev  [1] [2] [3] [4] [5] 

Close    To Top
  • Prev Article-Java:
  • Next Article-Java:
  • Now: Tutorial for Web and Software Design > Java > JavaBeans > Java Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction