Jonathan Hart

Fix registering config listener in SingleSwitchFibInstaller

Change-Id: I559d89063236c81fa63530aa5db61f4b68006287
......@@ -127,8 +127,6 @@ public class SingleSwitchFibInstaller {
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;
......@@ -149,9 +147,10 @@ public class SingleSwitchFibInstaller {
// 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,
......@@ -173,9 +172,8 @@ public class SingleSwitchFibInstaller {
networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
deviceListener = new InternalDeviceListener();
networkConfigService.addListener(configListener);
deviceService.addListener(deviceListener);
interfaceService.addListener(internalInterfaceList);
updateConfig();
......@@ -192,6 +190,7 @@ public class SingleSwitchFibInstaller {
routeService.removeListener(routeListener);
deviceService.removeListener(deviceListener);
interfaceService.removeListener(internalInterfaceList);
networkConfigService.removeListener(configListener);
//processIntfFilters(false, configService.getInterfaces()); //TODO necessary?
......@@ -557,7 +556,7 @@ public class SingleSwitchFibInstaller {
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:
......
......@@ -41,6 +41,7 @@ import org.onosproject.incubator.net.routing.RouteServiceAdapter;
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;
......@@ -131,6 +132,8 @@ public class SingleSwitchFibInstallerTest {
interfaceService = createMock(InterfaceService.class);
networkConfigService = createMock(NetworkConfigService.class);
networkConfigService.addListener(anyObject(NetworkConfigListener.class));
expectLastCall().anyTimes();
networkConfigRegistry = createMock(NetworkConfigRegistry.class);
flowObjectiveService = createMock(FlowObjectiveService.class);
applicationService = createNiceMock(ApplicationService.class);
......