com.oakgrovesystems.reactor.processMediation
Class Policy

java.lang.Object
  |
  +--com.oakgrovesystems.reactor.processMediation.Policy
All Implemented Interfaces:
ProcessAssociatedObject, ProcessMediationObject, java.io.Serializable

public class Policy
extends java.lang.Object
implements java.io.Serializable, ProcessAssociatedObject

Policy objects encapsulate arbitrary logic that is relevant to the process being modeled. They allow processes to be custom scripted and extremely flexible. Policies associate a Java class or BSF script with an event that should trigger its execution. The execution of a Policy is triggered in response to the firing of an event. Events consist of an event type (e.g. "ProcessStarted", "StatusAddition", etc.), an event source (e.g. "ProcessCommandService"), a table of event attributes, and an optional Process id that determines the scope of the event. If the scope Process id is included, only Policies associated with the Process specified or its ancestor Processes or Policies in the root node may be triggered by the event. The attributes in the table are specific to the type of event. For example, the attributes of a "ProcessFinished" event contains values for the following keys: "ProcessID" and "ProcessLabelPath"; the attributes of a "StatusAddition" event contains values for the following keys: "ProcessID", "ProcessLabelPath", "StatusID", and "StatusLabelPath". Appendix B lists the attributes that are available from events that are fired from within the Reactor system. Events are sent to Reactor's Policy Execution Service by other parts of the Reactor system in response to actions that occur. Events can also be sent from external systems to Reactor and in the future external systems will be able to register to be notified of events from within Reactor. Events only trigger the execution of Policies that match the event. The attributes of a Policy determine which events the Policy matches. A Policy can specify the type, source, and/or attributes of the events that should trigger it. For example, if a Policy specifies a type of "ProcessStarted" and an attribute value of "foo.bar" for the key "ProcessLabelPath", any event of type "ProcessStarted" with that attribute in its list of attributes will trigger the execution of that Policy, regardless of the source of the event or the other attributes of the event. Each Policy consists of one of two types of executable instructions that get execute when the Policy is triggered: Java classes and BSF scripts. The source code type attribute of a Policy attribute indicates the type of the Policy and how to access the executable instructions so that they can be executed. The source code type must be one of the following three values:

If the source code type is Classname, the contents of the source code attribute of the Policy are assumed to be a fully qualified Java class name. It attempts to load the class from the class path of the application server and execute an instance of it. The class must implement the java.lang.Runnable interface to be executed correctly. If the source code type is SourceCode, the contents of the source code attribute of the Policy are interpreted as raw source code of the language specified by the language attribute of the Policy. This source code is sent to BSF for execution. If the source code type is URL, the contents of the source code attribute of the Policy is assumed to be a URL that can be used to retrieve the raw source code of the language specified by the language attribute of the policy. If no language is specified by the language attribute of the policy, the Reactor system attempts to determine the language from the file extension of the URL. The source code is sent to BSF for execution.

See Also:
Serialized Form

Field Summary
protected  com.oakgrovesystems.reactor.processMediation.ACL acl
          the ACL of this Policy
static int CLASSNAME
          The value for sourceCodeType that indicates that the String sourceCode attribute is the classname of a runnable Java class
static int CODE
          The value for sourceCodeType that indicates that the String sourceCode attribute is source code of a BSF script.
protected  java.lang.String description
          the description of this Policy
protected  java.util.HashMap eventAttributes
          the event name (aka event type) a ReactorEvent must have to trigger the execution of this Policy.
protected  java.lang.String eventName
          the event name (aka event type) a ReactorEvent must have to trigger the execution of this Policy (null indicates that a ReactorEvent of any type may trigger the execution of this Policy).
protected  java.lang.String eventSource
          the event source a ReactorEvent must have to trigger the execution of this Policy (null indicates that a ReactorEvent with any event source may trigger the execution of this Policy).
protected  java.lang.String id
          the id of this Policy
protected  java.lang.String label
          the label of this Policy
protected  java.lang.String language
          the language of this Policy (only used with BSF Policies).
protected  com.oakgrovesystems.reactor.processMediation.MetaDataParser metaDataParser
           
protected  java.lang.String metaDataString
           
protected  com.oakgrovesystems.reactor.ReactorObjectId process
          the id of the Process with which this Policy is associated
protected  java.lang.String securityPolicy
          the name of the security policy to enforce on the execution of this Policy.
protected  java.lang.String sourceCode
          the classname, URL, or raw source for the executable code of this Policy, as specified by the sourceCodeType attribute
protected  int sourceCodeType
          whether the String sourceCode attribute contains the classname, url or raw source for the executable code of this Policy
static int URL
          The value for sourceCodeType that indicates that the String sourceCode attribute is the URL of an ASCII file that contains the source code for a BSF script
 
Constructor Summary
Policy()
          Creates a new Policy and sets it Id
 
