blob: 4c1dc4fb03382b5f7b89ed84ffd8968e00bb3811 [file] [log] [blame]
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -07001/*
2 * Copyright 2016-present 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
Ray Milkey85267002016-11-16 11:06:35 -080017package org.onosproject.drivers.optical;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070018
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080019import static org.onosproject.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY;
20
21import java.util.List;
22import org.apache.felix.scr.annotations.Activate;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070023import org.apache.felix.scr.annotations.Component;
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080024import org.apache.felix.scr.annotations.Deactivate;
25import org.apache.felix.scr.annotations.Reference;
26import org.apache.felix.scr.annotations.ReferenceCardinality;
27import org.onosproject.driver.optical.config.FlowTableConfig;
28import org.onosproject.net.DeviceId;
29import org.onosproject.net.config.ConfigFactory;
30import org.onosproject.net.config.NetworkConfigRegistry;
31import org.onosproject.net.config.NetworkConfigRegistryAdapter;
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070032import org.onosproject.net.driver.AbstractDriverLoader;
33import org.onosproject.net.optical.OpticalDevice;
34
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080035import com.google.common.collect.ImmutableList;
36
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070037/**
38 * Loader for other optical device drivers.
39 */
40@Component(immediate = true)
41public class OpticalDriversLoader extends AbstractDriverLoader {
42
43 // OSGI: help bundle plugin discover runtime package dependency.
44 @SuppressWarnings("unused")
45 private OpticalDevice optical;
46
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080047 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
48 protected NetworkConfigRegistry registry = new NetworkConfigRegistryAdapter();
49
50
51
52 private final List<ConfigFactory> factories = ImmutableList.of(
53 new ConfigFactory<DeviceId, FlowTableConfig>(DEVICE_SUBJECT_FACTORY,
54 FlowTableConfig.class,
55 FlowTableConfig.CONFIG_KEY) {
56 @Override
57 public FlowTableConfig createConfig() {
58 return new FlowTableConfig();
59 }
60
61 });
62
63
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070064 public OpticalDriversLoader() {
65 super("/optical-drivers.xml");
66 }
Yuta HIGUCHI44f18e92017-03-02 22:05:41 -080067
68 @Activate
69 @Override
70 protected void activate() {
71 factories.forEach(registry::registerConfigFactory);
72
73 super.activate();
74 }
75
76 @Deactivate
77 @Override
78 protected void deactivate() {
79 factories.forEach(registry::unregisterConfigFactory);
80 super.deactivate();
81 }
82
HIGUCHI Yuta07a9e562016-05-23 16:41:17 -070083}