Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
1K views11 pages

Drools.NET 3.0 User Guide

This document provides an installation and user guide for Drools.NET 3.0. It describes installing and using Drools.NET, including its basic rule features, decision tables, pre-compilation support, and support for multiple .NET languages. Examples are included in the org.drools.dotnet.examples.dll library and can be run with NUnit. The guide covers rule syntax, debugging support, known issues, and planned future enhancements.

Uploaded by

Johannes Kuah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views11 pages

Drools.NET 3.0 User Guide

This document provides an installation and user guide for Drools.NET 3.0. It describes installing and using Drools.NET, including its basic rule features, decision tables, pre-compilation support, and support for multiple .NET languages. Examples are included in the org.drools.dotnet.examples.dll library and can be run with NUnit. The guide covers rule syntax, debugging support, known issues, and planned future enhancements.

Uploaded by

Johannes Kuah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

User Guide for Drools.NET-3.0 V1.

0-Feb 27th , 2007

ABOUT THIS DOCUMENT This document is an installation and user guide for Drools.NET 3.0
REVISION HISTORY Date 1. Feb 27th , 2006 2. 3. Description Created

Table of Contents

EXECUTIVE SUMMARY 4 1.1 Purpose ..........................................................................................4 1.2 Business Vision...............................................................................4 Drools.NET Installation 5 1.3 System Requirements.....................................................................5 1.4 Release Contents............................................................................5 1.5 Installation......................................................................................5 Drools.NET Features Description and Usage 7 1.6 Using Basic Features of Drools........................................................7 1.7 Drools.NET Decision Tables.............................................................8
1.7.1 Getting Drools.NET Decision Tables working:........................................8 1.7.2 Drools.NET v/s Drools Decision Tables:..................................................9 1.7.3 Syntax of Decision Tables:....................................................................9

1.8 Pre-Compilation Support...............................................................10 1.9 Support for Multiple .NET languages.............................................10 Running Examples 11 Rules Syntax 11 Debugging Support 11 Known Issues 11 Future work and Enhancements 11

EXECUTIVE SUMMARY 1.1 Purpose


This document provides a description of the following Installing Drools.NET-3.0 Drools.NET-3.0 Features Description and their Usage Running example applications. Rules Syntax

Each of these will be described in a different section of this document.

1.2 Business Vision


The Drools.NET-3.0 is a .NET version of Jboss-Rules 3.0, which is a Rules Engine implementation based on Charles Forgy's Rete algorithm tailored for the Java language. Drools.NET enables .NET developers/Users to exploit the powerful Rule Engine like Jboss-Rules through a completely managed .NET code base.

Drools.NET Installation

1.3 System Requirements


