Moved BGP code and Router code into their own bundle.

The main goal of this is to allow routing code to be used by multiple
applications.

Changes include:
 * Created an onos-app-routing bundle and moved BGP code and routing code
   into it.
 * Created an onos-app-routing-api bundle as a common API bundle between
   onos-app-routing and onos-app-sdnip, to prevent circular dependencies.
 * Moved API classes into onos-app-routing-api bundle.
 * Made Router and BgpSessionManager into OSGi components. This is not quite
   clean, because there is still a chain of start() method calls from SdnIp
   through to BgpSessionManager to preserve startup order. This should be
   revisted so components can be started using activate()
 * Created BgpService and RoutingService APIs to glue different components
   together.
 * Many unit test changes. A lot of the previous unit tests spanned the
   Router and IntentSynchronizer classes, but this is not possible any more
   since these classes are in different bundles. I had to rewrite some of
   these tests so that each unit test class only tests one real class. A
   nice side-effect is that the tests are now simpler because each test
   tests less functionality.
 * Removed SdnIp test seeing as it doesn't run automatically, was already
   broken and has been largely superseded by other unit tests and the nightly
   functional tests.

Change-Id: I70ecf5391aa353e99e7cdcf7ed38a530c87571bb
diff --git a/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java b/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
index 0b921ff..b375852 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
@@ -32,14 +32,11 @@
 import org.onosproject.core.CoreService;
 import org.onosproject.net.host.HostService;
 import org.onosproject.net.intent.IntentService;
-import org.onosproject.sdnip.bgp.BgpRouteEntry;
-import org.onosproject.sdnip.bgp.BgpSession;
-import org.onosproject.sdnip.bgp.BgpSessionManager;
+import org.onosproject.routingapi.RoutingService;
 import org.onosproject.sdnip.config.SdnIpConfigurationReader;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 
-import java.util.Collection;
 import java.util.Dictionary;
 
 import static org.slf4j.LoggerFactory.getLogger;
@@ -69,8 +66,11 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected LeadershipService leadershipService;
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected RoutingService routingService;
+
     //
-    // NOTE: Unused reference - needed to guarentee that the
+    // NOTE: Unused reference - needed to guarantee that the
     // NetworkConfigReader component is activated and the network configuration
     // is read.
     //
@@ -83,8 +83,7 @@
     private IntentSynchronizer intentSynchronizer;
     private SdnIpConfigurationReader config;
     private PeerConnectivityManager peerConnectivity;
-    private Router router;
-    private BgpSessionManager bgpSessionManager;
+
     private LeadershipEventListener leadershipEventListener =
         new InnerLeadershipEventListener();
     private ApplicationId appId;
@@ -114,23 +113,18 @@
                                                        interfaceService);
         peerConnectivity.start();
 
-        router = new Router(intentSynchronizer, hostService);
-        router.start();
+        routingService.start(intentSynchronizer);
 
         leadershipService.addListener(leadershipEventListener);
         leadershipService.runForLeadership(appId.name());
 
         log.info("Starting BGP with port {}", bgpPort);
-
-        bgpSessionManager = new BgpSessionManager(router);
-        bgpSessionManager.start(bgpPort);
+        // TODO feed port information through to the BgpService
     }
 
     @Deactivate
     protected void deactivate() {
-
-        bgpSessionManager.stop();
-        router.stop();
+        routingService.stop();
         peerConnectivity.stop();
         intentSynchronizer.stop();
 
@@ -168,31 +162,6 @@
     }
 
     @Override
-    public Collection<BgpSession> getBgpSessions() {
-        return bgpSessionManager.getBgpSessions();
-    }
-
-    @Override
-    public Collection<BgpRouteEntry> getBgpRoutes4() {
-        return bgpSessionManager.getBgpRoutes4();
-    }
-
-    @Override
-    public Collection<BgpRouteEntry> getBgpRoutes6() {
-        return bgpSessionManager.getBgpRoutes6();
-    }
-
-    @Override
-    public Collection<RouteEntry> getRoutes4() {
-        return router.getRoutes4();
-    }
-
-    @Override
-    public Collection<RouteEntry> getRoutes6() {
-        return router.getRoutes6();
-    }
-
-    @Override
     public void modifyPrimary(boolean isPrimary) {
         intentSynchronizer.leaderChanged(isPrimary);
     }