move the reactive routing to new config subsystem

Change-Id: I3e570138afb800c5bd7dbef872cbf9044732fa49
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java
index d9d1824..00c598f 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/LocalIpPrefixEntry.java
@@ -15,7 +15,6 @@
  */
 package org.onosproject.routing.config;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.base.MoreObjects;
 
 import java.util.Objects;
@@ -53,15 +52,14 @@
     /**
      * Creates a new IP prefix entry.
      *
-     * @param ipPrefix         an IP prefix as a String
+     * @param ipPrefix         an IP prefix
      * @param type             an IP prefix type as an IpPrefixType
      * @param gatewayIpAddress IP of the gateway
      */
-    public LocalIpPrefixEntry(@JsonProperty("ipPrefix") String ipPrefix,
-                              @JsonProperty("type") IpPrefixType type,
-                              @JsonProperty("gatewayIp") IpAddress
-                                      gatewayIpAddress) {
-        this.ipPrefix = IpPrefix.valueOf(ipPrefix);
+    public LocalIpPrefixEntry(IpPrefix ipPrefix,
+                              IpPrefixType type,
+                              IpAddress gatewayIpAddress) {
+        this.ipPrefix = ipPrefix;
         this.type = type;
         this.gatewayIpAddress = gatewayIpAddress;
     }
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/ReactiveRoutingConfig.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/ReactiveRoutingConfig.java
new file mode 100644
index 0000000..caf723d
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/ReactiveRoutingConfig.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * 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.config;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.routing.config.LocalIpPrefixEntry.IpPrefixType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Configuration object for prefix config.
+ */
+public class ReactiveRoutingConfig extends Config<ApplicationId> {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    public static final String IP4LOCALPREFIXES = "ip4LocalPrefixes";
+    public static final String IP6LOCALPREFIXES = "ip6LocalPrefixes";
+    public static final String IPPREFIX = "ipPrefix";
+    public static final String TYPE = "type";
+    public static final String GATEWAYIP = "gatewayIp";
+    public static final String VIRTUALGATEWAYMACADDRESS =
+                               "virtualGatewayMacAddress";
+
+    /**
+     * Gets the set of configured local IPv4 prefixes.
+     *
+     * @return IPv4 prefixes
+     */
+    public Set<LocalIpPrefixEntry> localIp4PrefixEntries() {
+        Set<LocalIpPrefixEntry> prefixes = Sets.newHashSet();
+
+        JsonNode prefixesNode = object.get(IP4LOCALPREFIXES);
+        if (prefixesNode == null) {
+            log.warn("ip4LocalPrefixes is null!");
+            return prefixes;
+        }
+
+        prefixesNode.forEach(jsonNode -> {
+
+            prefixes.add(new LocalIpPrefixEntry(
+                    IpPrefix.valueOf(jsonNode.get(IPPREFIX).asText()),
+                    IpPrefixType.valueOf(jsonNode.get(TYPE).asText()),
+                    IpAddress.valueOf(jsonNode.get(GATEWAYIP).asText())));
+        });
+
+        return prefixes;
+    }
+
+    /**
+     * Gets the set of configured local IPv6 prefixes.
+     *
+     * @return IPv6 prefixes
+     */
+    public Set<LocalIpPrefixEntry> localIp6PrefixEntries() {
+        Set<LocalIpPrefixEntry> prefixes = Sets.newHashSet();
+
+        JsonNode prefixesNode = object.get(IP6LOCALPREFIXES);
+
+        if (prefixesNode == null) {
+            log.warn("ip6LocalPrefixes is null!");
+            return prefixes;
+        }
+
+        prefixesNode.forEach(jsonNode -> {
+
+            prefixes.add(new LocalIpPrefixEntry(
+                    IpPrefix.valueOf(jsonNode.get(IPPREFIX).asText()),
+                    IpPrefixType.valueOf(jsonNode.get(TYPE).asText()),
+                    IpAddress.valueOf(jsonNode.get(GATEWAYIP).asText())));
+        });
+
+        return prefixes;
+    }
+
+    /**
+     *  Gets of the virtual gateway MAC address.
+     *
+     */
+    public MacAddress virtualGatewayMacAddress() {
+        return MacAddress.valueOf(
+                object.get(VIRTUALGATEWAYMACADDRESS).asText());
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
index 45316bd..9a298a6 100644
--- a/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
@@ -15,38 +15,23 @@
  */
 package org.onosproject.routing.config;
 
+import java.util.Set;
+
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onosproject.net.ConnectPoint;
 
-import java.util.Map;
-import java.util.Set;
-
 /**
  * Provides information about the routing configuration.
  */
 public interface RoutingConfigurationService {
 
-    /**
-     * Gets the list of BGP speakers inside the SDN network.
-     *
-     * @return the map of BGP speaker names to BGP speaker objects
-     */
-    Map<String, BgpSpeaker> getBgpSpeakers();
+    String REACTIVE_ROUTING_APP_ID = "org.onosproject.reactive.routing";
 
-    /**
-     * Gets the list of configured BGP peers.
-     *
-     * @return the map from peer IP address to BgpPeer object
-     */
-    Map<IpAddress, BgpPeer> getBgpPeers();
+    Class<ReactiveRoutingConfig> CONFIG_CLASS = ReactiveRoutingConfig.class;
 
-    /**
-     * Gets the MAC address configured for virtual gateway in SDN network.
-     *
-     * @return the MAC address of virtual gateway
-     */
+
     MacAddress getVirtualGatewayMacAddress();
 
     /**
@@ -81,15 +66,5 @@
      */
     Set<ConnectPoint> getBgpPeerConnectPoints();
 
-    /**
-     * Retrieves the interface that matches the given IP address. Matching
-     * means that the IP address is in one of the interface's assigned subnets.
-     *
-     * @param ipAddress IP address to match
-     * @return the matching interface
-     * @deprecated in Drake release - use InterfaceService instead
-     */
-    @Deprecated
-    Interface getMatchingInterface(IpAddress ipAddress);
 
 }