Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-04-17 08:03:33 -0400
committerUwe Stieber2013-04-17 08:03:33 -0400
commitc311eab9167b0f11561c654b7f03832125596b69 (patch)
tree3b855a8242e5e317f3cd2b639756b1758d238a24 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parentb9b1be06adb5d5e7cdc8c41ff5754fab156962c0 (diff)
downloadorg.eclipse.tcf-c311eab9167b0f11561c654b7f03832125596b69.tar.gz
org.eclipse.tcf-c311eab9167b0f11561c654b7f03832125596b69.tar.xz
org.eclipse.tcf-c311eab9167b0f11561c654b7f03832125596b69.zip
Target Explorer: Disconnect a connection via the stepper service if needed on shutdown
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java56
1 files changed, 55 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
index 61f27ee0d..3d4c3e93b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
@@ -17,8 +17,18 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.core.async.AsyncCallbackCollector;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
+import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts;
import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
@@ -91,9 +101,53 @@ public class UIPlugin extends AbstractUIPlugin {
if (proceedShutdown || forced) {
// Terminate the scanner
- ILocatorModel model = Model.getModel(true);
+ final ILocatorModel model = Model.getModel(true);
if (model != null) model.getScanner().terminate();
+ // Disconnect all connected connections via the stepper service
+ if (model != null) {
+ final AsyncCallbackCollector collector = new AsyncCallbackCollector();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Get all peer model objects
+ IPeerModel[] peers = model.getPeers();
+ // Loop them and check if disconnect is available
+ for (IPeerModel peerModel : peers) {
+ IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class);
+ if (service != null) {
+ String stepGroupId = service.getStepGroupId(peerModel, IStepperService.OPERATION_DISCONNECT);
+ IStepContext stepContext = service.getStepContext(peerModel, IStepperService.OPERATION_DISCONNECT);
+ String name = service.getStepGroupName(peerModel, IStepperService.OPERATION_DISCONNECT);
+ boolean isEnabled = service.isEnabled(peerModel, IStepperService.OPERATION_DISCONNECT);
+
+ if (isEnabled && stepGroupId != null && stepContext != null) {
+ IPropertiesContainer data = new PropertiesContainer();
+ StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
+ stepContext,
+ data,
+ stepGroupId,
+ IStepperService.OPERATION_DISCONNECT);
+
+ ICallback callback = new AsyncCallbackCollector.SimpleCollectorCallback(collector);
+ job.setJobCallback(callback);
+
+ job.schedule();
+ }
+ }
+ }
+
+ collector.initDone();
+ }
+ };
+
+ Assert.isTrue(!Protocol.isDispatchThread());
+ Protocol.invokeAndWait(runnable);
+
+ ExecutorsUtil.waitAndExecute(0, collector.getConditionTester());
+ }
+
// Close all channels now
Tcf.getChannelManager().closeAll(!Protocol.isDispatchThread());
}

Back to the top