blob: 9045e24a4ce285cd2ba36a98b87d94ae5d0b6aac [file] [log] [blame]
Yuta HIGUCHIb9af6b72016-06-10 10:52:58 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Yuta HIGUCHIb9af6b72016-06-10 10:52:58 -07003 *
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 */
16package org.onosproject.net.optical.internal;
17
18import static org.onosproject.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY;
19
20import org.apache.felix.scr.annotations.Activate;
21import org.apache.felix.scr.annotations.Component;
22import org.apache.felix.scr.annotations.Deactivate;
23import org.apache.felix.scr.annotations.Reference;
24import org.apache.felix.scr.annotations.ReferenceCardinality;
25import org.onosproject.net.ConnectPoint;
26import org.onosproject.net.config.ConfigFactory;
27import org.onosproject.net.config.NetworkConfigRegistry;
28import org.onosproject.net.config.PortConfigOperatorRegistry;
29import org.onosproject.net.optical.config.OpticalPortConfig;
30import org.onosproject.net.optical.config.OpticalPortOperator;
31import org.slf4j.Logger;
32import org.slf4j.LoggerFactory;
33
34/**
35 * Loader which registers optical model related config, etc.
36 */
37@Component(immediate = true)
38public class OpticalModelLoader {
39
40 private final Logger log = LoggerFactory.getLogger(getClass());
41
42 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
43 protected PortConfigOperatorRegistry portOperatorRegistry;
44
45 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
46 protected NetworkConfigRegistry netcfgRegistry;
47
48
49 private OpticalPortOperator opticalPortOp;
50
51 private ConfigFactory<ConnectPoint, OpticalPortConfig>
52 opticalPortConfigFactory = new ConfigFactory<ConnectPoint, OpticalPortConfig>(CONNECT_POINT_SUBJECT_FACTORY,
53 OpticalPortConfig.class,
Yuta HIGUCHI5ccaefb2016-09-07 11:18:13 -070054 OpticalPortConfig.CONFIG_KEY) {
Yuta HIGUCHIb9af6b72016-06-10 10:52:58 -070055 @Override
56 public OpticalPortConfig createConfig() {
57 return new OpticalPortConfig();
58 }
59 };
60
61 @Activate
62 protected void activate() {
63 netcfgRegistry.registerConfigFactory(opticalPortConfigFactory);
64
65 opticalPortOp = new OpticalPortOperator();
66 portOperatorRegistry.registerPortConfigOperator(opticalPortOp,
67 OpticalPortConfig.class);
68
69 log.info("Started");
70 }
71
72 @Deactivate
73 protected void deactivate() {
74 portOperatorRegistry.unregisterPortConfigOperator(opticalPortOp);
75
76 netcfgRegistry.unregisterConfigFactory(opticalPortConfigFactory);
77 log.info("Stopped");
78 }
79}