blob: e9d6b30b8bcc55de7d28e5962d4aea3efb8e81e5 [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
53
54
55 private final List<ConfigFactory> factories = ImmutableList.of(
56 new ConfigFactory<DeviceId, FlowTableConfig>(DEVICE_SUBJECT_FACTORY,
57 FlowTableConfig.class,
58 FlowTableConfig.CONFIG_KEY) {
59 @Override
60 public FlowTableConfig createConfig() {
61 return new FlowTableConfig();
62 }
Yuta HIGUCHI66e35f42017-03-11 14:12:05 -080063 },
64 new ConfigFactory<ConnectPoint, LambdaConfig>(CONNECT_POINT_SUBJECT_FACTORY,
65 LambdaConfig.class,
66 LambdaConfig.CONFIG_KEY) {
67 @Override
68 public LambdaConfig createConfig() {
69 return new LambdaConfig();
70 }
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080071 });
72
73
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070074 public OpticalDriversLoader() {
75 super("/optical-drivers.xml");
76 }
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080077
78 @Activate
79 @Override
80 protected void activate() {
81 factories.forEach(registry::registerConfigFactory);
82
83 super.activate();
84 }
85
86 @Deactivate
87 @Override
88 protected void deactivate() {
89 factories.forEach(registry::unregisterConfigFactory);
90 super.deactivate();
91 }
92
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070093}