use of org.eclipse.smarthome.automation.core.internal.ruleengine.WrappedRule in project smarthome by eclipse.
the class RuleEngineImpl method scheduleRuleInitialization.
/**
* Creates and schedules a re-initialization task for the {@link Rule} with the specified UID.
*
* @param rUID the UID of the {@link Rule}.
*/
protected void scheduleRuleInitialization(final String rUID) {
Future<?> f = scheduleTasks.get(rUID);
if (f == null || f.isDone()) {
ScheduledExecutorService ex = getScheduledExecutor();
f = ex.schedule(new Runnable() {
@Override
public void run() {
final WrappedRule managedRule = getManagedRule(rUID);
if (managedRule == null) {
return;
}
setRule(managedRule);
}
}, scheduleReinitializationDelay, TimeUnit.MILLISECONDS);
scheduleTasks.put(rUID, f);
}
}
use of org.eclipse.smarthome.automation.core.internal.ruleengine.WrappedRule in project smarthome by eclipse.
the class RuleEngineImpl method removeRule.
/**
* This method removes Rule from the rule engine.
*
* @param rUID id of removed {@link Rule}
* @return true when a rule is deleted, false when there is no rule with such id.
*/
protected boolean removeRule(String rUID) {
final WrappedRule r = managedRules.remove(rUID);
if (r != null) {
unregister(r);
synchronized (this) {
for (Iterator<Map.Entry<String, Set<String>>> it = mapModuleTypeToRules.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, Set<String>> e = it.next();
Set<String> rules = e.getValue();
if (rules != null && rules.contains(rUID)) {
rules.remove(rUID);
if (rules.size() < 1) {
it.remove();
}
}
}
}
scheduleTasks.remove(rUID);
return true;
}
return false;
}
Aggregations