From 0c8e1910386c860e997ea148c8fa06f2d9cbb8a3 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Mon, 6 Jan 2014 20:53:59 +0100 Subject: [PATCH] Added constructor which allows for custom NetconfClientSessionListener Change-Id: I95c1f59a704c91cb1c06c1765935612fc13bc890 Signed-off-by: Tony Tkacik --- .../controller/netconf/client/NetconfClient.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java index 2ce779a1f5..8b8c886a1c 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java @@ -71,6 +71,10 @@ public class NetconfClient implements Closeable { return new NetconfClient(clientLabelForLogging,address,strat,netconfClientDispatcher); } + public static NetconfClient clientFor(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strat, NetconfClientDispatcher netconfClientDispatcher,NetconfClientSessionListener listener) throws InterruptedException { + return new NetconfClient(clientLabelForLogging,address,strat,netconfClientDispatcher,listener); + } + public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException { this(clientLabelForLogging, address, @@ -83,6 +87,17 @@ public class NetconfClient implements Closeable { DEFAULT_CONNECT_TIMEOUT), netconfClientDispatcher); } + public NetconfClient(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strat, + NetconfClientDispatcher netconfClientDispatcher, NetconfClientSessionListener listener) throws InterruptedException{ + this.label = clientLabelForLogging; + dispatch = netconfClientDispatcher; + sessionListener = listener; + Future clientFuture = dispatch.createClient(address, sessionListener, strat); + this.address = address; + clientSession = get(clientFuture); + this.sessionId = clientSession.getSessionId(); + } + public NetconfMessage sendMessage(NetconfMessage message) { return sendMessage(message, 5, 1000); } @@ -90,6 +105,7 @@ public class NetconfClient implements Closeable { public NetconfMessage sendMessage(NetconfMessage message, int attempts, int attemptMsDelay) { long startTime = System.currentTimeMillis(); Preconditions.checkState(clientSession.isUp(), "Session was not up yet"); + //logger.debug("Sending message: {}",XmlUtil.toString(message.getDocument())); clientSession.sendMessage(message); try { return sessionListener.getLastMessage(attempts, attemptMsDelay); -- 2.36.6