Fire up your applications with Jazz
RSS
Jazz/Jetfire Wiki

About Us

Code Plex Projects

COR COR Administration Custom software Debug GUI Jazz Jazz Administration Jazz Web Parts Jetfire Administration Jetfire Code Jetfire Core Jetfire Language Jetfire Web Part Library misc Release Notes Roles Solutions States Training User Administration Versioning Web Parts Web Service Website Design Website Procedures Wiki conventions WordML Workflow Administration

Quick Search
»
Advanced Search »

PoweredBy

Overview

Rules, in Jetfire, are methods are are automatically invoked by changes to fields or properties allowing policies to be implemented. A rule method will typically test one or more conditions to determine if an action should be performed. Rules support forward chaining and using rules Jetfire becomes a Business Rule Engine.

Rules provide a simple programming model requiring no knowledge of complex programming structures such as events, delegates, threads and mutual exclusion.

Jetfire internally implements a data flow architecture that allows a simple rule programming model to be presented to the programmer.

Rules can be used to implement Aspect-Oriented Programming 'concerns' involving data.

Rules are first class constructs.

Table of Contents [Hide/Show]

Rule Method

  1. A rule method is public method with a void return type and no parameters (see 'Rule Declaration' below).
  2. A rule method is guaranteed to be automatically executed if any instance properties, or fields, used by the rule method change.
    • Jetfire optimizes calling rule methods to prevent unnecessary execution of a rule method; however rule methods must be designed to allow for execution even if no changes occur.
  3. A rule method may change instance properties or fields that cause other rules to execute.
  4. A rule method may be called like any standard method from Jetfire code or the application interface.


Rule Declaration

A rule method is method that has no parameters and has a void return type. To declare a rule method use the key word 'rule' as shown in the following example:
rule MyRule()
{
// normal jetfire code
}
Rule methods are always treated as public; however no access modifier is allowed to be specified.

Rule Example

In the following example "MyRule" will automatically set a property ("Completed") when all members of the List ("taskList") are true.

The method "MyRule" will execute automatically whenever the collection("taskList") changes (member added or removed) or whenever a member of the collection is modified. In this example other code is responsible for changing the List("taskList").

namespace RuleExample
{
public workflow Tasks()
{
private List taskList;
public bool Completed
{
get;
private set;
}
// constructor
public Tasks(List taskList)
{
this.Completed = false;
this.taskList = taskList;
}
// MyRule is invoked whenever 'TaskList' changes or
// whenever a workflow in the 'TaskList' collection changes value.
rule MyRule()
{
// check all 'Task's (workflows) in the collection 'TaskList'
foreach(Task f in this.TaskList)
{
if(!f.IsCompleted)
{
//if a single task is not completed
this.IsAllTasksCompleted = false;
return;
}
}
// tasks must be completed
this.IsAllTasksCompleted = true;
}
}
}

Note: This example my be confusing to seasoned programmers because they might expect that more programming effort is required to have the rule method properly. The execution of the rule method is performed by the Jetfire system which optimizes the execution of the 'rule' method so it executes only when it is required.

Complete Example

A complete examples are available in the download at jetfire.codeplex.com in the project JetfireCoreExampleTests.RuleTests.

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.