openstack and routing app OSGi property migration

Change-Id: I855020959456f059911284bb7d8ade376cbc20c5
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
index 6eb23d4..d12c6d8 100644
--- a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
@@ -81,10 +81,18 @@
 import java.util.Map;
 import java.util.Set;
 
+import static org.onosproject.routing.fibinstaller.OsgiPropertyConstants.ROUTE_TO_NEXT_HOP;
+import static org.onosproject.routing.fibinstaller.OsgiPropertyConstants.ROUTE_TO_NEXT_HOP_DEFAULT;
+
 /**
  * Programs routes to a single OpenFlow switch.
  */
-@Component(immediate = true)
+@Component(
+    immediate = true,
+    property = {
+        ROUTE_TO_NEXT_HOP + ":Boolean=  " + ROUTE_TO_NEXT_HOP_DEFAULT
+    }
+)
 public class FibInstaller {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
@@ -124,9 +132,8 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected ApplicationService applicationService;
 
-    //@Property(name = "routeToNextHop", boolValue = false,
-    //        label = "Install a /32 or /128 route to each next hop")
-    private boolean routeToNextHop = false;
+    /** Install a /32 or /128 route to each next hop. */
+    private boolean routeToNextHop = ROUTE_TO_NEXT_HOP_DEFAULT;
 
     // Device id of data-plane switch - should be learned from config
     private DeviceId deviceId;
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java
new file mode 100644
index 0000000..731ce4f
--- /dev/null
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/OsgiPropertyConstants.java
@@ -0,0 +1,28 @@
+/*
+ * 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.routing.fibinstaller;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+    private OsgiPropertyConstants() {
+    }
+
+    public static final String ROUTE_TO_NEXT_HOP = "routeToNextHop";
+    public static final boolean ROUTE_TO_NEXT_HOP_DEFAULT = false;
+}
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
index 3973520..294ebe8 100644
--- a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/FpmManager.java
@@ -95,11 +95,28 @@
 
 import static java.util.concurrent.Executors.newCachedThreadPool;
 import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.CLEAR_ROUTES;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.CLEAR_ROUTES_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_ENABLED;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_ENABLED_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV4;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV4_DEFAULT;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV6;
+import static org.onosproject.routing.fpm.OsgiPropertyConstants.PD_PUSH_NEXT_HOP_IPV6_DEFAULT;
 
 /**
  * Forwarding Plane Manager (FPM) route source.
  */
-@Component(immediate = true, service = FpmInfoService.class)
+@Component(
+       immediate = true,
+       service = FpmInfoService.class,
+       property = {
+           CLEAR_ROUTES + ":Boolean=" + CLEAR_ROUTES_DEFAULT,
+           PD_PUSH_ENABLED + ":Boolean=" + PD_PUSH_ENABLED_DEFAULT,
+           PD_PUSH_NEXT_HOP_IPV4 + "=" + PD_PUSH_NEXT_HOP_IPV4_DEFAULT,
+           PD_PUSH_NEXT_HOP_IPV6 + "=" + PD_PUSH_NEXT_HOP_IPV6_DEFAULT,
+       }
+)
 public class FpmManager implements FpmInfoService {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -159,20 +176,16 @@
     //Local cache for peers to be used in case of cluster partition.
     private Map<FpmPeer, Set<FpmConnectionInfo>> localPeers = new ConcurrentHashMap<>();
 
-    //@Property(name = "clearRoutes", boolValue = true,
-    //        label = "Whether to clear routes when the FPM connection goes down")
-    private boolean clearRoutes = true;
+    /** Whether to clear routes when the FPM connection goes down. */
+    private boolean clearRoutes = CLEAR_ROUTES_DEFAULT;
 
-    //@Property(name = "pdPushEnabled", boolValue = false,
-    //        label = "Whether to push prefixes to Quagga over fpm connection")
-    private boolean pdPushEnabled = false;
+    /** Whether to push prefixes to Quagga over fpm connection. */
+    private boolean pdPushEnabled = PD_PUSH_ENABLED_DEFAULT;
 
-    //@Property(name = "pdPushNextHopIPv4", value = "",
-    //        label = "IPv4 next-hop address for PD Pushing.")
+    /** IPv4 next-hop address for PD Pushing. */
     private List<Ip4Address> pdPushNextHopIPv4 = null;
 
-    //@Property(name = "pdPushNextHopIPv6", value = "",
-    //        label = "IPv6 next-hop address for PD Pushing.")
+    /** IPv6 next-hop address for PD Pushing. */
     private List<Ip6Address> pdPushNextHopIPv6 = null;
 
     protected void bindRipStore(FpmPrefixStore store) {
@@ -265,13 +278,13 @@
         if (properties == null) {
             return;
         }
-        String strClearRoutes = Tools.get(properties, "clearRoutes");
+        String strClearRoutes = Tools.get(properties, CLEAR_ROUTES);
         if (strClearRoutes != null) {
             clearRoutes = Boolean.parseBoolean(strClearRoutes);
             log.info("clearRoutes is {}", clearRoutes);
         }
 
-        String strPdPushEnabled = Tools.get(properties, "pdPushEnabled");
+        String strPdPushEnabled = Tools.get(properties, PD_PUSH_ENABLED);
         if (strPdPushEnabled != null) {
             boolean oldValue = pdPushEnabled;
             pdPushEnabled = Boolean.parseBoolean(strPdPushEnabled);
@@ -280,7 +293,7 @@
                 pdPushNextHopIPv4 = new ArrayList<Ip4Address>();
                 pdPushNextHopIPv6 = new ArrayList<Ip6Address>();
 
-                String strPdPushNextHopIPv4 = Tools.get(properties, "pdPushNextHopIPv4");
+                String strPdPushNextHopIPv4 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV4);
                 if (strPdPushNextHopIPv4 != null) {
                     List<String> strPdPushNextHopIPv4List = Arrays.asList(strPdPushNextHopIPv4.split(","));
                     for (String nextHop : strPdPushNextHopIPv4List) {
@@ -288,7 +301,7 @@
                         pdPushNextHopIPv4.add(Ip4Address.valueOf(nextHop));
                     }
                 }
-                String strPdPushNextHopIPv6 = Tools.get(properties, "pdPushNextHopIPv6");
+                String strPdPushNextHopIPv6 = Tools.get(properties, PD_PUSH_NEXT_HOP_IPV6);
                 if (strPdPushNextHopIPv6 != null) {
                     List<String> strPdPushNextHopIPv6List = Arrays.asList(strPdPushNextHopIPv6.split(","));
                     for (String nextHop : strPdPushNextHopIPv6List) {
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java
new file mode 100644
index 0000000..2092657
--- /dev/null
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/OsgiPropertyConstants.java
@@ -0,0 +1,37 @@
+/*
+ * 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.routing.fpm;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+    private OsgiPropertyConstants() {
+    }
+
+    public static final String CLEAR_ROUTES = "clearRoutes";
+    public static final boolean CLEAR_ROUTES_DEFAULT = true;
+
+    public static final String PD_PUSH_ENABLED = "pdPushEnabled";
+    public static final boolean PD_PUSH_ENABLED_DEFAULT = false;
+
+    public static final String PD_PUSH_NEXT_HOP_IPV4 = "pdPushNextHopIPv4";
+    public static final String PD_PUSH_NEXT_HOP_IPV4_DEFAULT = "";
+
+    public static final String PD_PUSH_NEXT_HOP_IPV6 = "pdPushNextHopIPv6";
+    public static final String PD_PUSH_NEXT_HOP_IPV6_DEFAULT = "";
+}