Method Summary
 com.oakgrovesystems.reactor.processMediation.ProcessMediationObject copy()
          returns a deep copy of this ProcessMediationObject
 com.oakgrovesystems.reactor.processMediation.ACL getACL()
          gets the ACL of this ProcessMediationObject.
 java.lang.String getDescription()
          gets the desciption of this ProcessMediationObject.
 java.util.Map getEventAttributes()
           
 java.lang.String getEventName()
           
 java.lang.String getEventSource()
           
 java.lang.String getId()
          gets the Id of this ProcessMediationObject.
 java.lang.String getLabel()
          set the desciption of this ProcessMediationObject.
 java.lang.String getLanguage()
           
 java.lang.String getMetaDataString()
           
 java.lang.String getMetaDataValue(java.lang.String key)
           
 com.oakgrovesystems.reactor.ReactorObjectId getProcess()
          Gets the ReactorObjectId of the Process object with which this ProcessAssociatedObject is associated.
 java.lang.String getSecurityPolicy()
           
 java.lang.String getSourceCode()
           
 int getSourceCodeType()
           
 boolean isTriggeredBy(com.oakgrovesystems.reactor.ReactorEvent trigger)
          Determines whether or not a particular ReactorEvent triggers the execution of this Policy p.
 boolean sameAs(java.lang.Object o)
          compares two Policies for content equality
 void setACL(com.oakgrovesystems.reactor.processMediation.ACL acl)
          set the ACL of this ProcessMediationObject.
 void setDescription(java.lang.String description)
          set the desciption of this ProcessMediationObject.
 void setEventAttributes(java.util.Map eventAttributes)
           
 void setEventName(java.lang.String eventName)
           
 void setEventSource(java.lang.String eventSource)
           
 void setId(java.lang.String id)
          set the Id of this ProcessMediationObject.
 void setLabel(java.lang.String label)
          set the label of this ProcessMediationObject.
 void setLanguage(java.lang.String language)
           
 void setMetaDataKeyValue(java.lang.String key, java.lang.String value)
           
 void setMetaDataString(java.lang.String s)
           
 void setProcess(com.oakgrovesystems.reactor.ReactorObjectId id)
          Associates this ProcessAssociatedObject with the Process object referred to by the ReactorObjectId procId.
 void setSecurityPolicy(java.lang.String securityPolicy)
           
 void setSourceCode(java.lang.String sourceCode)
           
 void setSourceCodeType(int sourceCodeType)
           
 java.lang.String toString()
          returns the label if it is not empty or null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected java.lang.String id
the id of this Policy


label

protected java.lang.String label
the label of this Policy


description

protected java.lang.String description
the description of this Policy


acl

protected com.oakgrovesystems.reactor.processMediation.ACL acl
the ACL of this Policy


eventSource

protected java.lang.String eventSource
the event source a ReactorEvent must have to trigger the execution of this Policy (null indicates that a ReactorEvent with any event source may trigger the execution of this Policy).


eventName

protected java.lang.String eventName
the event name (aka event type) a ReactorEvent must have to trigger the execution of this Policy (null indicates that a ReactorEvent of any type may trigger the execution of this Policy).


eventAttributes

protected java.util.HashMap eventAttributes
the event name (aka event type) a ReactorEvent must have to trigger the execution of this Policy.


language

protected java.lang.String language
the language of this Policy (only used with BSF Policies).


securityPolicy

protected java.lang.String securityPolicy
the name of the security policy to enforce on the execution of this Policy.


sourceCode

protected java.lang.String sourceCode
the classname, URL, or raw source for the executable code of this Policy, as specified by the sourceCodeType attribute


sourceCodeType

protected int sourceCodeType
whether the String sourceCode attribute contains the classname, url or raw source for the executable code of this Policy


process

protected com.oakgrovesystems.reactor.ReactorObjectId process
the id of the Process with which this Policy is associated


metaDataString

protected java.lang.String metaDataString

metaDataParser

protected com.oakgrovesystems.reactor.processMediation.MetaDataParser metaDataParser

CLASSNAME

public static final int CLASSNAME
The value for sourceCodeType that indicates that the String sourceCode attribute is the classname of a runnable Java class

See Also:
Constant Field Values

URL

public static final int URL
The value for sourceCodeType that indicates that the String sourceCode attribute is the URL of an ASCII file that contains the source code for a BSF script

See Also:
Constant Field Values

CODE

public static final int CODE
The value for sourceCodeType that indicates that the String sourceCode attribute is source code of a BSF script.

See Also:
Constant Field Values
Constructor Detail

Policy

public Policy()
Creates a new Policy and sets it Id

Method Detail

getId

public java.lang.String getId()
gets the Id of this ProcessMediationObject. Ids are used to uniquely identify objects in the Reactor system ids should be created using the com.oakgrovesystems.util.UniqueId class

Specified by:
getId in interface ProcessMediationObject
Returns:
the Id of this ProcessMediationObject

getLabel

public java.lang.String getLabel()
set the desciption of this ProcessMediationObject. Desciptions are human readable text describing a Process. They are not used by internal Reactor functionality, but are included for use by Reactor clients.

