Drools Expert User Guide

Drools Expert User Guide

Drools Expert User Guide ....................................................................................................................................... vii 1. The Rule Engine .......................................................................................................... 1 1.1. What is a Rule Engine? ...................................................................................... 1 1.1.1. Introduction and Background .................................................................... 1 1.2. Why use a Rule Engine? .................................................................................... 6 1.2.1. Advantages of a Rule Engine ................................................................... 6 1.2.2. When should you use a Rule Engine? ....................................................... 7 1.2.3. When not to use a Rule Engine ................................................................ 8 1.2.4. Scripting or Process Engines .................................................................... 8 1.2.5. Strong and Loose Coupling ...................................................................... 9 2. Quick Start ................................................................................................................. 11 2.1. The Basics ....................................................................................................... 11 2.1.1. Stateless Knowledge Session ................................................................. 11 2.1.2. Stateful Knowledge Session .................................................................... 14 2.2. A Little Theory .................................................................................................. 19 2.2.1. Methods versus Rules ............................................................................ 19 2.2.2. Cross Products ...................................................................................... 20 2.2.3. Activations, Agenda and Conflict Sets. .................................................... 21 2.2.4. Inference ............................................................................................... 26 2.2.5. Inference and TruthMaintenance ............................................................. 28 2.3. More on building and deploying ......................................................................... 30 2.3.1. Knowledge Base by Configuration Using Changesets ............................... 30 2.3.2. Knowledge Agent ................................................................................... 31 3. Advanced Concepts and Theory ............................................................................... 35 3.1. Truth Maintenance with Logical Objects ............................................................. 35 3.1.1. Example Scenario .................................................................................. 37 3.1.2. Lazy Truth Maintenance ......................................................................... 38 3.1.3. Important note: Equality for Java objects ................................................. 38 3.2. Rete Algorithm .................................................................................................. 38 4. User Guide ................................................................................................................. 45 4.1. Building ............................................................................................................ 45 4.1.1. Building using Code ............................................................................... 46 4.1.2. Building using Configuration and the ChangeSet XML .............................. 49 4.2. Deploying ......................................................................................................... 52 4.2.1. KnowledgePackage and Knowledge Definitions ........................................ 52 4.2.2. KnowledgeBase ..................................................................................... 53 4.2.3. In-Process Building and Deployment ....................................................... 55 4.2.4. Building and Deployment in Separate Processes ...................................... 56 4.2.5. StatefulknowledgeSessions and KnowledgeBase Modifications ................. 57 4.2.6. KnowledgeAgent .................................................................................... 57 4.3. Running ............................................................................................................ 61 4.3.1. KnowledgeBase ..................................................................................... 61 4.3.2. StatefulKnowledgeSession ...................................................................... 62 4.3.3. KnowledgeRuntime ................................................................................. 62 iii Drools Expert User Guide 4.3.4. Agenda .................................................................................................. 71 4.3.5. Event Model .......................................................................................... 76 4.3.6. KnowledgeRuntimeLogger ...................................................................... 78 4.3.7. StatelessKnowledgeSession .................................................................... 79 4.3.8. Commands and the CommandExecutor ................................................... 83 4.3.9. Marshalling ............................................................................................ 91 4.3.10. Persistence and Transactions ............................................................... 93 4.3.11. Drools Clips ......................................................................................... 95 5. The Rule Language .................................................................................................... 97 5.1. Overview .......................................................................................................... 97 5.1.1. A rule file ............................................................................................... 97 5.1.2. What makes a rule ................................................................................. 97 5.2. Keywords ......................................................................................................... 98 5.3. Comments ...................................................................................................... 100 5.3.1. Single line comment ............................................................................. 100 5.3.2. Multi-line comment ............................................................................... 101 5.4. Error Messages .............................................................................................. 101 5.4.1. Message format ................................................................................... 101 5.4.2. Error Messages Description .................................................................. 102 5.4.3. Other Messages ................................................................................... 106 5.5. Package ......................................................................................................... 106 5.5.1. import .................................................................................................. 107 5.5.2. global .................................................................................................. 108 5.6. Function ......................................................................................................... 109 5.7. Type Declaration ............................................................................................. 110 5.7.1. Declaring New Types ........................................................................... 111 5.7.2. Declaring Metadata .............................................................................. 113 5.7.3. Declaring Metadata for Existing Types ................................................... 115 5.7.4. Parameterized constructors for declared types ....................................... 115 5.7.5. Non Typesafe Classes .......................................................................... 116 5.7.6. Accessing Declared Types from the Application Code ............................. 116 5.7.7. Type Declaration 'extends' .................................................................... 117 5.8. Rule ............................................................................................................... 118 5.8.1. Rule Attributes ..................................................................................... 119 5.8.2. Timers and Calendars .......................................................................... 123 5.8.3. Left Hand Side (when) syntax ............................................................... 124 5.8.4. The Right Hand Side (then) .................................................................. 171 5.8.5. A Note on Auto-boxing and Primitive Types ........................................... 174 5.9. Query ............................................................................................................. 174 5.10. Domain Specific Languages ........................................................................... 177 5.10.1. When to Use a DSL ........................................................................... 177 5.10.2. DSL Basics ........................................................................................ 178 5.10.3.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    354 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us