diff options
author | Uwe Stieber | 2012-04-05 09:55:38 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-04-05 09:56:41 +0000 |
commit | baf7e9de27649d62c66f030bab4d8481a18eebbe (patch) | |
tree | b5fe1f9eac3c72a69624b98c5db7ec06dacf383e /target_explorer/plugins/org.eclipse.tcf.te.tcf.core | |
parent | 501d4943db3dec38d7f30017a810ea9cc64d7df9 (diff) | |
download | org.eclipse.tcf-baf7e9de27649d62c66f030bab4d8481a18eebbe.tar.gz org.eclipse.tcf-baf7e9de27649d62c66f030bab4d8481a18eebbe.tar.xz org.eclipse.tcf-baf7e9de27649d62c66f030bab4d8481a18eebbe.zip |
Target Explorer: Changed IChannelManager API to allow for greater flexibility in regards to future parameterization needs
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.core')
3 files changed, 40 insertions, 26 deletions
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 735a9605d..9c5f5431c 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 @@ -21,6 +21,26 @@ import org.eclipse.tcf.protocol.IPeer; public interface IChannelManager extends IAdaptable { /** + * If set to <code>true</code>, a new and not reference counted channel is opened. + * The returned channel must be closed by the caller himself. The channel manager + * is not keeping track of non reference counted channels. + * <p> + * If not present in the flags map passed in to open channel, the default value is + * <code>false</code>. + */ + public static final String FLAG_FORCE_NEW = "forceNew"; //$NON-NLS-1$ + + /** + * If set to <code>true</code>, the channel is opened if necessary, but no value + * add is launched and associated with the channel. This option should be used + * with extreme caution. + * <p> + * If not present in the flags map passed in to open channel, the default value is + * <code>false</code>. + */ + public static final String FLAG_NO_VALUE_ADD = "noValueAdd"; //$NON-NLS-1$ + + /** * Client call back interface for openChannel(...). */ interface DoneOpenChannel { @@ -36,34 +56,28 @@ public interface IChannelManager extends IAdaptable { /** * Opens a new channel to communicate with the given peer. * <p> - * If <code>forceNew</code> is <code>true</code>, a new and not reference counted channel is - * opened and returned. The returned channel must be closed by the caller himself. The channel - * manager is not keeping track of non reference counted channels. - * <p> * Reference counted channels are cached by the channel manager and must be closed via {@link #closeChannel(IChannel)}. * <p> * The method can be called from any thread context. * * @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>. * @param done The client callback. Must not be <code>null</code>. */ - public void openChannel(IPeer peer, boolean forceNew, DoneOpenChannel done); + 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> - * If <code>forceNew</code> is <code>true</code>, a new and not reference counted channel is - * opened and returned. The returned channel must be closed by the caller himself. The channel - * manager is not keeping track of non reference counted channels. - * <p> * Reference counted channels are cached by the channel manager and must be closed via {@link #closeChannel(IChannel)}. * <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, boolean forceNew, DoneOpenChannel done); + 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 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 2fbb73529..b71f80f43 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 @@ -98,14 +98,14 @@ public final class ChannelManager extends PlatformObject implements IChannelMana } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(org.eclipse.tcf.protocol.IPeer, boolean, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) + * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(org.eclipse.tcf.protocol.IPeer, java.util.Map, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) */ @Override - public void openChannel(final IPeer peer, final boolean forceNew, final DoneOpenChannel done) { + public void openChannel(final IPeer peer, final Map<String, Boolean> flags, final DoneOpenChannel done) { Runnable runnable = new Runnable() { @Override public void run() { - internalOpenChannel(peer, forceNew, done); + internalOpenChannel(peer, flags, done); } }; if (Protocol.isDispatchThread()) runnable.run(); @@ -115,18 +115,15 @@ public final class ChannelManager extends PlatformObject implements IChannelMana /** * Internal implementation of {@link #openChannel(IPeer, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel)}. * <p> - * If <code>forceNew</code> is <code>true</code>, a new and not reference counted channel is opened and returned. The returned - * channel must be closed by the caller himself. The channel manager is not keeping track of non reference counted channels. - * <p> * Reference counted channels are cached by the channel manager and must be closed via {@link #closeChannel(IChannel)} . * <p> * Method must be called within the TCF dispatch thread. * * @param peer The peer. Must not be <code>null</code>. - * @param forceNew Specify <code>true</code> to force opening a new channel, <code>false</code> otherwise. + * @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 IPeer peer, final boolean forceNew, final DoneOpenChannel done) { + /* default */ void internalOpenChannel(final IPeer peer, final Map<String, Boolean> flags, final DoneOpenChannel done) { Assert.isNotNull(peer); Assert.isNotNull(done); Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$ @@ -138,10 +135,13 @@ public final class ChannelManager extends PlatformObject implements IChannelMana final String id = peer.getID(); if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_CHANNEL_MANAGER)) { - CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_message, id, Boolean.valueOf(forceNew)), + CoreBundleActivator.getTraceHandler().trace(NLS.bind(Messages.ChannelManager_openChannel_message, id, flags), 0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, this); } + // Extract the flags of interest form the given flags map + boolean forceNew = flags != null && flags.containsKey(IChannelManager.FLAG_FORCE_NEW) ? flags.get(IChannelManager.FLAG_FORCE_NEW).booleanValue() : false; + // Check if there is already a channel opened to this peer channel = !forceNew ? channels.get(id) : null; if (channel != null && (channel.getState() == IChannel.STATE_OPEN || channel.getState() == IChannel.STATE_OPENING)) { @@ -253,14 +253,14 @@ public final class ChannelManager extends PlatformObject implements IChannelMana } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager#openChannel(java.util.Map, boolean, org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel) + * @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 boolean forceNew, final DoneOpenChannel done) { + public void openChannel(final Map<String, String> peerAttributes, final Map<String, Boolean> flags, final DoneOpenChannel done) { Runnable runnable = new Runnable() { @Override public void run() { - internalOpenChannel(peerAttributes, forceNew, done); + internalOpenChannel(peerAttributes, flags, done); } }; if (Protocol.isDispatchThread()) runnable.run(); @@ -273,14 +273,14 @@ public final class ChannelManager extends PlatformObject implements IChannelMana * Method must be called within the TCF dispatch thread. * * @param peerAttributes The peer attributes. Must not be <code>null</code>. - * @param forceNew Specify <code>true</code> to force opening a new channel, <code>false</code> otherwise. + * @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 boolean forceNew, final DoneOpenChannel done) { + /* 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$ - internalOpenChannel(getOrCreatePeerInstance(peerAttributes), forceNew, done); + internalOpenChannel(getOrCreatePeerInstance(peerAttributes), flags, done); } /** 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 074a24a6d..d2c944354 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 @@ -8,7 +8,7 @@ InternalChannelOpenListener_onChannelOpen_message=Channel opened. InternalChannelListener_onChannelClosed_message=Channel closed. {0} InternalChannelListener_onChannelClosed_cause=; Possibly caused by: {0} -ChannelManager_openChannel_message=Request to open channel. Peer id = {0}, forceNew = {1} +ChannelManager_openChannel_message=Request to open channel. Peer id = {0}, flags = {1} ChannelManager_openChannel_reuse_message=Reusing already opened channel. Peer id = {0}, new reference count = {1} ChannelManager_openChannel_new_message=Opening new channel. Peer id = {0} ChannelManager_openChannel_success_message=Opening channel succeeded. Peer id = {0} |