Fixing component properties for various providers.
Change-Id: I909c84958109f61e10a542774a2d4b82c428c0f5
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index 33ffdb6..bc06fe6 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -102,13 +102,18 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.provider.of.flow.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an OpenFlow controller to detect network end-station
* hosts.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
+ ADAPTIVE_FLOW_SAMPLING + ":Boolean=" + ADAPTIVE_FLOW_SAMPLING_DEFAULT,
+ })
public class OpenFlowRuleProvider extends AbstractProvider
implements FlowRuleProvider {
@@ -126,18 +131,16 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DriverService driverService;
- private static final int DEFAULT_POLL_FREQUENCY = 5;
private static final int MIN_EXPECTED_BYTE_LEN = 56;
private static final int SKIP_BYTES = 4;
- private static final boolean DEFAULT_ADAPTIVE_FLOW_SAMPLING = false;
//@Property(name = "flowPollFrequency", intValue = DEFAULT_POLL_FREQUENCY,
// label = "Frequency (in seconds) for polling flow statistics")
- private int flowPollFrequency = DEFAULT_POLL_FREQUENCY;
+ private int flowPollFrequency = POLL_FREQUENCY_DEFAULT;
//@Property(name = "adaptiveFlowSampling", boolValue = DEFAULT_ADAPTIVE_FLOW_SAMPLING,
// label = "Adaptive Flow Sampling is on or off")
- private boolean adaptiveFlowSampling = DEFAULT_ADAPTIVE_FLOW_SAMPLING;
+ private boolean adaptiveFlowSampling = ADAPTIVE_FLOW_SAMPLING_DEFAULT;
private FlowRuleProviderService providerService;
@@ -194,7 +197,7 @@
Dictionary<?, ?> properties = context.getProperties();
int newFlowPollFrequency;
try {
- String s = get(properties, "flowPollFrequency");
+ String s = get(properties, POLL_FREQUENCY);
newFlowPollFrequency = isNullOrEmpty(s) ? flowPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
@@ -209,7 +212,7 @@
log.info("Settings: flowPollFrequency={}", flowPollFrequency);
boolean newAdaptiveFlowSampling;
- String s = get(properties, "adaptiveFlowSampling");
+ String s = get(properties, ADAPTIVE_FLOW_SAMPLING);
newAdaptiveFlowSampling = isNullOrEmpty(s) ? adaptiveFlowSampling : Boolean.parseBoolean(s.trim());
if (newAdaptiveFlowSampling != adaptiveFlowSampling) {
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OsgiPropertyConstants.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..36022e8
--- /dev/null
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/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.flow.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY = "flowPollFrequency";
+ public static final String ADAPTIVE_FLOW_SAMPLING = "adaptiveFlowSampling";
+
+ public static final int POLL_FREQUENCY_DEFAULT = 5;
+ public static final boolean ADAPTIVE_FLOW_SAMPLING_DEFAULT = false;
+
+}