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.client;
11 import org.opendaylight.controller.netconf.api.NetconfMessage;
12 import org.opendaylight.controller.netconf.util.xml.XmlElement;
13 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
16 * Class extending {@link NetconfClientSessionListener} to provide notification capability.
18 public abstract class AbstractNetconfClientNotifySessionListener extends SimpleNetconfClientSessionListener {
20 * Maybe some capabilities could be expressed as internal NetconfClientSessionListener handlers.
21 * It would enable NetconfClient functionality to be extended by using namespace handlers.
22 * So far let just enable notification capability by extending and let parent class intact.
26 * As class purpose is to provide notification capability to session listener
27 * onMessage method is not allowed to be further overridden.
28 * {@see #onNotification(NetconfClientSession, NetconfMessage)}
30 * @param session {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
31 * @param message {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
34 public final void onMessage(NetconfClientSession session, NetconfMessage message) {
35 if (isNotification(message)) {
36 onNotification(session, message);
38 super.onMessage(session, message);
43 * Method intended to customize notification processing.
45 * @param session {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
46 * @param message {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
48 public abstract void onNotification(NetconfClientSession session, NetconfMessage message);
50 private boolean isNotification(NetconfMessage message) {
51 XmlElement xmle = XmlElement.fromDomDocument(message.getDocument());
52 return XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME.equals(xmle.getName()) ;