From c43fd1cc65ca58c532f1765cd19c33483df747e6 Mon Sep 17 00:00:00 2001 From: Jonathan Hart Date: Mon, 18 Jan 2016 20:02:20 -0800 Subject: [PATCH] Ensure basic SubjectFactories have been initialized before NetworkConfigLoader Change-Id: I233a5c40f83cc969f187c176af2a9e31e3526c1c --- .../net/config/BasicNetworkConfigService.java | 23 +++++++++++++++++++ .../net/config/impl/BasicNetworkConfigs.java | 5 +++- .../net/config/impl/NetworkConfigLoader.java | 6 +++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java diff --git a/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java b/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java new file mode 100644 index 0000000000..45b2e44581 --- /dev/null +++ b/core/api/src/main/java/org/onosproject/net/config/BasicNetworkConfigService.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 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.net.config; + +/** + * Service representing the availability of the basic network configs. + */ +public interface BasicNetworkConfigService { +} diff --git a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java index c44a4e288d..d735dddf61 100644 --- a/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java +++ b/core/net/src/main/java/org/onosproject/net/config/impl/BasicNetworkConfigs.java @@ -21,12 +21,14 @@ 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.CoreService; import org.onosproject.incubator.net.config.basics.InterfaceConfig; import org.onosproject.net.ConnectPoint; import org.onosproject.net.DeviceId; import org.onosproject.net.HostId; import org.onosproject.net.LinkKey; +import org.onosproject.net.config.BasicNetworkConfigService; import org.onosproject.net.config.ConfigFactory; import org.onosproject.net.config.NetworkConfigRegistry; import org.onosproject.net.config.basics.BasicDeviceConfig; @@ -44,8 +46,9 @@ import static org.onosproject.net.config.basics.SubjectFactories.*; /** * Component for registration of builtin basic network configurations. */ +@Service @Component(immediate = true) -public class BasicNetworkConfigs { +public class BasicNetworkConfigs implements BasicNetworkConfigService { private final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java b/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java index 01348c1582..7dfaddb6a4 100644 --- a/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java +++ b/core/net/src/main/java/org/onosproject/net/config/impl/NetworkConfigLoader.java @@ -24,6 +24,7 @@ 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.onosproject.net.config.BasicNetworkConfigService; import org.onosproject.net.config.Config; import org.onosproject.net.config.NetworkConfigEvent; import org.onosproject.net.config.NetworkConfigListener; @@ -46,6 +47,11 @@ public class NetworkConfigLoader { private final Logger log = LoggerFactory.getLogger(getClass()); + // Dependency to ensure the basic subject factories are properly initialized + // before we start loading configs from file + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected BasicNetworkConfigService basicConfigs; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected NetworkConfigService networkConfigService;