HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 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 Milkey | 8526700 | 2016-11-16 11:06:35 -0800 | [diff] [blame] | 17 | package org.onosproject.drivers.optical; |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 18 | |
Yuta HIGUCHI | 66e35f4 | 2017-03-11 14:12:05 -0800 | [diff] [blame] | 19 | import static org.onosproject.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY; |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 20 | import static org.onosproject.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY; |
| 21 | |
| 22 | import java.util.List; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 23 | import org.osgi.service.component.annotations.Activate; |
| 24 | import org.osgi.service.component.annotations.Component; |
| 25 | import org.osgi.service.component.annotations.Deactivate; |
| 26 | import org.osgi.service.component.annotations.Reference; |
| 27 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 28 | import org.onosproject.driver.optical.config.FlowTableConfig; |
Yuta HIGUCHI | 66e35f4 | 2017-03-11 14:12:05 -0800 | [diff] [blame] | 29 | import org.onosproject.driver.optical.config.LambdaConfig; |
| 30 | import org.onosproject.net.ConnectPoint; |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 31 | import org.onosproject.net.DeviceId; |
| 32 | import org.onosproject.net.config.ConfigFactory; |
| 33 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 34 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 35 | import org.onosproject.net.driver.AbstractDriverLoader; |
| 36 | import org.onosproject.net.optical.OpticalDevice; |
| 37 | |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 38 | import com.google.common.collect.ImmutableList; |
| 39 | |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Loader for other optical device drivers. |
| 42 | */ |
| 43 | @Component(immediate = true) |
| 44 | public class OpticalDriversLoader extends AbstractDriverLoader { |
| 45 | |
| 46 | // OSGI: help bundle plugin discover runtime package dependency. |
| 47 | @SuppressWarnings("unused") |
| 48 | private OpticalDevice optical; |
| 49 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 50 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 51 | protected NetworkConfigRegistry registry = new NetworkConfigRegistryAdapter(); |
| 52 | |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 53 | 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 HIGUCHI | 66e35f4 | 2017-03-11 14:12:05 -0800 | [diff] [blame] | 61 | }, |
| 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 HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 69 | }); |
| 70 | |
| 71 | |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 72 | public OpticalDriversLoader() { |
| 73 | super("/optical-drivers.xml"); |
| 74 | } |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 75 | |
| 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 Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 91 | } |