HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 1 | /* |
| 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 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 | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame^] | 19 | import static org.onosproject.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY; |
| 20 | |
| 21 | import java.util.List; |
| 22 | import org.apache.felix.scr.annotations.Activate; |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Component; |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame^] | 24 | import org.apache.felix.scr.annotations.Deactivate; |
| 25 | import org.apache.felix.scr.annotations.Reference; |
| 26 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 27 | import org.onosproject.driver.optical.config.FlowTableConfig; |
| 28 | import org.onosproject.net.DeviceId; |
| 29 | import org.onosproject.net.config.ConfigFactory; |
| 30 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 31 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 32 | import org.onosproject.net.driver.AbstractDriverLoader; |
| 33 | import org.onosproject.net.optical.OpticalDevice; |
| 34 | |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame^] | 35 | import com.google.common.collect.ImmutableList; |
| 36 | |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Loader for other optical device drivers. |
| 39 | */ |
| 40 | @Component(immediate = true) |
| 41 | public class OpticalDriversLoader extends AbstractDriverLoader { |
| 42 | |
| 43 | // OSGI: help bundle plugin discover runtime package dependency. |
| 44 | @SuppressWarnings("unused") |
| 45 | private OpticalDevice optical; |
| 46 | |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame^] | 47 | @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 Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 64 | public OpticalDriversLoader() { |
| 65 | super("/optical-drivers.xml"); |
| 66 | } |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame^] | 67 | |
| 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 Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 83 | } |