Specified by:
getLabel in interface ProcessMediationObject
Returns:
the label of this ProcessMediationObject

getDescription

public java.lang.String getDescription()
gets the desciption of this ProcessMediationObject. Desciptions are human readable text describing a Process. They are not used by internal Reactor functionality, but are included for use by Reactor clients.

Specified by:
getDescription in interface ProcessMediationObject
Returns:
the description of this ProcessMediationObject

getACL

public com.oakgrovesystems.reactor.processMediation.ACL getACL()
gets the ACL of this ProcessMediationObject. ACLs describe the relationships between ProcessMediationObjects and users of the Reactor system.

Specified by:
getACL in interface ProcessMediationObject
Returns:
the acl of this ProcessMediationObject

getEventSource

public java.lang.String getEventSource()

getEventName

public java.lang.String getEventName()

getEventAttributes

public java.util.Map getEventAttributes()

getLanguage

public java.lang.String getLanguage()

getSecurityPolicy

public java.lang.String getSecurityPolicy()

getSourceCode

public java.lang.String getSourceCode()

getSourceCodeType

public int getSourceCodeType()

getProcess

public com.oakgrovesystems.reactor.ReactorObjectId getProcess()
Gets the ReactorObjectId of the Process object with which this ProcessAssociatedObject is associated.

Specified by:
getProcess in interface ProcessAssociatedObject
Returns:
The ReactorObjectId of the Process object with which this ProcessAssociatedObject is associated.

setId

public void setId(java.lang.String id)
set the Id of this ProcessMediationObject. Ids are used to uniquely identify objects in the Reactor system ids should be created using the com.oakgrovesystems.util.UniqueId class

Specified by:
setId in interface ProcessMediationObject
Parameters:
id - the Id of this ProcessMediationObject

setLabel

public void setLabel(java.lang.String label)
set the label of this ProcessMediationObject. Labels are short human-readable strings that can be used as an alternative to ids to identify a Process. All the objects associated with a Process should have unique labels.

Specified by:
setLabel in interface ProcessMediationObject
Parameters:
label - the label of this ProcessMediationObject

setDescription

public void setDescription(java.lang.String description)
set the desciption of this ProcessMediationObject. Desciptions are human readable text describing a Process. They are not used by internal Reactor functionality, but are included for use by Reactor clients.

Specified by:
setDescription in interface ProcessMediationObject
Parameters:
description - the description of this ProcessMediationObject

setACL

public void setACL(com.oakgrovesystems.reactor.processMediation.ACL acl)
set the ACL of this ProcessMediationObject. ACLs describe the relationships between ProcessMediationObjects and users of the Reactor system.

Specified by:
setACL in interface ProcessMediationObject
Parameters:
acl - the acl of this ProcessMediationObject

setEventSource

public void setEventSource(java.lang.String eventSource)

setEventName

public void setEventName(java.lang.String eventName)

setEventAttributes

public void setEventAttributes(java.util.Map eventAttributes)

setLanguage

public void setLanguage(java.lang.String language)

setSecurityPolicy

public void setSecurityPolicy(java.lang.String securityPolicy)

setSourceCode

public void setSourceCode(java.lang.String sourceCode)

setSourceCodeType

public void setSourceCodeType(int sourceCodeType)

setProcess

public void setProcess(com.oakgrovesystems.reactor.ReactorObjectId id)
Associates this ProcessAssociatedObject with the Process object referred to by the ReactorObjectId procId.

Specified by:
setProcess in interface ProcessAssociatedObject
Parameters:
id - The id of the Process with which this ProcessAssociatedObject should be associated.

getMetaDataString

public java.lang.String getMetaDataString()

setMetaDataString

public void setMetaDataString(java.lang.String s)

getMetaDataValue

public java.lang.String getMetaDataValue(java.lang.String key)

setMetaDataKeyValue

public void setMetaDataKeyValue(java.lang.String key,
                                java.lang.String value)

isTriggeredBy

public boolean isTriggeredBy(com.oakgrovesystems.reactor.ReactorEvent trigger)
Determines whether or not a particular ReactorEvent triggers the execution of this Policy p.

Parameters:
trigger - the Reactor Event that could potentially trigger the execution of this Policy
Returns:
true is the Policy should be executed, false otherwise.

copy

public com.oakgrovesystems.reactor.processMediation.ProcessMediationObject copy()
returns a deep copy of this ProcessMediationObject

Specified by:
copy in interface ProcessMediationObject
Returns:
a deep copy of this ProcessMediationObject

sameAs

public boolean sameAs(java.lang.Object o)
compares two Policies for content equality

Parameters:
o - the Policy to compare for content equality
Returns:
a boolean indicating if the Policies are equal

toString

public java.lang.String toString()
returns the label if it is not empty or null. otherwise, returns the id

Overrides:
toString in class java.lang.Object
Returns:
the label if it is not empty or null. otherwise, returns the id


Copyright (c) 1999-2004 Oak Grove Systems. All Rights Reserved.