Fix registering config listener in SingleSwitchFibInstaller
Change-Id: I559d89063236c81fa63530aa5db61f4b68006287
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
index f0649b9..bbd8638 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/impl/SingleSwitchFibInstaller.java
@@ -122,8 +122,6 @@
label = "Install a /32 route to each next hop")
private boolean routeToNextHop = false;
- private InternalDeviceListener deviceListener;
-
// Device id of data-plane switch - should be learned from config
private DeviceId deviceId;
@@ -143,9 +141,10 @@
// Mapping from next hop IP to next hop object containing group info
private final Map<IpAddress, Integer> nextHops = Maps.newHashMap();
- //interface object for event
- private InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener();
- private InternalRouteListener routeListener = new InternalRouteListener();
+ private final InternalDeviceListener deviceListener = new InternalDeviceListener();
+ private final InternalInterfaceListener internalInterfaceList = new InternalInterfaceListener();
+ private final InternalRouteListener routeListener = new InternalRouteListener();
+ private final InternalNetworkConfigListener configListener = new InternalNetworkConfigListener();
private ConfigFactory<ApplicationId, McastConfig> mcastConfigFactory =
new ConfigFactory<ApplicationId, McastConfig>(SubjectFactories.APP_SUBJECT_FACTORY,
@@ -166,9 +165,8 @@
networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
- deviceListener = new InternalDeviceListener();
+ networkConfigService.addListener(configListener);
deviceService.addListener(deviceListener);
-
interfaceService.addListener(internalInterfaceList);
updateConfig();
@@ -181,6 +179,7 @@
routeService.removeListener(routeListener);
deviceService.removeListener(deviceListener);
interfaceService.removeListener(internalInterfaceList);
+ networkConfigService.removeListener(configListener);
//processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
@@ -532,7 +531,7 @@
private class InternalNetworkConfigListener implements NetworkConfigListener {
@Override
public void event(NetworkConfigEvent event) {
- if (event.subject().equals(RoutingService.ROUTER_CONFIG_CLASS)) {
+ if (event.configClass().equals(RoutingService.ROUTER_CONFIG_CLASS)) {
switch (event.type()) {
case CONFIG_ADDED:
case CONFIG_UPDATED:
diff --git a/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java b/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
index b1b80c5..932d2c3 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/impl/SingleSwitchFibInstallerTest.java
@@ -40,6 +40,7 @@
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.device.DeviceListener;
@@ -130,6 +131,8 @@
interfaceService = createMock(InterfaceService.class);
networkConfigService = createMock(NetworkConfigService.class);
+ networkConfigService.addListener(anyObject(NetworkConfigListener.class));
+ expectLastCall().anyTimes();
networkConfigRegistry = createMock(NetworkConfigRegistry.class);
flowObjectiveService = createMock(FlowObjectiveService.class);
deviceService = new TestDeviceService();