2 * Copyright (c) 2015 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.netconf.mdsal.notification;
11 import java.util.Collections;
13 import org.opendaylight.netconf.mapping.api.NetconfOperation;
14 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
15 import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
16 import org.opendaylight.netconf.notifications.impl.ops.CreateSubscription;
18 public class NetconfNotificationOperationService implements NetconfOperationService {
19 private final Set<NetconfOperation> netconfOperations;
21 public NetconfNotificationOperationService(String netconfSessionIdForReporting, NetconfNotificationRegistry netconfNotificationRegistry) {
22 this.netconfOperations = Collections.singleton(new CreateSubscription(netconfSessionIdForReporting, netconfNotificationRegistry));
27 public Set<NetconfOperation> getNetconfOperations() {
28 return netconfOperations;
33 for (NetconfOperation netconfOperation : netconfOperations) {
34 if (netconfOperation instanceof AutoCloseable) {
36 ((AutoCloseable) netconfOperation).close();
37 } catch (Exception e) {
38 throw new IllegalStateException("Exception while closing " + netconfOperation, e);