895bcc5a30987a8c72e89d19c0afd8ac8272af03
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / ConfigSubsystemFacadeFactory.java
1 /*
2  * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.config.facade.xml;
10
11 import com.google.common.collect.Sets;
12 import java.util.Set;
13 import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
14 import org.opendaylight.controller.config.util.ConfigRegistryClient;
15 import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
16 import org.opendaylight.controller.config.util.capability.Capability;
17 import org.opendaylight.controller.config.util.capability.YangModuleCapability;
18 import org.opendaylight.yangtools.yang.model.api.Module;
19
20 public class ConfigSubsystemFacadeFactory {
21
22     private final ConfigRegistryClient cfgRegClient;
23     private final ConfigRegistryJMXClient cfgRegClientNoNotifications;
24     private final YangStoreService yangStoreService;
25
26     public ConfigSubsystemFacadeFactory(final ConfigRegistryClient cfgRegClient,
27             final ConfigRegistryJMXClient jmxClientNoNotifications, final YangStoreService yangStoreService) {
28         this.cfgRegClient = cfgRegClient;
29         this.cfgRegClientNoNotifications = jmxClientNoNotifications;
30         this.yangStoreService = yangStoreService;
31     }
32
33     /**
34      * Create new instance of ConfigSubsystemFacade. Each instance works with a
35      * dedicated transaction provider, making the instances suitable for
36      * facade-per-client use.
37      */
38     public ConfigSubsystemFacade createFacade(final String id) {
39         return new ConfigSubsystemFacade(cfgRegClient, cfgRegClientNoNotifications, yangStoreService, id);
40     }
41
42     public YangStoreService getYangStoreService() {
43         return yangStoreService;
44     }
45
46     public Set<Capability> getCurrentCapabilities() {
47         Set<Module> modules = yangStoreService.getModules();
48         final Set<Capability> capabilities = Sets.newHashSet();
49         for (Module module : modules) {
50             capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(module)));
51         }
52         return capabilities;
53     }
54 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.