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 java.util.Collections;
12 import java.util.HashSet;
14 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
15 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
16 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
17 import org.opendaylight.controller.netconf.util.CloseableUtil;
19 public class NetconfOperationServiceSnapshotImpl implements NetconfOperationServiceSnapshot {
21 private final Set<NetconfOperationService> services;
22 private final String netconfSessionIdForReporting;
24 public NetconfOperationServiceSnapshotImpl(Set<NetconfOperationServiceFactory> factories, String sessionIdForReporting) {
25 Set<NetconfOperationService> services = new HashSet<>();
26 netconfSessionIdForReporting = sessionIdForReporting;
27 for (NetconfOperationServiceFactory factory : factories) {
28 services.add(factory.createService(netconfSessionIdForReporting));
30 this.services = Collections.unmodifiableSet(services);
36 public String getNetconfSessionIdForReporting() {
37 return netconfSessionIdForReporting;
41 public Set<NetconfOperationService> getServices() {
46 public void close() throws Exception {
47 CloseableUtil.closeAll(services);
51 public String toString() {
52 return "NetconfOperationServiceSnapshotImpl{" + netconfSessionIdForReporting + '}';