diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java')
-rw-r--r-- | target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java deleted file mode 100644 index 599383404..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java +++ /dev/null @@ -1,86 +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.locator.listener; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.tcf.protocol.IChannel; -import org.eclipse.tcf.protocol.IPeer; -import org.eclipse.tcf.protocol.Protocol; -import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener; -import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator; -import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService; - - -/** - * Channel state change listener implementation. - */ -public class ChannelStateChangeListener implements IChannelStateChangeListener { - // Reference to the parent model - private final IPeerModel model; - - /** - * Constructor. - * - * @param model The parent locator model. Must not be <code>null</code>. - */ - public ChannelStateChangeListener(IPeerModel model) { - Assert.isNotNull(model); - this.model = model; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.tcf.core.interfaces.listeners.IChannelStateChangeListener#stateChanged(org.eclipse.tcf.protocol.IChannel, int) - */ - @Override - public void stateChanged(IChannel channel, int state) { - Assert.isNotNull(channel); - Assert.isTrue(Protocol.isDispatchThread()); - - if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_CHANNEL_STATE_CHANGE_LISTENER)) { - CoreBundleActivator.getTraceHandler().trace("ChannelStateChangeListener.stateChanged( " + channel + ", " + (state == IChannel.STATE_OPEN ? "OPEN" : "CLOSED") + " )", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - ITracing.ID_TRACE_CHANNEL_STATE_CHANGE_LISTENER, this); - } - - switch (state) { - case IChannel.STATE_OPEN: - IPeer peer = channel.getRemotePeer(); - if (peer != null && peer.getID() != null) { - // Find the corresponding model node - IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); - if (node != null) { - // Increase the channel reference counter by 1 - int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER); - if (counter < 0) counter = 0; - counter++; - node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter); - } - } - break; - case IChannel.STATE_CLOSED: - peer = channel.getRemotePeer(); - if (peer != null && peer.getID() != null) { - // Find the corresponding model node - IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID()); - if (node != null) { - // Decrease the channel reference counter by 1 - int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER); - counter--; - if (counter < 0) counter = 0; - node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter); - } - } - break; - } - } -} |