Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2014-11-07 09:30:30 +0000
committerMarkus Tiede2014-11-07 09:30:36 +0000
commit3283016fbf627be5019c988562a94fe14df6f66d (patch)
tree358a7fdf8e82efa7e70a1d820844d1a2354705a2 /org.eclipse.jubula.client.api
parent9574693786500dfcd507a35d8a997f6945132263 (diff)
downloadorg.eclipse.jubula.core-3283016fbf627be5019c988562a94fe14df6f66d.tar.gz
org.eclipse.jubula.core-3283016fbf627be5019c988562a94fe14df6f66d.tar.xz
org.eclipse.jubula.core-3283016fbf627be5019c988562a94fe14df6f66d.zip
Non-sprint task - implement error handling in case of remote connection / termination problems.
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java3
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java59
2 files changed, 62 insertions, 0 deletions
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
index f014ccc97..499c78b8e 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/AUTConnection.java
@@ -13,6 +13,7 @@ package org.eclipse.jubula.client.internal;
import java.util.Map;
import org.eclipse.jubula.client.internal.exceptions.ConnectionException;
+import org.eclipse.jubula.client.internal.impl.AUTAgentImpl.ErrorListener;
import org.eclipse.jubula.communication.internal.message.ConnectToAutMessage;
import org.eclipse.jubula.communication.internal.message.SendAUTListOfSupportedComponentsMessage;
import org.eclipse.jubula.tools.internal.constants.EnvConstants;
@@ -101,6 +102,8 @@ public class AUTConnection extends BaseAUTConnection {
try {
LOGGER.info("Establishing connection to AUT..."); //$NON-NLS-1$
run();
+ getCommunicator().addCommunicationErrorListener(
+ new ErrorListener(Thread.currentThread()));
final AutAgentConnection autAgent = AutAgentConnection
.getInstance();
autAgent.getCommunicator().send(
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
index 17b7a233b..5fe82df0d 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/AUTAgentImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.jubula.client.internal.impl;
import java.net.ConnectException;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -30,7 +31,9 @@ import org.eclipse.jubula.client.internal.Synchronizer;
import org.eclipse.jubula.client.internal.exceptions.ConnectionException;
import org.eclipse.jubula.client.launch.AUTConfiguration;
import org.eclipse.jubula.communication.internal.Communicator;
+import org.eclipse.jubula.communication.internal.listener.ICommunicationErrorListener;
import org.eclipse.jubula.communication.internal.message.GetRegisteredAutListMessage;
+import org.eclipse.jubula.communication.internal.message.Message;
import org.eclipse.jubula.communication.internal.message.StartAUTServerMessage;
import org.eclipse.jubula.communication.internal.message.StopAUTServerMessage;
import org.eclipse.jubula.toolkit.ToolkitInfo;
@@ -46,6 +49,59 @@ import org.slf4j.LoggerFactory;
/** @author BREDEX GmbH */
public class AUTAgentImpl implements AUTAgent {
+ /** @author BREDEX GmbH */
+ public static class ErrorListener implements ICommunicationErrorListener {
+ /** the logger */
+ private static Logger logger = LoggerFactory.getLogger(
+ ErrorListener.class);
+
+ /** the thread */
+ private Thread m_thread;
+
+ /**
+ * Constructor
+ *
+ * @param thread
+ * the thread to interrupt on communication problems
+ */
+ public ErrorListener(Thread thread) {
+ m_thread = thread;
+ }
+
+ /** {@inheritDoc} */
+ public void connectionGained(InetAddress inetAddress, int port) {
+ // currently empty
+ }
+
+ /** {@inheritDoc} */
+ public void shutDown() {
+ logger.debug("shutdown() called. Interrupting thread: " //$NON-NLS-1$
+ + m_thread.getName());
+ m_thread.interrupt();
+ }
+
+ /** {@inheritDoc} */
+ public void sendFailed(Message message) {
+ logger.error("sendFailed() called. Interrupting thread: " //$NON-NLS-1$
+ + m_thread.getName());
+ m_thread.interrupt();
+ }
+
+ /** {@inheritDoc} */
+ public void acceptingFailed(int port) {
+ logger.error("acceptingFailed() called. Interrupting thread: " //$NON-NLS-1$
+ + m_thread.getName());
+ m_thread.interrupt();
+ }
+
+ /** {@inheritDoc} */
+ public void connectingFailed(InetAddress inetAddress, int port) {
+ logger.error("connectingFailed() called. Interrupting thread: " //$NON-NLS-1$
+ + m_thread.getName());
+ m_thread.interrupt();
+ }
+ }
+
/** the logger */
private static Logger log = LoggerFactory.getLogger(AUTAgentImpl.class);
/** the hosts name */
@@ -77,6 +133,9 @@ public class AUTAgentImpl implements AUTAgent {
try {
AutAgentConnection.createInstance(m_hostname, m_port);
m_agent = AutAgentConnection.getInstance();
+ m_agent.getCommunicator()
+ .addCommunicationErrorListener(new ErrorListener(
+ Thread.currentThread()));
m_agent.run();
if (!isConnected()) {
throw new CommunicationException(

Back to the top