diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java index e9062e6bc..5baff6c57 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java @@ -74,6 +74,7 @@ import org.openhab.core.automation.type.TriggerType; import org.openhab.core.automation.util.ReferenceResolver; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ComponentPropertyType; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.annotations.ReferenceCardinality; @@ -103,6 +104,14 @@ import org.slf4j.LoggerFactory; @NonNullByDefault public class RuleEngineImpl implements RuleManager, RegistryChangeListener { + @ComponentPropertyType + public @interface Config { + /** + * Delay between rule's re-initialization tries. + */ + long rule_reinitialization_delay() default 500; + } + /** * Constant defining separator between module id and output name. */ @@ -240,7 +249,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener>(); this.moduleHandlerFactories = new HashMap(20); @@ -255,11 +264,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener() { @Override diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java index ad38bac31..a4a9d3107 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java @@ -49,7 +49,6 @@ import org.osgi.framework.BundleContext; 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; @@ -100,28 +99,14 @@ import org.slf4j.LoggerFactory; * @author Benedikt Niehues - added events for rules * @author Victor Toni - return only copies of {@link Rule}s */ -@Component(service = RuleRegistry.class, immediate = true, property = { "rule.reinitialization.delay:Long=500" }) +@Component(service = RuleRegistry.class, immediate = true) public class RuleRegistryImpl extends AbstractRegistry implements RuleRegistry, RegistryChangeListener { - /** - * Default value of delay between rule's re-initialization tries. - */ - static final long DEFAULT_REINITIALIZATION_DELAY = 500; - - /** - * Delay between rule's re-initialization tries. - */ - private static final String CONFIG_PROPERTY_REINITIALIZATION_DELAY = "rule.reinitialization.delay"; - private static final String SOURCE = RuleRegistryImpl.class.getSimpleName(); private final Logger logger = LoggerFactory.getLogger(RuleRegistryImpl.class.getName()); - /** - * Delay between rule's re-initialization tries. - */ - private long scheduleReinitializationDelay; private ModuleTypeRegistry moduleTypeRegistry; private RuleTemplateRegistry templateRegistry; @@ -143,27 +128,12 @@ public class RuleRegistryImpl extends AbstractRegistry properties) throws Exception { - modified(properties); + protected void activate(BundleContext bundleContext) { super.activate(bundleContext); } - /** - * This method is responsible for updating the value of delay between rule's re-initialization tries. - * - * @param config a {@link Map} containing the new value of delay. - */ - @Modified - protected void modified(Map config) { - Object value = config == null ? null : config.get(CONFIG_PROPERTY_REINITIALIZATION_DELAY); - this.scheduleReinitializationDelay = (value != null && value instanceof Number) ? (((Number) value).longValue()) - : DEFAULT_REINITIALIZATION_DELAY; - if (value != null && !(value instanceof Number)) { - logger.warn("Invalid configuration value: {}. It MUST be Number.", value); - } - } - @Override @Deactivate protected void deactivate() { @@ -678,15 +648,4 @@ public class RuleRegistryImpl extends AbstractRegistry