Jonathan Hart
Committed by Gerrit Code Review

Ensure basic SubjectFactories have been initialized before NetworkConfigLoader

Change-Id: I233a5c40f83cc969f187c176af2a9e31e3526c1c
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.net.config;
18 +
19 +/**
20 + * Service representing the availability of the basic network configs.
21 + */
22 +public interface BasicNetworkConfigService {
23 +}
...@@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Component; ...@@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Component;
21 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
22 import org.apache.felix.scr.annotations.Reference; 22 import org.apache.felix.scr.annotations.Reference;
23 import org.apache.felix.scr.annotations.ReferenceCardinality; 23 import org.apache.felix.scr.annotations.ReferenceCardinality;
24 +import org.apache.felix.scr.annotations.Service;
24 import org.onosproject.core.CoreService; 25 import org.onosproject.core.CoreService;
25 import org.onosproject.incubator.net.config.basics.InterfaceConfig; 26 import org.onosproject.incubator.net.config.basics.InterfaceConfig;
26 import org.onosproject.net.ConnectPoint; 27 import org.onosproject.net.ConnectPoint;
27 import org.onosproject.net.DeviceId; 28 import org.onosproject.net.DeviceId;
28 import org.onosproject.net.HostId; 29 import org.onosproject.net.HostId;
29 import org.onosproject.net.LinkKey; 30 import org.onosproject.net.LinkKey;
31 +import org.onosproject.net.config.BasicNetworkConfigService;
30 import org.onosproject.net.config.ConfigFactory; 32 import org.onosproject.net.config.ConfigFactory;
31 import org.onosproject.net.config.NetworkConfigRegistry; 33 import org.onosproject.net.config.NetworkConfigRegistry;
32 import org.onosproject.net.config.basics.BasicDeviceConfig; 34 import org.onosproject.net.config.basics.BasicDeviceConfig;
...@@ -44,8 +46,9 @@ import static org.onosproject.net.config.basics.SubjectFactories.*; ...@@ -44,8 +46,9 @@ import static org.onosproject.net.config.basics.SubjectFactories.*;
44 /** 46 /**
45 * Component for registration of builtin basic network configurations. 47 * Component for registration of builtin basic network configurations.
46 */ 48 */
49 +@Service
47 @Component(immediate = true) 50 @Component(immediate = true)
48 -public class BasicNetworkConfigs { 51 +public class BasicNetworkConfigs implements BasicNetworkConfigService {
49 52
50 private final Logger log = LoggerFactory.getLogger(getClass()); 53 private final Logger log = LoggerFactory.getLogger(getClass());
51 54
......
...@@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Component; ...@@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Component;
24 import org.apache.felix.scr.annotations.Deactivate; 24 import org.apache.felix.scr.annotations.Deactivate;
25 import org.apache.felix.scr.annotations.Reference; 25 import org.apache.felix.scr.annotations.Reference;
26 import org.apache.felix.scr.annotations.ReferenceCardinality; 26 import org.apache.felix.scr.annotations.ReferenceCardinality;
27 +import org.onosproject.net.config.BasicNetworkConfigService;
27 import org.onosproject.net.config.Config; 28 import org.onosproject.net.config.Config;
28 import org.onosproject.net.config.NetworkConfigEvent; 29 import org.onosproject.net.config.NetworkConfigEvent;
29 import org.onosproject.net.config.NetworkConfigListener; 30 import org.onosproject.net.config.NetworkConfigListener;
...@@ -46,6 +47,11 @@ public class NetworkConfigLoader { ...@@ -46,6 +47,11 @@ public class NetworkConfigLoader {
46 47
47 private final Logger log = LoggerFactory.getLogger(getClass()); 48 private final Logger log = LoggerFactory.getLogger(getClass());
48 49
50 + // Dependency to ensure the basic subject factories are properly initialized
51 + // before we start loading configs from file
52 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
53 + protected BasicNetworkConfigService basicConfigs;
54 +
49 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 55 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
50 protected NetworkConfigService networkConfigService; 56 protected NetworkConfigService networkConfigService;
51 57
......