Here are the system requirements for using Drools.NET: Microsoft .NET Framework 2.0. Drools.NET will NOT run on .NET Framework 1.1 (http://msdn.microsoft.com/netframework/downloads/updates/) IKVM 0.28.0.0 (http://www.ikvm.net) , included with the distribution NUnit-2.2.6 or above (http://www.nunit.org), framework is included with the distribution

1.4 Release Contents


Drools.NET release consists of the following External Libraries: o Drools-3.0.dll - The core drools assembly compiled using IKVM (IKVM is a compiler used to compile Java classes and jars into a .NET assembly) o Drools-dep.dll Dependencies required by drools-3.0.dll o IKVM.GNU.Classpath.dll - IKVM dependency required by the drools3.0.dll assembly o IKVM.Runtime.dll - IKVM dependency required by the drools-3.0.dll assembly o nunit.framework.dll and nunit.core.dll Assemblies required to create and run NUnit tests Drools.NET Libraries o org.drools.dotnet.dll - Drools .NET wrapper classes and .NET semantic layer classes o org.drools.dotnet.examples.dll - Drools .NET examples implemented as NUnit tests o /drls directory The example rules definition files that are embedded in the example library (Given here just for reference) o The source code for Drools.NET libraries and example drl files can be downloaded from CVS. The module name is drools-dotnet (Provide CVS Download Instructions)

1.5 Installation

The Drools.NET BRE can be used in an application by referencing the following assemblies: drools-3.0.dll IKVM.GNU.Classpath.dll drools.dotnet.dll

Drools.NET Features Description and Usage

Drools.NET currently supports most of the features supported by Drools-3.0 and more. Basic features of Jboss-Rules-3.0 See the core-engine features at http://labs.jboss.com/portal/jbossrules. The work for Rules Authoring Tool for .Net is underway Support for Decision Tables Support for Precompiled Rule-Bases Serialized Rule-Bases can be stored by the user and loaded as required. Support for Multiple .NET languages Support for debugging consequnces a drl file

1.6 Using Basic Features of Drools


Drools.NET allows you to create, load and execute Rules in the same manner as it is done in Jboss-Rules 3.0. It also exposes underlying Jboss-Rules API to allow greater flexibility to a dotnet user. API classes PackageBuilder and RuleBaseLoader provides functions for creating a Rule-Base. RuleBaseLoader is a high level helper class for creating RuleBases from source, while PackageBuilder class provides additional control on how the rulebase is created. A basic sequence of steps to use a PackageBuilder or RuleBaseLoader is as follows: //Step 1: include the following namespace using org.drools.dotnet.compiler; using org.drools.dotnet.rule; //Step 2: Use following steps to create a RuleBase //Approach 1 using RuleBaseLoader

Stream stream = Assembly.GetAssembly(this.getType()).GetManifestResourceStream(test.drl) ; RuleBase ruleBase = RuleBaseLoader.getInstance.LoadFromStream(stream); //Approach 2 using PackageBuilder PackageBuilder builder = new PackcageBuilder(); Stream stream = Assembly.GetAssembly(this.getType()).GetManifestResourceStream(test.drl) ; builder.AddPackageFromDrl(test.drl , stream); Package pkg = builder.getPackage(); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(pkg) //Step 3: Get an instance of WorkingMemory for the loaded RuleBase WorkingMemory workingMemory = ruleBase.NewWorkingMemory(); //Step 4: Assert facts workingMemory.AssertObject(Hello); //Step 5: Fire all Rules workingMemory.FireAllRules();

1.7 Drools.NET Decision Tables


Decision Tables in Drools.NET work similarly to decision tables in Jboss-Rules. Please visit the documentation provided at Jboss Rules website (http://labs.jboss.com/portal/jbossrules/docs) , in order to get an understanding of how decision tables are used in Jboss-Rules. 1.7.1 Getting Drools.NET Decision Tables working:

Using Drools.NET decision tables is very similar to the regular Drools.NET API. A class called DecisionTableLoader defines functions for using decision-tables in .NET. Following is an example code snippet:
//Get drl string from the spreadsheet SpreadSheetCompiler converter = new SpreadsheetCompiler(); Stream stream = Assembly.gtAssembly(this.getType()).GtManifestResourceStream(test .xls); String drl = converter.Compile(stream, InputType.XLS); //build a rule base PackageBuilder builder = new PackageBuilder(); builder.AddPackageFromDrl(drl) //everything from here is just like normal Drools.NET Package pkg = builder.getPackage(); RuleBase ruleBase = RuleBaseFactory.NewRuleBase(); ruleBase.AddPackage(pkg); WorkingMemory engine = ruleBase.NewWorkingMemory(); TestModel model = new TestModel (); engine.AssertObject(model); engine.FireAllRules();

1.7.2

Drools.NET v/s Drools Decision Tables:

The only difference between the two decision tables is the language used for specifying conditions, consequences, functions etc. For Drools.NET, the language should be a .NET language, while in Drools Decision Tables it is Java. 1.7.3 Syntax of Decision Tables:

Decision Tables syntax in Drools.NET is exactly the same as Decision Tables in Drools. NOTE: If a class from an external library (not current working directory) is being referenced in a decision table, then its assembly name must be specified in the decision table with its declaration as follows:

RuleTable allocateStream(org.drools.dotnet.examples.decisiontables.model.Claim.ASSEMBLY .org.drools.dotnet.examples claim) The class name must be a fully classified name followed by string .ASSEMBLY. and then the assembly name. It ensures that the class gets loaded correctly.

1.8 Pre-Compilation Support


A Rulebase can be persisted and reloaded in an application as required, no recompilation necessary. It is good for people who have very large Rule-Sets.

RuleBase class provide API functions to save and reload a RuleBase. The Rulebase is serialized and stored in a System.Stream provided by the user. There are examples provided in the examples library.

1.9 Support for Multiple .NET languages


Drools.Net currently supports C# only. In the future it might support other .NET languages too.

10

Running Examples
Drools.NET examples can be found in library org.drools.dotnet.examples.dll. All the examples are implemented as NUnit tests, which can be run directly using NUnit GUI or Console application. They can also run in Visual Studio .NET. All of these examples are taken directly from Jboss-Rules-3.0 and have been ported to .NET.

Rules Syntax Debugging Support Known Issues


TBD

Future work and Enhancements


TBD

11

You might also like