Differences between revisions 2 and 3
Deletions are marked like this. Additions are marked like this.
Line 83: Line 83:
----
CategoryPonder2Project

Ponder2 Policies

Anatomy of a Policy

Policies are the Event Condition Action rules of the Ponder2. A policy is written in XML and describes the [:Ponder2UsingEvents:Event Type] that it will respond to, the event's arguments that it will use, optional conditions that must be satisfied and a set of actions to be performed.

A policy, called /policy/testpolicy, that uses testevent can be described as follows:

XSLT option disabled, please look at HelpOnConfiguration.
<use name="/policy">
  <add name="testpolicy">
    <use name="/template/policy">
      <create type="obligation" event="/event/testevent" active="true">
        <arg name="colour"/>
        <arg name="intensity"/>
        <condition>
          <and>
            <equals>!colour;<!-- -->red</equals>
            <gt>!intensity;<!-- -->34</gt>
          </and>
        </condition>
        <action>
          <!-- Add one to a counter managed object -->
          <use name="/dom1/counter">
            <inc/>
          </use>
        </action>
      </create>
    </use>
  </add>
</use>

Breakdown of Policy XML

Create a new Policy called /Policy/testpolicy

<use name="/policy">
  <add name="testpolicy">
    <use name="/template/policy">
      <create ...>
        ...
      </create>
    </use>
  </add>
</use>

The policy will be an ECA type policy ("obligation") and it will respond to events of type /event/testevent, described here. The policy will become active as soon as it is created.

      <create type="obligation" event="/event/testevent" active="true">
        ...
      </create>

The policy will make use of two named arguments that the event provides:

      <create event="/event/testevent" ...>
        <arg name="colour"/>
        <arg name="intensity"/>
        ...
      </create>

Named arguments are substituted as text before the XML action is evaluated by enclosing the name inside the two characters "!" and ";"

Condition

The optional condition can contain simple boolean statements comparing string and integer values. In this case we are checking whether the colour is red and the intensity is greater than 34. Conditions can contain any combination of and, or, not, eq, ne, gt, ge, lt or le. And and or take any number of XML sub-elements, not takes one, the others all take two. Note the string substitution of the arguments colour and intensity. Note also that the arguments for the comparisons have been separated by XML comments to ensure that they are separate XML elements.

        <condition>
          <and>
            <equals>!colour;<!-- -->red</equals>
            <gt>!intensity;<!-- -->34</gt>
          </and>
        </condition>

Action

The action part of the ECA policy is mandatory. It simply consists of Ponder2 XML, the only difference being that execution of the XML is delayed until the policy's event and condition parts are satisfied.

       <action>
          <!-- Add one to a counter managed object -->
          <use name="/dom1/counter">
            <inc/>
          </use>
        </action>


CategoryPonder2Project

ObligationPolicies (last edited 2008-01-25 12:39:01 by KevinTwidle)