Jump To Close Expand all Collapse all Table of contents JBoss Rules 5 Reference Guide Preface 1. Preface Expand section "1. Preface" Collapse section "1. Preface" 1.1. Business Integration 1.2. What is a Service-Oriented Architecture? 1.3. Key Points of a Service-Oriented Architecture 1.4. What is the JBoss Enterprise SOA Platform? 1.5. The Service-Oriented Architecture Paradigm 1.6. Core and Components 1.7. Components of the JBoss Enterprise SOA Platform 1.8. JBoss Enterprise SOA Platform Features 1.9. Features of the JBoss Enterprise SOA Platform's JBossESB Component 1.10. Task Management 1.11. Integration Use Case 1.12. Utilising the JBoss Enterprise SOA Platform in a Business Environment 2. Introduction Expand section "2. Introduction" Collapse section "2. Introduction" 2.1. Intended Audience 2.2. Aim of the Guide 3. Quick Start Expand section "3. Quick Start" Collapse section "3. Quick Start" 3.1. JBoss Rules 3.2. The JBoss Rules Engine 3.3. Production Rules 3.4. The Inference Engine 3.5. ReteOO 3.6. Production Memory 3.7. Working Memory 3.8. Conflict Resolution Strategy 3.9. Hybrid Rule Systems 3.10. Forward-Chaining 3.11. Backward-Chaining 3.12. Reasoning Capabilities 3.13. Expert Systems 3.14. The Rete Root Node 3.15. The ObjectTypeNode 3.16. AlphaNodes 3.17. Hashing 3.18. BetaNodes 3.19. Alpha Memory 3.20. Beta Memory 3.21. Lookups with BetaNodes 3.22. LeftInputNodeAdapters 3.23. Terminal Nodes 3.24. Node Sharing 3.25. Node Sharing Example 3.26. Loose Coupling 3.27. Strong Coupling 3.28. Declarative Programming 3.29. Logic and Data Separation 3.30. Knowledge Base 4. User Guide Expand section "4. User Guide" Collapse section "4. User Guide" 4.1. Stateless Knowledge Sessions 4.2. Configuring Rules in a Stateless Session 4.3. Configuring Rules with Multiple Objects 4.4. Stateful Sessions 4.5. Common Use Cases for Stateful Sessions 4.6. Stateful Session Monitoring Example 4.7. First Order Logic 4.8. Configuring Rules with First Order Logic 4.9. Rule System Sample Configuration 4.10. Methods in JBoss Rules 4.11. Method Example 4.12. Rule Example 4.13. Cross-Products 4.14. Cross-Product Constraining 4.15. The Inference Engine 4.16. Inference Example 4.17. Logical Assertions 4.18. Stated Insertions 4.19. Justified Insertions 4.20. The WM_BEHAVIOR_PRESERVE Setting 4.21. Stated Insertion Flowchart 4.22. Logical Insertion Flowchart 4.23. The Truth Maintenance System 4.24. The insertLogical Fact 4.25. Using Inference and TMS 5. Decision Tables Expand section "5. Decision Tables" Collapse section "5. Decision Tables" 5.1. Decision Tables 5.2. Decision Tables in Spreadsheets 5.3. Open Office Example 5.4. Rules and Spreadsheets 5.5. The RuleTable Keyword 5.6. The RuleSet Keyword 5.7. Rule Template Example 5.8. Data-Defining Cells 5.9. Rule Table Columns 5.10. Rule Set Entries 5.11. Entries in the Rule Set Area 5.12. Rule Attribute Entries in the Rule Set Area 5.13. The RuleTable Cell 5.14. Column Types 5.15. Column Headers in the Rule Table 5.16. Conditional Elements 5.17. Action Statements 5.18. Metadata Statements 5.19. Interpolating Cell Data Example 5.20. Tips for Working Within Cells 5.21. The SpreadsheetCompiler Class 5.22. Using Spreadsheet-Based Decision Tables 5.23. Lists 5.24. Revision Control 5.25. Tabular Data Sources 5.26. Rule Template Capabilities 5.27. Rule Template Example 5.28. Executing Rule Templates 5.29. Extended Changeset Example 5.30. Changesets and Directories Example 5.31. Knowledge Agent 5.32. Knowledge Agent Example 5.33. KnowledgeAgent Objects 5.34. Starting Polling Services 5.35. Custom ClassLoaders for KnowledgeBuilder 5.36. Reusing the KnowledgeBase ClassLoader 5.37. KnowledgeAgentConfiguration Example 5.38. The newInstance Property 5.39. Using the newInstance Property 5.40. newInstance Example 5.41. Remote HTTP Resource Caching 5.42. Restoring Resource Caching After a Restart 6. Processing Expand section "6. Processing" Collapse section "6. Processing" 6.1. Agenda 6.2. Agenda Processing 6.3. Default Conflict Resolution Strategies 6.4. AgendaGroup 6.5. setFocus() 6.6. setFocus() Example 6.7. ActivationGroup 6.8. ActivationGroup Example 6.9. RuleFlowGroup 6.10. RuleFlowGroup Example 6.11. The Difference Between Rules and Methods 6.12. Cross Product Example 6.13. Activations, Agenda and Conflict Sets Example 6.14. Conflict Resolver Strategy 6.15. Conflict Resolver Strategy Example 6.16. Trigger Example 6.17. ruleflow-group Example 6.18. Inference Example 6.19. Implementing Inference and TruthMaintenance 7. The Rule Language Expand section "7. The Rule Language" Collapse section "7. The Rule Language" 7.1. The KnowledgeBuilder 7.2. The ResourceFactory 7.3. Creating a new KnowledgeBuilder 7.4. Adding DRL Resources 7.5. KnowledgeBuilder Result Inspection Methods 7.6. Getting the KnowledgePackages 7.7. Extended KnowledgeBuilder Example 7.8. Using KnowledgeBuilder in Batch Mode 7.9. Discard the Build of the Last Added DRL 7.10. Building Using Configuration and the ChangeSet XML 7.11. XML Schema for ChangeSet XML (not normative) 8. ChangeSets Expand section "8. ChangeSets" Collapse section "8. ChangeSets" 8.1. Changesets 8.2. Changeset Example 8.3. ChangeSet XML Example 8.4. ChangeSet Protocols 8.5. Loading the ChangeSet XML 8.6. ChangeSet XML with Resource Configuration Example 8.7. ChangeSet XML and Directories 9. Building Expand section "9. Building" Collapse section "9. Building" 9.1. Build Result Severity 9.2. Setting the Default Build Result Severity 9.3. KnowledgePackage 9.4. Creating a new KnowledgeBase 9.5. In-Process Building and Deployment 9.6. Add KnowledgePackages to a KnowledgeBase 9.7. Building and Deployment in Separate Processes 9.8. Writing the KnowledgePackage to an OutputStream 9.9. Reading the KnowledgePackage from an InputStream 9.10. The JBoss Rules Management System 9.11. StatefulknowledgeSessions and KnowledgeBase Modifications 9.12. New KnowledgeAgents 9.13. Writing the KnowledgePackage to an OutputStream 9.14. Starting the Scanning and Notification Services 9.15. The ResourceChangeScanner 9.16. Changing the Scanning Intervals 9.17. Interactions Between Knowledge Agents and Knowledge Bases 9.18. Using an Existing KnowledgeBase 9.19. The applyChangeSet() Method 9.20. ChangeSet XML to Add Directory Contents 9.21. The KnowledgeAgentConfiguration Property 9.22. Change the Scanning Behavior 10. Sessions Expand section "10. Sessions" Collapse section "10. Sessions" 10.1. Sessions in JBoss Rules 10.2. Create a StatefulKnowledgeSession From a KnowledgeBase 10.3. The WorkingMemoryEntryPoint Method 10.4. The KnowledgeRuntime Interface 10.5. Fact Insertion 10.6. The FactHandle Token 10.7. FactHandle Example 10.8. Identity and Equality 10.9. Retraction 10.10. Retraction Example 10.11. The update() Method 10.12. update() Example 10.13. Queries 10.14. Query Example 10.15. Live Queries 10.16. ViewChangedEventListener Implementation Example 10.17. KnowledgeRuntime 11. Objects and Interfaces Expand section "11. Objects and Interfaces" Collapse section "11. Objects and Interfaces" 11.1. Globals 11.2. Working With Globals 11.3. Resolving Globals 11.4. Session Scoped Global Example 11.5. StatefulRuleSessions 11.6. AgendaFilter Objects 11.7. Using the AgendaFilter 11.8. Rule Engine Phases 11.9. The Event Model 11.10. The KnowlegeRuntimeEventManager 11.11. The WorkingMemoryEventManager 11.12. Adding an AgendaEventListener 11.13. Printing Working Memory Events 11.14. KnowlegeRuntimeEvents 11.15. Supported Events for the KnowledgeRuntimeEvent Interface 11.16. The KnowledgeRuntimeLogger 11.17. Enabling a FileLogger 11.18. Using StatelessKnowledgeSession in JBoss Rules 11.19. Performing a StatelessKnowledgeSession Execution with a Collection 11.20. Performing a StatelessKnowledgeSession Execution with the InsertElements Command 11.21. The BatchExecutionHelper 11.22. The CommandExecutor Interface 11.23. Out Identifiers 12. Modes and Methods Expand section "12. Modes and Methods" Collapse section "12. Modes and Methods" 12.1. Sequential Mode 12.2. Sequential Mode Options 12.3. Activating Sequential Mode 12.4. The CommandFactory 12.5. Supported CommandFactory Options 12.6. The Insert Command 12.7. Insert Command Example 12.8. The Execute Method 12.9. Execute Method Example 12.10. The BatchExecution Command 12.11. The FireAllRules Command 12.12. Out Identifiers 12.13. Out Identifier Example 12.14. Execution XML Examples 12.15. Execution Marshalling Examples 12.16. Batch-execution and Command Examples 12.17. The MarshallerFactory 12.18. Marshaller Example 12.19. Marshalling Options 12.20. IdentityMarshallingStrategy Example 12.21. The ObjectMarshallingStrategyAcceptor 12.22. The ClassFilterAcceptor Implementation 12.23. IdentityMarshallingStrategy with Acceptor Example 12.24. Persistence and Transactions in JBoss Rules 12.25. Transaction Example 12.26. Using a JPA 12.27. Loading a StatefulKnowledgeSession with JPA 12.28. Configuring JPA 12.29. Configuring JTA DataSource 12.30. JNDI Properties 12.31. KnowledgeBase Namespaces 13. Using Spreadsheet Decision Tables Expand section "13. Using Spreadsheet Decision Tables" Collapse section "13. Using Spreadsheet Decision Tables" 13.1. Hard Keywords 13.2. Soft Keywords 13.3. List of Soft Keywords 13.4. Comments 13.5. Single Line Comment Example 13.6. Multi-Line Comment Example 13.7. Error Messages 13.8. Package 13.9. Import Statements 13.10. Using Globals 13.11. The From Element 13.12. Using Globals with an e-Mail Service 14. Functions Expand section "14. Functions" Collapse section "14. Functions" 14.1. Functions 14.2. Function Declaration Example 14.3. Function Declaration with Static Method Example 14.4. Calling a Function Declaration Example 14.5. Type Declarations 14.6. Type Declaration Roles 14.7. Declaring New Types 14.8. Declaring a New Fact Type Example 14.9. Declaring a New Fact Type Additional Example 14.10. Using Import Example 14.11. Generated Java Classes 14.12. Generated Java Class Example 14.13. Using the Declared Types in Rules Example 14.14. Declaring Metadata 14.15. Working with Metadata Attributes 14.16. Declaring a Metadata Attribute with Fact Types Example 14.17. The @position Attribute 14.18. @position Example 14.19. Predefined Class Level Annotations 14.20. @key Attribute Functions 14.21. @key Declaration Example 14.22. Creating an Instance with the Key Instructor Example 14.23. Positional Arguments 14.24. Positional Argument Example 14.25. The @Position Annotation 14.26. Example Patterns 15. Additional Declarations Expand section "15. Additional Declarations" Collapse section "15. Additional Declarations" 15.1. Declaring Metadata for Existing Types 15.2. Declaring Metadata for Existing Types Example 15.3. Declaring Metadata Using a Fully Qualified Class Name Example 15.4. Parametrized Constructors for Declared Types Example 15.5. Non-Typesafe Classes 15.6. Accessing Declared Types from the Application Code 15.7. Declaring a Type 15.8. Handling Declared Fact Types Through the API Example 15.9. Type Declaration Extends 15.10. Type Declaration Extends Example 15.11. Traits 15.12. Traits Example 15.13. Core Objects and Traits 15.14. @Traitable Example 15.15. Writing Rules with Traits 15.16. Rules with Traits Example 15.17. Hidden Fields 15.18. The Two-Part Proxy 15.19. Wrappers 15.20. Wrapper Example 15.21. Wrapper with isA Annotation Example 15.22. Removing Traits 15.23. Rule Syntax Example 15.24. Timer Attribute Example 15.25. Timers 15.26. Cron Timer Example 15.27. Calendars 15.28. Quartz Calendar Example 15.29. Registering a Calendar 15.30. Left Hand Side 15.31. Conditional Elements 15.32. Rule Without a Conditional Element Example 16. Patterns Expand section "16. Patterns" Collapse section "16. Patterns" 16.1. Patterns 16.2. Pattern Example 16.3. Pattern Matching 16.4. Pattern Binding 16.5. Pattern Binding with Variable Example 16.6. Constraints 17. Elements and Variables Expand section "17. Elements and Variables" Collapse section "17. Elements and Variables" 17.1. Property Access on Java Beans (POJOs) 17.2. POJO Example 17.3. Working with POJOs 17.4. POJO Fallbacks 17.5. Fallback Example 17.6. Java Expressions 17.7. Comma-Separated Operators 17.8. Comma-Separated Operator Example 17.9. Binding Variables 17.10. Binding Variable Examples 17.11. Unification 17.12. Unification Example 17.13. Options and Operators in JBoss Rules 17.14. Operator Precedence 17.15. Fine Grained Property Change Listeners 17.16. Fine Grained Property Change Listener Example 17.17. Working with Fine Grained Property Change Listeners 17.18. Using Patterns with @watch 17.19. @watch Example 17.20. Using @PropertySpecificOption 17.21. Basic Conditional Elements 17.22. The Conditional Element Forall 17.23. Forall Examples 17.24. The Conditional Element From 17.25. From Examples 17.26. The Conditional Element Collect 17.27. The Conditional Element Accumulate 17.28. Syntax for the Conditional Element Accumulate 17.29. Functions of the Conditional Element Accumulate 17.30. The Conditional Element accumulate and Pluggability 17.31. The Conditional Element accumulate and Pluggability Example 17.32. Code for the Conditional Element Accumulate's Functions 17.33. Accumulate with Inline Custom Code 17.34. Accumulate with Inline Custom Code Examples 17.35. Conditional Element Eval 17.36. Conditional Element Eval Examples 17.37. The Right Hand Side 17.38. RHS Convenience Methods 17.39. Convenience Methods using the Drools Variable 17.40. Convenience Methods using the Kcontext Variable 17.41. The Modify Statement 17.42. Query Examples 17.43. QueryResults Example 17.44. Queries Calling Other Queries 17.45. Queries Calling Other Queries Example 17.46. Unification for Derivation Queries 18. Domain Specific Languages (DSLs) Expand section "18. Domain Specific Languages (DSLs)" Collapse section "18. Domain Specific Languages (DSLs)" 18.1. Domain Specific Languages 18.2. Using DSLs 18.3. DSL Example 18.4. How the DSL Parser Works 18.5. The DSL Compiler 18.6. DSL Syntax Examples 18.7. Chaining DSL Expressions 18.8. Adding Constraints to Facts 18.9. Tips for Developing DSLs 18.10. DSL and DSLR Reference 18.11. The Make Up of a DSL Entry 18.12. Debug Options for DSL Expansion 18.13. DSL Definition Example 18.14. Transformation of a DSLR File 18.15. String Transformation Functions 18.16. Stringing DSL Transformation Functions 19. XML Expand section "19. XML" Collapse section "19. XML" 19.1. The XML Format 19.2. XML Rule Example 19.3. XML Elements 19.4. Detail of a Rule Element 19.5. XML Rule Elements 19.6. Automatic Transforming Between XML and DRL 19.7. Classes for Automatic Transforming Between XML and DRL 20. The Java Rule Engine Application Programming Interface Expand section "20. The Java Rule Engine Application Programming Interface" Collapse section "20. The Java Rule Engine Application Programming Interface" 20.1. JSR94 20.2. Javax.rules Interfaces 20.3. Javax.rules Classes 20.4. Javax.rules Exceptions 20.5. Using a Rule Service Provider 20.6. Javax.rules.admin Interfaces 20.7. Javax.rules.admin Exceptions 20.8. The RuleServiceProvider 20.9. The RuleServiceProviderManager 20.10. Automatic RuleServiceProvider Registration Example 20.11. Registering a LocalRuleExecutionSet with the RuleAdministrator API 20.12. Using Stateful and Stateless RuleSessions 20.13. Using Globals with JSR94 20.14. Using Globals with JSR94 Example 20.15. Further Reading About JSR94 21. JBoss Developer Studio Expand section "21. JBoss Developer Studio" Collapse section "21. JBoss Developer Studio" 21.1. The Rules Integrated Development Environment (IDE) 21.2. Rules IDE Features 21.3. JBoss Rules Runtimes 21.4. Defining a JBoss Rules Runtime 21.5. Selecting a Runtime for JBoss Rules Projects 21.6. Example Rule Files 21.7. The JBoss Rules Builder 21.8. Creating a New Rule 21.9. The Rule Editor 21.10. JBoss Rules Views 21.11. Using JBoss Rules Views 21.12. The Show Logical Structure 21.13. Creating Audit Logs 21.14. Event Icons in Audit View 21.15. Methods for Retrieving Causes 21.16. The DSL Editor 21.17. Rule Language Mapping 21.18. Working with Rule Language Mapping 21.19. DSL Translation Components 21.20. Tips for Working with Large DRL Files 21.21. Creating Breakpoints 21.22. Debugging as a JBoss Rules Application 21.23. Rules IDE Preferences 22. Hello World Example Expand section "22. Hello World Example" Collapse section "22. Hello World Example" 22.1. HelloWorld Example: Creating the KnowledgeBase and Session 22.2. HelloWorld Example: Event Logging and Auditing 22.3. HelloWorld Example: Message Class 22.4. HelloWorld Example: Execution 22.5. HelloWorld Example: System.out in the Console Window 22.6. HelloWorld Example: Rule "Hello World" 22.7. HelloWorld Example: Using the "Debug as..." Option 22.8. HelloWorld Example: Rule "Good Bye" 23. Salience State Example Expand section "23. Salience State Example" Collapse section "23. Salience State Example" 23.1. Salience State Example: State Class Example 23.2. Salience State Example: Execution 23.3. Salience State Example: Executing Applications 23.4. Salience State Example: Using Audit Logging with Operations 23.5. Salience State Example: Rule "Bootstrap" 23.6. Salience State Example: Rule "B to C" 23.7. Salience State Example: Rule "B to D" 23.8. Salience State Example: Inserting a Dynamic Fact 23.9. Salience State Example: Setter with PropertyChangeSupport 23.10. Salience State Example: Agenda Group Rules "B to C" 23.11. Salience State Example: Agenda Group Rules "B to D" 23.12. Salience State Example: Agenda Group Rules "D to E" 24. Fibonacci Example Expand section "24. Fibonacci Example" Collapse section "24. Fibonacci Example" 24.1. Fibonacci Example: The Class 24.2. Fibonacci Example: Execution 24.3. Fibonacci Example: Execution Details 24.4. Fibonacci Example: Recurse Rule 24.5. Fibonacci Example: Bootstrap Rule 24.6. Fibonacci Example: Calculate Rule 25. Banking Example Expand section "25. Banking Example" Collapse section "25. Banking Example" 25.1. Banking Example: RuleRunner 25.2. Banking Example: Rule in Example1.drl 25.3. Banking Example: Java Example 2 25.4. Banking Example: Rule in Example2.drl 25.5. Banking Example: Example3.java 25.6. Banking Example: Rule in Example3.drl 25.7. Banking Example: Class Cashflow 25.8. Banking Example: Example4.java 25.9. Banking Example: Class SimpleDate 25.10. Banking Example: Rule in Example4.drl 25.11. Banking Example: Class TypedCashflow 25.12. Banking Example: Example5.java 25.13. Banking Example: Class Account 25.14. Banking Example: Class AllocatedCashflow 25.15. Banking Example: Extending Example5.java 25.16. Banking Example: Rule in Example6.drl 26. Pricing Rule Example Expand section "26. Pricing Rule Example" Collapse section "26. Pricing Rule Example" 26.1. Pricing Rule Example: Executing the Pricing Rule Example 26.2. Pricing Rule Example: Decision Table Configuration 26.3. Pricing Rule Example: Base Price Calculation Example 26.4. Pricing Rule Example: Discount Calculation Example 27. Pet Store Example Expand section "27. Pet Store Example" Collapse section "27. Pet Store Example" 27.1. Pet Store Example 27.2. Pet Store Example: Creating the PetStore RuleBase in PetStore.main 27.3. Pet Store Example: Firing Rules from CheckoutCallBack.checkout() 27.4. Pet Store Example: Package, Imports, Globals and Dialect from PetStore.drl 27.5. Pet Store Example: Java Functions in the Rules Extracted from PetStore.drl 27.6. Pet Store Example: Putting Items Into Working Memory from PetStore.drl 27.7. Pet Store Example: Show Items in the GUI from PetStore.drl 27.8. Pet Store Example: Evaluate Agenda Group from PetStore.drl 27.9. Pet Store Example: Doing the Checkout Extract from PetStore.drl 27.10. Pet Store Example: Checkout Rules from PetStore.drl 27.11. Pet Store Example: Running PetStore.java 27.12. Pet Store Example: The Do Checkout Rule 28. Sudoku Example Expand section "28. Sudoku Example" Collapse section "28. Sudoku Example" 28.1. Sudoku Example: Loading the Example 28.2. Sudoku Example: Debugging a Broken Example 28.3. Sudoku Example: Java Source and Rules 28.4. Sudoku Example: Cell Objects 28.5. Sudoku Example: Classes and Objects 28.6. Sudoku Example: Validate.drl 28.7. Sudoku Example: Sudoku.drl 29. Number Guess Example Expand section "29. Number Guess Example" Collapse section "29. Number Guess Example" 29.1. Number Guess Example: Loading the Example 29.2. Number Guess Example: Starting the RuleFlow 29.3. Number Guess Example: Classes and Methods 29.4. Number Guess Example: Observing the RuleFlow 29.5. Number Guess Example: RuleFlow Nodes 29.6. Number Guess Example: Firing Rules at a Specific Point in NumberGuess.drl 29.7. Number Guess Example: Viewing RuleFlow Constraints 29.8. Number Guess Example: Console Output A. Revision History Legal Notice Settings Close Language: 日本語 English Language: 日本語 English Format: Multi-page Single-page PDF Format: Multi-page Single-page PDF Language and Page Formatting Options Language: 日本語 English Language: 日本語 English Format: Multi-page Single-page PDF Format: Multi-page Single-page PDF Red Hat Training A Red Hat training course is available for JBoss Enterprise SOA Platform Appendix A. Revision History Revision HistoryRevision 5.3.1-73.4002013-10-31Rüdiger Landmann Rebuild with publican 4.0.0 Revision 5.3.1-73Tue Feb 05 2013 David Le Sage Built from Content Specification: 11912, Revision: 371716 by dlesage Previous Next