Moved registering routing configs out of the RoutingConfigImpl
Change-Id: Ib2e7bcfd7a84ee3dc8a285265ca4599e99744531
diff --git a/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java b/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
deleted file mode 100644
index c41724f..0000000
--- a/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.routing.config.impl;
-
-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.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.intf.InterfaceService;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.routing.config.BgpConfig;
-import org.onosproject.routing.config.RouterConfig;
-import org.onosproject.routing.config.RoutersConfig;
-import org.onosproject.routing.config.RoutingConfigurationService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of RoutingConfigurationService which reads routing
- * configuration from the network configuration service.
- */
-@Component(immediate = true)
-@Service
-public class RoutingConfigurationImpl implements RoutingConfigurationService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigRegistry registry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigService configService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected InterfaceService interfaceService;
-
- private ConfigFactory<ApplicationId, BgpConfig> bgpConfigFactory =
- new ConfigFactory<ApplicationId, BgpConfig>(
- SubjectFactories.APP_SUBJECT_FACTORY, BgpConfig.class, "bgp") {
- @Override
- public BgpConfig createConfig() {
- return new BgpConfig();
- }
- };
-
- private ConfigFactory<ApplicationId, RouterConfig> routerConfigFactory =
- new ConfigFactory<ApplicationId, RouterConfig>(
- SubjectFactories.APP_SUBJECT_FACTORY, RouterConfig.class, "router") {
- @Override
- public RouterConfig createConfig() {
- return new RouterConfig();
- }
- };
-
- private ConfigFactory<ApplicationId, RoutersConfig> routersConfigFactory =
- new ConfigFactory<ApplicationId, RoutersConfig>(
- SubjectFactories.APP_SUBJECT_FACTORY, RoutersConfig.class, "routers", true) {
- @Override
- public RoutersConfig createConfig() {
- return new RoutersConfig();
- }
- };
-
- @Activate
- public void activate() {
- registry.registerConfigFactory(bgpConfigFactory);
- registry.registerConfigFactory(routerConfigFactory);
- registry.registerConfigFactory(routersConfigFactory);
- log.info("Routing configuration service started");
- }
-
- @Deactivate
- public void deactivate() {
- registry.unregisterConfigFactory(bgpConfigFactory);
- registry.unregisterConfigFactory(routerConfigFactory);
- registry.unregisterConfigFactory(routersConfigFactory);
- log.info("Routing configuration service stopped");
- }
-
-}
diff --git a/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/package-info.java b/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/package-info.java
deleted file mode 100644
index b7a9594..0000000
--- a/apps/routing/common/src/main/java/org/onosproject/routing/config/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of routing configuration APIs.
- */
-package org.onosproject.routing.config.impl;
diff --git a/apps/routing/cpr/src/main/java/org/onosproject/routing/cpr/ControlPlaneRedirectManager.java b/apps/routing/cpr/src/main/java/org/onosproject/routing/cpr/ControlPlaneRedirectManager.java
index 8e793e2..6aa2823 100644
--- a/apps/routing/cpr/src/main/java/org/onosproject/routing/cpr/ControlPlaneRedirectManager.java
+++ b/apps/routing/cpr/src/main/java/org/onosproject/routing/cpr/ControlPlaneRedirectManager.java
@@ -44,7 +44,7 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
@@ -57,13 +57,12 @@
import org.onosproject.net.flowobjective.NextObjective;
import org.onosproject.net.host.HostService;
import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.routing.RouterInfo;
import org.onosproject.routing.InterfaceProvisionRequest;
import org.onosproject.routing.Router;
+import org.onosproject.routing.RouterInfo;
import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.RouterConfigHelper;
+import org.onosproject.routing.config.RoutingConfiguration;
import org.onosproject.routing.config.RoutersConfig;
-import org.onosproject.routing.config.RoutingConfigurationService;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
@@ -113,7 +112,7 @@
protected FlowObjectiveService flowObjectiveService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected NetworkConfigService networkConfigService;
+ protected NetworkConfigRegistry networkConfigService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
@@ -125,9 +124,6 @@
protected ApplicationService applicationService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RoutingConfigurationService rs;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ComponentConfigService cfgService;
@Property(name = "forceUnprovision", boolValue = false,
@@ -151,6 +147,8 @@
cfgService.registerProperties(getClass());
modified(context);
+ RoutingConfiguration.register(networkConfigService);
+
networkConfigService.addListener(networkConfigListener);
processRouterConfig();
@@ -163,6 +161,7 @@
protected void deactivate() {
cfgService.unregisterProperties(getClass(), false);
networkConfigService.removeListener(networkConfigListener);
+ RoutingConfiguration.unregister(networkConfigService);
}
@Modified
@@ -196,7 +195,7 @@
coreService.registerApplication(RoutingService.ROUTER_APP_ID);
Set<RoutersConfig.Router> routerConfigs =
- RouterConfigHelper.getRouterConfigurations(networkConfigService, routingAppId);
+ RoutingConfiguration.getRouterConfigurations(networkConfigService, routingAppId);
for (RoutersConfig.Router router : routerConfigs) {
DeviceId deviceId = router.controlPlaneConnectPoint().deviceId();
diff --git a/apps/routing/cpr/src/test/java/org/onosproject/routing/cpr/ControlPlaneRedirectManagerTest.java b/apps/routing/cpr/src/test/java/org/onosproject/routing/cpr/ControlPlaneRedirectManagerTest.java
index 40c27d3..21db3e5 100644
--- a/apps/routing/cpr/src/test/java/org/onosproject/routing/cpr/ControlPlaneRedirectManagerTest.java
+++ b/apps/routing/cpr/src/test/java/org/onosproject/routing/cpr/ControlPlaneRedirectManagerTest.java
@@ -48,8 +48,8 @@
import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigEvent.Type;
import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.NetworkConfigServiceAdapter;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigRegistryAdapter;
import org.onosproject.net.device.DeviceEvent;
import org.onosproject.net.device.DeviceListener;
import org.onosproject.net.device.DeviceService;
@@ -98,7 +98,7 @@
private DeviceService deviceService;
private FlowObjectiveService flowObjectiveService;
- private NetworkConfigService networkConfigService;
+ private NetworkConfigRegistry networkConfigService;
private final Set<Interface> interfaces = Sets.newHashSet();
static Device dev3 = NetTestTools.device("0000000000000001");
private static final int OSPF_IP_PROTO = 0x59;
@@ -588,7 +588,7 @@
}
- private class TestNetworkConfigService extends NetworkConfigServiceAdapter {
+ private class TestNetworkConfigService extends NetworkConfigRegistryAdapter {
@Override
public void addListener(NetworkConfigListener listener) {
diff --git a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
index 18e28c3..fe8403f 100644
--- a/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
+++ b/apps/routing/fibinstaller/src/main/java/org/onosproject/routing/fibinstaller/FibInstaller.java
@@ -72,9 +72,8 @@
import org.onosproject.routing.Router;
import org.onosproject.routing.RouterInfo;
import org.onosproject.routing.RoutingService;
-import org.onosproject.routing.config.RouterConfigHelper;
+import org.onosproject.routing.config.RoutingConfiguration;
import org.onosproject.routing.config.RoutersConfig;
-import org.onosproject.routing.config.RoutingConfigurationService;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,9 +125,6 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ApplicationService applicationService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected RoutingConfigurationService rs;
-
@Property(name = "routeToNextHop", boolValue = false,
label = "Install a /32 or /128 route to each next hop")
private boolean routeToNextHop = false;
@@ -168,6 +164,8 @@
componentConfigService.registerProperties(getClass());
modified(context);
+ RoutingConfiguration.register(networkConfigRegistry);
+
coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME);
routerAppId = coreService.registerApplication(RoutingService.ROUTER_APP_ID);
fibAppId = coreService.registerApplication(APP_NAME);
@@ -187,6 +185,8 @@
protected void deactivate() {
networkConfigService.removeListener(configListener);
+ RoutingConfiguration.unregister(networkConfigRegistry);
+
componentConfigService.unregisterProperties(getClass(), false);
log.info("Stopped");
@@ -207,7 +207,7 @@
private void processRouterConfig() {
Set<RoutersConfig.Router> routerConfigs =
- RouterConfigHelper.getRouterConfigurations(networkConfigService, routerAppId);
+ RoutingConfiguration.getRouterConfigurations(networkConfigService, routerAppId);
if (routerConfigs.isEmpty()) {
log.info("Router config not available");
return;