when deactivate sdn-ip, also delete all relative intents
Change-Id: I7a6bd64b5a9525dc49ca2b9353fcc45dc9a16288
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 1b3eda9..ace888d 100644
--- a/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
+++ b/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIp.java
@@ -15,12 +15,17 @@
*/
package org.onosproject.sdnip;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Objects;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
+import org.onosproject.app.ApplicationService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.cluster.LeadershipEvent;
@@ -28,8 +33,8 @@
import org.onosproject.cluster.LeadershipService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
-import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.incubator.net.intf.InterfaceService;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.IntentService;
import org.onosproject.routing.IntentSynchronizationService;
@@ -38,10 +43,6 @@
import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
-import java.util.Objects;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* Component for the SDN-IP peering application.
*/
@@ -59,6 +60,9 @@
protected IntentService intentService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ApplicationService applicationService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostService hostService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -84,7 +88,7 @@
private SdnIpFib fib;
private LeadershipEventListener leadershipEventListener =
- new InnerLeadershipEventListener();
+ new InnerLeadershipEventListener();
private ApplicationId appId;
private ControllerNode localControllerNode;
@@ -113,6 +117,10 @@
leadershipService.addListener(leadershipEventListener);
leadershipService.runForLeadership(appId.name());
+
+ applicationService.registerDeactivateHook(appId,
+ intentSynchronizer::removeIntents);
+
}
@Deactivate