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; |
| 23 | import org.apache.felix.scr.annotations.Activate; |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 24 | import org.apache.felix.scr.annotations.Component; |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 25 | import org.apache.felix.scr.annotations.Deactivate; |
| 26 | import org.apache.felix.scr.annotations.Reference; |
| 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 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 | |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 50 | @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 HIGUCHI | 66e35f4 | 2017-03-11 14:12:05 -0800 | [diff] [blame] | 63 | }, |
| 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 HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 71 | }); |
| 72 | |
| 73 | |
HIGUCHI Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 74 | public OpticalDriversLoader() { |
| 75 | super("/optical-drivers.xml"); |
| 76 | } |
Yuta HIGUCHI | 44f18e9 | 2017-03-02 22:05:41 -0800 | [diff] [blame] | 77 | |
| 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 Yuta | 07a9e56 | 2016-05-23 16:41:17 -0700 | [diff] [blame] | 93 | } |