net.ponder2.policy
Class ObligationPolicy

java.lang.Object
  extended by net.ponder2.policy.Policy
      extended by net.ponder2.policy.ObligationPolicy
All Implemented Interfaces:
ManagedObject, EventListener

public class ObligationPolicy
extends Policy
implements ManagedObject, EventListener

an obligation policy that performs Event, Condition, Action rules for the SMC

Version:
$Id:$
Author:
Kevin Twidle

Field Summary
 
Fields inherited from class net.ponder2.policy.Policy
defaultDomain
 
Constructor Summary
ObligationPolicy(P2Object myP2Object)
          creates a new obligation policy.
 
Method Summary
protected  void attach(P2Object aManagedObject)
          attaches this policy to aManagedObject.
 void event(Event event)
          called to deal with an event when one occurs
 P2ManagedObject getId()
          Called to get an ID to keep track of events
protected  void onError(P2Block anErrorBlock)
          associates anErrorBlock with the receiver.
protected  P2Object operation_action(P2Block aBlock)
          adds aBlock to the list of actions of the policy.
protected  P2Boolean operation_canExecute(P2Object anEvent)
          answers true if anEvent has the values that satisfy all the policy's conditions
protected  P2Object operation_condition(P2Block aBlock)
          adds aBlock to the list of conditions of the policy.
protected  P2Object operation_eaction(P2Block aBlock)
          adds aBlock to the list of actions to be handed the whole event when it occurs.
protected  P2Object operation_event(P2Object anEventTemplate)
          Sets anEventTemplate to be the type of event that this policy should be triggered by.
protected  void operation_execute(P2Object anEvent)
          executes all the actions using anEvent.
protected  void operation_value(P2Object source, P2Object anEvent)
          executes all the actions using anEvent.
 
Methods inherited from class net.ponder2.policy.Policy
getDefaultDomain, isActive, isAttached, operation_active, setActive, setAttached
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObligationPolicy

public ObligationPolicy(P2Object myP2Object)
creates a new obligation policy. The policy is empty until filled by other messages. The policy is initially not active.

Method Detail

event

public void event(Event event)
           throws Ponder2Exception
Description copied from interface: EventListener
called to deal with an event when one occurs

Specified by:
event in interface EventListener
Parameters:
event - the event to be handled
Throws:
Ponder2Exception

getId

public P2ManagedObject getId()
Description copied from interface: EventListener
Called to get an ID to keep track of events

Specified by:
getId in interface EventListener
Returns:
the managed object of the event listener

operation_canExecute

protected P2Boolean operation_canExecute(P2Object anEvent)
                                  throws Ponder2ArgumentException
answers true if anEvent has the values that satisfy all the policy's conditions

Parameters:
anEvent - the event of the correct type
Returns:
true if the condition returns true
Throws:
Ponder2ArgumentException
Ponder2Exception

attach

protected void attach(P2Object aManagedObject)
Description copied from class: Policy
attaches this policy to aManagedObject. This policy may be attached to more than one managed object. This command forms part of the proximity event bus.

Specified by:
attach in class Policy
Parameters:
aManagedObject - the managed object that the policy should be attached to

operation_execute

protected void operation_execute(P2Object anEvent)
executes all the actions using anEvent. AnEvent is given to every action defined for the policy. Actions may be executed in parallel. Statements within an action block are executed serially. Answers the receiver. This policy is the source for the action blocks

Parameters:
anEvent - the event (of the expected event type) to give arguments for the actions

operation_value

protected void operation_value(P2Object source,
                               P2Object anEvent)
                        throws Ponder2Exception
executes all the actions using anEvent. AnEvent is given to every action defined for the policy. Different actions could be executed in parallel. Statements within an action block are executed serially. Answers the receiver. This message makes the policy look like a block with the source being the caller.

Parameters:
anEvent - the event (of the expected event type) to give arguments for the actions
Throws:
Ponder2Exception

operation_event

protected P2Object operation_event(P2Object anEventTemplate)
Sets anEventTemplate to be the type of event that this policy should be triggered by. Answers anEventTemplate.

Parameters:
anEventTemplate - the eventTemplate to be used by this policy
Returns:
the event template given

operation_condition

protected P2Object operation_condition(P2Block aBlock)
adds aBlock to the list of conditions of the policy. Answers aBlock.

Parameters:
aBlock - a condition block
Returns:
the block given

operation_action

protected P2Object operation_action(P2Block aBlock)
adds aBlock to the list of actions of the policy. Answers aBlock.

Parameters:
aBlock - an action block
Returns:
the block given

operation_eaction

protected P2Object operation_eaction(P2Block aBlock)
adds aBlock to the list of actions to be handed the whole event when it occurs. Answers aBlock.

Parameters:
aBlock - an action block
Returns:
the block given

onError

protected void onError(P2Block anErrorBlock)
associates anErrorBlock with the receiver. The error block is executed if a Ponder2 error occurs in the receiver. The error block is given one P2Error argument which contains the error details.

Parameters:
anErrorBlock -


Copyright © 2008 Imperial College. All Rights Reserved.