<groupId>${project.groupId}</groupId>
<artifactId>netconf-ssh</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<reference id="netconfServerDispatcher" interface="org.opendaylight.netconf.api.NetconfServerDispatcher"/>
<reference id="globalWorkerGroup" interface="io.netty.channel.EventLoopGroup" odl:type="global-worker-group"/>
- <reference id="executor" interface="io.netty.util.concurrent.EventExecutor" odl:type="global-event-executor"/>
<reference id="authProvider" interface="org.opendaylight.netconf.auth.AuthProvider" odl:type="netconf-auth-provider"/>
+ <reference id="executor" interface="io.netty.util.concurrent.EventExecutor" odl:type="global-event-executor">
+ <reference-listener ref="netconfMdsalServer" unbind-method="unbind"/>
+ </reference>
+
<!-- NETCONF server for MD-SAL (listening by default on port 2830)-->
<cm:property-placeholder persistent-id="org.opendaylight.netconf.ssh" update-strategy="none">
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
+import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
localServer.cancel(true);
}
}
+
+ /*
+ * Called when the underlying reference to EventExecutor is about to be removed from the container allowing
+ * us to close the ssh server while it still exists.
+ */
+ public void unbind(final ServiceReference<?> reference) {
+ LOG.debug("EventExecutor is being removed, closing netconf ssh server. {}", reference);
+
+ try {
+ close();
+ } catch (final IOException e) {
+ LOG.error("Closing of ssh server failed while unbinding reference listener.", e);
+ }
+ }
}