02a7914a167abc4d67b179c77a162b338c1da5a3
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / ConfigSubsystemFacadeFactory.java
1 /*
2  * Copyright (c) 2015 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 ConfigRegistryClient cfgRegClient;
23     private ConfigRegistryJMXClient cfgRegClientNoNotifications;
24     private YangStoreService yangStoreService;
25
26     public ConfigSubsystemFacadeFactory(final ConfigRegistryClient cfgRegClient, final ConfigRegistryJMXClient jmxClientNoNotifications, final YangStoreService yangStoreService) {
27         this.cfgRegClient = cfgRegClient;
28         this.cfgRegClientNoNotifications = jmxClientNoNotifications;
29         this.yangStoreService = yangStoreService;
30     }
31
32     /**
33      * Create new instance of ConfigSubsystemFacade. Each instance works with a dedicated transaction provider, making
34      * the instances suitable for facade-per-client use.
35      */
36     public ConfigSubsystemFacade createFacade(final String id) {
37         return new ConfigSubsystemFacade(cfgRegClient, cfgRegClientNoNotifications, yangStoreService, id);
38     }
39
40     public YangStoreService getYangStoreService() {
41         return yangStoreService;
42     }
43
44     public Set<Capability> getCurrentCapabilities() {
45         Set<Module> modules = yangStoreService.getModules();
46         final Set<Capability> capabilities = Sets.newHashSet();
47         for (Module module : modules) {
48             capabilities.add(new YangModuleCapability(module, yangStoreService.getModuleSource(module)));
49         }
50
51         return capabilities;
52     }
53
54
55 }