Fixing component properties for various providers.
Change-Id: I909c84958109f61e10a542774a2d4b82c428c0f5
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 130ad53..6117339 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -139,13 +139,18 @@
import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription;
import static org.onosproject.openflow.controller.Dpid.dpid;
import static org.onosproject.openflow.controller.Dpid.uri;
+import static org.onosproject.provider.of.device.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure devices.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQ + ":Integer=" + POLL_FREQ_DEFAULT,
+ PROP_FREQ + ":Boolean=" + PROP_FREQ_DEFAULT,
+ })
public class OpenFlowDeviceProvider extends AbstractProvider implements DeviceProvider {
private static final Logger LOG = getLogger(OpenFlowDeviceProvider.class);
@@ -448,17 +453,13 @@
private final InternalDeviceProvider listener = new InternalDeviceProvider();
- private static final String POLL_PROP_NAME = "portStatsPollFrequency";
- private static final int POLL_INTERVAL = 5;
//@Property(name = POLL_PROP_NAME, intValue = POLL_INTERVAL,
//label = "Frequency (in seconds) for polling switch Port statistics")
- private int portStatsPollFrequency = POLL_INTERVAL;
+ private int portStatsPollFrequency = POLL_FREQ_DEFAULT;
- private static final String PROP_FREQ = "propertyFrequency";
- private static final boolean DEFAULT_PROP_FREQ = true;
//@Property(name = PROP_FREQ, boolValue = DEFAULT_PROP_FREQ,
//label = "It indicates frequency must be used instead of wavelength for port tuning.")
- private static boolean propFreq = DEFAULT_PROP_FREQ;
+ private static boolean propFreq = PROP_FREQ_DEFAULT;
private final Timer timer = new Timer("onos-openflow-portstats-collector");
@@ -501,7 +502,7 @@
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
int newPortStatsPollFrequency;
try {
- String s = get(properties, POLL_PROP_NAME);
+ String s = get(properties, POLL_FREQ);
newPortStatsPollFrequency = isNullOrEmpty(s) ? portStatsPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..7c6b804
--- /dev/null
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java
@@ -0,0 +1,32 @@
+/*
+ * 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.of.device.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQ = "portStatsPollFrequency";
+ public static final int POLL_FREQ_DEFAULT = 5;
+
+ public static final String PROP_FREQ = "propertyFrequency";
+ public static final boolean PROP_FREQ_DEFAULT = true;
+
+}