Fix vRouter app IDs and deactivation of components.

CORD-710.

Change-Id: I66da47eef8ec5978c3f36447be4d12f6f07f88f8
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/SingleSwitchFibInstaller.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
similarity index 96%
rename from apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/SingleSwitchFibInstaller.java
rename to apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
index c6b3af4..6401679 100644
--- a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/SingleSwitchFibInstaller.java
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
@@ -85,10 +85,10 @@
  * Programs routes to a single OpenFlow switch.
  */
 @Component(immediate = true)
-public class SingleSwitchFibInstaller {
+public class FibInstaller {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
-    private static final String APP_NAME = "org.onosproject.vrouter";
+    private static final String APP_NAME = "org.onosproject.fibinstaller";
 
     private static final int PRIORITY_OFFSET = 100;
     private static final int PRIORITY_MULTIPLIER = 5;
@@ -138,7 +138,7 @@
 
     private ApplicationId coreAppId;
     private ApplicationId routerAppId;
-    private ApplicationId vrouterAppId;
+    private ApplicationId fibAppId;
 
     // Reference count for how many times a next hop is used by a route
     private final Multiset<IpAddress> nextHopsCount = ConcurrentHashMultiset.create();
@@ -168,7 +168,7 @@
 
         coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME);
         routerAppId = coreService.registerApplication(RoutingService.ROUTER_APP_ID);
-        vrouterAppId = coreService.registerApplication(APP_NAME);
+        fibAppId = coreService.registerApplication(APP_NAME);
 
         networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
 
@@ -178,19 +178,13 @@
 
         processRouterConfig();
 
-        // FIXME: There can be an issue when this component is deactivated before vRouter.
-        //        This will be addressed in CORD-710.
-        applicationService.registerDeactivateHook(vrouterAppId, () -> cleanUp());
+        applicationService.registerDeactivateHook(fibAppId, () -> cleanUp());
 
         log.info("Started");
     }
 
     @Deactivate
     protected void deactivate() {
-         // FIXME: This will also remove flows when an instance goes down.
-         //        This is a temporary solution and should be addressed in CORD-710.
-        cleanUp();
-
         asyncDeviceFetcher.shutdown();
         networkConfigService.removeListener(configListener);
 
@@ -295,7 +289,7 @@
         int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET;
 
         ForwardingObjective.Builder fwdBuilder = DefaultForwardingObjective.builder()
-                .fromApp(routerAppId)
+                .fromApp(fibAppId)
                 .makePermanent()
                 .withSelector(selector)
                 .withPriority(priority)
@@ -367,7 +361,7 @@
                     .withId(nextId)
                     .addTreatment(treatment.build())
                     .withType(NextObjective.Type.SIMPLE)
-                    .fromApp(routerAppId);
+                    .fromApp(fibAppId);
             if (metabuilder != null) {
                 nextBuilder.withMeta(metabuilder.build());
             }
@@ -457,7 +451,7 @@
                     .pushVlan().setVlanId(assignedVlan).build();
             fob.withMeta(tt);
         }
-        fob.permit().fromApp(routerAppId);
+        fob.permit().fromApp(fibAppId);
         sendFilteringObjective(install, fob, intf);
 
         if (controlPlaneConnectPoint != null) {
@@ -489,7 +483,7 @@
                 .pushVlan().setVlanId(assignedVlan).build();
         fob.withMeta(tt);
 
-        fob.permit().fromApp(routerAppId);
+        fob.permit().fromApp(fibAppId);
         sendFilteringObjective(install, fob, intf);
     }