2 * Copyright (c) 2015 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.netconf.test.tool;
11 import io.netty.util.Timer;
12 import java.net.SocketAddress;
13 import java.util.HashMap;
16 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
17 import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
18 import org.opendaylight.netconf.impl.SessionIdProvider;
19 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
20 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
22 public class TesttoolNegotiationFactory extends NetconfServerSessionNegotiatorFactory {
24 private final Map<SocketAddress, NetconfOperationService> cachedOperationServices = new HashMap<>();
26 public TesttoolNegotiationFactory(final Timer timer, final NetconfOperationServiceFactory netconfOperationProvider,
27 final SessionIdProvider idProvider, final long connectionTimeoutMillis,
28 final NetconfMonitoringService monitoringService) {
29 super(timer, netconfOperationProvider, idProvider, connectionTimeoutMillis, monitoringService);
32 public TesttoolNegotiationFactory(final Timer timer, final NetconfOperationServiceFactory netconfOperationProvider,
33 final SessionIdProvider idProvider, final long connectionTimeoutMillis,
34 final NetconfMonitoringService monitoringService, final Set<String> baseCapabilities) {
35 super(timer, netconfOperationProvider, idProvider, connectionTimeoutMillis, monitoringService, baseCapabilities);
39 protected NetconfOperationService getOperationServiceForAddress(final String netconfSessionIdForReporting, final SocketAddress socketAddress) {
40 if (cachedOperationServices.containsKey(socketAddress)) {
41 return cachedOperationServices.get(socketAddress);
43 final NetconfOperationService service = getOperationServiceFactory().createService(netconfSessionIdForReporting);
44 cachedOperationServices.put(socketAddress, service);