Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-06-12 10:17:20 +0000
committerUwe Stieber2014-06-12 10:17:20 +0000
commitace29dbdea46bb91d8bef2f3dd145110a788f18b (patch)
tree0386fc7fbdd773babdfc7d939895676619a77f72
parent2bace60b015cb7dc35caa255a84abd89f87773c2 (diff)
downloadorg.eclipse.tcf-ace29dbdea46bb91d8bef2f3dd145110a788f18b.tar.gz
org.eclipse.tcf-ace29dbdea46bb91d8bef2f3dd145110a788f18b.tar.xz
org.eclipse.tcf-ace29dbdea46bb91d8bef2f3dd145110a788f18b.zip
Target Explorer: Add support to connect to targets via proxies to the channel manager (part 1)
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPeerProperties.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java170
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/persistence/PeerDataHelper.java65
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerNodeDataHelper.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerDataHelper.java)45
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java8
10 files changed, 266 insertions, 71 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPeerProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPeerProperties.java
new file mode 100644
index 000000000..7852e3bf1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IPeerProperties.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.interfaces;
+
+import org.eclipse.tcf.te.tcf.core.util.persistence.PeerDataHelper;
+
+/**
+ * Custom peer property IDs.
+ */
+public interface IPeerProperties {
+
+ /**
+ * Property: The list of proxies to use to connect to the target.
+ * The value of this property is of type <code>String</code> and
+ * must be decoded using {@link PeerDataHelper#decodePeerList(String)}.
+ */
+ public static final String PROP_PROXIES = "Proxies"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
index 3b9b45956..ffa0b25dc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/ChannelManager.java
@@ -37,9 +37,11 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.core.interfaces.IPathMapService;
+import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties;
import org.eclipse.tcf.te.tcf.core.interfaces.tracing.ITraceIds;
import org.eclipse.tcf.te.tcf.core.nls.Messages;
import org.eclipse.tcf.te.tcf.core.peers.Peer;
+import org.eclipse.tcf.te.tcf.core.util.persistence.PeerDataHelper;
import org.eclipse.tcf.te.tcf.core.va.ValueAddManager;
import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd;
@@ -903,6 +905,19 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
}
/**
+ * Client call back interface for doChainProxies(...).
+ */
+ interface DoneChainProxies {
+ /**
+ * Called when a proxies has been chained.
+ *
+ * @param error The error description if operation failed, <code>null</code> if succeeded.
+ * @param channel The channel object or <code>null</code>.
+ */
+ void doneChainProxies(Throwable error, IChannel channel);
+ }
+
+ /**
* Chain the value-adds until the original target peer is reached.
*
* @param valueAdds The list of value-add's to chain. Must not be <code>null</code>.
@@ -931,6 +946,8 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
// If noValueAdd == true or noPathMap == true -> forceNew has to be true as well
if (noValueAdd || noPathMap) forceNew = true;
+ final boolean finForceNew = forceNew;
+
// Check if there is already a channel opened to this peer
IChannel channel = !forceNew ? channels.get(id) : null;
if (channel != null && (channel.getState() == IChannel.STATE_OPEN || channel.getState() == IChannel.STATE_OPENING)) {
@@ -975,20 +992,35 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
}
// No existing channel -> open a new one
- final DoneChainValueAdd innerDone = new DoneChainValueAdd() {
+ final DoneChainValueAdd chainValueAddDone = new DoneChainValueAdd() {
@Override
- public void doneChainValueAdd(Throwable error, IChannel channel) {
- done.doneOpenChannel(error, channel);
+ public void doneChainValueAdd(final Throwable error, final IChannel channel) {
+ // Ending up here means that the channel is redirected to the last
+ // value-add in the chain, but it is not yet redirected through the
+ // proxy configuration.
+ String proxyConfiguration = peer.getAttributes().get(IPeerProperties.PROP_PROXIES);
+ IPeer[] proxies = proxyConfiguration != null ? PeerDataHelper.decodePeerList(proxyConfiguration) : null;
+
+ // Create the done callback
+ final DoneChainProxies chainProxiesDone = new DoneChainProxies() {
+ @Override
+ public void doneChainProxies(final Throwable error, final IChannel channel) {
+ // Invoke the outer callback
+ done.doneOpenChannel(error, channel);
+ }
+ };
+
+ // Continue the redirect chain by chaining the proxies and connecting to the target
+ doChainProxies(id, peer.getAttributes(), proxies, finForceNew, valueAdds.length, channel, chainProxiesDone);
}
};
- doChainValueAdd(id, peer.getAttributes(), forceNew, valueAdds, innerDone);
+ doChainValueAdd(id, forceNew, valueAdds, chainValueAddDone);
}
- /* default */ void doChainValueAdd(final String id, final Map<String, String> attrs, final boolean forceNew, final IValueAdd[] valueAdds, final DoneChainValueAdd done) {
+ /* default */ void doChainValueAdd(final String id, final boolean forceNew, final IValueAdd[] valueAdds, final DoneChainValueAdd done) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(id);
- Assert.isNotNull(attrs);
Assert.isNotNull(valueAdds);
Assert.isNotNull(done);
@@ -1028,13 +1060,13 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
if (!forceNew) refCounters.put(id, new AtomicInteger(1));
if (forceNew) forcedChannels.add(channel);
- // Attach the channel listener to catch open/closed events
+ // Create and attach the channel listener to catch open/closed events
final IChannel finChannel = channel;
- channel.addChannelListener(new IChannel.IChannelListener() {
+ final IChannel.IChannelListener finChannelListener = new IChannel.IChannelListener() {
@Override
public void onChannelOpened() {
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) {
- CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_valueAdd_redirect_succeeded,
+ CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_redirect_succeeded,
new Object[] { valueAddPeer.get().getID(), finChannel.getRemotePeer().getID(), Integer.valueOf(index.get()) }),
0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
}
@@ -1077,7 +1109,15 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
}
// Redirect the channel to the next value-add in chain
- finChannel.redirect(nextValueAddPeer.get() != null ? nextValueAddPeer.get().getAttributes() : attrs);
+ if (nextValueAddPeer.get() != null) {
+ finChannel.redirect(nextValueAddPeer.get().getAttributes());
+ } else {
+ // Remove ourself as channel listener
+ finChannel.removeChannelListener(this);
+
+ // No other value-add in the chain -> all done
+ done.doneChainValueAdd(null, finChannel);
+ }
}
}
@@ -1087,7 +1127,7 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
finChannel.removeChannelListener(this);
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) {
- CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_valueAdd_redirect_failed, valueAddPeer.get().getID(),
+ CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_redirect_failed, valueAddPeer.get().getID(),
nextValueAddPeer.get() != null ? nextValueAddPeer.get().getID() : id),
0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
}
@@ -1097,18 +1137,27 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
if (!forceNew) refCounters.remove(id);
if (forceNew) forcedChannels.remove(finChannel);
- // Channel opening failed -> This will break everything
+ // Channel redirect failed -> This will break everything
done.doneChainValueAdd(error, finChannel);
}
@Override
public void congestionLevel(int level) {
}
- });
+ };
+ channel.addChannelListener(finChannelListener);
// Redirect the channel to the next value-add in chain
// Note: If the redirect succeeds, channel.getRemotePeer().getID() will be identical to id.
- channel.redirect(nextValueAddPeer.get() != null ? nextValueAddPeer.get().getAttributes() : attrs);
+ if (nextValueAddPeer.get() != null) {
+ channel.redirect(nextValueAddPeer.get().getAttributes());
+ } else {
+ // Remove ourself as channel listener
+ finChannel.removeChannelListener(finChannelListener);
+
+ // No other value-add in the chain -> all done
+ done.doneChainValueAdd(null, finChannel);
+ }
} else {
// Channel is null? Something went terrible wrong.
done.doneChainValueAdd(new Exception("Unexpected null return value from IPeer#openChannel()!"), null); //$NON-NLS-1$
@@ -1125,6 +1174,99 @@ public final class ChannelManager extends PlatformObject implements IChannelMana
}
}
+ /* default */ void doChainProxies(final String id, final Map<String, String> attrs, final IPeer[] proxies, final boolean forceNew, final int numberOfValueAdds, final IChannel channel, final DoneChainProxies done) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(id);
+ Assert.isNotNull(attrs);
+ Assert.isNotNull(channel);
+ Assert.isNotNull(done);
+
+ // The index of the currently processed proxy
+ final AtomicInteger index = new AtomicInteger(0);
+
+ // Get the proxy to chain
+ final AtomicReference<IPeer> proxy = new AtomicReference<IPeer>();
+ proxy.set(proxies != null && proxies.length > 0 ? proxies[index.get()] : null);
+ // Get the next proxy in chain
+ final AtomicReference<IPeer> nextProxy = new AtomicReference<IPeer>();
+ nextProxy.set(proxies != null && index.get() + 1 < proxies.length ? proxies[index.get() + 1] : null);
+
+ // The channel must be in open or opening state, otherwise we cannot do the redirect
+ if (channel.getState() == IChannel.STATE_CLOSED) {
+ done.doneChainProxies(new Exception(NLS.bind(Messages.ChannelManager_openChannel_redirect_invalidChannelState, id)), channel);
+ return;
+ }
+
+ // Determine the ID of the last value-add in the chain
+ final String lastValueAddID = channel.getRemotePeer().getID();
+
+ // Create and attach the channel listener
+ channel.addChannelListener(new IChannel.IChannelListener() {
+ @Override
+ public void onChannelOpened() {
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) {
+ CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_redirect_succeeded,
+ new Object[] { lastValueAddID, channel.getRemotePeer().getID(), Integer.valueOf(numberOfValueAdds + index.get()) }),
+ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
+ }
+
+ // Channel redirect succeeded. Check if we are done.
+ if (nextProxy.get() == null) {
+ // Remove ourself as channel listener
+ channel.removeChannelListener(this);
+
+ // No other proxy is in the chain -> reached the target -> all done
+ done.doneChainProxies(null, channel);
+ } else {
+ // Process the next proxy in chain
+ index.incrementAndGet();
+
+ // Update the proxy reference
+ proxy.set(nextProxy.get());
+
+ // Determine the next proxy to redirect too
+ nextProxy.set(index.get() + 1 < proxies.length ? proxies[index.get() + 1] : null);
+
+ // Redirect the channel to the next proxy in chain, if available, or directly to the target
+ // if no more proxies are configured
+ channel.redirect(nextProxy.get() != null ? nextProxy.get().getAttributes() : attrs);
+ }
+
+ // Remove ourself as channel listener
+ channel.removeChannelListener(this);
+
+ // Invoke the done callback
+ done.doneChainProxies(null, channel);
+ }
+
+ @Override
+ public void onChannelClosed(Throwable error) {
+ // Remove ourself as channel listener
+ channel.removeChannelListener(this);
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) {
+ CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_redirect_failed, lastValueAddID, id),
+ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
+ }
+
+ // Clean the reference counter and the channel map
+ if (forceNew) channels.remove(id);
+ if (forceNew) refCounters.remove(id);
+ if (forceNew) forcedChannels.remove(channel);
+
+ // Channel redirect failed -> This will break everything
+ done.doneChainProxies(error, channel);
+ }
+
+ @Override
+ public void congestionLevel(int level) {
+ }
+ });
+
+ // If there is no proxy configured, directly redirect to the target
+ channel.redirect(proxy.get() != null ? proxy.get().getAttributes() : attrs);
+ }
+
/**
* Private stream listener proxy implementation.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java
index 2f0a7b418..3e738ea6d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java
@@ -83,8 +83,9 @@ public class Messages extends NLS {
public static String ChannelManager_openChannel_valueAdd_isAlive;
public static String ChannelManager_openChannel_valueAdd_launch;
public static String ChannelManager_openChannel_valueAdd_startChaining;
- public static String ChannelManager_openChannel_valueAdd_redirect_succeeded;
- public static String ChannelManager_openChannel_valueAdd_redirect_failed;
+ public static String ChannelManager_openChannel_redirect_succeeded;
+ public static String ChannelManager_openChannel_redirect_failed;
+ public static String ChannelManager_openChannel_redirect_invalidChannelState;
public static String ChannelManager_createPeer_new_message;
public static String ChannelManager_closeChannel_message;
public static String ChannelManager_closeChannel_inuse_message;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties
index 381ac934e..11fcc50a4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties
@@ -24,8 +24,9 @@ ChannelManager_openChannel_valueAdd_numApplicable={0} applicable value-add contr
ChannelManager_openChannel_valueAdd_isAlive=Value-add #{0} ({1}): isAlive = {2}. Target id = {3}
ChannelManager_openChannel_valueAdd_launch=Value-add #{0} ({1}): launch {2} (error = ''{3}''). Target id = {4}
ChannelManager_openChannel_valueAdd_startChaining=Start chaining of value-add's. Target id = {0}
-ChannelManager_openChannel_valueAdd_redirect_succeeded=Successfully redirected channel from {0} to {1}. Redirect Level = {2}
-ChannelManager_openChannel_valueAdd_redirect_failed=Failed to redirect channel from {0} to {1}.
+ChannelManager_openChannel_redirect_succeeded=Successfully redirected channel from {0} to {1}. Redirect Level = {2}
+ChannelManager_openChannel_redirect_failed=Failed to redirect channel from {0} to {1}.
+ChannelManager_openChannel_redirect_invalidChannelState=Channel not in open state. Cannot redirect channel to {1}.
ChannelManager_createPeer_new_message=New target created. Target id = {0}, isTransient = {1}
ChannelManager_closeChannel_message=Request to close channel. Target id = {0}
ChannelManager_closeChannel_inuse_message=Channel not closed. Still in use. Target id = {0}, new reference count = {1}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/persistence/PeerDataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/persistence/PeerDataHelper.java
new file mode 100644
index 000000000..2421e9d1f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/util/persistence/PeerDataHelper.java
@@ -0,0 +1,65 @@
+/**
+ * PeerDataHelper.java
+ * Created on Jun 12, 2014
+ *
+ * Copyright (c) 2014 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.core.util.persistence;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+
+/**
+ * Data helper for encoding or decoding a peer list.
+ */
+public class PeerDataHelper {
+
+ /**
+ * Encode an array of peers to a string.
+ * @param contexts The array of peers.
+ * @return String representing the array of peers.
+ */
+ public static final String encodePeerList(IPeer[] contexts) {
+ try {
+ if (contexts != null && contexts.length > 0) {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
+ return (String)delegate.writeList(contexts, String.class);
+ }
+ }
+ catch (Exception e) {
+ }
+ return null;
+ }
+
+ /**
+ * Decode a string encoded array of peers.
+ * @param encoded The string encoded peers.
+ * @return Array of peers.
+ */
+ public static final IPeer[] decodePeerList(String encoded) {
+ try {
+ if (encoded != null && encoded.trim().length() > 0) {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
+ Object[] input = delegate.readList(IPeer.class, encoded);
+ List<IPeer> peers = new ArrayList<IPeer>();
+ for (Object object : input) {
+ if (object instanceof IPeer) {
+ peers.add((IPeer)object);
+ }
+ }
+ return peers.toArray(new IPeer[peers.size()]);
+ }
+ }
+ catch (Exception e) {
+ }
+ return new IPeer[0];
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java
index 41c0ed4b9..932fb7236 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java
@@ -11,6 +11,7 @@ package org.eclipse.tcf.te.tcf.locator.interfaces.nodes;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties;
/**
* Default set of peer node properties.
@@ -44,9 +45,10 @@ public interface IPeerNodeProperties {
public static final String PROP_PEER_ID = "PeerId"; //$NON-NLS-1$
/**
- * Property: List of proxies to use to connect to the target. (List<Map<String, String>>).
+ * Property: List of proxies to use to connect to the target.
+ * @see IPeerProperties#PROP_PROXIES
*/
- public static final String PROP_PROXIES = "Proxies"; //$NON-NLS-1$
+ public static final String PROP_PROXIES = IPeerProperties.PROP_PROXIES;
/**
* Property: Ping interval.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerDataHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerNodeDataHelper.java
index 549998994..82bc32836 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerDataHelper.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/PeerNodeDataHelper.java
@@ -1,5 +1,5 @@
/**
- * PeerDataHelper.java
+ * PeerNodeDataHelper.java
* Created on Aug 21, 2013
*
* Copyright (c) 2013, 2014 Wind River Systems, Inc.
@@ -21,7 +21,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Data helper for de/encoding .
*/
-public class PeerDataHelper {
+public class PeerNodeDataHelper {
/**
* Encode an array of peer nodes to a string.
@@ -63,45 +63,4 @@ public class PeerDataHelper {
}
return new IPeerNode[0];
}
-
- /**
- * Encode an array of peers to a string.
- * @param contexts The array of peers.
- * @return String representing the array of peers.
- */
- public static final String encodePeerList(IPeer[] contexts) {
- try {
- if (contexts != null && contexts.length > 0) {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
- return (String)delegate.writeList(contexts, String.class);
- }
- }
- catch (Exception e) {
- }
- return null;
- }
-
- /**
- * Decode a string encoded array of peers.
- * @param encoded The string encoded peers.
- * @return Array of peers.
- */
- public static final IPeer[] decodePeerList(String encoded) {
- try {
- if (encoded != null && encoded.trim().length() > 0) {
- IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
- Object[] input = delegate.readList(IPeer.class, encoded);
- List<IPeer> peers = new ArrayList<IPeer>();
- for (Object object : input) {
- if (object instanceof IPeer) {
- peers.add((IPeer)object);
- }
- }
- return peers.toArray(new IPeer[peers.size()]);
- }
- }
- catch (Exception e) {
- }
- return new IPeer[0];
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
index f4a13103f..45af5a150 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/delegates/DefaultContextToolbarDelegate.java
@@ -20,7 +20,7 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper;
import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
-import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerNodeDataHelper;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.services.IStepGroupIds;
@@ -145,7 +145,7 @@ public class DefaultContextToolbarDelegate extends AbstractDefaultContextToolbar
dialog = new AttachContextSelectionDialog(Display.getDefault().getActiveShell(), null);
}
if (dialog != null) {
- data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerDataHelper.encodeContextList(new IPeerNode[]{peerNode}));
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerNodeDataHelper.encodeContextList(new IPeerNode[]{peerNode}));
dialog.setupData(data);
if (dialog.open() == Window.OK) {
data = new PropertiesContainer();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
index d1757821d..0a7f5de76 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/AttachContextSelectionDialog.java
@@ -55,7 +55,7 @@ import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
-import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerNodeDataHelper;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessContextItem;
import org.eclipse.tcf.te.tcf.processes.core.interfaces.IProcessesDataProperties;
import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager;
@@ -415,7 +415,7 @@ public class AttachContextSelectionDialog extends CustomTitleAreaDialog implemen
this.data = new PropertiesContainer();
this.data.setProperties(data.getProperties());
- IPeerNode[] contexts = PeerDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
+ IPeerNode[] contexts = PeerNodeDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
IPeerNode newPeerNode = contexts != null && contexts.length > 0 ? contexts[0] : null;
if (peerNode == null || peerNode != newPeerNode) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
index 637ef2a94..18450f682 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractContextStepperCommandHandler.java
@@ -26,7 +26,7 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IContextDataProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
import org.eclipse.tcf.te.tcf.locator.services.selection.RuntimeServiceContextFilter;
-import org.eclipse.tcf.te.tcf.locator.utils.PeerDataHelper;
+import org.eclipse.tcf.te.tcf.locator.utils.PeerNodeDataHelper;
import org.eclipse.tcf.te.ui.handler.AbstractStepperCommandHandler;
import org.eclipse.tcf.te.ui.interfaces.IDataExchangeDialog;
import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
@@ -93,13 +93,13 @@ public abstract class AbstractContextStepperCommandHandler extends AbstractStepp
protected void setContextList(ExecutionEvent event, IPropertiesContainer data) {
IPeerNode context = getContext(event);
if (context != null) {
- data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerDataHelper.encodeContextList(new IPeerNode[]{context}));
+ data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, PeerNodeDataHelper.encodeContextList(new IPeerNode[]{context}));
}
}
protected String getContextName(IPropertiesContainer data) {
String encoded = data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST);
- IPeerNode[] contexts = PeerDataHelper.decodeContextList(encoded);
+ IPeerNode[] contexts = PeerNodeDataHelper.decodeContextList(encoded);
if (contexts != null && contexts.length > 0) {
return contexts[0].getName();
}
@@ -157,7 +157,7 @@ public abstract class AbstractContextStepperCommandHandler extends AbstractStepp
*/
@Override
protected Object getContext(IPropertiesContainer data) {
- IPeerNode[] contexts = PeerDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
+ IPeerNode[] contexts = PeerNodeDataHelper.decodeContextList(data.getStringProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST));
data.setProperty(IContextDataProperties.PROPERTY_CONTEXT_LIST, null);
return contexts.length == 1 ? contexts[0] : null;
}

Back to the top