Fixing component properties for various providers.
Change-Id: I909c84958109f61e10a542774a2d4b82c428c0f5
diff --git a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
index 1415290..44dd60d 100644
--- a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
+++ b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
@@ -58,13 +58,19 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.provider.linkdiscovery.impl.OsgiPropertyDefaults.POLL_DELAY_SECONDS_DEFAULT;
+import static org.onosproject.provider.linkdiscovery.impl.OsgiPropertyDefaults.POLL_FREQUENCY_SECONDS_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Link provider capable of polling the environment using the device driver
* {@link LinkDiscovery} behaviour.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ "linkPollDelaySeconds:Integer=" + POLL_DELAY_SECONDS_DEFAULT,
+ "linkPollFrequencySeconds:Integer=" + POLL_FREQUENCY_SECONDS_DEFAULT,
+ })
public class LinkDiscoveryProvider extends AbstractProvider
implements LinkProvider {
@@ -72,14 +78,13 @@
protected static final String SCHEME_NAME = "linkdiscovery";
private static final String LINK_PROVIDER_PACKAGE = "org.onosproject.provider.linkdiscovery";
private final Logger log = getLogger(getClass());
- private static final int DEFAULT_POLL_DELAY_SECONDS = 20;
//@Property(name = "linkPollDelaySeconds", intValue = DEFAULT_POLL_DELAY_SECONDS,
// label = "Initial delay (in seconds) for polling link discovery")
- protected static int linkPollDelaySeconds = DEFAULT_POLL_DELAY_SECONDS;
- private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 10;
+ protected static int linkPollDelaySeconds = POLL_DELAY_SECONDS_DEFAULT;
+
//@Property(name = "linkPollFrequencySeconds", intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
// label = "Frequency (in seconds) for polling link discovery")
- protected static int linkPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+ protected static int linkPollFrequencySeconds = POLL_FREQUENCY_SECONDS_DEFAULT;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
@@ -118,7 +123,7 @@
cfgService.registerProperties(getClass());
if (context == null) {
- linkPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+ linkPollFrequencySeconds = POLL_FREQUENCY_SECONDS_DEFAULT;
log.info("No component configuration");
} else {
Dictionary<?, ?> properties = context.getProperties();
@@ -169,7 +174,7 @@
String s = get(properties, "linkPollFrequencySeconds");
newPollFrequency = isNullOrEmpty(s) ? pollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
- newPollFrequency = DEFAULT_POLL_FREQUENCY_SECONDS;
+ newPollFrequency = POLL_FREQUENCY_SECONDS_DEFAULT;
}
return newPollFrequency;
}
@@ -180,7 +185,7 @@
String s = get(properties, "linkPollDelaySeconds");
newPollFrequency = isNullOrEmpty(s) ? pollDelay : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
- newPollFrequency = DEFAULT_POLL_DELAY_SECONDS;
+ newPollFrequency = POLL_DELAY_SECONDS_DEFAULT;
}
return newPollFrequency;
}
diff --git a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/OsgiPropertyDefaults.java b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..ba85b86
--- /dev/null
+++ b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/OsgiPropertyDefaults.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.provider.linkdiscovery.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+ private OsgiPropertyDefaults() {}
+
+ public static final int POLL_DELAY_SECONDS_DEFAULT = 20;
+ public static final int POLL_FREQUENCY_SECONDS_DEFAULT = 10;
+
+}