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 com.google.common.collect.ImmutableSet;
12 import com.google.common.collect.ImmutableSet.Builder;
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(final Set<NetconfOperationServiceFactory> factories, final String sessionIdForReporting) {
25 final Builder<NetconfOperationService> b = ImmutableSet.builder();
26 netconfSessionIdForReporting = sessionIdForReporting;
27 for (NetconfOperationServiceFactory factory : factories) {
28 b.add(factory.createService(netconfSessionIdForReporting));
30 this.services = b.build();
34 public String getNetconfSessionIdForReporting() {
35 return netconfSessionIdForReporting;
39 public Set<NetconfOperationService> getServices() {
44 public void close() throws Exception {
45 CloseableUtil.closeAll(services);
49 public String toString() {
50 return "NetconfOperationServiceSnapshotImpl{" + netconfSessionIdForReporting + '}';