public interface RuleBuilder
RuleBuilder objects can be instantiated via the RuleEngine.createRuleBuilder(String) method.
Example:
RuleEngine engine = ...
RuleBuilder builder = engine.createRuleBuilder("My Rule");
Rule rule =
builder.setDeviceScope("mprm.osgi.device", "ROOT/", null)
.addTriger(ManualTrigger.create(), null, false)
.setAction("target.consoleCommand('config.ls')")
.buildRule();
rule.enable();
rule.fire();
| Modifier and Type | Method and Description |
|---|---|
RuleBuilder |
addTriger(TriggerEvent fire,
java.lang.String triggerConditionScript,
boolean sync)
Adds a trigger definition to this Rule.
|
Rule |
buildRule()
Assembles all Rule parameters set via this builder and creates the built Rule object.
|
RuleBuilder |
setAction(java.lang.String action)
Defines the Rule action.
|
RuleBuilder |
setAutoDisable(boolean autoDisable)
Defines whether the Rule should be automatically disabled once all targets from the Scope pass through the triggering conditions.
|
RuleBuilder |
setConcurrency(int limit)
Defines concurrency limit execution option.
|
RuleBuilder |
setDeviceCustomScope(java.lang.String listingScript,
java.lang.String isMemberScript)
Sets the built-up Rule to have Device scope with custom involving of devices.
|
RuleBuilder |
setDeviceScope(java.lang.String deviceType,
java.lang.String groupId,
java.lang.String deviceFilter)
Sets the built-up Rule to have Device scope with default involving of devices.
|
RuleBuilder |
setDeviceScopeIsMemberCheck(java.lang.String isMemberScript)
Sets the built-up Rule with already defined Device scope (see
setDeviceScope(String, String, String))
to have a custom groovy 'is-member' verification. |
RuleBuilder |
setGeneralCondition(java.lang.String triggerConditionScript)
Sets the general condition for the Rule triggers.
|
RuleBuilder |
setOncePerDeviceFlag(boolean oncePerDevice)
Defines whether the Rule can be executed multiple times on a given device, or should be executed only once,
skipping subsequent triggers for that device.
|
RuleBuilder |
setOverlapping(ExecOptions.Overlapping option)
Sets
ExecOptions.Overlapping execution option to the created Rule. |
RuleBuilder |
setSystemScope(boolean singleHostPerRole,
java.lang.String[] beHostRoles)
Sets the built-up Rule to have System scope.
|
RuleBuilder |
setTimeConstraint(TimeConstraint timeConstraint)
Defines at what time-schedule it is permitted for the Rule to act.
|
RuleBuilder setSystemScope(boolean singleHostPerRole, java.lang.String[] beHostRoles)
singleBeHost - defines whether single or all backend hosts with the supplied (by beHostRoles parameter)
role(s) should execute the Rule.beTargets - array of the target backend host roles.
Elements of the array can be one of Roles.CC, Roles.MS, Roles.RAS,
or id of particular Management Server. Also, array of concrete backend host ids can be provided - in such
a case, the singleHostPerRole parameter is ignored.RuleBuilder having the changes applied.RuleBuilder setDeviceScope(java.lang.String deviceType, java.lang.String groupId, java.lang.String deviceFilter)
deviceType - specifies the type of devices to be in the execution scope.groupId - specifies the device group, whose member devices to be in the execution scope.deviceFilter - devices that satisfy this device filter will be in the execution scope.RuleBuilder having the changes applied.RuleBuilder setDeviceScopeIsMemberCheck(java.lang.String isMemberScript)
setDeviceScope(String, String, String))
to have a custom groovy 'is-member' verification.isMemberScript - should be a groovy script that will be executed for each device
(restricted by deviceType and deviceGroupId) bound as 'target'; the script must return
boolean value specifying if the target device to be or not to be included in the execution scope.RuleBuilder having the changes applied.RuleBuilder setDeviceCustomScope(java.lang.String listingScript, java.lang.String isMemberScript)
listingScript - groovy script that lists devices. The device objects must have methods
getDeviceType and getDeviceId in order to determine the target device.isMemberScript - should be a groovy script that will be executed for each device
(listed by the targetsListScript script) bound as 'target'; the script must return
boolean value specifying if the target device to be or not to be included in the execution scope.RuleBuilder having the changes applied.RuleBuilder addTriger(TriggerEvent fire, java.lang.String triggerConditionScript, boolean sync)
TriggerEvent, condition and sync option. All triggers then go under an option general condtion
specified via the setGeneralCondition(String) method.fire - Fire definition.triggerConditionScript - trigger condition.sync - flag stating whether rule processing should be done synchronously in the thread of the firing event.RuleBuilder having the changes applied.java.lang.IllegalArgumentException - if fire supplied parameter is null.RuleBuilder setGeneralCondition(java.lang.String triggerConditionScript)
true or false.generalCondition - general condition in the form of a groovy script.RuleBuilder having the changes applied.RuleBuilder setOverlapping(ExecOptions.Overlapping option)
ExecOptions.Overlapping execution option to the created Rule.option - overlapping option.RuleBuilder having the changes applied.RuleBuilder setConcurrency(int limit)
limit - concurrency limit number.RuleBuilder having the changes applied.RuleBuilder setOncePerDeviceFlag(boolean oncePerDevice)
oncePerDevice - flag indicating whether the Rule should be triggered no more than once for the same device.RuleBuilder having the changes applied.RuleBuilder setAutoDisable(boolean autoDisable)
setOncePerDeviceFlag(boolean) set to
true.autoDisable - flag indicating whether autoDisable option is switched on.RuleBuilder having the changes applied.RuleBuilder setTimeConstraint(TimeConstraint timeConstraint)
timeConstraint - time schedule constraint definition.RuleBuilder having the changes applied.RuleBuilder setAction(java.lang.String action)
action - the Rule action provided as groovy script.RuleBuilder having the changes applied.Rule buildRule() throws ManagementException
Rule object representing built up Rule.ManagementException - if system error occurs.java.lang.IllegalArgumentException - if Task parameters are inconsistent or not correct.Copyright © 2019 Bosch Software Innovations GmbH. All Rights Reserved.