2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.netconf.impl.osgi;
11 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
12 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
13 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
14 import org.opendaylight.controller.netconf.util.CloseableUtil;
16 import java.util.Collections;
17 import java.util.HashSet;
20 public class NetconfOperationServiceSnapshotImpl implements NetconfOperationServiceSnapshot {
22 private final Set<NetconfOperationService> services;
23 private final String netconfSessionIdForReporting;
25 public NetconfOperationServiceSnapshotImpl(Set<NetconfOperationServiceFactory> factories, String sessionIdForReporting) {
26 Set<NetconfOperationService> services = new HashSet<>();
27 netconfSessionIdForReporting = sessionIdForReporting;
28 for (NetconfOperationServiceFactory factory : factories) {
29 services.add(factory.createService(netconfSessionIdForReporting));
31 this.services = Collections.unmodifiableSet(services);
37 public String getNetconfSessionIdForReporting() {
38 return netconfSessionIdForReporting;
42 public Set<NetconfOperationService> getServices() {
47 public void close() throws Exception {
48 CloseableUtil.closeAll(services);
52 public String toString() {
53 return "NetconfOperationServiceSnapshotImpl{" + netconfSessionIdForReporting + '}';