Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-11-09 06:03:28 -0500
committerTobias Schwarz2012-11-09 06:03:28 -0500
commit6535aaec17b30ef774bc430900e902a4930eeb1d (patch)
tree6445e1b4ecfdf43eff3249e63df16b522b4211df /target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core
parent43c76cddca331f5cf3bd3aff837c1c9a6299b2dc (diff)
downloadorg.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.tar.gz
org.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.tar.xz
org.eclipse.tcf-6535aaec17b30ef774bc430900e902a4930eeb1d.zip
[Target Explorer] automatically import and export remote debugger launch
config when peer is imported/exported
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java67
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java74
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java26
6 files changed, 156 insertions, 48 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
index 273a48cc5..c1c711f54 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/META-INF/MANIFEST.MF
@@ -29,6 +29,7 @@ Export-Package: org.eclipse.tcf.te.tcf.launch.core.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.launch.core.filetransfer,
org.eclipse.tcf.te.tcf.launch.core.interfaces,
org.eclipse.tcf.te.tcf.launch.core.internal.adapters;x-internal:=true,
+ org.eclipse.tcf.te.tcf.launch.core.internal.services,
org.eclipse.tcf.te.tcf.launch.core.lm.delegates,
org.eclipse.tcf.te.tcf.launch.core.nls;x-internal:=true,
org.eclipse.tcf.te.tcf.launch.core.steps,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
index 4fda2ac58..783b383b4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml
@@ -17,6 +17,20 @@
</factory>
</extension>
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ id="org.eclipse.tcf.te.tcf.launch.services.persistence.import"
+ class="org.eclipse.tcf.te.tcf.launch.core.internal.services.ImportPersistenceService">
+ <serviceType class="org.eclipse.tcf.te.tcf.core.interfaces.IImportPersistenceService"/>
+ </service>
+ <service
+ id="org.eclipse.tcf.te.tcf.launch.services.persistence.export"
+ class="org.eclipse.tcf.te.tcf.launch.core.internal.services.ExportPersistenceService">
+ <serviceType class="org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService"/>
+ </service>
+ </extension>
+
<!-- Launch Configuration Type contributions -->
<extension point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java
deleted file mode 100644
index 8814fd406..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/interfaces/IPeerModelProperties.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 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.launch.core.interfaces;
-
-
-/**
- * Default set of custom peer properties.
- */
-public interface IPeerModelProperties {
-
- /**
- * Property: The peers launch configuration "Template" for new attach launch.
- */
- public static final String PROP_LAUNCH_CONFIG_ATTRIBUTES = "LaunchConfigAttributes"; //$NON-NLS-1$
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java
new file mode 100644
index 000000000..ea67e28fa
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ExportPersistenceService.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.launch.core.internal.services;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.services.URIPersistenceService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+
+/**
+ * Persistence service implementation for import/export.
+ */
+public class ExportPersistenceService extends URIPersistenceService implements IExportPersistenceService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public void write(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (context instanceof IPeerModel) {
+ final IPeerModel node = (IPeerModel)context;
+ ILaunchConfiguration launchConfig = (ILaunchConfiguration)Platform.getAdapterManager().getAdapter(node, ILaunchConfiguration.class);
+ if (launchConfig != null) {
+ IPersistenceDelegate launchDelegate = PersistenceManager.getInstance().getDelegate(launchConfig, String.class);
+ if (launchDelegate != null) {
+ final String launchConfigString = (String)launchDelegate.write(launchConfig, String.class);
+ Map<String,String> attrs = new HashMap<String, String>(node.getPeer().getAttributes());
+ attrs.put(ILaunchTypes.ATTACH, launchConfigString);
+ delegate.write(new TransientPeer(attrs), uri);
+ return;
+ }
+ }
+ }
+
+ // Pass on to the delegate for writing
+ delegate.write(context, uri);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java
new file mode 100644
index 000000000..9f096d99f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/services/ImportPersistenceService.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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.launch.core.internal.services;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.services.URIPersistenceService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IExportPersistenceService;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes;
+
+/**
+ * Persistence service implementation for import/export.
+ */
+public class ImportPersistenceService extends URIPersistenceService implements IExportPersistenceService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService#write(java.lang.Object, java.net.URI)
+ */
+ @Override
+ public void write(Object context, URI uri) throws IOException {
+ Assert.isNotNull(context);
+
+ uri = uri != null ? uri : getURI(context);
+
+ // Determine the persistence delegate
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(context, uri);
+ // If the persistence delegate could not be determined, throw an IOException
+ if (delegate == null) {
+ throw new IOException("The persistence delegate for context '" + context.getClass().getName() + "' cannot be determined."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (context instanceof IPeer) {
+ final String launchConfigString = ((IPeer)context).getAttributes().get(ILaunchTypes.ATTACH);
+ if (launchConfigString != null && launchConfigString.trim().length() > 0) {
+ IPersistenceDelegate launchDelegate = PersistenceManager.getInstance().getDelegate(ILaunchConfigurationWorkingCopy.class, launchConfigString);
+ if (launchDelegate != null) {
+ Map<String,String> attrs = new HashMap<String, String>(((IPeer)context).getAttributes());
+ attrs.remove(ILaunchTypes.ATTACH);
+ IPeer peer = new TransientPeer(attrs);
+ delegate.write(peer, uri);
+
+ try {
+ ILaunchConfigurationWorkingCopy config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(ILaunchTypes.ATTACH).newInstance(null, peer.getName());
+ config = (ILaunchConfigurationWorkingCopy)launchDelegate.read(config, launchConfigString);
+ config.doSave();
+ }
+ catch (Exception e) {
+ }
+ return;
+ }
+ }
+ }
+
+ // Pass on to the delegate for writing
+ delegate.write(context, uri);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
index 49ede291e..72043a891 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/AttachLaunchManagerDelegate.java
@@ -13,25 +13,18 @@ package org.eclipse.tcf.te.tcf.launch.core.lm.delegates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.tcf.internal.debug.launch.TCFLaunchDelegate;
import org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ICommonLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.selection.interfaces.IRemoteSelectionContext;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
import org.eclipse.tcf.te.tcf.launch.core.interfaces.IAttachLaunchAttributes;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
/**
* RemoteAppLaunchManagerDelegate
@@ -106,25 +99,6 @@ public class AttachLaunchManagerDelegate extends DefaultLaunchManagerDelegate {
LaunchContextsPersistenceDelegate.setLaunchContexts(launchSpec, launchContexts.toArray(new IModelNode[launchContexts.size()]));
}
- if (remoteCtx instanceof IPeerModel) {
- String launchConfigAttributes = ((IPeerModel)remoteCtx).getPeer().getAttributes().get(IPeerModelProperties.PROP_LAUNCH_CONFIG_ATTRIBUTES);
- if (launchConfigAttributes != null) {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(Map.class, launchConfigAttributes, false);
- try {
- Map<String, String> attributes = delegate != null ? (Map<String,String>)delegate.read(Map.class, launchConfigAttributes, null) : null;
- if (attributes != null) {
- attributes.remove(ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS);
- attributes.remove(ICommonLaunchAttributes.ATTR_UUID);
- attributes.remove(ICommonLaunchAttributes.ATTR_LAST_LAUNCHED);
- for (Entry<String, String> entry : attributes.entrySet()) {
- launchSpec.addAttribute(entry.getKey(), entry.getValue(), true);
- }
- }
- }
- catch (Exception e) { /* ignored on purpose */ }
- }
- }
-
launchSpec.setLaunchConfigName(getDefaultLaunchName(launchSpec));
}

Back to the top