Jonathan Hart
Committed by Gerrit Code Review

Ensure basic SubjectFactories have been initialized before NetworkConfigLoader

Change-Id: I233a5c40f83cc969f187c176af2a9e31e3526c1c
/*
* 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 {
}
......@@ -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());
......
......@@ -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;
......