Java Documentation
software.tomorrow.rules.base Class Rule
public abstract class Rule
extends java.lang.Object
Field Summary | |
static int | PERFLEVEL_ALL Performance monitoring for transactions and timing, individual URI performance and connection pools |
static int | PERFLEVEL_TIMING Performance monitoring for both transactions and timing |
static int | PERFLEVEL_TRANSACTIONS Performance monitoring for transactions only |
static int | PERFLEVEL_UNKNOWN Performance monitoring is not set |
static int | PERFLEVEL_URI Performance monitoring for transactions and timing and individual URI performance |
static int | RUNTYPE_DEBUG_OFF Bit mask to disable debug messages (console alerts) |
static int | RUNTYPE_NORMAL Bit mask for running in normal mode |
static int | RUNTYPE_SEND_ALERTS Bit mask for allowing sending of alerts |
static int | RUNTYPE_WRITE_CASES Bit mask for writing cases into case managers |
static int | RUNTYPE_WRITE_DATA Bit mask for allowing write of data |
static int | VAR_NUMBER The data provided is a number |
static int | VAR_STRING The data provided is a string |
static int | VAR_VARIABLE The data provided is a variable |
Constructor Summary | |
Rule() |
Method Summary | |
void | addMonitoredFile(java.io.File file) Add a file to be monitored by the rule. |
void | addPerformanceData(java.lang.StringBuffer data, java.lang.String ruleSet) Get the performance data for the currently running X Engine and add it to the provided StringBuffer as well-formed XML Note: This approach is not synchronized and can suffer from inaccuracies on a busy system |
void | addTransaction() Increment transaction count |
void | addTransactionTime(long time) Increment inline timings |
software.tomorrow.rules.base.VariableAttributeObject | chainAll(software.tomorrow.rules.base.VariableAttributeObject vao, Rule source) Chain through to all the chain points in sequence |
software.tomorrow.rules.base.VariableAttributeObject | chainTo(java.lang.String name, software.tomorrow.rules.base.VariableAttributeObject vao, Rule source) Chain through to a chain point |
abstract void | cleanup() Clean up any allocated resources before shutting down |
software.tomorrow.rules.base.VariableAttributeObject | execute(software.tomorrow.rules.base.VariableAttributeObject vao, software.tomorrow.rules.base.ChainPoint source) Wrap the processing of the rule and its performance testing, exception handling This method is for the X Engine only and should not be called directly |
java.lang.String | getConfigurationSetting(java.lang.String key) Return a configuration setting for the X Engine. |
java.lang.String | getCredentialsValue(java.lang.String key, java.lang.String field) Obtain the value for a given credential key and field |
java.lang.String | getId() Get the ID of this rule |
java.lang.String | getLabel() Get the text label for this rule |
java.util.Hashtable | getProperties() Get the specific properties of this rule to show for maintenance |
java.util.Hashtable | getRuleChainPoints() Get a list of points into which this rule can chain |
software.tomorrow.rules.base.RuleSet | getRuleSet() Get the parent rule set for this rule |
java.lang.String | getRuntimeValue(software.tomorrow.rules.base.VariableAttributeObject vao, java.lang.String value) Resolve the runtime value of a given parameter, based on the string supplied to it |
java.lang.String | getRuntimeValue(software.tomorrow.rules.base.VariableAttributeObject vao, java.lang.String value, int maxLength) Resolve the runtime value of a given parameter, based on the string supplied to it |
int | getRunType() Obtain the run-type for this rule as defined by the RUNTYPE constants |
long | getTransactions() Get the transaction count for this rule |
java.lang.String | getValueString(java.lang.String value) Resolve the string value type of a provided value parameter, removing any quote characters |
int | getValueType(java.lang.String value) Detect what kind of value has been passed as a parameter. |
abstract void | initialize() Initialize the internal state of the rule, based on the set properties |
boolean | isChainPointAddAllowed() Are new (custom) chain points allowed |
void | log(int level, java.lang.String message, java.lang.Throwable exception) Use this method to log rule exceptions to any installed LogAdapter. |
void | log(int level, java.lang.String message, java.lang.Throwable exception, Rule rule, software.tomorrow.rules.base.VariableAttributeObject vao) Use this method to log rule exceptions to any installed LogAdapter. |
void | materializeRule(software.tomorrow.rules.base.RuleSet ruleSet) Prepare this rule to be executable (connect all chain points to their rules) |
abstract software.tomorrow.rules.base.VariableAttributeObject | processRule(software.tomorrow.rules.base.VariableAttributeObject vao, software.tomorrow.rules.base.ChainPoint source) Process the rule to the depth of all connected subrules. |
void | removeFileMonitor() Removes all file monitors for this rule |
java.lang.String | renderMessage(java.lang.String errorCode, java.lang.String[] parms) Record the fact on the console that a warning was detected. |
void | setError(java.lang.String errorCode, java.lang.String[] parms) Record the fact that an error has occured. |
void | setId(java.lang.String id) Set the ID of this rule |
void | setLabel(java.lang.String label) Set the text label for this rule |
void | setProperties(java.util.Hashtable properties) Set rule specific properties |
void | setRuleChainPoint(java.lang.String chainPointId, software.tomorrow.rules.base.ChainPoint chainPoint) Attach a rule to a chain point |
void | setRuleSet(software.tomorrow.rules.base.RuleSet ruleSet) Set the parent rule set for this rule |
void | setRunType(int runType) Set the run-type for this rule |
void | setTransactions(long transactions) Set the transaction count for this rule |
void | setWarning(java.lang.String errorCode, java.lang.String[] parms) Record the fact on the console that a warning was detected. |
void | writeConsole(java.lang.String message) Send a message to the console |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RUNTYPE_NORMAL
public static final int RUNTYPE_NORMAL
Bit mask for running in normal mode
See Also:
Constant Field Values
RUNTYPE_WRITE_DATA
public static final int RUNTYPE_WRITE_DATA
Bit mask for allowing write of data
See Also:
Constant Field Values
RUNTYPE_SEND_ALERTS
public static final int RUNTYPE_SEND_ALERTS
Bit mask for allowing sending of alerts
See Also:
Constant Field Values
RUNTYPE_WRITE_CASES
public static final int RUNTYPE_WRITE_CASES
Bit mask for writing cases into case managers
See Also:
Constant Field Values
RUNTYPE_DEBUG_OFF
public static final int RUNTYPE_DEBUG_OFF
Bit mask to disable debug messages (console alerts)
See Also:
Constant Field Values
PERFLEVEL_UNKNOWN
public static final int PERFLEVEL_UNKNOWN
Performance monitoring is not set
See Also:
Constant Field Values
PERFLEVEL_TRANSACTIONS
public static final int PERFLEVEL_TRANSACTIONS
Performance monitoring for transactions only
See Also:
Constant Field Values
PERFLEVEL_TIMING
public static final int PERFLEVEL_TIMING
Performance monitoring for both transactions and timing
See Also:
Constant Field Values
PERFLEVEL_URI
public static final int PERFLEVEL_URI
Performance monitoring for transactions and timing and individual URI performance
See Also:
Constant Field Values
PERFLEVEL_ALL
public static final int PERFLEVEL_ALL
Performance monitoring for transactions and timing, individual URI performance and connection pools
See Also:
Constant Field Values
VAR_NUMBER
public static final int VAR_NUMBER
The data provided is a number
See Also:
Constant Field Values
VAR_STRING
public static final int VAR_STRING
The data provided is a string
See Also:
Constant Field Values
VAR_VARIABLE
public static final int VAR_VARIABLE
The data provided is a variable
See Also:
Constant Field Values
Rule
public Rule()
setError
public void setError(java.lang.String errorCode,
java.lang.String[] parms)
Record the fact that an error has occured. Setting an error causes the X Engine to abort with a runtime exception.
Parameters:
errorCode - The error code to report
parms - The parameters to inject into the error text
getConfigurationSetting
public java.lang.String getConfigurationSetting(java.lang.String key)
Return a configuration setting for the X Engine. This method searches the configuration setting in the order of the configuration itself, followed by the X Engine configuration file
Parameters:
key -
Returns:
The value of the configuration setting
getCredentialsValue
public java.lang.String getCredentialsValue(java.lang.String key,
java.lang.String field)
Obtain the value for a given credential key and field
Parameters:
key -
field -
Returns:
Valid credential value or null if not found
renderMessage
public java.lang.String renderMessage(java.lang.String errorCode,
java.lang.String[] parms)
Record the fact on the console that a warning was detected. The X Engine will continue
Parameters:
errorCode - The error code to report
parms - The parameters to inject into the error text
Returns:
The rendered message
setWarning
public void setWarning(java.lang.String errorCode,
java.lang.String[] parms)
Record the fact on the console that a warning was detected. The X Engine will continue
Parameters:
errorCode - The error code to report
parms - The parameters to inject into the error text
addMonitoredFile
public void addMonitoredFile(java.io.File file)
Add a file to be monitored by the rule. If the file changes during the life of the rule, a notification will be sent to the rules "updateFile" method.
Parameters:
file - the file to monitor
removeFileMonitor
public void removeFileMonitor()
Removes all file monitors for this rule
getValueType
public int getValueType(java.lang.String value)
Detect what kind of value has been passed as a parameter. Return type are: VAR_NUMBER: The parameter is a number VAR_STRING: The parameter is a string VAR_VARIABLE: The parameter is a variable
Parameters:
value - The value to test
Returns:
The value type of a provided value parameter
getValueString
public java.lang.String getValueString(java.lang.String value)
Resolve the string value type of a provided value parameter, removing any quote characters
Parameters:
value - The value to resolve
Returns:
The resolved (clean) value
getRuntimeValue
public java.lang.String getRuntimeValue(software.tomorrow.rules.base.VariableAttributeObject vao,
java.lang.String value)
Resolve the runtime value of a given parameter, based on the string supplied to it
Parameters:
vao - The variable attribute object to use
value - The value to resolve
Returns:
The resolved (runtime) value
getRuntimeValue
public java.lang.String getRuntimeValue(software.tomorrow.rules.base.VariableAttributeObject vao,
java.lang.String value,
int maxLength)
Resolve the runtime value of a given parameter, based on the string supplied to it
Parameters:
vao - The variable attribute object to use
value - The value to resolve
maxLength - The maximum length of the returned value
Returns:
The resolved (runtime) value
initialize
public abstract void initialize()
Initialize the internal state of the rule, based on the set properties
cleanup
public abstract void cleanup()
Clean up any allocated resources before shutting down
processRule
public abstract software.tomorrow.rules.base.VariableAttributeObject processRule(software.tomorrow.rules.base.VariableAttributeObject vao,
software.tomorrow.rules.base.ChainPoint source)
throws java.lang.Throwable
Process the rule to the depth of all connected subrules. The outcome is the processed object with any new attributes and changes.
Parameters:
vao - The variable attribute object with current data
source - The originating chain point
Returns:
the processed object
Throws:
java.lang.Throwable
execute
public software.tomorrow.rules.base.VariableAttributeObject execute(software.tomorrow.rules.base.VariableAttributeObject vao,
software.tomorrow.rules.base.ChainPoint source)
throws java.lang.Throwable
Wrap the processing of the rule and its performance testing, exception handling This method is for the X Engine only and should not be called directly
Parameters:
vao - The variable attribute object with current data
source - The originating chain point
Returns:
the processed object
Throws:
java.lang.Throwable
addPerformanceData
public void addPerformanceData(java.lang.StringBuffer data,
java.lang.String ruleSet)
Get the performance data for the currently running X Engine and add it to the provided StringBuffer as well-formed XML Note: This approach is not synchronized and can suffer from inaccuracies on a busy system
Parameters:
data - The performance data to add
ruleSet - The ID of the rule set
getProperties
public java.util.Hashtable getProperties()
Get the specific properties of this rule to show for maintenance
Returns:
Hashtable with property/value value pairs as Strings
getRuleChainPoints
public java.util.Hashtable getRuleChainPoints()
Get a list of points into which this rule can chain
Returns:
Hashtable with point name/chain point value pair
setRuleChainPoint
public void setRuleChainPoint(java.lang.String chainPointId,
software.tomorrow.rules.base.ChainPoint chainPoint)
Attach a rule to a chain point
Parameters:
chainPointId - The Id of the rule to chain into
chainPoint - The name of the point to connect to
isChainPointAddAllowed
public boolean isChainPointAddAllowed()
Are new (custom) chain points allowed
Returns:
True if yes, false if no
materializeRule
public void materializeRule(software.tomorrow.rules.base.RuleSet ruleSet)
Prepare this rule to be executable (connect all chain points to their rules)
Parameters:
ruleSet - The originating rule set
getId
public java.lang.String getId()
Get the ID of this rule
Returns:
Returns the id.
setId
public void setId(java.lang.String id)
Set the ID of this rule
Parameters:
id - The id to set.
setProperties
public void setProperties(java.util.Hashtable properties)
Set rule specific properties
Parameters:
properties - The properties to set.
getTransactions
public long getTransactions()
Get the transaction count for this rule
Returns:
Returns the transactions.
setTransactions
public void setTransactions(long transactions)
Set the transaction count for this rule
Parameters:
transactions - The transactions to set.
addTransaction
public void addTransaction()
Increment transaction count
addTransactionTime
public void addTransactionTime(long time)
Increment inline timings
chainTo
public software.tomorrow.rules.base.VariableAttributeObject chainTo(java.lang.String name,
software.tomorrow.rules.base.VariableAttributeObject vao,
Rule source)
throws java.lang.Throwable
Chain through to a chain point
Parameters:
name - The name of the chain point
vao - The data packet to supply
source - The originating rule
Returns:
the data packet processed by rules further down the chain
Throws:
java.lang.Throwable
chainAll
public software.tomorrow.rules.base.VariableAttributeObject chainAll(software.tomorrow.rules.base.VariableAttributeObject vao,
Rule source)
throws java.lang.Throwable
Chain through to all the chain points in sequence
Parameters:
vao - The data packet to supply
source - The originating rule
Returns:
the data packet processed by rules further down the chain
Throws:
java.lang.Throwable
getRuleSet
public software.tomorrow.rules.base.RuleSet getRuleSet()
Get the parent rule set for this rule
Returns:
Returns the ruleSet.
setRuleSet
public void setRuleSet(software.tomorrow.rules.base.RuleSet ruleSet)
Set the parent rule set for this rule
Parameters:
ruleSet - The ruleSet to set.
getRunType
public int getRunType()
Obtain the run-type for this rule as defined by the RUNTYPE constants
Returns:
Returns the runType.
setRunType
public void setRunType(int runType)
Set the run-type for this rule
Parameters:
runType - The runType to set.
getLabel
public java.lang.String getLabel()
Get the text label for this rule
Returns:
Returns the label.
setLabel
public void setLabel(java.lang.String label)
Set the text label for this rule
Parameters:
label - The label to set.
writeConsole
public void writeConsole(java.lang.String message)
Send a message to the console
Parameters:
message - Message to send
log
public void log(int level,
java.lang.String message,
java.lang.Throwable exception,
Rule rule,
software.tomorrow.rules.base.VariableAttributeObject vao)
Use this method to log rule exceptions to any installed LogAdapter.
Parameters:
level - The log level of the log entry as per the constants defined on this adapter
message - The message logged.
exception - Any exception caught. Can be null.
rule - Any rule that triggered the log entry. Can be null.
vao - Any data packet that caused the failure. Can be null.
software.tomorrow.rules.base Class VariableAttributeObject
public class VariableAttributeObject
extends java.lang.Object
Field Summary | |
static int | LOOP The completion is for the current loop only |
static int | PROCESS The completion is for the entire process |
static int | RULESET The completion is for the current rule set only |
Method Summary | |
void | addTraceData(java.lang.String traceData) Add a new trace data line |
java.lang.String | getAttribute(java.lang.String id) Retrieve an attribute value by name. |
int | getAttributeCount() Obtain a count of current attributes |
java.util.Enumeration | getAttributeNames() Obtain all the current attribute names |
int | getCompletionScope() Get the scope of the completion. |
software.tomorrow.rules.base.DataWrapper | getDataWrapper() Returns the raw data that was used as the basis for the initial variable setting |
java.lang.Throwable | getException() Get the stored exception |
java.lang.StringBuffer | getLargeAttribute(java.lang.String id) Retrieve a large attribute value by name. |
java.lang.Object | getObjectAttribute(java.lang.String id) Retrieve an object attribute value by name. |
java.util.Vector | getTraceData() get the full trace data vector |
boolean | hasAttribute(java.lang.String id) Determine if a given attribute exists |
boolean | hasContent() |
boolean | isCompleted() |
boolean | isLargeAttribute(java.lang.String id) Check if an attribute is large |
boolean | isObjectAttribute(java.lang.String id) Check if a variable is an object (not String or String Buffer) |
boolean | isRedirected() Determine if the response from the X Engine has resulted in a redirection (for example a HTTP redirect) |
boolean | isTrace() |
void | setAttribute(java.lang.String id, java.lang.String value) Set the value of an attribute. |
void | setCompleted(boolean completed) |
void | setCompletionScope(int completionScope) Set the current completion scope. |
void | setDataWrapper(software.tomorrow.rules.base.DataWrapper dataWrapper) Set the raw data that was used as the basis for the initial variable setting |
void | setException(java.lang.Throwable exception) Store an exception for later analysis |
void | setHasContent(boolean hasContent) |
void | setLargeAttribute(java.lang.String id, java.lang.StringBuffer value) Set the value of an attribute. |
void | setObjectAttribute(java.lang.String id, java.lang.Object value) Set the value of an attribute. |
void | setRedirected(boolean redirected) Advise that the response from the engine is performing a redirect |
void | setTrace(boolean trace) |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROCESS
public static final int PROCESS
The completion is for the entire process
See Also:
Constant Field Values
RULESET
public static final int RULESET
The completion is for the current rule set only
See Also:
Constant Field Values
LOOP
public static final int LOOP
The completion is for the current loop only
See Also:
Constant Field Values
VariableAttributeObject
public VariableAttributeObject()
getAttribute
public java.lang.String getAttribute(java.lang.String id)
Retrieve an attribute value by name. If not found, blank will be returned
Parameters:
id - The name of the attribute
Returns:
The attribute value
getLargeAttribute
public java.lang.StringBuffer getLargeAttribute(java.lang.String id)
Retrieve a large attribute value by name. If not found, blank will be returned
Parameters:
id - The name of the attribute
Returns:
The attribute value
getObjectAttribute
public java.lang.Object getObjectAttribute(java.lang.String id)
Retrieve an object attribute value by name. If not found, a blank string object will be returned
Parameters:
id - The name of the attribute
Returns:
The attribute value
isLargeAttribute
public boolean isLargeAttribute(java.lang.String id)
Check if an attribute is large
Parameters:
id -
Returns:
true if large and stored as StringBuffer, false otherwise
isObjectAttribute
public boolean isObjectAttribute(java.lang.String id)
Check if a variable is an object (not String or String Buffer)
Parameters:
id -
Returns:
true if large and stored as StringBuffer, false otherwise
hasAttribute
public boolean hasAttribute(java.lang.String id)
Determine if a given attribute exists
Parameters:
id - The name of the attribute
Returns:
true if the attribute exists
setAttribute
public void setAttribute(java.lang.String id,
java.lang.String value)
Set the value of an attribute. If a banned attribute name is provided it will be ignored
Parameters:
id - The name of the attribute to set
value - The value to set
setLargeAttribute
public void setLargeAttribute(java.lang.String id,
java.lang.StringBuffer value)
Set the value of an attribute. If a banned attribute name is provided it will be ignored
Parameters:
id - The name of the attribute to set
value - The value to set as a StringBuffer
setObjectAttribute
public void setObjectAttribute(java.lang.String id,
java.lang.Object value)
Set the value of an attribute. If a banned attribute name is provided it will be ignored if null is provided, the attribute will be deleted
Parameters:
id - The name of the attribute to set
value - The value to set as an Object
getAttributeNames
public java.util.Enumeration getAttributeNames()
Obtain all the current attribute names
Returns:
Enumeration of attribute names
getAttributeCount
public int getAttributeCount()
Obtain a count of current attributes
Returns:
the count of attributes
isCompleted
public boolean isCompleted()
Returns:
Returns the completion status of the rule set.
setCompleted
public void setCompleted(boolean completed)
Parameters:
completed - The new completion status.
getDataWrapper
public software.tomorrow.rules.base.DataWrapper getDataWrapper()
Returns the raw data that was used as the basis for the initial variable setting
Returns:
Returns the dataWrapper.
setDataWrapper
public void setDataWrapper(software.tomorrow.rules.base.DataWrapper dataWrapper)
Set the raw data that was used as the basis for the initial variable setting
Parameters:
dataWrapper - The dataWrapper to set.
getException
public java.lang.Throwable getException()
Get the stored exception
Returns:
Returns the exception.
setException
public void setException(java.lang.Throwable exception)
Store an exception for later analysis
Parameters:
exception - The exception to set.
getCompletionScope
public int getCompletionScope()
Get the scope of the completion. This can either resolve to: LOOP, PROCESS or RULESET
Returns:
Returns the completionScope.
setCompletionScope
public void setCompletionScope(int completionScope)
Set the current completion scope. This can either be LOOP, PROCESS or RULESET
Parameters:
completionScope - The completionScope to set.
isRedirected
public boolean isRedirected()
Determine if the response from the X Engine has resulted in a redirection (for example a HTTP redirect)
Returns:
Returns the redirected.
setRedirected
public void setRedirected(boolean redirected)
Advise that the response from the engine is performing a redirect
Parameters:
redirected - The redirected to set.
isTrace
public boolean isTrace()
Returns:
Returns the trace.
setTrace
public void setTrace(boolean trace)
Parameters:
trace - The trace to set.
getTraceData
public java.util.Vector getTraceData()
get the full trace data vector
Returns:
The trace as a vector of Strings
addTraceData
public void addTraceData(java.lang.String traceData)
Add a new trace data line
Parameters:
traceData -
hasContent
public boolean hasContent()
Returns:
Returns the hasContent.
setHasContent
public void setHasContent(boolean hasContent)
Parameters:
hasContent - The hasContent to set.
Last updated