Fixing component properties in incubator.

Change-Id: I6479271c4465300b561994ba9d3aab430fab1db6
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualFlowRuleStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualFlowRuleStore.java
index e7533ca..0ad6ec1 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualFlowRuleStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualFlowRuleStore.java
@@ -94,6 +94,7 @@
 import static com.google.common.base.Strings.isNullOrEmpty;
 import static org.onlab.util.Tools.get;
 import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.incubator.store.virtual.impl.OsgiPropertyDefaults.*;
 import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -102,7 +103,13 @@
  * for virtual networks.
  */
 //TODO: support backup and persistent mechanism
-@Component(immediate = true, enabled = false, service = VirtualNetworkFlowRuleStore.class)
+@Component(immediate = true, enabled = false, service = VirtualNetworkFlowRuleStore.class,
+        property = {
+                "messageHandlerThreadPoolSize:Integer=" + MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT,
+                "pendingFutureTimeoutMinutes:Integer=" + BACKUP_PERIOD_MILLIS_DEFAULT,
+                "persistenceEnabled:Boolean=" + PERSISTENCE_ENABLED_DEFAULT,
+        })
+
 public class DistributedVirtualFlowRuleStore
         extends AbstractVirtualStore<FlowRuleBatchEvent, FlowRuleStoreDelegate>
         implements VirtualNetworkFlowRuleStore {
@@ -111,8 +118,6 @@
 
     //TODO: confirm this working fine with multiple thread more than 1
     private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1;
-    private static final boolean DEFAULT_PERSISTENCE_ENABLED = false;
-    private static final int DEFAULT_BACKUP_PERIOD_MILLIS = 2000;
     private static final long FLOW_RULE_STORE_TIMEOUT_MILLIS = 5000;
 
     private static final String FLOW_OP_TOPIC = "virtual-flow-ops-ids";
@@ -129,16 +134,16 @@
     private static final MessageSubject REMOTE_APPLY_COMPLETED
             = new MessageSubject("virtual-peer-apply-completed");
 
-    //@Property(name = "msgHandlerPoolSize", intValue = MESSAGE_HANDLER_THREAD_POOL_SIZE,
+    //@Property(name = "msgHandlerThreadPoolSize", intValue = MESSAGE_HANDLER_THREAD_POOL_SIZE,
     //        label = "Number of threads in the message handler pool")
-    private int msgHandlerPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE;
+    private int msgHandlerThreadPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT;
 
     //@Property(name = "backupPeriod", intValue = DEFAULT_BACKUP_PERIOD_MILLIS,
     //        label = "Delay in ms between successive backup runs")
-    private int backupPeriod = DEFAULT_BACKUP_PERIOD_MILLIS;
+    private int backupPeriod = BACKUP_PERIOD_MILLIS_DEFAULT;
     //@Property(name = "persistenceEnabled", boolValue = false,
     //        label = "Indicates whether or not changes in the flow table should be persisted to disk.")
-    private boolean persistenceEnabled = DEFAULT_PERSISTENCE_ENABLED;
+    private boolean persistenceEnabled = PERSISTENCE_ENABLED_DEFAULT;
 
     private InternalFlowTable flowTable = new InternalFlowTable();
 
@@ -195,7 +200,7 @@
         eventHandler = Executors.newSingleThreadExecutor(
                 groupedThreads("onos/virtual-flow", "event-handler", log));
         messageHandlingExecutor = Executors.newFixedThreadPool(
-                msgHandlerPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
+                msgHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
 
         registerMessageHandlers(messageHandlingExecutor);
 
@@ -236,13 +241,13 @@
         int newBackupPeriod;
         try {
             String s = get(properties, "msgHandlerPoolSize");
-            newPoolSize = isNullOrEmpty(s) ? msgHandlerPoolSize : Integer.parseInt(s.trim());
+            newPoolSize = isNullOrEmpty(s) ? msgHandlerThreadPoolSize : Integer.parseInt(s.trim());
 
             s = get(properties, "backupPeriod");
             newBackupPeriod = isNullOrEmpty(s) ? backupPeriod : Integer.parseInt(s.trim());
         } catch (NumberFormatException | ClassCastException e) {
             newPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE;
-            newBackupPeriod = DEFAULT_BACKUP_PERIOD_MILLIS;
+            newBackupPeriod = BACKUP_PERIOD_MILLIS_DEFAULT;
         }
 
         boolean restartBackupTask = false;
@@ -254,11 +259,11 @@
         if (restartBackupTask) {
             log.warn("Currently, backup tasks are not supported.");
         }
-        if (newPoolSize != msgHandlerPoolSize) {
-            msgHandlerPoolSize = newPoolSize;
+        if (newPoolSize != msgHandlerThreadPoolSize) {
+            msgHandlerThreadPoolSize = newPoolSize;
             ExecutorService oldMsgHandler = messageHandlingExecutor;
             messageHandlingExecutor = Executors.newFixedThreadPool(
-                    msgHandlerPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
+                    msgHandlerThreadPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
 
             // replace previously registered handlers.
             registerMessageHandlers(messageHandlingExecutor);
@@ -564,7 +569,7 @@
 
     private void logConfig(String prefix) {
         log.info("{} with msgHandlerPoolSize = {}; backupPeriod = {}",
-                 prefix, msgHandlerPoolSize, backupPeriod);
+                 prefix, msgHandlerThreadPoolSize, backupPeriod);
     }
 
     private void storeBatchInternal(NetworkId networkId, FlowRuleBatchOperation operation) {
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualPacketStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualPacketStore.java
index 997f627..c1a1210 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualPacketStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/DistributedVirtualPacketStore.java
@@ -63,6 +63,7 @@
 import static java.util.concurrent.Executors.newFixedThreadPool;
 import static org.onlab.util.Tools.get;
 import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.incubator.store.virtual.impl.OsgiPropertyDefaults.MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT;
 import static org.onosproject.net.packet.PacketEvent.Type.EMIT;
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -70,7 +71,10 @@
  * Distributed virtual packet store implementation allowing packets to be sent to
  * remote instances.  Implementation is based on DistributedPacketStore class.
  */
-@Component(immediate = true, enabled = false, service = VirtualNetworkPacketStore.class)
+@Component(immediate = true, enabled = false, service = VirtualNetworkPacketStore.class,
+        property = {
+                 "messageHandlerThreadPoolSize:Integer=" + MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT,
+        })
 public class DistributedVirtualPacketStore
         extends AbstractVirtualStore<PacketEvent, PacketStoreDelegate>
         implements VirtualNetworkPacketStore {
@@ -103,10 +107,9 @@
 
     private ExecutorService messageHandlingExecutor;
 
-    private static final int DEFAULT_MESSAGE_HANDLER_THREAD_POOL_SIZE = 4;
     //@Property(name = "messageHandlerThreadPoolSize", intValue = DEFAULT_MESSAGE_HANDLER_THREAD_POOL_SIZE,
     //        label = "Size of thread pool to assign message handler")
-    private static int messageHandlerThreadPoolSize = DEFAULT_MESSAGE_HANDLER_THREAD_POOL_SIZE;
+    private static int messageHandlerThreadPoolSize = MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT;
 
     @Activate
     public void activate(ComponentContext context) {
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/OsgiPropertyDefaults.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..765903a
--- /dev/null
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/OsgiPropertyDefaults.java
@@ -0,0 +1,31 @@
+/*
+ * 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.incubator.store.virtual.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+    private OsgiPropertyDefaults() {}
+
+    public static final int MESSAGE_HANDLER_THREAD_POOL_SIZE_DEFAULT = 4;
+    public static final int BACKUP_PERIOD_MILLIS_DEFAULT = 2000;
+    public static final boolean PERSISTENCE_ENABLED_DEFAULT = false;
+    public static final int PENDING_FUTURE_TIMEOUT_MINUTES_DEFAULT = 5;
+
+}
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualFlowRuleStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualFlowRuleStore.java
index c12044d..c2edd81 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualFlowRuleStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/virtual/impl/SimpleVirtualFlowRuleStore.java
@@ -62,6 +62,7 @@
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.onosproject.incubator.store.virtual.impl.OsgiPropertyDefaults.PENDING_FUTURE_TIMEOUT_MINUTES_DEFAULT;
 import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
 import static org.slf4j.LoggerFactory.getLogger;
 
@@ -71,7 +72,10 @@
  */
 //TODO: support distributed flowrule store for virtual networks
 
-@Component(immediate = true, service = VirtualNetworkFlowRuleStore.class)
+@Component(immediate = true, service = VirtualNetworkFlowRuleStore.class,
+        property = {
+                 "pendingFutureTimeoutMinutes:Integer=" + PENDING_FUTURE_TIMEOUT_MINUTES_DEFAULT,
+        })
 public class SimpleVirtualFlowRuleStore
         extends AbstractVirtualStore<FlowRuleBatchEvent, FlowRuleStoreDelegate>
         implements VirtualNetworkFlowRuleStore {
@@ -88,10 +92,9 @@
 
     private final AtomicInteger localBatchIdGen = new AtomicInteger();
 
-    private static final int DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES = 5;
     //@Property(name = "pendingFutureTimeoutMinutes", intValue = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES,
     //        label = "Expiration time after an entry is created that it should be automatically removed")
-    private int pendingFutureTimeoutMinutes = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES;
+    private int pendingFutureTimeoutMinutes = PENDING_FUTURE_TIMEOUT_MINUTES_DEFAULT;
 
     private Cache<Integer, SettableFuture<CompletedBatchOperation>> pendingFutures =
             CacheBuilder.newBuilder()
@@ -136,7 +139,7 @@
         Integer newPendingFutureTimeoutMinutes =
                 Tools.getIntegerProperty(properties, "pendingFutureTimeoutMinutes");
         if (newPendingFutureTimeoutMinutes == null) {
-            pendingFutureTimeoutMinutes = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES;
+            pendingFutureTimeoutMinutes = PENDING_FUTURE_TIMEOUT_MINUTES_DEFAULT;
             log.info("Pending future timeout is not configured, " +
                              "using current value of {}", pendingFutureTimeoutMinutes);
         } else {