Questo contenuto non è disponibile nella lingua selezionata.

14.3. Using rules from a jBPM process definition


A rule base can act as a jBPM action, decision, or assignment handler in either a pageflow or a business process definition.
<decision name="approval">         
  <handler class="org.jboss.seam.drools.DroolsDecisionHandler">
    <workingMemoryName>orderApprovalRulesWorkingMemory</workingMemoryName>
    <assertObjects>
      <element>#{customer}</element>
      <element>#{order}</element>
      <element>#{order.lineItems}</element>
    </assertObjects>
  </handler>
    
  <transition name="approved" to="ship">
    <action class="org.jboss.seam.drools.DroolsActionHandler">
      <workingMemoryName>shippingRulesWorkingMemory</workingMemoryName>
      <assertObjects>
        <element>#{customer}</element>
        <element>#{order}</element>
        <element>#{order.lineItems}</element>
      </assertObjects>
    </action>
  </transition>  
  <transition name="rejected" to="cancelled"/> 
</decision>
Copy to Clipboard Toggle word wrap
The <assertObjects> element specifies EL expressions that return an object or collection of objects to be asserted as facts into the WorkingMemory.
Using Drools for jBPM task assignments is also supported:
<task-node name="review">
  <task name="review" description="Review Order">
    <assignment handler="org.jboss.seam.drools.DroolsAssignmentHandler">
      <workingMemoryName>
        orderApprovalRulesWorkingMemory
      </workingMemoryName>
      <assertObjects>
        <element>#{actor}</element>
        <element>#{customer}</element>
        <element>#{order}</element>
        <element>#{order.lineItems}</element>
      </assertObjects>
    </assignment>
  </task>
  <transition name="rejected" to="cancelled"/>
  <transition name="approved" to="approved"/>
</task-node>
Copy to Clipboard Toggle word wrap
Certain objects are available as Drools globals — the jBPM Assignable is available as assignable, and the Seam Decision object is available as decision. Rules that handle decisions should call decision.setOutcome("result") to determine the decision result. Rules that perform assignments should set the actor ID with Assignable.
package org.jboss.seam.examples.shop
import org.jboss.seam.drools.Decision 
global Decision decision 
rule "Approve Order For Loyal Customer" 
  when 
    Customer( loyaltyStatus == "GOLD" ) 
    Order( totalAmount <= 10000 ) 
  then 
    decision.setOutcome("approved"); 
end
Copy to Clipboard Toggle word wrap
package org.jboss.seam.examples.shop 
import org.jbpm.taskmgmt.exe.Assignable 
global Assignable assignable 
rule "Assign Review For Small Order" 
  when 
    Order( totalAmount <= 100 ) 
  then 
    assignable.setPooledActors( new String[] {"reviewers"} ); 
end
Copy to Clipboard Toggle word wrap

Note

More information about Drools is available at http://www.drools.org.

Important

Seam comes packaged with enough Drools dependencies to implement some simple rules. To add extra capabilities, download the full Drools distribution and add extra dependencies as required.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2026 Red Hat