blob: f532dc9af4d9e4d391f89803aedabe110a26c69e [file] [log] [blame]
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -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 */
16
Ray Milkey85267002016-11-16 11:06:35 -080017package org.onosproject.drivers.optical;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070018
Yuta HIGUCHI66e35f42017-03-11 14:12:05 -080019import static org.onosproject.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY;
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080020import static org.onosproject.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY;
21
22import java.util.List;
23import org.apache.felix.scr.annotations.Activate;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070024import org.apache.felix.scr.annotations.Component;
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080025import org.apache.felix.scr.annotations.Deactivate;
26import org.apache.felix.scr.annotations.Reference;
27import org.apache.felix.scr.annotations.ReferenceCardinality;
28import org.onosproject.driver.optical.config.FlowTableConfig;
Yuta HIGUCHI66e35f42017-03-11 14:12:05 -080029import org.onosproject.driver.optical.config.LambdaConfig;
30import org.onosproject.net.ConnectPoint;
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080031import org.onosproject.net.DeviceId;
32import org.onosproject.net.config.ConfigFactory;
33import org.onosproject.net.config.NetworkConfigRegistry;
34import org.onosproject.net.config.NetworkConfigRegistryAdapter;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070035import org.onosproject.net.driver.AbstractDriverLoader;
36import org.onosproject.net.optical.OpticalDevice;
37
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080038import com.google.common.collect.ImmutableList;
39
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070040/**
41 * Loader for other optical device drivers.
42 */
43@Component(immediate = true)
44public class OpticalDriversLoader extends AbstractDriverLoader {
45
46 // OSGI: help bundle plugin discover runtime package dependency.
47 @SuppressWarnings("unused")
48 private OpticalDevice optical;
49
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080050 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
51 protected NetworkConfigRegistry registry = new NetworkConfigRegistryAdapter();
52
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080053 private final List<ConfigFactory> factories = ImmutableList.of(
54 new ConfigFactory<DeviceId, FlowTableConfig>(DEVICE_SUBJECT_FACTORY,
55 FlowTableConfig.class,
56 FlowTableConfig.CONFIG_KEY) {
57 @Override
58 public FlowTableConfig createConfig() {
59 return new FlowTableConfig();
60 }
Yuta HIGUCHI66e35f42017-03-11 14:12:05 -080061 },
62 new ConfigFactory<ConnectPoint, LambdaConfig>(CONNECT_POINT_SUBJECT_FACTORY,
63 LambdaConfig.class,
64 LambdaConfig.CONFIG_KEY) {
65 @Override
66 public LambdaConfig createConfig() {
67 return new LambdaConfig();
68 }
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080069 });
70
71
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070072 public OpticalDriversLoader() {
73 super("/optical-drivers.xml");
74 }
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080075
76 @Activate
77 @Override
78 protected void activate() {
79 factories.forEach(registry::registerConfigFactory);
80
81 super.activate();
82 }
83
84 @Deactivate
85 @Override
86 protected void deactivate() {
87 factories.forEach(registry::unregisterConfigFactory);
88 super.deactivate();
89 }
90
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070091}