Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-01-07 08:36:14 -0500
committerTobias Schwarz2014-01-07 08:36:14 -0500
commitfa7aae748bd022ee902a2132468410737d23814e (patch)
tree08fa87fa468a8e883e0f6b9057c35a91e30e8177 /target_explorer
parent21dabe663f8d826044d76be2d1fa8f26c21606fd (diff)
downloadorg.eclipse.tcf-fa7aae748bd022ee902a2132468410737d23814e.tar.gz
org.eclipse.tcf-fa7aae748bd022ee902a2132468410737d23814e.tar.xz
org.eclipse.tcf-fa7aae748bd022ee902a2132468410737d23814e.zip
Target Explorer: add channel listener to disconnect when channel is
closed
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java16
3 files changed, 34 insertions, 9 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java
index 04315119e..6885ac4a6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java
@@ -9,6 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.locator.interfaces.nodes;
+import org.eclipse.tcf.protocol.IChannel.IChannelListener;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.core.interfaces.IDecoratable;
@@ -21,7 +22,7 @@ import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
* <p>
* <b>Note:</b> Read and write access to the peer model must happen within the TCF dispatch thread.
*/
-public interface IPeerNode extends IContainerModelNode, IDecoratable, IConnectable {
+public interface IPeerNode extends IContainerModelNode, IDecoratable, IConnectable, IChannelListener {
/**
* Returns the parent locator model instance.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
index 4484e34bb..e10e3f74f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
@@ -426,4 +426,28 @@ public class PeerNode extends ContainerModelNode implements IPeerNode, IPeerNode
}
return false;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#onChannelOpened()
+ */
+ @Override
+ public void onChannelOpened() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#onChannelClosed(java.lang.Throwable)
+ */
+ @Override
+ public void onChannelClosed(Throwable error) {
+ if (isConnectStateChangeActionAllowed(IConnectable.ACTION_DISCONNECT)) {
+ changeConnectState(IConnectable.ACTION_DISCONNECT, null, null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#congestionLevel(int)
+ */
+ @Override
+ public void congestionLevel(int level) {
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
index 8530a59a0..d9d8ad03a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
@@ -33,6 +33,7 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
import org.eclipse.tcf.te.tcf.locator.nls.Messages;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
/**
* WaitForReadyStep
@@ -62,13 +63,16 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
if (peerNode != null && !Boolean.getBoolean("WaitForReadyStep.skip")) { //$NON-NLS-1$
Protocol.invokeLater(new Runnable() {
final Runnable thisRunnable = this;
- int refreshCount = 0;
+ // set repeat count to 1 if real target is used
+ int totalWork = getTotalWork(context, data);
+ SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId));
+ int refreshCount = result != null ? 0 : totalWork-1;
@Override
public void run() {
if (ProgressHelper.isCancel(WaitForReadyStep.this, monitor, callback)) {
return;
}
- else if (refreshCount >= getTotalWork(context, data)) {
+ else if (refreshCount >= totalWork) {
@SuppressWarnings("synthetic-access")
String message = NLS.bind(Messages.WaitForReadyStep_error_timeout, getActivePeerContext(context, data, fullQualifiedId).getName());
callback(data, fullQualifiedId, callback, StatusHelper.getStatus(new TimeoutException(message)), null);
@@ -88,9 +92,6 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
status = Status.OK_STATUS;
}
- // Close the channel right away
-// if (channel != null) Tcf.getChannelManager().closeChannel(channel);
-
// If we have an OK status, we are done
if (status != null && status.isOK()) {
// Get the local service
@@ -98,9 +99,6 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
// Get the remote services
List<String> remoteServices = new ArrayList<String>(channel.getRemoteServices());
- // Close the channel
- Tcf.getChannelManager().closeChannel(channel);
-
// Sort the service lists
Collections.sort(localServices);
Collections.sort(remoteServices);
@@ -109,6 +107,8 @@ public class WaitForReadyStep extends AbstractPeerNodeStep {
IPeerModelUpdateService updateService = peerNode.getModel().getService(IPeerModelUpdateService.class);
updateService.updatePeerServices(peerNode, localServices, remoteServices);
+ channel.addChannelListener(peerNode);
+
callback(data, fullQualifiedId, callback, status, null);
return;
}

Back to the top