diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessor.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessor.java index 6b42abcc16..4334b5c7ca 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessor.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessor.java @@ -23,6 +23,7 @@ import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.config.core.ConfigurableService; import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.discovery.DiscoveryResult; import org.eclipse.smarthome.config.discovery.DiscoveryResultFlag; @@ -39,9 +40,11 @@ import org.eclipse.smarthome.core.thing.ThingTypeUID; import org.eclipse.smarthome.core.thing.events.ThingStatusInfoChangedEvent; import org.eclipse.smarthome.core.thing.type.ThingType; import org.eclipse.smarthome.core.thing.type.ThingTypeRegistry; +import org.osgi.framework.Constants; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Modified; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; @@ -83,8 +86,10 @@ import org.slf4j.LoggerFactory; * @author Henning Sudbrock - added hook for selectively auto-approving inbox entries */ @Component(immediate = true, configurationPid = "org.eclipse.smarthome.inbox", service = EventSubscriber.class, property = { - "service.config.description.uri=system:inbox", "service.config.label=Inbox", "service.config.category=system", - "service.pid=org.eclipse.smarthome.inbox" }) + Constants.SERVICE_PID + "=org.eclipse.smarthome.inbox", + ConfigurableService.SERVICE_PROPERTY_CATEGORY + "=system", + ConfigurableService.SERVICE_PROPERTY_LABEL + "=Inbox", + ConfigurableService.SERVICE_PROPERTY_DESCRIPTION_URI + "=system:inbox" }) @NonNullByDefault public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber implements InboxListener, RegistryChangeListener { @@ -92,7 +97,7 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber properties) { this.thingRegistry.addRegistryChangeListener(this); this.inbox.addInboxListener(this); + + modified(properties); + } + + @Modified + protected void modified(@Nullable Map properties) { + if (properties != null) { + Object value = properties.get(AUTO_IGNORE_CONFIG_PROPERTY); + autoIgnore = value == null || !value.toString().equals("false"); + value = properties.get(ALWAYS_AUTO_APPROVE_CONFIG_PROPERTY); + alwaysAutoApprove = value != null && value.toString().equals("true"); + autoApproveInboxEntries(); + } } @Deactivate @@ -256,16 +274,6 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber predicate.test(result)); } - protected void activate(@Nullable Map properties) { - if (properties != null) { - Object value = properties.get(AUTO_IGNORE_CONFIG_PROPERTY); - autoIgnore = value == null || !value.toString().equals("false"); - value = properties.get(ALWAYS_AUTO_APPROVE_CONFIG_PROPERTY); - alwaysAutoApprove = value != null && value.toString().equals("true"); - autoApproveInboxEntries(); - } - } - @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) protected void addInboxAutoApprovePredicate(InboxAutoApprovePredicate inboxAutoApprovePredicate) { inboxAutoApprovePredicates.add(inboxAutoApprovePredicate); diff --git a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessorTest.java b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessorTest.java index 4925ffb36e..60ce7d3101 100644 --- a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessorTest.java +++ b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/AutomaticInboxProcessorTest.java @@ -160,7 +160,7 @@ public class AutomaticInboxProcessorTest { inbox.activate(); automaticInboxProcessor = new AutomaticInboxProcessor(thingTypeRegistry, thingRegistry, inbox); - automaticInboxProcessor.activate(); + automaticInboxProcessor.activate(null); } @After