blob: e77e1da09cca034f27612f6d2954953d39973674 [file] [log] [blame]
Thomas Vachuska4998caa2015-08-26 13:28:38 -07001/*
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 */
16package org.onosproject.incubator.net.config.impl;
17
18import com.google.common.collect.ImmutableSet;
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.onosproject.incubator.net.domain.IntentDomainConfig;
25import org.onosproject.incubator.net.domain.IntentDomainId;
26import org.onosproject.net.config.ConfigFactory;
27import org.onosproject.net.config.NetworkConfigRegistry;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
31import java.util.Set;
32
33import 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)
39public 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}