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
22 netconfNotificationRegistry) {
23 this.netconfOperations = Collections.singleton(new CreateSubscription(netconfSessionIdForReporting,
24 netconfNotificationRegistry));
29 public Set<NetconfOperation> getNetconfOperations() {
30 return netconfOperations;
33 @SuppressWarnings("checkstyle:IllegalCatch")
36 for (NetconfOperation netconfOperation : netconfOperations) {
37 if (netconfOperation instanceof AutoCloseable) {
39 ((AutoCloseable) netconfOperation).close();
40 } catch (Exception e) {
41 throw new IllegalStateException("Exception while closing " + netconfOperation, e);