Skip to content

Commit

Permalink
Log reason for rules/scripts refresh (openhab#1812)
Browse files Browse the repository at this point in the history
* Log reason for rules/scripts refresh

Fixes openhab#1293

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored Nov 13, 2020
1 parent 7d2a505 commit 8102cff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ public class RulesRefresher implements ReadyTracker {
private final ItemRegistryChangeListener itemRegistryChangeListener = new ItemRegistryChangeListener() {
@Override
public void added(Item element) {
logger.debug("Item \"{}\" added => rules are going to be refreshed", element.getName());
scheduleRuleRefresh();
}

@Override
public void removed(Item element) {
logger.debug("Item \"{}\" removed => rules are going to be refreshed", element.getName());
scheduleRuleRefresh();
}

Expand All @@ -91,18 +93,21 @@ public void updated(Item oldElement, Item element) {

@Override
public void allItemsChanged(Collection<String> oldItemNames) {
logger.debug("All items changed => rules are going to be refreshed");
scheduleRuleRefresh();
}
};

private final ThingRegistryChangeListener thingRegistryChangeListener = new ThingRegistryChangeListener() {
@Override
public void added(Thing element) {
logger.debug("Thing \"{}\" added => rules are going to be refreshed", element.getUID().getAsString());
scheduleRuleRefresh();
}

@Override
public void removed(Thing element) {
logger.debug("Thing \"{}\" removed => rules are going to be refreshed", element.getUID().getAsString());
scheduleRuleRefresh();
}

Expand Down Expand Up @@ -130,25 +135,29 @@ protected void activate() {
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addActionService(ActionService actionService) {
if (started) {
logger.debug("Script action added => rules are going to be refreshed");
scheduleRuleRefresh();
}
}

protected void removeActionService(ActionService actionService) {
if (started) {
logger.debug("Script action removed => rules are going to be refreshed");
scheduleRuleRefresh();
}
}

@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addThingActions(ThingActions thingActions) {
if (started) {
logger.debug("Thing automation action added => rules are going to be refreshed");
scheduleRuleRefresh();
}
}

protected void removeThingActions(ThingActions thingActions) {
if (started) {
logger.debug("Thing automation action removed => rules are going to be refreshed");
scheduleRuleRefresh();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,24 @@ public void unsetItemRegistry(ItemRegistry itemRegistry) {

@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addActionService(ActionService actionService) {
logger.debug("Script action added => scripts are going to be refreshed");
scheduleScriptRefresh();
}

protected void removeActionService(ActionService actionService) {
logger.debug("Script action removed => scripts are going to be refreshed");
scheduleScriptRefresh();
}

@Override
public void added(Item element) {
logger.debug("Item \"{}\" added => scripts are going to be refreshed", element.getName());
scheduleScriptRefresh();
}

@Override
public void removed(Item element) {
logger.debug("Item \"{}\" removed => scripts are going to be refreshed", element.getName());
scheduleScriptRefresh();
}

Expand All @@ -98,6 +102,7 @@ public void updated(Item oldElement, Item element) {

@Override
public void allItemsChanged(Collection<String> oldItemNames) {
logger.debug("All items changed => scripts are going to be refreshed");
scheduleScriptRefresh();
}

Expand Down

0 comments on commit 8102cff

Please sign in to comment.