Modified BGP and FPM route sources to push to new route service.

Also created an adapter to adapt the new interface to the old one for
backwards compatibilty with existing FIB components.

Change-Id: If8eb2220d9e4e69af135a8f9469ffda567ed4448
diff --git a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
index 5c3c18e..92448b4 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
@@ -19,6 +19,8 @@
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Modified;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
 import org.jboss.netty.bootstrap.ServerBootstrap;
 import org.jboss.netty.channel.Channel;
@@ -34,8 +36,8 @@
 import org.onlab.packet.Ip4Prefix;
 import org.onlab.packet.Ip6Prefix;
 import org.onlab.packet.IpPrefix;
-import org.onosproject.routing.RouteSourceService;
-import org.onosproject.routing.RouteListener;
+import org.onosproject.incubator.net.routing.Route;
+import org.onosproject.incubator.net.routing.RouteAdminService;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,7 +50,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import static com.google.common.base.Preconditions.checkNotNull;
 import static java.util.concurrent.Executors.newCachedThreadPool;
 import static org.onlab.util.Tools.groupedThreads;
 
@@ -57,10 +58,13 @@
  */
 @Component(immediate = true, enabled = false)
 @Service
-public class BgpSessionManager implements BgpInfoService, RouteSourceService {
+public class BgpSessionManager implements BgpInfoService {
     private static final Logger log =
             LoggerFactory.getLogger(BgpSessionManager.class);
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected RouteAdminService routeService;
+
     boolean isShutdown = true;
     private Channel serverChannel;     // Listener for incoming BGP connections
     private ServerBootstrap serverBootstrap;
@@ -75,19 +79,19 @@
     private ConcurrentMap<Ip6Prefix, BgpRouteEntry> bgpRoutes6 =
             new ConcurrentHashMap<>();
 
-    private RouteListener routeListener;
-
     private static final int DEFAULT_BGP_PORT = 2000;
     private int bgpPort;
 
     @Activate
     protected void activate(ComponentContext context) {
         readComponentConfiguration(context);
+        start();
         log.info("BgpSessionManager started");
     }
 
     @Deactivate
     protected void deactivate() {
+        stop();
         log.info("BgpSessionManager stopped");
     }
 
@@ -128,15 +132,6 @@
     }
 
     /**
-     * Gets the route listener.
-     *
-     * @return the route listener to use
-     */
-    RouteListener getRouteListener() {
-        return routeListener;
-    }
-
-    /**
      * Gets the BGP sessions.
      *
      * @return the BGP sessions
@@ -290,13 +285,29 @@
         return bgpRouteSelector;
     }
 
-    @Override
-    public void start(RouteListener routeListener) {
+    /**
+     * Sends updates routes to the route service.
+     *
+     * @param updates routes to update
+     */
+    void update(Collection<Route> updates) {
+        routeService.update(updates);
+    }
+
+    /**
+     * Sends withdrawn routes to the routes service.
+     *
+     * @param withdraws routes to withdraw
+     */
+    void withdraw(Collection<Route> withdraws) {
+        routeService.withdraw(withdraws);
+    }
+
+
+    public void start() {
         log.debug("BGP Session Manager start.");
         isShutdown = false;
 
-        this.routeListener = checkNotNull(routeListener);
-
         ChannelFactory channelFactory = new NioServerSocketChannelFactory(
                 newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")),
                 newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d")));
@@ -330,7 +341,6 @@
         }
     }
 
-    @Override
     public void stop() {
         isShutdown = true;
         allChannels.close().awaitUninterruptibly();