Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -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 | package org.onosproject.incubator.net.config.impl; |
| 17 | |
| 18 | import com.google.common.collect.ImmutableSet; |
| 19 | import org.apache.felix.scr.annotations.Activate; |
| 20 | import org.apache.felix.scr.annotations.Component; |
| 21 | import org.apache.felix.scr.annotations.Deactivate; |
| 22 | import org.apache.felix.scr.annotations.Reference; |
| 23 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame] | 24 | import org.onosproject.net.config.ConfigFactory; |
| 25 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | |
| 29 | import java.util.Set; |
| 30 | |
Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Component for registration of builtin basic network configurations. |
| 33 | */ |
| 34 | @Component(immediate = true) |
| 35 | public class ExtraNetworkConfigs { |
| 36 | |
| 37 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 38 | |
Brian O'Connor | bd7f878 | 2015-11-19 23:12:37 -0800 | [diff] [blame] | 39 | private final Set<ConfigFactory> factories = ImmutableSet.of(); |
Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame] | 40 | |
| 41 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 42 | protected NetworkConfigRegistry registry; |
| 43 | |
| 44 | @Activate |
| 45 | public void activate() { |
| 46 | factories.forEach(registry::registerConfigFactory); |
| 47 | log.info("Started"); |
| 48 | } |
| 49 | |
| 50 | @Deactivate |
| 51 | public void deactivate() { |
| 52 | factories.forEach(registry::unregisterConfigFactory); |
| 53 | log.info("Stopped"); |
| 54 | } |
| 55 | |
| 56 | } |