Modify test app usages of Property annotations for new OSGi implementation
Change-Id: Ie16cc4c41541f9e199c0c9e5f1338ee617097942
diff --git a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
index 7b7cf1b..3f8dbaf 100644
--- a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
+++ b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
@@ -46,6 +46,8 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.loadtest.OsgiPropertyConstants.RATE;
+import static org.onosproject.loadtest.OsgiPropertyConstants.RATE_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -53,7 +55,13 @@
* <p>
* This application simply increments as {@link AsyncAtomicCounter} at a configurable rate.
*/
-@Component(immediate = true, service = DistributedConsensusLoadTest.class)
+@Component(
+ immediate = true,
+ service = DistributedConsensusLoadTest.class,
+ property = {
+ RATE + ":Integer=" + RATE_DEFAULT
+ }
+)
public class DistributedConsensusLoadTest {
private final Logger log = getLogger(getClass());
@@ -71,12 +79,10 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
- private static final int DEFAULT_RATE = 100;
private static final int TOTAL_COUNTERS = 50;
- //@Property(name = "rate", intValue = DEFAULT_RATE,
- // label = "Total number of increments per second to the atomic counter")
- protected int rate = 0;
+ /** Total number of increments per second to the atomic counter. */
+ protected int rate = RATE_DEFAULT;
private final AtomicLong previousReportTime = new AtomicLong(0);
private final AtomicLong previousCount = new AtomicLong(0);
@@ -145,11 +151,11 @@
@Modified
public void modified(ComponentContext context) {
- int newRate = DEFAULT_RATE;
+ int newRate = RATE_DEFAULT;
if (context != null) {
Dictionary properties = context.getProperties();
try {
- String s = get(properties, "rate");
+ String s = get(properties, RATE);
newRate = isNullOrEmpty(s)
? rate : Integer.parseInt(s.trim());
} catch (Exception e) {
diff --git a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.java b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.java
new file mode 100644
index 0000000..930945b
--- /dev/null
+++ b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.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.loadtest;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String RATE = "rate";
+ public static final int RATE_DEFAULT = 100;
+
+}