net.ponder2
Class EventTemplate

java.lang.Object
  extended by net.ponder2.EventTemplate
All Implemented Interfaces:
ManagedObject

public class EventTemplate
extends java.lang.Object
implements ManagedObject

Managed object to act as a template for notifications (events). Each instance of the template contains a set of named arguments. These argument names can be retrieved for checking against Policies that expect to be activated by the events. When an event is created using this template the named arguments are packed into a map and sent around the system inside the event.

Version:
$Id:$
Author:
Kevin Twidle

Field Summary
protected  ArgumentList argList
           
static java.lang.String defaultDomain
           
 
Constructor Summary
protected EventTemplate(P2Object myP2Object)
          creates an empty template.
protected EventTemplate(P2Object myP2Object, P2Array anArray)
          creates an event template with anArray containing the argument names.
 
Method Summary
protected  void operation_arg(java.lang.String arg)
          adds an argument field to this event definition.
protected  void operation_args(P2Object anArray)
          adds anArray of argument fields to this event template.
protected  void operation_create(P2Object source)
          creates and sends an event of this type with no values.
protected  void operation_create(P2Object source, P2Array anArray)
          creates and sends an event of this type with values from anArray.
protected  void operation_create(P2Object source, P2Hash aHash)
          creates and sends an event of this type with values from aHash.
 P2Hash packageArgs(P2Array anArray)
           
 P2Hash packageArgs(P2Object... args)
          INTERNAL OPERATION.
 P2Hash packageHash(P2Hash args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

argList

protected ArgumentList argList

defaultDomain

public static java.lang.String defaultDomain
Constructor Detail

EventTemplate

protected EventTemplate(P2Object myP2Object)
creates an empty template. Further messages must be sent to give the named arguments.

Parameters:
myP2Object -

EventTemplate

protected EventTemplate(P2Object myP2Object,
                        P2Array anArray)
                 throws Ponder2ArgumentException,
                        Ponder2OperationException
creates an event template with anArray containing the argument names.

Parameters:
myP2Object -
anArray -
Throws:
Ponder2ArgumentException
Ponder2OperationException
Method Detail

packageArgs

public P2Hash packageArgs(P2Object... args)
                   throws Ponder2ArgumentException
INTERNAL OPERATION. Takes a list of objects and packages them into a hash indexed with the argument names. Answers the new hash.

Parameters:
args - the arguments to be taken as values
Returns:
a hash containing named values from args
Throws:
Ponder2ArgumentException

packageArgs

public P2Hash packageArgs(P2Array anArray)
                   throws Ponder2ArgumentException
Throws:
Ponder2ArgumentException

packageHash

public P2Hash packageHash(P2Hash args)
                   throws Ponder2ArgumentException
Throws:
Ponder2ArgumentException

operation_arg

protected void operation_arg(java.lang.String arg)
                      throws Ponder2ArgumentException
adds an argument field to this event definition. Answers the receiver

Parameters:
arg - the name of the argument to add
Throws:
Ponder2ArgumentException

operation_args

protected void operation_args(P2Object anArray)
                       throws Ponder2ArgumentException,
                              Ponder2OperationException
adds anArray of argument fields to this event template. Answers the receiver.

Parameters:
anArray - the names of the arguments to become attributes of the event
Throws:
Ponder2ArgumentException
Ponder2OperationException

operation_create

protected void operation_create(P2Object source)
                         throws Ponder2Exception
creates and sends an event of this type with no values. Answers the receiver

Parameters:
source - the ID of the object initiating the event
Throws:
Ponder2Exception

operation_create

protected void operation_create(P2Object source,
                                P2Array anArray)
                         throws Ponder2Exception
creates and sends an event of this type with values from anArray. Answers the receiver

Parameters:
source - the ID of the object initiating the event
anArray - the values to be filled in as attributes of the event
Throws:
Ponder2Exception

operation_create

protected void operation_create(P2Object source,
                                P2Hash aHash)
                         throws Ponder2Exception
creates and sends an event of this type with values from aHash. Answers the receiver

Parameters:
source - the ID of the object initiating the event
aHash - the named values to be filled in as attributes of the event
Throws:
Ponder2Exception


Copyright © 2008 Imperial College. All Rights Reserved.