Thomas Vachuska | 4998caa | 2015-08-26 13:28:38 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015 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 | 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; |
| 24 | import org.onosproject.incubator.net.domain.IntentDomainConfig; |
| 25 | import org.onosproject.incubator.net.domain.IntentDomainId; |
| 26 | import org.onosproject.net.config.ConfigFactory; |
| 27 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 28 | import org.slf4j.Logger; |
| 29 | import org.slf4j.LoggerFactory; |
| 30 | |
| 31 | import java.util.Set; |
| 32 | |
| 33 | import static org.onosproject.incubator.net.config.basics.ExtraSubjectFactories.INTENT_DOMAIN_SUBJECT_FACTORY; |
| 34 | |
| 35 | /** |
| 36 | * Component for registration of builtin basic network configurations. |
| 37 | */ |
| 38 | @Component(immediate = true) |
| 39 | public class ExtraNetworkConfigs { |
| 40 | |
| 41 | private final Logger log = LoggerFactory.getLogger(getClass()); |
| 42 | |
| 43 | private final Set<ConfigFactory> factories = ImmutableSet.of( |
| 44 | new ConfigFactory<IntentDomainId, IntentDomainConfig>(INTENT_DOMAIN_SUBJECT_FACTORY, |
| 45 | IntentDomainConfig.class, |
| 46 | "basic") { |
| 47 | @Override |
| 48 | public IntentDomainConfig createConfig() { |
| 49 | return new IntentDomainConfig(); |
| 50 | } |
| 51 | } |
| 52 | ); |
| 53 | |
| 54 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 55 | protected NetworkConfigRegistry registry; |
| 56 | |
| 57 | @Activate |
| 58 | public void activate() { |
| 59 | factories.forEach(registry::registerConfigFactory); |
| 60 | log.info("Started"); |
| 61 | } |
| 62 | |
| 63 | @Deactivate |
| 64 | public void deactivate() { |
| 65 | factories.forEach(registry::unregisterConfigFactory); |
| 66 | log.info("Stopped"); |
| 67 | } |
| 68 | |
| 69 | } |