2 * Copyright (c) 2014 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
8 package org.opendaylight.netconf.client.conf;
10 import java.net.InetSocketAddress;
11 import java.util.List;
12 import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
13 import org.opendaylight.netconf.client.NetconfClientSessionListener;
14 import org.opendaylight.netconf.client.SslHandlerFactory;
15 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
16 import org.opendaylight.protocol.framework.ReconnectStrategy;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
19 public class NetconfClientConfigurationBuilder {
21 public static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000;
22 public static final NetconfClientConfiguration.NetconfClientProtocol DEFAULT_CLIENT_PROTOCOL =
23 NetconfClientConfiguration.NetconfClientProtocol.TCP;
25 private InetSocketAddress address;
26 private long connectionTimeoutMillis = DEFAULT_CONNECTION_TIMEOUT_MILLIS;
27 private NetconfHelloMessageAdditionalHeader additionalHeader;
28 private NetconfClientSessionListener sessionListener;
29 private ReconnectStrategy reconnectStrategy;
30 private AuthenticationHandler authHandler;
31 private NetconfClientConfiguration.NetconfClientProtocol clientProtocol = DEFAULT_CLIENT_PROTOCOL;
32 private SslHandlerFactory sslHandlerFactory;
33 private List<Uri> odlHelloCapabilities;
36 protected NetconfClientConfigurationBuilder() {
39 public static NetconfClientConfigurationBuilder create() {
40 return new NetconfClientConfigurationBuilder();
43 @SuppressWarnings("checkstyle:hiddenField")
44 public NetconfClientConfigurationBuilder withAddress(final InetSocketAddress address) {
45 this.address = address;
49 @SuppressWarnings("checkstyle:hiddenField")
50 public NetconfClientConfigurationBuilder withConnectionTimeoutMillis(final long connectionTimeoutMillis) {
51 this.connectionTimeoutMillis = connectionTimeoutMillis;
55 @SuppressWarnings("checkstyle:hiddenField")
56 public NetconfClientConfigurationBuilder withProtocol(
57 final NetconfClientConfiguration.NetconfClientProtocol clientProtocol) {
58 this.clientProtocol = clientProtocol;
62 @SuppressWarnings("checkstyle:hiddenField")
63 public NetconfClientConfigurationBuilder withAdditionalHeader(
64 final NetconfHelloMessageAdditionalHeader additionalHeader) {
65 this.additionalHeader = additionalHeader;
69 @SuppressWarnings("checkstyle:hiddenField")
70 public NetconfClientConfigurationBuilder withSessionListener(final NetconfClientSessionListener sessionListener) {
71 this.sessionListener = sessionListener;
75 @SuppressWarnings("checkstyle:hiddenField")
76 public NetconfClientConfigurationBuilder withReconnectStrategy(final ReconnectStrategy reconnectStrategy) {
77 this.reconnectStrategy = reconnectStrategy;
81 @SuppressWarnings("checkstyle:hiddenField")
82 public NetconfClientConfigurationBuilder withAuthHandler(final AuthenticationHandler authHandler) {
83 this.authHandler = authHandler;
87 @SuppressWarnings("checkstyle:hiddenField")
88 public NetconfClientConfigurationBuilder withSslHandlerFactory(final SslHandlerFactory sslHandlerFactory) {
89 this.sslHandlerFactory = sslHandlerFactory;
93 @SuppressWarnings("checkstyle:hiddenField")
94 public NetconfClientConfigurationBuilder withOdlHelloCapabilities(final List<Uri> odlHelloCapabilities) {
95 this.odlHelloCapabilities = odlHelloCapabilities;
99 final InetSocketAddress getAddress() {
103 final long getConnectionTimeoutMillis() {
104 return connectionTimeoutMillis;
107 final NetconfHelloMessageAdditionalHeader getAdditionalHeader() {
108 return additionalHeader;
111 final NetconfClientSessionListener getSessionListener() {
112 return sessionListener;
115 final ReconnectStrategy getReconnectStrategy() {
116 return reconnectStrategy;
119 final AuthenticationHandler getAuthHandler() {
123 final NetconfClientConfiguration.NetconfClientProtocol getProtocol() {
124 return clientProtocol;
127 final SslHandlerFactory getSslHandlerFactory() {
128 return sslHandlerFactory;
131 final List<Uri> getOdlHelloCapabilities() {
132 return odlHelloCapabilities;
135 public NetconfClientConfiguration build() {
136 return new NetconfClientConfiguration(clientProtocol, address, connectionTimeoutMillis, additionalHeader,
137 sessionListener, reconnectStrategy, authHandler, sslHandlerFactory, odlHelloCapabilities);