*/
package org.opendaylight.netconf.server;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.monitoring.SessionListener;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.server.osgi.NetconfOperationRouter;
+import org.opendaylight.netconf.server.osgi.NetconfOperationRouterImpl;
import org.opendaylight.netconf.util.messages.SubtreeFilter;
import org.opendaylight.yangtools.yang.common.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.ErrorTag;
private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionListener.class);
private final SessionListener monitoringSessionListener;
- private final NetconfOperationRouter operationRouter;
+ private final NetconfOperationRouterImpl operationRouter;
private final AutoCloseable onSessionDownCloseable;
- public NetconfServerSessionListener(final NetconfOperationRouter operationRouter,
- final NetconfMonitoringService monitoringService,
- final AutoCloseable onSessionDownCloseable) {
- this.operationRouter = operationRouter;
+ NetconfServerSessionListener(final NetconfOperationRouterImpl operationRouter,
+ final NetconfMonitoringService monitoringService, final AutoCloseable onSessionDownCloseable) {
+ this.operationRouter = requireNonNull(operationRouter);
monitoringSessionListener = monitoringService.getSessionListener();
this.onSessionDownCloseable = onSessionDownCloseable;
}
import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator;
import org.opendaylight.netconf.nettyutil.NetconfSessionNegotiatorFactory;
-import org.opendaylight.netconf.server.osgi.NetconfOperationRouter;
import org.opendaylight.netconf.server.osgi.NetconfOperationRouterImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
private NetconfServerSessionListener getListener(final String netconfSessionIdForReporting,
final SocketAddress socketAddress) {
- final NetconfOperationService service = getOperationServiceForAddress(netconfSessionIdForReporting,
- socketAddress);
- final NetconfOperationRouter operationRouter =
- new NetconfOperationRouterImpl(service, monitoringService, netconfSessionIdForReporting);
- return new NetconfServerSessionListener(operationRouter, monitoringService, service);
+ final var service = getOperationServiceForAddress(netconfSessionIdForReporting, socketAddress);
+ return new NetconfServerSessionListener(
+ new NetconfOperationRouterImpl(service, monitoringService, netconfSessionIdForReporting), monitoringService,
+ service);
}
protected NetconfOperationService getOperationServiceForAddress(final String netconfSessionIdForReporting,
import org.opendaylight.netconf.server.NetconfServerSession;
import org.w3c.dom.Document;
-public interface NetconfOperationRouter extends AutoCloseable {
+public interface NetconfOperationRouter {
Document onNetconfMessage(Document message, NetconfServerSession session) throws DocumentedException;
}
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
-public class NetconfOperationRouterImpl implements NetconfOperationRouter {
+// Non-final for testing
+public class NetconfOperationRouterImpl implements NetconfOperationRouter, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetconfOperationRouterImpl.class);
private final NetconfOperationService netconfOperationServiceSnapshot;
private final Collection<NetconfOperation> allNetconfOperations;
public NetconfOperationRouterImpl(final NetconfOperationService netconfOperationServiceSnapshot,
- final NetconfMonitoringService netconfMonitoringService, final String sessionId) {
+ final NetconfMonitoringService netconfMonitoringService, final String sessionId) {
this.netconfOperationServiceSnapshot = requireNonNull(netconfOperationServiceSnapshot);
final Set<NetconfOperation> ops = new HashSet<>();
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
- public Document onNetconfMessage(final Document message, final NetconfServerSession session) throws
- DocumentedException {
+ public Document onNetconfMessage(final Document message, final NetconfServerSession session)
+ throws DocumentedException {
requireNonNull(allNetconfOperations, "Operation router was not initialized properly");
final NetconfOperationExecution netconfOperationExecution;
import org.opendaylight.netconf.api.monitoring.SessionEvent;
import org.opendaylight.netconf.api.monitoring.SessionListener;
import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.server.osgi.NetconfOperationRouter;
+import org.opendaylight.netconf.server.osgi.NetconfOperationRouterImpl;
import org.w3c.dom.Document;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class NetconfServerSessionListenerTest {
@Mock
- private NetconfOperationRouter router;
+ private NetconfOperationRouterImpl router;
@Mock
private NetconfMonitoringService monitoring;
@Mock