2 * Copyright (c) 2016 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
8 package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
14 import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
15 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
16 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
19 * {@link NotificationListenerAdapter} is responsible to track events on notifications.
21 public final class NotificationListenerAdapter extends AbstractNotificationListenerAdaptor {
22 private final Absolute path;
25 * Set path of listener and stream name.
27 * @param path Schema path of YANG notification.
28 * @param streamName Name of the stream.
29 * @param outputType Type of output on notification (JSON or XML).
31 NotificationListenerAdapter(final Absolute path, final String streamName, final NotificationOutputType outputType) {
32 super(path.lastNodeIdentifier(), streamName, outputType);
33 this.path = requireNonNull(path);
37 EffectiveModelContext effectiveModel() {
38 return databindProvider.currentContext().modelContext();
42 * Get schema path of notification.
44 * @return The configured schema path that points to observing YANG notification schema node.
46 public Absolute getSchemaPath() {
50 public synchronized void listen(final DOMNotificationService notificationService) {
52 setRegistration(notificationService.registerNotificationListener(this, getSchemaPath()));
57 ToStringHelper addToStringAttributes(final ToStringHelper helper) {
58 return super.addToStringAttributes(helper.add("path", path));