X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fmapping%2Foperations%2FDefaultStopExi.java;h=2a24ae32fa0cad9bef292cd53cc8718424692b7c;hp=d841a6619eab5bc285f4a23eabd3a4b9d9ea43bd;hb=25a9fb7730311a5ca298d8c6c8b24f0afb0e27be;hpb=dad78e1fc8a7c67fa4b88cf09d6a952443462feb diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java index d841a6619e..2a24ae32fa 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java @@ -7,26 +7,21 @@ */ package org.opendaylight.controller.netconf.impl.mapping.operations; -import org.opendaylight.controller.netconf.api.NetconfSession; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfOperationRouter; -import org.opendaylight.controller.netconf.impl.mapping.ExiDecoderHandler; -import org.opendaylight.controller.netconf.impl.mapping.ExiEncoderHandler; -import org.opendaylight.controller.netconf.mapping.api.DefaultNetconfOperation; -import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; -import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation; +import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; +import org.opendaylight.controller.netconf.impl.NetconfServerSession; +import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation; import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -public class DefaultStopExi extends AbstractNetconfOperation implements DefaultNetconfOperation { +public class DefaultStopExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation { public static final String STOP_EXI = "stop-exi"; - private NetconfSession netconfSession; + private NetconfServerSession netconfSession; private static final Logger logger = LoggerFactory .getLogger(DefaultStartExi.class); @@ -36,38 +31,28 @@ public class DefaultStopExi extends AbstractNetconfOperation implements DefaultN } @Override - protected HandlingPriority canHandle(String operationName, - String netconfOperationNamespace) { - if (operationName.equals(STOP_EXI) == false) - return HandlingPriority.CANNOT_HANDLE; - if (netconfOperationNamespace - .equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false) - return HandlingPriority.CANNOT_HANDLE; + protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException { + logger.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement)); - return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY; - } - - @Override - protected Element handle(Document document, XmlElement operationElement, - NetconfOperationRouter opRouter) throws NetconfDocumentedException { + netconfSession.stopExiCommunication(); - netconfSession.remove(ExiDecoderHandler.class); - netconfSession.removeAfterMessageSent(ExiEncoderHandler.HANDLER_NAME); - - Element getSchemaResult = document.createElement(XmlNetconfConstants.OK); - XmlUtil.addNamespaceAttr(getSchemaResult, - XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK); logger.trace("{} operation successful", STOP_EXI); - logger.debug("received stop-exi message {} ", XmlUtil.toString(document)); return getSchemaResult; } @Override - public void setNetconfSession(NetconfSession s) { - this.netconfSession = s; + protected String getOperationName() { + return STOP_EXI; } - public NetconfSession getNetconfSession() { - return netconfSession; + @Override + protected String getOperationNamespace() { + return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0; + } + + @Override + public void setNetconfSession(NetconfServerSession s) { + this.netconfSession = s; } -} \ No newline at end of file +}