Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java71
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java60
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/AttachPathMapsListenerStep.java141
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java138
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/RemoveExternalPathMapsStep.java41
9 files changed, 430 insertions, 34 deletions
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
index acdc8a653..f0c97d927 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFLaunch.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2015 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -47,6 +48,7 @@ import org.eclipse.tcf.services.IDPrintf;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.services.IFileSystem.IFileHandle;
+import org.eclipse.tcf.services.IPathMap.PathMapRule;
import org.eclipse.tcf.services.IMemory;
import org.eclipse.tcf.services.IMemoryMap;
import org.eclipse.tcf.services.IPathMap;
@@ -243,6 +245,54 @@ public class TCFLaunch extends Launch {
public void contextException(String context, String msg) {
}
};
+
+ /**
+ * This PathMapListener applies the shared path map rules set by other clients in the same channel.
+ */
+ private final IPathMap.PathMapListener path_map_listener = new IPathMap.PathMapListener() {
+ @Override
+ public void changed() {
+ IPathMap path_map_service = getService(IPathMap.class);
+ if (path_map_service != null) {
+ path_map_service.get(new IPathMap.DoneGet() {
+ @Override
+ public void doneGet(IToken token, Exception error, PathMapRule[] map) {
+ if (map != null) {
+ if (host_path_map == null) {
+ host_path_map = new ArrayList<IPathMap.PathMapRule>();
+ }
+
+ // Remove old path map rules
+ List<IPathMap.PathMapRule> new_rules = Arrays.asList(map);
+ for (IPathMap.PathMapRule rule:host_path_map) {
+ if (!new_rules.contains(rule)) {
+ host_path_map.remove(rule);
+ }
+ }
+
+ // Look for new shared path map rules
+ List<IPathMap.PathMapRule> diff_rules = new ArrayList<IPathMap.PathMapRule>();
+ for (IPathMap.PathMapRule rule:map) {
+ if (Boolean.parseBoolean((String)rule.getProperties().get("Shared")) &&
+ !host_path_map.contains(rule) &&
+ !diff_rules.contains(rule)) {
+ diff_rules.add(rule);
+ }
+ }
+ if (diff_rules.size() > 0) {
+ host_path_map.addAll(diff_rules);
+ applyPathMap(channel, diff_rules.toArray(new IPathMap.PathMapRule[0]), new IPathMap.DoneSet() {
+ public void doneSet(IToken token, Exception error) {
+ if (error != null) channel.terminate(error);
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ }
+ };
private static LaunchListener[] getListeners() {
if (listeners_array != null) return listeners_array;
@@ -1525,6 +1575,7 @@ public class TCFLaunch extends Launch {
public void onChannelOpened() {
try {
peer_name = getPeerName(getPeer());
+ attachPathMapListener();
onConnected();
}
catch (Throwable x) {
@@ -1537,9 +1588,9 @@ public class TCFLaunch extends Launch {
public void onChannelClosed(Throwable error) {
channel.removeChannelListener(this);
+ detachPathMapListener();
onDisconnected(error);
}
-
});
assert channel.getState() == IChannel.STATE_OPENING;
if (launch_monitor != null) launch_monitor.subTask("Connecting to " + peer_name);
@@ -1774,4 +1825,20 @@ public class TCFLaunch extends Launch {
public Set<String> getContextFilter() {
return context_filter;
}
+
+ private void attachPathMapListener() {
+ IPathMap path_map_service = getService(IPathMap.class);
+ if (path_map_service != null) {
+ path_map_service.addListener(path_map_listener);
+ }
+ }
+
+ private void detachPathMapListener() {
+ if (path_map_listener != null) {
+ IPathMap path_map_service = getService(IPathMap.class);
+ if (path_map_service != null) {
+ path_map_service.removeListener(path_map_listener);
+ }
+ }
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties
index 2334fb16a..1ae91632c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.properties
@@ -31,3 +31,4 @@ InitializeLoggingStep.name=Initialize channel communication logging
ApplyPatMapsStep.name=Apply path map to channel
CloseChannelStep.name=Close channel
ShutdownValueAddStep.name=Shutdown value-add
+AttachPathMapsListenerStep.name=Attach path maps listener
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml
index 6a4632f2f..bdcd81469 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/plugin.xml
@@ -77,6 +77,11 @@
id="org.eclipse.tcf.te.tcf.core.channelmanager.calculateLogNameStep"
class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.CalculateLogNameStep"
label="%CalculateLogNameStep.name"/>
+
+ <step
+ id="org.eclipse.tcf.te.tcf.core.channelmanager.attachPathMapsListenerStep"
+ class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.AttachPathMapsListenerStep"
+ label="%AttachPathMapsListenerStep.name"/>
</extension>
<!-- Step contributions -->
@@ -88,6 +93,7 @@
<reference id="org.eclipse.tcf.te.tcf.core.channelmanager.chainPeersStepGroup"/>
<reference id="org.eclipse.tcf.te.tcf.core.channelmanager.initializeLoggingStep"/>
<reference id="org.eclipse.tcf.te.tcf.core.channelmanager.applyPathMapsStep"/>
+ <reference id="org.eclipse.tcf.te.tcf.core.channelmanager.attachPathMapsListenerStep"/>
</references>
</stepGroup>
<stepGroup id="org.eclipse.tcf.te.tcf.core.channelmanager.launchValueAddsStepGroup"
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
index 03c0a5ae2..3a40768c5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPathMapService.java
@@ -71,6 +71,42 @@ public interface IPathMapService extends IService {
public IPathMap.PathMapRule addPathMap(Object context, String source, String destination);
/**
+ * Adds new path mapping rules to the configured (object) path mapping for the
+ * given context.
+ * <p>
+ * The method will check the path mappings if path map rules given already exist. If
+ * this is the case, the method will do nothing for them and it will add just the
+ * new ones.
+ *
+ * <p>
+ * The method auto applies the new path maps to an possibly open shared channel.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
+ *
+ * @param context
+ * @param rules
+ */
+ public void addPathMap(Object context, IPathMap.PathMapRule[] rules);
+
+ /**
+ * Adds new shared path mapping rules to the configured (object) path mapping for the
+ * given context.
+ * <p>
+ * The method will check the path mappings if path map rules given already exist. If
+ * this is the case, the method will do nothing for them and it will add just the
+ * new ones.
+ *
+ * <p>
+ * The method auto applies the new path map to an possibly open shared channel.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
+ *
+ * @param context
+ * @param rules
+ */
+ public void addSharedPathMapRules(Object context, IPathMap.PathMapRule[] rules);
+
+ /**
* Removes the given path mapping rule from the configured (object) path mappings
* for the given context.
* <p>
@@ -84,6 +120,30 @@ public interface IPathMapService extends IService {
public void removePathMap(Object context, IPathMap.PathMapRule rule);
/**
+ * Removes the given path mapping rules from the configured (object) path mappings
+ * for the given context.
+ * <p>
+ * The method auto applies the new path maps to an possibly open shared channel.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
+ *
+ * @param context
+ * @param rules
+ */
+ public void removePathMap(Object context, IPathMap.PathMapRule[] rules);
+
+ /**
+ * Removes all the shared path map rules for the given context.
+ * <p>
+ * The method auto applies the new path map to an possibly open shared channel.
+ * <p>
+ * <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
+ *
+ * @param context
+ */
+ public void cleanSharedPathMapRules(Object context);
+
+ /**
* Apply the configured (object) path mappings to the given context.
* <p>
* <b>Note:</b> This method must be called from outside the TCF event dispatch thread.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/AttachPathMapsListenerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/AttachPathMapsListenerStep.java
new file mode 100644
index 000000000..f1f617a90
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/AttachPathMapsListenerStep.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IPathMap;
+import org.eclipse.tcf.services.IPathMap.PathMapRule;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService;
+import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes;
+import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep;
+
+public class AttachPathMapsListenerStep extends AbstractPeerStep {
+ public String PATH_MAP_PROP_SHARED = "Shared"; //$NON-NLS-1$
+
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(fullQualifiedId);
+ Assert.isNotNull(monitor);
+
+ IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ if (channel == null || channel.getState() != IChannel.STATE_OPEN) {
+ throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Channel to target not available or closed.")); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
+ Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(fullQualifiedId);
+ Assert.isNotNull(monitor);
+ Assert.isNotNull(callback);
+
+ final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data);
+ Assert.isNotNull(channel);
+ final IPeer peer = getActivePeerContext(context, data, fullQualifiedId);
+ Assert.isNotNull(peer);
+
+ if (IChannel.STATE_OPEN == channel.getState()) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ final IPathMap svc = channel.getRemoteService(IPathMap.class);
+ if (svc != null) {
+ svc.addListener(new IPathMap.PathMapListener() {
+ @Override
+ public void changed() {
+ svc.get(new IPathMap.DoneGet() {
+ @Override
+ public void doneGet(IToken token, Exception error, final PathMapRule[] map) {
+ Thread th = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class);
+ if (service != null) {
+ List<PathMapRule> existingRules = Arrays.asList(service.getPathMap(peer));
+ List<PathMapRule> newRules = Arrays.asList(map);
+ List<PathMapRule> diffRules = new ArrayList<IPathMap.PathMapRule>();
+
+ // Remove old shared path maps
+ for (PathMapRule rule:existingRules) {
+ if (!existsPathMapRuleInList(rule, newRules) &&
+ !diffRules.contains(rule)) {
+ diffRules.add(rule);
+ }
+ }
+
+ if (diffRules.size() > 0) {
+ service.removePathMap(peer, diffRules.toArray(new IPathMap.PathMapRule[0]));
+ diffRules.clear();
+ }
+
+ // Add new shared path maps
+ for (PathMapRule rule:newRules) {
+ if (Boolean.parseBoolean((String)rule.getProperties().get(PATH_MAP_PROP_SHARED )) &&
+ !existsPathMapRuleInList(rule, existingRules) &&
+ !diffRules.contains(rule)) {
+ diffRules.add(rule);
+ }
+ }
+
+ if (diffRules.size() > 0) {
+ service.addSharedPathMapRules(peer, diffRules.toArray(new IPathMap.PathMapRule[0]));
+ diffRules.clear();
+ }
+ }
+ }
+ });
+ th.start();
+ }
+ });
+
+ }
+ });
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+ }
+ };
+ Protocol.invokeLater(runnable);
+ }
+ }
+
+ protected boolean existsPathMapRuleInList(PathMapRule rule, List<PathMapRule> rules) {
+ for (PathMapRule r:rules) {
+ if (r.getSource().equals(rule.getSource()) &&
+ r.getDestination().equals(rule.getDestination())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
index 46bb5e56e..17a0974ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/PathMapService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2014 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2016 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -63,6 +63,9 @@ public class PathMapService extends AbstractService implements IPathMapService {
// Lock to handle multi thread access
private final Lock lock = new ReentrantLock();
+ // Contains a list of the shared Path Map rules for each context
+ private final Map<String, List<IPathMap.PathMapRule>> sharedPathMapRules = new HashMap<String, List<IPathMap.PathMapRule>>();
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#generateSourcePathMappings(java.lang.Object)
*/
@@ -206,17 +209,39 @@ public class PathMapService extends AbstractService implements IPathMapService {
return rules;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#addPathMap(java.lang.Object, java.lang.String, java.lang.String)
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#addSharedPathMapRules(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule[])
*/
- @Override
- public PathMapRule addPathMap(Object context, String source, String destination) {
- Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ @Override
+ public void addSharedPathMapRules(Object context, PathMapRule[] rules) {
+ Assert.isNotNull(context);
+ Assert.isNotNull(rules);
+
+ if (context instanceof IPeer) {
+ List<IPathMap.PathMapRule> rulesToAdd = new ArrayList<IPathMap.PathMapRule>();
+ for (PathMapRule rule:rules) {
+ Map<String, Object> props = new LinkedHashMap<String, Object>();
+ props.put(IPathMap.PROP_SOURCE, rule.getSource());
+ props.put(IPathMap.PROP_DESTINATION, rule.getDestination());
+ rulesToAdd.add(new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props));
+ }
+ sharedPathMapRules.put(((IPeer)context).getID(), rulesToAdd);
+ addPathMap(context, rules);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#addPathMap(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule[])
+ */
+ @Override
+ public void addPathMap(Object context, IPathMap.PathMapRule[] rules) {
+ Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(context);
- Assert.isNotNull(source);
- Assert.isNotNull(destination);
+ Assert.isNotNull(rules);
- PathMapRule rule = null;
+ List<PathMapRule> rulesWithoutMatching = new ArrayList<PathMapRule>();
try {
// Acquire the lock before accessing the path mappings
@@ -234,20 +259,27 @@ public class PathMapService extends AbstractService implements IPathMapService {
populatePathMapRulesList(config, rulesList);
// Find an existing path map rule for the given source and destination
- for (PathMapRule candidate : rulesList) {
- if (source.equals(candidate.getSource()) && destination.equals(candidate.getDestination())) {
- rule = candidate;
- break;
+ for (PathMapRule r:rules) {
+ PathMapRule matchingRule = null;
+ for (PathMapRule candidate : rulesList) {
+ if (r.getSource().equals(candidate.getSource()) && r.getDestination().equals(candidate.getDestination())) {
+ matchingRule = candidate;
+ break;
+ }
+ }
+ if (matchingRule == null) {
+ rulesWithoutMatching.add(r);
}
}
- // If not matching path map rule exist, create a new one
- if (rule == null) {
- Map<String, Object> props = new LinkedHashMap<String, Object>();
- props.put(IPathMap.PROP_SOURCE, source);
- props.put(IPathMap.PROP_DESTINATION, destination);
- rule = new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props);
- rulesList.add(rule);
+ // Add new path map rules
+ if (rulesWithoutMatching.size() > 0) {
+ for (PathMapRule rule:rulesWithoutMatching) {
+ Map<String, Object> props = new LinkedHashMap<String, Object>();
+ props.put(IPathMap.PROP_SOURCE, rule.getSource());
+ props.put(IPathMap.PROP_DESTINATION, rule.getDestination());
+ rulesList.add(new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props));
+ }
// Update the launch configuration
updateLaunchConfiguration(config, rulesList);
@@ -267,18 +299,32 @@ public class PathMapService extends AbstractService implements IPathMapService {
// Release the lock
lock.unlock();
}
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#addPathMap(java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public PathMapRule addPathMap(Object context, String source, String destination) {
+ Map<String, Object> props = new LinkedHashMap<String, Object>();
+ props.put(IPathMap.PROP_SOURCE, source);
+ props.put(IPathMap.PROP_DESTINATION, destination);
+ org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule rule = new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props);
+
+ addPathMap(context, new PathMapRule[] {rule});
return rule;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#removePathMap(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule)
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#removePathMap(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule[])
*/
- @Override
- public void removePathMap(final Object context, final PathMapRule rule) {
- Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ @Override
+ public void removePathMap(Object context, IPathMap.PathMapRule[] rules) {
+ Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(context);
- Assert.isNotNull(rule);
+ Assert.isNotNull(rules);
try {
// Acquire the lock before accessing the path mappings
@@ -297,15 +343,18 @@ public class PathMapService extends AbstractService implements IPathMapService {
// If the original rule has an ID set, create a copy of the rule
// but without the ID property
- PathMapRule r = rule;
- if (r.getID() != null) {
- Map<String, Object> props = new HashMap<String, Object>(r.getProperties());
- props.remove(IPathMap.PROP_ID);
- r = new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props);
+ List<PathMapRule> rulesToRemove = new ArrayList<PathMapRule>();
+ for (PathMapRule rule:rules) {
+ if (rule.getID() != null) {
+ Map<String, Object> props = new HashMap<String, Object>(rule.getProperties());
+ props.remove(IPathMap.PROP_ID);
+ rule = new org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate.PathMapRule(props);
+ }
+ rulesToRemove.add(rule);
}
// Remove the given rule from the list of present
- if (rulesList.remove(r)) {
+ if (rulesList.removeAll(rulesToRemove)) {
// Update the launch configuration
updateLaunchConfiguration(config, rulesList);
@@ -324,8 +373,33 @@ public class PathMapService extends AbstractService implements IPathMapService {
// Release the lock
lock.unlock();
}
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#removePathMap(java.lang.Object, org.eclipse.tcf.services.IPathMap.PathMapRule)
+ */
+ @Override
+ public void removePathMap(final Object context, final PathMapRule rule) {
+ removePathMap(context, new PathMapRule[]{rule});
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService#cleanSharedPathMapRules()
+ */
+ @Override
+ public void cleanSharedPathMapRules(Object context) {
+ Assert.isNotNull(context);
+
+ if (context instanceof IPeer) {
+ List<PathMapRule> pathMapRulesToRemove = sharedPathMapRules.get(((IPeer)context).getID());
+ if (pathMapRulesToRemove != null) {
+ removePathMap(context, pathMapRulesToRemove.toArray(new IPathMap.PathMapRule[0]));
+ }
+ sharedPathMapRules.remove(((IPeer)context).getID());
+ }
+ }
+
/**
* Populate the given path map rules list from the given launch configuration.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
index 610a623bb..6729be252 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.properties
@@ -21,3 +21,4 @@ StartDebuggerStep.name=Start Debugger
StopDebuggerStep.name=Stop Debugger
WaitForReadyStep.name=Wait until peer becomes ready
SetAsDefaultContextStep.name=Set peer as default context
+RemoveExternalPathMapsStep.name=Remove external Path Map rules
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index 86f4daf5d..772570e69 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -210,6 +210,10 @@
id="org.eclipse.tcf.te.tcf.locator.startPingTimerStep"
class="org.eclipse.tcf.te.tcf.locator.steps.StartPingTimerStep"
label="%StartPingTimerStep.name"/>
+ <step
+ id="org.eclipse.tcf.te.tcf.locator.removeExternalPathMapsStep"
+ class="org.eclipse.tcf.te.tcf.locator.steps.RemoveExternalPathMapsStep"
+ label="%RemoveExternalPathMapsStep.name"/>
</extension>
<!-- Step group contributions -->
@@ -253,6 +257,7 @@
<reference id="org.eclipse.tcf.te.tcf.locator.stopDebuggerStep"/>
<reference id="org.eclipse.tcf.te.tcf.core.shutDownStep"/>
<reference id="org.eclipse.tcf.te.tcf.locator.stopSimulatorStep"/>
+ <reference id="org.eclipse.tcf.te.tcf.locator.removeExternalPathMapsStep"/>
<reference id="org.eclipse.tcf.te.core.setConnectStateStep" secondaryId="disconnected">
<parameter name="state" value="disconnected"/>
</reference>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/RemoveExternalPathMapsStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/RemoveExternalPathMapsStep.java
new file mode 100644
index 000000000..08749a3c5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/RemoveExternalPathMapsStep.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2016 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.locator.steps;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService;
+
+public class RemoveExternalPathMapsStep extends AbstractPeerNodeStep {
+
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+
+ @Override
+ public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
+ Assert.isNotNull(context);
+ Assert.isNotNull(data);
+ Assert.isNotNull(fullQualifiedId);
+
+ final IPeer peer = getActivePeerContext(context, data, fullQualifiedId);
+ final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class);
+ service.cleanSharedPathMapRules(peer);
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+}

Back to the top