diff options
Diffstat (limited to 'target_explorer/plugins')
16 files changed, 191 insertions, 224 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java index 1de88770c..a53f32407 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/AbstractStep.java @@ -99,9 +99,8 @@ public abstract class AbstractStep extends ExecutableExtension implements IStep */ @Override public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - if (callback != null) { - callback.done(this, Status.OK_STATUS); - } + Assert.isNotNull(callback); + callback.done(this, Status.OK_STATUS); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF index 0722e01da..b916bd82b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF @@ -28,6 +28,7 @@ Export-Package: org.eclipse.tcf.te.tcf.core, org.eclipse.tcf.te.tcf.core.interfaces.tracing, org.eclipse.tcf.te.tcf.core.internal;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.channelmanager;x-internal:=true, + org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.services;x-internal:=true, org.eclipse.tcf.te.tcf.core.internal.utils;x-internal:=true, 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 7ec0813d4..f4f218167 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 @@ -65,7 +65,7 @@ class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.CloseChannelStep" label="%CloseChannelStep.name"/> <step - id="org.eclipse.tcf.te.tcf.core.channelmanager.shutdownValueAddsStepGroup" + id="org.eclipse.tcf.te.tcf.core.channelmanager.shutdownValueAddStep" class="org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps.ShutdownValueAddStep" label="%ShutdownValueAddStep.name"/> @@ -81,13 +81,13 @@ </references> </stepGroup> <stepGroup id="org.eclipse.tcf.te.tcf.core.channelmanager.launchValueAddsStepGroup" - iterator="org.eclipse.tcf.te.tcf.core.iterators.ValueAddsIterator"> + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ValueAddsIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.core.channelmanager.launchValueAddStep"/> </references> </stepGroup> <stepGroup id="org.eclipse.tcf.te.tcf.core.channelmanager.chainPeersStepGroup" - iterator="org.eclipse.tcf.te.tcf.core.iterators.ChainPeersIterator"> + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ChainPeersIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.core.channelmanager.chainPeerStep"/> </references> @@ -101,7 +101,7 @@ </references> </stepGroup> <stepGroup id="org.eclipse.tcf.te.tcf.core.channelmanager.shutdownValueAddsStepGroup" - iterator="org.eclipse.tcf.te.tcf.core.iterators.ValueAddsIterator"> + iterator="org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators.ValueAddsIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.core.channelmanager.shutdownValueAddStep"/> </references> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java index 92fc04553..a8f564f6f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/interfaces/IChannelManager.java @@ -81,7 +81,8 @@ public interface IChannelManager extends IAdaptable { * Channels opened by the channel manager must be closed by the channel managers * {@link #closeChannel(IChannel)} API. * <p> - * The method can be called from any thread context. + * The method can be called from any thread context, the client done callback + * is always invoked within the TCF event dispatch thread. * * @param peer The peer. Must not be <code>null</code>. * @param flags Map containing the flags to parameterize the channel opening, or <code>null</code>. @@ -90,20 +91,6 @@ public interface IChannelManager extends IAdaptable { public void openChannel(IPeer peer, Map<String, Boolean> flags, DoneOpenChannel done); /** - * Opens a new channel to communicate with the peer described by the given peer attributes. - * <p> - * Channels opened by the channel manager must be closed by the channel managers - * {@link #closeChannel(IChannel)} API. - * <p> - * The method can be called from any thread context. - * - * @param peerAttributes The peer attributes. Must not be <code>null</code>. - * @param flags Map containing the flags to parameterize the channel opening, or <code>null</code>. - * @param done The client callback. Must not be <code>null</code>. - */ - public void openChannel(Map<String, String> peerAttributes, Map<String, Boolean> flags, DoneOpenChannel done); - - /** * Returns the shared channel instance for the given peer. Channels retrieved using this * method cannot be closed by the caller. * <p> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java index c2403d82b..ad957936e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.core.AbstractPeer; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.IToken; @@ -40,7 +39,6 @@ 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; @@ -318,76 +316,6 @@ public final class ChannelManager extends PlatformObject implements IChannelMana } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(java.util.Map, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) - */ - @Override - public void openChannel(final Map<String, String> peerAttributes, final Map<String, Boolean> flags, final DoneOpenChannel done) { - Runnable runnable = new Runnable() { - @Override - public void run() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - internalOpenChannel(peerAttributes, flags, done); - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeLater(runnable); - } - - /** - * Internal implementation of {@link #openChannel(Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel)}. - * <p> - * Method must be called within the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be <code>null</code>. - * @param flags Map containing the flags to parameterize the channel opening, or <code>null</code>. - * @param done The client callback. Must not be <code>null</code>. - */ - /* default */ void internalOpenChannel(final Map<String, String> peerAttributes, final Map<String, Boolean> flags, final DoneOpenChannel done) { - Assert.isNotNull(peerAttributes); - Assert.isNotNull(done); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - // Call openChannel(IPeer, ...) instead of calling internalOpenChannel(IPeer, ...) directly - // to include the value-add handling. - openChannel(getOrCreatePeerInstance(peerAttributes), flags, done); - } - - /** - * Tries to find an existing peer instance or create an new {@link IPeer} - * instance if not found. - * <p> - * <b>Note:</b> This method must be invoked at the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be <code>null</code>. - * @return The peer instance. - */ - private IPeer getOrCreatePeerInstance(final Map<String, String> peerAttributes) { - Assert.isNotNull(peerAttributes); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the peer id from the properties - String peerId = peerAttributes.get(IPeer.ATTR_ID); - Assert.isNotNull(peerId); - - // Check if we shall open the peer transient - boolean isTransient = peerAttributes.containsKey("transient") ? Boolean.parseBoolean(peerAttributes.remove("transient")) : false; //$NON-NLS-1$ //$NON-NLS-2$ - - // Look the peer via the Locator Service. - IPeer peer = Protocol.getLocator().getPeers().get(peerId); - // If not peer could be found, create a new one - if (peer == null) { - peer = isTransient ? new Peer(peerAttributes) : new AbstractPeer(peerAttributes); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_createPeer_new_message, peerId, Boolean.valueOf(isTransient)), - 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, this); - } - } - - // Return the peer instance - return peer; - } - - /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#getChannel(org.eclipse.tcf.protocol.IPeer) */ @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java index 8d1ea51e1..57f8f2dfd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager2.java @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.osgi.util.NLS; -import org.eclipse.tcf.core.AbstractPeer; import org.eclipse.tcf.protocol.IChannel; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.IToken; @@ -39,7 +38,6 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes; 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; /** * Channel manager implementation. @@ -85,6 +83,23 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } } + // The client done callback must be called within the TCF event dispatch thread + final DoneOpenChannel internalDone = new DoneOpenChannel() { + + @Override + public void doneOpenChannel(final Throwable error, final IChannel channel) { + Runnable runnable = new Runnable() { + @Override + public void run() { + done.doneOpenChannel(error, channel); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); + } + }; + // The channel instance to return IChannel channel = null; @@ -127,7 +142,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } // Invoke the channel open done callback - done.doneOpenChannel(null, channel); + internalDone.doneOpenChannel(null, channel); } // If the channel is opening, wait for the channel to become fully opened. // Add the done open channel callback to the list of pending callback's. @@ -138,10 +153,10 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingDones.put(id, dones); } Assert.isNotNull(dones); - dones.add(done); + dones.add(internalDone); if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(done.hashCode())), //$NON-NLS-1$ + CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(internalDone.hashCode())), //$NON-NLS-1$ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); } } @@ -187,7 +202,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingOpenChannel.remove(id); // Invoke the primary "open channel" done callback - done.doneOpenChannel(error, null); + internalDone.doneOpenChannel(error, null); // Invoke pending callback's List<DoneOpenChannel> pending = pendingDones.remove(id); @@ -216,7 +231,7 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } // Invoke the primary "open channel" done callback - done.doneOpenChannel(null, channel); + internalDone.doneOpenChannel(null, channel); // Invoke pending callback's List<DoneOpenChannel> pending = pendingDones.remove(id); @@ -252,10 +267,10 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { pendingDones.put(id, dones); } Assert.isNotNull(dones); - dones.add(done); + dones.add(internalDone); if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(done.hashCode())), //$NON-NLS-1$ + CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_pending_message, id, "0x" + Integer.toHexString(internalDone.hashCode())), //$NON-NLS-1$ 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); } } @@ -263,61 +278,6 @@ public class ChannelManager2 extends PlatformObject implements IChannelManager { } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(java.util.Map, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) - */ - @Override - public void openChannel(final Map<String, String> peerAttributes, final Map<String, Boolean> flags, final DoneOpenChannel done) { - Assert.isNotNull(peerAttributes); - Assert.isNotNull(done); - - Runnable runnable = new Runnable() { - @Override - public void run() { - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - openChannel(getOrCreatePeerInstance(peerAttributes), flags, done); - } - }; - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeLater(runnable); - } - - /** - * Tries to find an existing peer instance or create an new {@link IPeer} - * instance if not found. - * <p> - * <b>Note:</b> This method must be invoked at the TCF dispatch thread. - * - * @param peerAttributes The peer attributes. Must not be <code>null</code>. - * @return The peer instance. - */ - /* default */ IPeer getOrCreatePeerInstance(final Map<String, String> peerAttributes) { - Assert.isNotNull(peerAttributes); - Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ - - // Get the peer id from the properties - String peerId = peerAttributes.get(IPeer.ATTR_ID); - Assert.isNotNull(peerId); - - // Check if we shall open the peer transient - boolean isTransient = peerAttributes.containsKey("transient") ? Boolean.parseBoolean(peerAttributes.remove("transient")) : false; //$NON-NLS-1$ //$NON-NLS-2$ - - // Look the peer via the Locator Service. - IPeer peer = Protocol.getLocator().getPeers().get(peerId); - // If not peer could be found, create a new one - if (peer == null) { - peer = isTransient ? new Peer(peerAttributes) : new AbstractPeer(peerAttributes); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_createPeer_new_message, peerId, Boolean.valueOf(isTransient)), - 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager2.this); - } - } - - // Return the peer instance - return peer; - } - - /* (non-Javadoc) * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#getChannel(org.eclipse.tcf.protocol.IPeer) */ @Override diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java index 11f1c99ea..a0e5ef47e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ChainPeersIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ChainPeersIterator.java @@ -8,7 +8,7 @@ * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.tcf.core.iterators; +package org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators; import java.util.ArrayList; import java.util.List; @@ -23,6 +23,7 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.tcf.core.interfaces.IPeerProperties; +import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; 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; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java index 066264b4d..8a1e90c1d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/iterators/ValueAddsIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/iterators/ValueAddsIterator.java @@ -8,7 +8,7 @@ * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.tcf.core.iterators; +package org.eclipse.tcf.te.tcf.core.internal.channelmanager.iterators; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -17,6 +17,7 @@ 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.interfaces.steps.ITcfStepAttributes; +import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator; import org.eclipse.tcf.te.tcf.core.va.ValueAddManager; import org.eclipse.tcf.te.tcf.core.va.interfaces.IValueAdd; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java index 080cdca2c..672e2835d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ApplyPathMapsStep.java @@ -10,12 +10,14 @@ package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps; +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.Protocol; import org.eclipse.tcf.services.IPathMap; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; @@ -46,7 +48,7 @@ public class ApplyPathMapsStep extends AbstractPeerStep { public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { 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(), "missing TCF channel")); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Channel to target not available.")); //$NON-NLS-1$ } } @@ -54,25 +56,40 @@ public class ApplyPathMapsStep extends AbstractPeerStep { * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final 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); final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class); - final IPathMap svc = channel.getRemoteService(IPathMap.class); - if (service != null && svc != null) { - // Apply the initial path map to the opened channel. - // This must happen outside the TCF dispatch thread as it may trigger - // the launch configuration change listeners. - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - service.applyPathMap(peer, true, callback); + + Runnable runnable = new Runnable() { + @Override + public void run() { + final IPathMapService service = ServiceManager.getInstance().getService(peer, IPathMapService.class); + final IPathMap svc = channel.getRemoteService(IPathMap.class); + if (service != null && svc != null) { + // Apply the initial path map to the opened channel. + // This must happen outside the TCF dispatch thread as it may trigger + // the launch configuration change listeners. + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + service.applyPathMap(peer, true, callback); + } + }); + thread.start(); + } else { + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); } - }); - thread.start(); - } else { - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); - } + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java index bae06eb14..6ac19ef1b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ChainPeerStep.java @@ -10,12 +10,16 @@ package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps; +import java.util.concurrent.atomic.AtomicReference; + +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.Protocol; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; @@ -48,49 +52,81 @@ public class ChainPeerStep extends AbstractPeerStep { */ @Override public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); - final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); + Assert.isNotNull(context); + Assert.isNotNull(data); + Assert.isNotNull(fullQualifiedId); + Assert.isNotNull(monitor); + Assert.isNotNull(callback); - if (channel == null) { - channel = peer.openChannel(); - } - else { - channel.redirect(peer.getAttributes()); - } + final AtomicReference<IChannel> channel = new AtomicReference<IChannel>((IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data)); + final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - final IChannel finChannel = channel; - channel.addChannelListener(new IChannel.IChannelListener() { + Runnable runnable = new Runnable() { @Override - public void onChannelOpened() { - finChannel.removeChannelListener(this); - StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data, finChannel, true); - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); - } + public void run() { + IChannel c = channel.get(); - @Override - public void onChannelClosed(Throwable error) { - // Remove ourself as listener from the channel - finChannel.removeChannelListener(this); - callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null); - } + // If the channel is not yet opened, open it now. + // Otherwise redirect the channel to the next peer. + if (c == null) { + c = peer.openChannel(); + channel.set(c); + } else { + c.redirect(peer.getAttributes()); + } - @Override - public void congestionLevel(int level) { + // At this point, channel must not be null and + // channel.get and c must be the same + Assert.isNotNull(c); + Assert.isTrue(c.equals(channel.get())); + + c.addChannelListener(new IChannel.IChannelListener() { + @Override + public void onChannelOpened() { + channel.get().removeChannelListener(this); + StepperAttributeUtil.setProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data, channel.get(), true); + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + } + + @Override + public void onChannelClosed(Throwable error) { + // Remove ourself as listener from the channel + channel.get().removeChannelListener(this); + callback(data, fullQualifiedId, callback, StatusHelper.getStatus(error), null); + } + + @Override + public void congestionLevel(int level) { + } + }); } - }); + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#rollback(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IStatus, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); + public void rollback(final IStepContext context, final IPropertiesContainer data, final IStatus status, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { - channel.close(); - } + Runnable runnable = new Runnable() { + @SuppressWarnings("synthetic-access") + @Override + public void run() { + channel.close(); + ChainPeerStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); + } + }; - super.rollback(context, data, status, fullQualifiedId, monitor, callback); + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); + } else { + super.rollback(context, data, status, fullQualifiedId, monitor, callback); + } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java index 67d5dfd90..cc645a8de 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/CloseChannelStep.java @@ -9,10 +9,12 @@ *******************************************************************************/ package org.eclipse.tcf.te.tcf.core.internal.channelmanager.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.IChannel; +import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; @@ -43,11 +45,26 @@ public class CloseChannelStep extends AbstractPeerStep { * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { - IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_CHANNEL, fullQualifiedId, data); - if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { - channel.close(); - } - callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final 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); + + Runnable runnable = new Runnable() { + @Override + public void run() { + if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { + channel.close(); + } + callback(data, fullQualifiedId, callback, Status.OK_STATUS, null); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java index 0cbcdaa2c..bb3d432ac 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/LaunchValueAddStep.java @@ -10,6 +10,7 @@ package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -53,6 +54,12 @@ public class LaunchValueAddStep extends AbstractPeerStep { */ @Override public void execute(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 IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); @@ -88,10 +95,11 @@ public class LaunchValueAddStep extends AbstractPeerStep { final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); Runnable runnable = new Runnable() { - @Override + @SuppressWarnings("synthetic-access") + @Override public void run() { valueAdd.shutdown(peerId, callback); - if (callback != null) callback.done(this, Status.OK_STATUS); + LaunchValueAddStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java index 37fbbeb3f..c52b6aa2a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/ShutdownValueAddStep.java @@ -14,6 +14,7 @@ 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.Protocol; import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; @@ -42,7 +43,7 @@ public class ShutdownValueAddStep extends AbstractPeerStep { public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); if (valueAdd == null) { - throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing value add channel")); //$NON-NLS-1$ + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Value-add descriptor instance not set.")); //$NON-NLS-1$ } } @@ -50,10 +51,18 @@ public class ShutdownValueAddStep extends AbstractPeerStep { * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { final IValueAdd valueAdd = (IValueAdd)StepperAttributeUtil.getProperty(ITcfStepAttributes.ATTR_VALUE_ADD, fullQualifiedId, data); final String peerId = getActivePeerContext(context, data, fullQualifiedId).getID(); - valueAdd.shutdown(peerId, callback); + Runnable runnable = new Runnable() { + @Override + public void run() { + valueAdd.shutdown(peerId, callback); + } + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } } 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 4bd8d0201..5b774472e 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 @@ -91,7 +91,6 @@ public class Messages extends NLS { 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_close_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 0da1b2ceb..4586af976 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 @@ -32,7 +32,6 @@ ChannelManager_openChannel_failed=Failed to open channel to {0}. Redirect Level 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_close_message=Closing 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.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 06523b44b..cf31d292c 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 @@ -179,15 +179,20 @@ public class WaitForReadyStep extends AbstractPeerNodeStep { * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#rollback(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.core.runtime.IStatus, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) */ @Override - public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { + public void rollback(final IStepContext context, final IPropertiesContainer data, final IStatus status, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { final IPeer peer = getActivePeerContext(context, data, fullQualifiedId); - Protocol.invokeAndWait(new Runnable() { - @Override + + Runnable runnable = new Runnable() { + @SuppressWarnings("synthetic-access") + @Override public void run() { Tcf.getChannelManager().shutdown(peer); + WaitForReadyStep.super.rollback(context, data, status, fullQualifiedId, monitor, callback); } - }); - callback.done(this, Status.OK_STATUS); + }; + + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeLater(runnable); } /* (non-Javadoc) |