- private NetconfClientDispatcher createDispatcher(long clientConnectionTimeoutMillis) {
- EventLoopGroup bossGroup = getBossThreadGroupDependency();
- EventLoopGroup workerGroup = getWorkerThreadGroupDependency();
- if(getTcpOnly()) {
- return new NetconfClientDispatcher( bossGroup, workerGroup, clientConnectionTimeoutMillis);
+ public void setBundleContext(final BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public NetconfReconnectingClientConfiguration getClientConfig(final NetconfDeviceCommunicator listener) {
+ final InetSocketAddress socketAddress = getSocketAddress();
+ final ReconnectStrategy strategy = getReconnectStrategy();
+ final long clientConnectionTimeoutMillis = getConnectionTimeoutMillis();
+
+ return NetconfReconnectingClientConfigurationBuilder.create()
+ .withAddress(socketAddress)
+ .withConnectionTimeoutMillis(clientConnectionTimeoutMillis)
+ .withReconnectStrategy(strategy)
+ .withSessionListener(listener)
+ .withAuthHandler(new LoginPassword(getUsername(),getPassword()))
+ .withProtocol(getTcpOnly() ?
+ NetconfClientConfiguration.NetconfClientProtocol.TCP :
+ NetconfClientConfiguration.NetconfClientProtocol.SSH)
+ .withConnectStrategyFactory(new ReconnectStrategyFactory() {
+ @Override
+ public ReconnectStrategy createReconnectStrategy() {
+ return getReconnectStrategy();
+ }
+ })
+ .build();
+ }
+
+ private ReconnectStrategy getReconnectStrategy() {
+ final Long connectionAttempts;
+ if (getMaxConnectionAttempts() != null && getMaxConnectionAttempts() > 0) {
+ connectionAttempts = getMaxConnectionAttempts();