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%2FDefaultCloseSession.java;h=303352c9c557f111cabde8866e4376698cb96190;hp=8c7465b02961197e4a1bc5c836d10d00c0441be5;hb=f9a9cd1ea40d2477ccb16b03c71a87595226595a;hpb=ee0877c07ff700157dd9fc2e445df095c88f79bc diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java index 8c7465b029..303352c9c5 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCloseSession.java @@ -9,18 +9,26 @@ package org.opendaylight.controller.netconf.impl.mapping.operations; import com.google.common.base.Optional; +import com.google.common.base.Preconditions; import java.util.Collections; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; 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.XmlUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -public class DefaultCloseSession extends AbstractSingletonNetconfOperation { +public class DefaultCloseSession extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation { + private static final Logger LOG = LoggerFactory.getLogger(DefaultCloseSession.class); + public static final String CLOSE_SESSION = "close-session"; + private final AutoCloseable sessionResources; + private NetconfServerSession session; public DefaultCloseSession(String netconfSessionIdForReporting, AutoCloseable sessionResources) { super(netconfSessionIdForReporting); @@ -42,6 +50,8 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation { throws NetconfDocumentedException { try { sessionResources.close(); + Preconditions.checkNotNull(session, "Session was not set").delayedClose(); + LOG.info("Session {} closing", session.getSessionId()); } catch (Exception e) { throw new NetconfDocumentedException("Unable to properly close session " + getNetconfSessionIdForReporting(), NetconfDocumentedException.ErrorType.application, @@ -51,4 +61,9 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation { } return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent()); } + + @Override + public void setNetconfSession(final NetconfServerSession s) { + this.session = s; + } }